PlayerInteractEvent errors?

Discussion in 'Plugin Development' started by QuipCream, Feb 18, 2016.

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

    QuipCream

    Hello, I've been trying to work on a KitPvP plugin and the PlayerInteractEvent is causing me errors

    Server Errors (open)

    Code:
    19.02 04:26:47 [Server] ERROR Could not pass event PlayerInteractEvent to KitPvP v1.0
    19.02 04:26:47 [Server] INFO org.bukkit.event.EventException
    19.02 04:26:47 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:297) ~[craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at org.bukkit.craftbukkit.v1_8_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:209) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerInteractManager.interact(PlayerInteractManager.java:462) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:703) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:52) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:670) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:336) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:626) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:534) [craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_72]
    19.02 04:26:47 [Server] INFO Caused by: java.lang.NullPointerException
    19.02 04:26:47 [Server] INFO at me.SpiicyAsian.KitPvP.Events.PlayerInteract.Interact(PlayerInteract.java:30) ~[?:?]
    19.02 04:26:47 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_72]
    19.02 04:26:47 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:295) ~[craftbukkit1.8.jar:git-Bukkit-61ef214]
    19.02 04:26:47 [Server] INFO ... 17 more


    Incase you need my code for the class:
    Code (open)
    package me.SpiicyAsian.KitPvP.Events;
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    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.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    
    
    public class PlayerInteract implements Listener {
    
        @EventHandler
        public void Interact(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            //ItemStack
            Inventory inv = Bukkit.getServer().createInventory(p, 18, ChatColor.RED + "EdgeBorder - Kits");
            ItemStack glass = new ItemStack(Material.THIN_GLASS);
            ItemMeta itemMeta1 = glass.getItemMeta();
            itemMeta1.setDisplayName(ChatColor.BLUE + "[EdgeBorder]");
            ItemStack PvP = new ItemStack(Material.STONE_SWORD);
            ItemMeta itemMeta = PvP.getItemMeta();
            itemMeta.setDisplayName(ChatColor.RED + "PvP");
            if(p.getItemInHand().getType() == Material.STICK) {
                if(p.getItemInHand().getItemMeta().getDisplayName().contains("KitPvP")) {
                    if(e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
                    inv.setItem(0, glass);
                    inv.setItem(9, glass);
                    inv.setItem(8, glass);
                    inv.setItem(17, glass);
                    inv.setItem(2, PvP);
                    e.setCancelled(true);
                    p.openInventory(inv);
                    }
                }
            }else{
                e.setCancelled(false);
            }
        }
       
    }


    Anyways, please get back to me. Thanks!

    Sincerely,
    QuipCream
     
  2. Offline

    teej107

  3. Offline

    QuipCream

  4. Offline

    BobTheHamster9

    You error is on line 30 of your PlayerInteract class.
    Code:
    19.02 04:26:47 [Server] INFO Caused by: java.lang.NullPointerException
    19.02 04:26:47 [Server] INFO at me.SpiicyAsian.KitPvP.Events.PlayerInteract.Interact(PlayerInteract.java:30) ~[?:?]
    
    Code:
    if(e.getAction()==Action.RIGHT_CLICK_AIR||(e.getAction()==Action.RIGHT_CLICK_BLOCK)){
    
     
  5. Offline

    teej107

    1. There is a reason why I linked him to that tutorial
    2. There is no way that the error will be thrown on that line. It's most likely the line above it and the OP missed copying the package.
     
  6. Offline

    Skylandz

    After RIGHT_CLICK_AIR on line 30 you are missing an ')' if im right. Kinda doubting if it should be there
     
Thread Status:
Not open for further replies.

Share This Page