PlayerList suddenly empty

Discussion in 'Plugin Development' started by D00py, May 4, 2014.

Thread Status:
Not open for further replies.
  1. 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
    1. @EventHandler
    2. public void onConquerAttend(final ConquerAttendEvent event) {
    3. playerList = event.getPlayerList();
    4. plugin.getLogger().info("onconquerattend; event.getPlayerList: " + event.getPlayerList());
    5. plugin.getLogger().info("onconquerattend; PlayerList: " + playerList);
    6. plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    7. ProtectedRegion region = event.getRegion();
    8. String faction = event.getFaction();
    9. int duration = 0;
    10. boolean spawned = false;
    11. IronGolem golem;
    12. boolean running = true;
    13. public void run() {
    14. if(running) {
    15. plugin.getLogger().info("running; playerList: " + playerList);
    16. plugin.getLogger().info("running; region: " + region);
    17. Iterator<Player> i = playerList.iterator();
    18. while(i.hasNext()) {
    19. Player p = i.next();
    20. if(!region.contains(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ())) {
    21. i.remove();
    22. p.sendMessage(WorldGuardConquer.getPrefix() + ChatColor.RED + "Du bist nun nicht mehr an der Eroberung beteiligt.");
    23. plugin.getLogger().info("Spieler hat Eroberung abgebrochen.");
    24. if(playerList.size() < event.getMinimumConquerer() && !spawned) {
    25. cancelConquer();
    26. }
    27. }
    28. }
    29. [...]
    30.  


    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
     
  2. Offline

    DxDy

    Please apply some proper formatting to your post. That code is almost unreadable the way it is presented.
     
  3. Sorry, somehow the formatting kept getting resetted.
     
  4. Nobody an idea?
     
Thread Status:
Not open for further replies.

Share This Page