Hey, I'm experiencing an issue with my current plugin. A custom event is called and then my custom EventListener starts a Scheduler Task, but somehow a playerList suddenly appears to be empty. Here is the code of the listener class: Code:java @EventHandlerpublic void onConquerAttend(final ConquerAttendEvent event) { playerList = event.getPlayerList(); plugin.getLogger().info("onconquerattend; event.getPlayerList: " + event.getPlayerList()); plugin.getLogger().info("onconquerattend; PlayerList: " + playerList); plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { ProtectedRegion region = event.getRegion(); String faction = event.getFaction(); int duration = 0; boolean spawned = false; IronGolem golem; boolean running = true; public void run() { if(running) { plugin.getLogger().info("running; playerList: " + playerList); plugin.getLogger().info("running; region: " + region); Iterator<Player> i = playerList.iterator(); while(i.hasNext()) { Player p = i.next(); if(!region.contains(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ())) { i.remove(); p.sendMessage(WorldGuardConquer.getPrefix() + ChatColor.RED + "Du bist nun nicht mehr an der Eroberung beteiligt."); plugin.getLogger().info("Spieler hat Eroberung abgebrochen."); if(playerList.size() < event.getMinimumConquerer() && !spawned) { cancelConquer(); } } }[...] In the console output you can see the following: Code: [13:19:46 INFO]: [WGC] onconquerattend; event.getPlayerList: [CraftPlayer{name=D00py}] [13:19:46 INFO]: [WGC] onconquerattend; PlayerList: [CraftPlayer{name=D00py}] [13:19:46 INFO]: [WGC] running; playerList: [] [13:19:46 INFO]: [WGC] running; region: com.sk89q.worldguard.protection.regions.ProtectedC uboidRegion@343aa5 [13:19:47 INFO]: [WGC] running; playerList: [] [13:19:47 INFO]: [WGC] running; region: com.sk89q.worldguard.protection.regions.ProtectedC uboidRegion@343aa5 As you can see the region has still its value. Anyone got an idea? Regards
Please apply some proper formatting to your post. That code is almost unreadable the way it is presented.