I have two player interact events in different classes and I dont think thats the problem, but whenever I attempt to activate the other It gives this error Code (Text): [18:47:39 ERROR]: Could not pass event PlayerInteractEvent to ArenaClasses v1.0 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.craftbukkit.v1_9_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:231) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.craftbukkit.v1_9_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:198) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at org.bukkit.craftbukkit.v1_9_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:194) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java:945) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:27) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_73] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_73] at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:721) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:660) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:559) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] at java.lang.Thread.run(Unknown Source) [?:1.8.0_73] Caused by: java.lang.NullPointerException at Arena.Listeners.ButtonPress.onButtonPress(ButtonPress.java:24) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f] ... 18 more > Here is the event: Code (Java): package Arena.Listeners; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import Arena.Main; import Arena.data; public class ButtonPress implements Listener{ Main pl; public ButtonPress(Main pl){ this.pl = pl; } @EventHandler public void onButtonPress(PlayerInteractEvent event){ if(event.getClickedBlock().getType() == Material.STONE_BUTTON && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){ data d = new data(pl); FileConfiguration data = d.getData(); Player p = event.getPlayer(); double x = event.getClickedBlock().getLocation().getX(); double y = event.getClickedBlock().getLocation().getY(); double z = event.getClickedBlock().getLocation().getZ(); String coords = data.getString("Assassin"); String[] loc = coords.split(", "); String coords2 = data.getString("Medic"); String[] loc2 = coords2.split(", "); if(x == Integer.parseInt(loc[0]) && y == Integer.parseInt(loc[1]) && z == Integer.parseInt(loc[2])){ for (PotionEffect effect : p.getActivePotionEffects()){ p.removePotionEffect(effect.getType()); } p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, true, true)); p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0, true, true)); d.removePlayer(p); d.addPlayer(p, "Assassin"); p.sendMessage(ChatColor.GRAY + "You are now an assassin..."); } else if(x == Integer.parseInt(loc2[0]) && y == Integer.parseInt(loc2[1]) && z == Integer.parseInt(loc2[2])){ for (PotionEffect effect : p.getActivePotionEffects()){ p.removePotionEffect(effect.getType()); } p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0, true, true)); d.removePlayer(p); d.addPlayer(p, "Medic"); p.sendMessage(ChatColor.GREEN + "You are now an Medic!"); } } } } It is getting stuck on this event and not going to my next event which activates when right-clicking a stick Anyone know why?
Code (Java): if(event.getClickedBlock().getType() == Material.STONE_BUTTON && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
Yea Its obvious now that you mentioned it, I just added an if statement to be sure a block is being clicked thanks