Could not pass event PlayerInteractEvent Error

Discussion in 'Bukkit Help' started by AdvsNoob, Apr 14, 2012.

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

    AdvsNoob

    The plugin works but for some reason it spams this error over and over.

    Nothing seems to be wrong so is there a way to block these errors?
     
  2. Offline

    andrewpo

  3. Offline

    AdvsNoob

    The whole plugin works and i dont see anything wrong. And its an updated version of another casino mod. But before i even modified it, it still did the same thing
     
  4. Offline

    andrewpo

    Report the error to the plugin developer and try to get the issue resolved with them.
     
  5. Offline

    AdvsNoob

    BUMP: This is what the file looks like

    Code:
    package me.darazo.ancasino.listeners;
     
    import me.darazo.ancasino.AnCasino;
    import me.darazo.ancasino.slot.SlotMachine;
    import me.darazo.ancasino.slot.Type;
    import me.darazo.ancasino.slot.game.Game;
     
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
     
     
    public class AnPlayerListener implements Listener {
     
        protected AnCasino plugin;
     
        public AnPlayerListener(AnCasino plugin) {
            this.plugin = plugin;
        }
        @EventHandler (priority = EventPriority.NORMAL)
        public void onPlayerInteract(PlayerInteractEvent event) {
         
            // Check if plugin is enabled
            if(plugin.isEnabled()) {
                Player player = event.getPlayer();
                Block b = event.getClickedBlock();
                 
                // Left clicked Lever
                if(b.getType() == Material.LEVER) {
                     
                    // Look for matching controller block
                    for(SlotMachine slot : plugin.slotData.getSlots()) {
                     
                        // Match found
                        if(b.equals(slot.getController())) {
                            Type type = plugin.typeData.getType(slot.getType());
                            Double cost = type.getCost();
                         
                            // Left click event And Right Click
                            if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() ==  Action.RIGHT_CLICK_BLOCK) {
                                //  Player has permission
                                if(plugin.permission.canUse(player)) {
                                    // Player has enough money
                                    if(plugin.economy.has(player.getName(), cost)) {
                                     
                                        // Slot is not busy
                                        if(!slot.isBusy()) {
                                         
                                            //Let's go!
                                            Game game = new Game(slot, player, plugin);
                                            game.play();
                                            return;
                                         
                                        }
                                     
                                        // Slot is busy
                                        else {
                                            plugin.sendMessage(player, type.getMessages().get("inUse"));
                                        }
                                    }
                                 
                                    // Player does not have enough money
                                    else {
                                        plugin.sendMessage(player, type.getMessages().get("noFunds"));
                                    }
                                }
                             
                                // Player does not have type permission
                                else {
                                    plugin.sendMessage(player, type.getMessages().get("noPermission"));
                                }
                             
                            }
                         
                            // Right click event
                            else if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                                if(plugin.permission.isOwner(player, slot)) {
                                    plugin.sendMessage(player, slot.getName() +":");
                                    plugin.sendMessage(player, "Type: " + slot.getType());
                                    plugin.sendMessage(player, "Owner: " + slot.getOwner());
                                    plugin.sendMessage(player, "Managed: " + slot.isManaged().toString());
                                    if(slot.isManaged()) {
                                        plugin.sendMessage(player, "Enabled: " + slot.isEnabled().toString());
                                        plugin.sendMessage(player, "Funds: " + slot.getFunds());
                                        plugin.sendMessage(player, "Funds required: " + plugin.typeData.getMaxPrize(slot.getType()));
                                    }
                                }
                            }
                         
                            // Match found
                            break;
                        }
                    }
                 
                }
             
                // Creating slots
                if(event.getAction() == Action.LEFT_CLICK_BLOCK && plugin.slotData.isCreatingSlots(player)) {
                 
                    BlockFace face = event.getBlockFace();
                 
                    if(face != BlockFace.DOWN && face != BlockFace.UP) {
                        SlotMachine slot = plugin.slotData.creatingSlots.get(player);
                        plugin.slotData.createReel(player, face, slot);
                     
                        plugin.slotData.toggleCreatingSlots(player, slot);
                        plugin.slotData.togglePlacingController(player, slot);
                        plugin.sendMessage(player, "Punch a lever to make dah controllaaaaaa!");
                    }
                    else {
                        plugin.sendMessage(player, "Only sides of blocks are valid targets for this operation.");
                    }
                }
             
                // Placing controller
                else if(event.getAction() == Action.LEFT_CLICK_BLOCK && plugin.slotData.isPlacingController(player)) {
                 
                    SlotMachine slot = plugin.slotData.placingController.get(player);
                    slot.setController(b);
                    plugin.slotData.togglePlacingController(player, slot);
                    plugin.slotData.addSlot(slot);
                    plugin.slotData.saveSlot(slot);
                    plugin.sendMessage(player, "Slot machine set up successfully, FUCK YEAH!");
                }
            }
        }
    }
    
    The error is this.

    Code:
    2012-04-26 01:55:34 [SEVERE] Could not pass event PlayerInteractEvent to AnCasino
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:303)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:459)
    at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:176)
    at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:146)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:605)
    at net.minecraft.server.Packet15Place.handle(SourceFile:39)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
    at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78)
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:551)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NullPointerException
    at me.darazo.ancasino.listeners.AnPlayerListener.onPlayerInteract(AnPlayerListener.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301)
    
    Happens when ever someone right clicks. The original creator wont respawn cause he isnt working on it any more but i have put so much time in this. :/ the plugin it self works like a charm its just when people right click anything but the casinos levers it gives this error... So anyone know how to fix it?

    BUMP: Can anyone help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  6. AdvsNoob
    Code:
    b.getState() instanceof Lever
     
  7. Offline

    wowzersam

    DJSkepter Necropost... it was posted in 2012
     
Thread Status:
Not open for further replies.

Share This Page