PlayerCommandPreprocess error

Discussion in 'Plugin Development' started by javoris767, Jun 25, 2012.

  1. Offline

    javoris767

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm getting an error caused by this event.
    Code:
        @EventHandler
        void onCommand(PlayerCommandPreprocessEvent event){
            if(plugin.PlayersBlocked.containsKey(event.getPlayer().getName()) && !plugin.Commands.contains(event.getMessage().substring(1).split(" ")[0])){
                event.setCancelled(true);
                event.getPlayer().sendMessage(ChatColor.Green + "[FairPvP] " + ChatColor.RED + "Sorry, you can't use that command that quick after pvp!");
                return;
            }
         
        }
    Code:
    012-06-25 15:44:30 [SEVERE] Could not pass event PlayerCommandPreprocessEvent to FairPvP
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:460)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:814)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:781)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:764)
    at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:34)
    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:567)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NullPointerException
    at me.javoris767.fairpvp.FairPvPListener.onCommand(FairPvPListener.java:19)
    at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
    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:302)
    ... 12 more

    This post has been edited 1 time. It was last edited by javoris767 Jun 25, 2012.
  2. Offline

    Orcem12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  3. Offline

    javoris767

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Code:
    if(plugin.PlayersBlocked.containsKey(event.getPlayer().getName()) && !plugin.Commands.contains(event.getMessage().substring(1).split(" ")[0])){
    
    
    I think this
  4. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    check plugin.PlayersBlocked.

    Is it initialized?
  5. Offline

    javoris767

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Yah
    Map<String, Boolean> PlayersBlocked = new HashMap<String, Boolean>();
  6. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    if so, then plugin.Commands is gonna be null. those are the only two objects that would be null at this point.
  7. Offline

    javoris767

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    public List<String> Commands = new ArrayList<String>();
    Here is what commands is set as.
  8. Offline

    javoris767

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    So... Whats the problem?
  9. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I believe PlayersBlocked doesnt have any entries in it, returning null when you try to grab the boolean value by the key
  10. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I think plugin is null
  11. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    or that.

Share This Page