org.bukkit.event.EventException

Discussion in 'Plugin Development' started by ShadyShroomz, Mar 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ShadyShroomz

    Ok, so I'm coding a mini-game, and I'm trying to remove players from the arena and I can't seem to get it to work :/

    Code:
    ERROR
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[spigot.jar:git-Spigot-1235]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1235]
        at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30) ~[spigot.jar:git-Spigot-1235]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:482) [spigot.jar:git-Spigot-1235]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:467) [spigot.jar:git-Spigot-1235]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:362) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntityPlayer.die(EntityPlayer.java:384) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntityLiving.damageEntity(EntityLiving.java:739) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntityHuman.damageEntity(EntityHuman.java:751) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntityPlayer.damageEntity(EntityPlayer.java:462) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntitySnowball.a(SourceFile:30) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.EntityProjectile.h(EntityProjectile.java:154) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1469) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1445) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1314) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.java:509) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:636) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:273) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:540) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:446) [spigot.jar:git-Spigot-1235]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [spigot.jar:git-Spigot-1235]
    Caused by: java.lang.NullPointerException
        at me.shadyshroomz.sh.Arena.removePlayer(Arena.java:92) ~[?:?]
        at me.shadyshroomz.sh.Arena.stop(Arena.java:134) ~[?:?]
        at me.shadyshroomz.sh.Arena.addDeath(Arena.java:143) ~[?:?]
        at me.shadyshroomz.listeners.PlayerDeath.onPlayerDeath(PlayerDeath.java:14) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_45]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[spigot.jar:git-Spigot-1235]
        ... 20 more
    
    Code:java
    1. //Add and Remove Player methods (The place where the error is)
    2. public void addPlayer(Player p) {
    3. players.add(new PlayerData(p.getName(), getTeamWithLessPlayers(), p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));
    4.  
    5. p.getInventory().clear();
    6. p.getInventory().addItem(new ItemStack(Material.GOLD_PICKAXE, 1));
    7. p.getInventory().addItem(new ItemStack(Material.FLINT, 64));
    8. p.getInventory().setHelmet(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
    9.  
    10. p.teleport(getSpawn(getData(p).getTeam()));
    11.  
    12. p.setGameMode(GameMode.SURVIVAL);
    13. p.setFlying(false);
    14.  
    15. MessageManager.getInstance().info(p, "You have joined arena " + getID() + " and are on the " + ChatColor.valueOf(getData(p).getTeam().toString()) + getData(p).getTeam().toString().toLowerCase() + ChatColor.BLUE + " team!");
    16.  
    17. if (players.size() >= 12 && !cd) start();
    18. }
    19.  
    20. public void removePlayer(Player p) {
    21. PlayerData pd = getData(p);
    22.  
    23. p.teleport(pd.getLocation()); //<--- the line it says the error is on
    24.  
    25. p.getInventory().clear();
    26. p.setHealth(20);
    27. p.setFoodLevel(20);
    28. p.setFireTicks(0);
    29. msg("You have been removed from the arena!");
    30. players.remove(pd);
    31.  
    32. if (players.size() == 0 && !cd) stop();
    33.  
    34. }
     
  2. Offline

    diage

    So there are three things that can be null in that statement, p, pd, or the location returned by pd.getLocation. Since I assume pd is your own object and getlocation is your own method, I might consider checking one of those two to find out which is null.
     
  3. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Locked. We do not support unofficial builds.
     
Thread Status:
Not open for further replies.

Share This Page