Solved Could not pass event PlayerInteractEvent

Discussion in 'Plugin Development' started by gidonyou, Feb 3, 2014.

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

    gidonyou

    Hello,

    I made a plugin but getting lot of error,

    Server Log
    Show Spoiler

    2014-02-03 19:13:06 [SEVERE] Could not pass event PlayerInteractEvent to Simple Mafia PVP v0.1
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
    at org.bukkit.craftbukkit.v1_5_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:190)
    at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java:549)
    at net.minecraft.server.v1_5_R3.Packet14BlockDig.handle(SourceFile:46)
    at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292)
    at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java:115)
    at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
    at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:30)
    at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:581)
    at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226)
    at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
    at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410)
    at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NullPointerException
    at me.gidonyou.mafiaeasy.MafiaEasyListener.OnPlayerInteract(MafiaEasyListener.java:34)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
    ... 15 more


    And here is the code I Built:
    Code:java
    1. @EventHandler
    2. public void OnPlayerInteract(PlayerInteractEvent event) {
    3. Player player = event.getPlayer();
    4.  
    5. if (player.getItemInHand().getItemMeta().getDisplayName()
    6. .equalsIgnoreCase(ChatColor.RED + "Mafia's Blood")) {
    7. if(!plugin.StartGame){
    8. plugin.hashmap.put(player, null);
    9. Bukkit.broadcastMessage(ChatColor.RED + "Mafia Selected");
    10. }else{
    11. player.sendMessage(ChatColor.DARK_RED + "Game Aready Started!");
    12. }
    13. }
    14.  
    15. }



    This Plugin is waiting to approve (which need help):
    http://dev.bukkit.org/bukkit-plugins/mafia-pvp/

    Thanks
     
  2. Offline

    clienthax

    check that the item in hand isnt null. and that it has meta, and a display name, before attempting to access
     
  3. Offline

    Jugglernaught

    Also, that could be from the console getting too many events and the code not handling it well (Don't trust what I just said because I don't actually know what the thing I am suggesting actually does) so what you want to do, is throw a try statement along with a catch and it will most-likely clear that error.

    Like so:

    Code:java
    1. public void onPlayerInteractEvent(PlayerInteractEvent e) {
    2. try{
    3. //Insert random event code that you want it to do here
    4. } catch (Exception except)
    5. }
    6. }
    7.  
    8.  
     
  4. Offline

    gidonyou

Thread Status:
Not open for further replies.

Share This Page