I use this code to close my event but its not teleport player to spawn and idk if check for players on a list is ok. and also it doesn't remove full event folder only folders is still in %player%'s event-1 is data and region idk why is that happening other files from folder is removed just fine.
code_language.skript:
command /closeevent:
permission: cc.command.eventclose
permission message: &cInvalid permission, sorry.
trigger:
loop all players:
loop-player's world is "plugins/CamCraftCore/CCEvents/%player%'s Event-1"
if player is in list {playerlist::*}
if player is in list {hosterlist::*}
skellett teleport all players to world "./world" spawn
unload world "plugins/CamCraftCore/CCEvents/%player%'s Event-1"
wait 2 seconds
delete folder "plugins/CamCraftCore/CCEvents/%player%'s Event-1/data/"
delete folder "plugins/CamCraftCore/CCEvents/%player%'s Event-1/region/"
delete folder "plugins/CamCraftCore/CCEvents/%player%'s Event-1/playerdata"
wait 2 ticks
delete file "plugins/CamCraftCore/CCEvents/%player%'s Event-1/level.dat"
delete file "plugins/CamCraftCore/CCEvents/%player%'s Event-1/uid.dat"
delete file "plugins/CamCraftCore/CCEvents/%player%'s Event-1/level.dat_old"
wait 2 ticks
delete file "plugins/CamCraftCore/CCEvents/%player%'s Event-1/session.lock"
delete folder "plugins/CamCraftCore/CCEvents/%player%'s Event-1"
wait 2 ticks
message "&0[&3&l%{eprefix}%&0] &3Successfully removed your event."
delete {cc.event.%player%}
clear {playerlist::*}
clear {hosterlist::*}