public class MVAWorldListener implements Listener {
private static final List<String> passes = new ArrayList<String>();
@EventHandler
public void worldLoad(WorldLoadEvent event) {
final WorldLoadEvent fevent = event;
if (!passes.contains(event.getWorld().getName())) {
MultiverseAdventure.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(MultiverseAdventure.getInstance(), new Runnable() {
@Override
public void run() {
MultiverseAdventure.getInstance().getAdventureWorldsManager().tryEnableWorld(fevent.getWorld().getName());
}
}, 20);
}
else {
MultiverseAdventure.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(MultiverseAdventure.getInstance(), new Runnable() {
@Override
public void run() {
MultiverseAdventure.getInstance().getAdventureWorldsManager().tryEnableWorld(fevent.getWorld().getName(), true); // Without reset here
}
}, 20);
passes.remove(event.getWorld().getName());
}
}