SpawnRegionEvents

Discussion in 'Spigot Plugin Development' started by Svenna, May 31, 2015.

  1. Hi all,

    I've made a region and set used WGRegionEvents to track when a player joins/leaves but I get a NPE, in the API. Any idea how ? Or how could I track when a player leaves/joins a region without WGRegionEvents

    Code:

    Code (Text):
        @EventHandler
        public void onEnter(RegionEnterEvent e){
            Player p = e.getPlayer();
            if (v.inSpawn.get(p.getUniqueId()) == null) return;
           
            if (e.getRegion().getId().equals("spawnGCA")){
                if (v.inSpawn.get(p.getUniqueId()) == false){
                    p.sendMessage(v.prefix + "You can't enter spawn again!");
                    e.setCancelled(true);
                } else if (v.inSpawn.get(p.getUniqueId()) == true){
                    p.sendMessage(v.prefix + "You are in spawn now. Once left you can never enter again!");
                }
            }
        }
       
        @EventHandler
        public void onLeave(RegionLeaveEvent e){
            Player p = e.getPlayer();
            if (v.inSpawn.get(p.getUniqueId()) == null) return;
           
            if (e.getRegion().getId().equals("spawnGCA")){
                p.sendMessage(v.prefix + "You left spawn. Good luck!");
                v.inSpawn.put(p.getUniqueId(), false);
            }
        }
     
  2. NullPointerException
     
  3. (I know, I was asking for the stack trace :p)
     
    • Funny Funny x 1
  4. Sorry, completely read the sentence wrong xP
    My bad.
     
  5. Something in the API is wrong. Probably outdated. I'm gonna close this topic, need to find a different way
     
  6. the API wouldn't throw NullPointerExceptions though (unless you are passing null to it, then it might), even when outdated.
     
  7. Nope. It's saying null when loading plugin. So outdated m8 ;)
     
  8. What exactly is null... Perhaps you are using the API in a way it wasn't intended to be used ;)
     
    • Agree Agree x 1