ArrayList error help

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

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

    Nachoman44

    So, i've come across an error which i've no idea why it's occurring so hopefully you guys will, I've created events in which certain things will be executed but I only want them to execute if they're in either teamRed or teamBlue, so here's what i've got:
    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e){
            if (!(teamRed.contains(e.getPlayer().getName()))) return;
            if (!(teamBlue.contains(e.getPlayer().getName()))) return;
            if (magicNachoPlayers.contains(e.getPlayer())){
                Player player = (Player) e.getPlayer();
                if (e.getAction() == e.getAction().RIGHT_CLICK_AIR || e.getAction() == e.getAction().RIGHT_CLICK_BLOCK){
                    if (e.getPlayer().getItemInHand().getType() == Material.GOLD_NUGGET){
                        kitSelection.show(player);
                    }
                }
            }
    }
    It throws an error and points to the lines "if(!(teamTEAM.contains(e.getPlayer()))) return;", have I coded something wrong? is the "!" in the wrong place? Any help is appreciated
    Oh, and here's the error message if you need it:
    Code:
    [20:43:54 ERROR]: Could not pass event PlayerInteractEvent to NachoMagic v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:471) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:195) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PlayerInteractManager.interact(PlayerInteractManager.java:374) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:628) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.a(SourceFile:60) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.handle(SourceFile:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NullPointerException
        at magicNachoArena.magicNachoListeners.onPlayerInteract(magicNachoListeners.java:92) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        ... 15 more
     
  2. Offline

    1Rogue

    A stacktrace would be nice
     
  3. Offline

    diage

    What error gets thrown?
     
  4. Offline

    Nachoman44

    I guess you guys read it before I edited in the error message :p, well the error is there now.
     
  5. Offline

    1Rogue


    How are you initializing/getting your lists, because they are null.
     
  6. Offline

    ZodiacTheories

    Nachoman44

    Just to make sure, so your ArrayLists are named teamRed, teamBlue and magicNachoPlayers ?
     
  7. Offline

    Nachoman44

    Well, this is embarrassing... it was the way method I used in order to get hold of the arraylists from my main class. Managed to fix it ^^ thanks for your help and quick replies <3
     
Thread Status:
Not open for further replies.

Share This Page