Development Assistance Could not pass event EntityDeathEvent -> Please HELP!

Discussion in 'Plugin Help/Development/Requests' started by xFoundation, Jun 14, 2015.

Thread Status:
Not open for further replies.
  1. Hey, i'm creating a custom bukkit plugin for my server and there are errors on the logs:

    Code:
    [21:31:19] [Server thread/INFO]: Starting minecraft server version 1.8.7
    [21:31:19] [Server thread/INFO]: Loading properties
    [21:31:19] [Server thread/INFO]: Default game type: SURVIVAL
    [21:31:19] [Server thread/INFO]: Generating keypair
    [21:31:19] [Server thread/INFO]: Starting Minecraft server on *:25565
    [21:31:19] [Server thread/INFO]: Using default channel type
    [21:31:20] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-1880a9c (MC: 1.8.7) (Implementing API version 1.8.7-R0.1-SNAPSHOT)
    [21:31:20] [Server thread/INFO]: [Game] Loading Game v0.1
    [21:31:20] [Server thread/INFO]: [HugoStats] Loading HugoStats v0.1
    [21:31:20] [Server thread/INFO]: Preparing level "world"
    [21:31:20] [Server thread/INFO]: Preparing start region for level 0 (Seed: 0)
    [21:31:20] [Server thread/INFO]: Preparing start region for level 1 (Seed: 0)
    [21:31:21] [Server thread/INFO]: Preparing start region for level 2 (Seed: -1575560157028647967)
    [21:31:21] [Server thread/INFO]: [Game] Enabling Game v0.1
    [21:31:21] [Server thread/INFO]: [HugoStats] Enabling HugoStats v0.1
    [21:31:21] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [21:31:21] [Server thread/INFO]: Done (1,083s)! For help, type "help" or "?"
    [21:33:25] [User Authenticator #1/INFO]: UUID of player HugoFLP is d9f0a68c-ae2c-4af0-9423-fa2264cdc690
    [21:33:25] [Server thread/INFO]: HugoFLP[/127.0.0.1:64309] logged in with entity id 249 at ([world]-135.3634836417522, 4.0, 16.706226510475247)
    [21:33:44] [Server thread/ERROR]: Could not pass event EntityDeathEvent to HugoStats v0.1
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[server.jar:git-Bukkit-1880a9c]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Bukkit-1880a9c]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [server.jar:git-Bukkit-1880a9c]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [server.jar:git-Bukkit-1880a9c]
        at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:347) [server.jar:git-Bukkit-1880a9c]
        at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:340) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityLiving.die(EntityLiving.java:866) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityZombie.die(EntityZombie.java:561) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:801) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityMonster.damageEntity(EntityMonster.java:42) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityZombie.damageEntity(EntityZombie.java:167) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityHuman.attack(EntityHuman.java:995) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.EntityPlayer.attack(EntityPlayer.java:1048) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1262) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.a(SourceFile:52) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.a(SourceFile:11) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Bukkit-1880a9c]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_11]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_11]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:676) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:632) [server.jar:git-Bukkit-1880a9c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:540) [server.jar:git-Bukkit-1880a9c]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_11]
    Caused by: java.lang.NullPointerException
        at fr.hugo.main.Main.onEntityDeath(Main.java:54) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[server.jar:git-Bukkit-1880a9c]
        ... 24 more
    [21:33:50] [Server thread/INFO]: Stopping the server
    [21:33:50] [Server thread/INFO]: Stopping server
    [21:33:50] [Server thread/INFO]: [HugoStats] Disabling HugoStats v0.1
    [21:33:50] [Server thread/INFO]: [Game] Disabling Game v0.1
    [21:33:50] [Server thread/INFO]: Saving players
    [21:33:50] [Server thread/INFO]: HugoFLP lost connection: Server closed
    [21:33:50] [Server thread/INFO]: HugoFLP left the game.
    [21:33:50] [Server thread/INFO]: Saving worlds
    [21:33:50] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
    [21:33:50] [Server thread/INFO]: Saving chunks for level 'world_nether'/Nether
    [21:33:50] [Server thread/INFO]: Saving chunks for level 'world_the_end'/The End
    
    Here the code for my scoreboard when adding +1 by an event.

    Code:
     package fr.hugo.main;
    import java.util.HashMap;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Zombie;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    public class Main extends JavaPlugin implements Listener {
       
        private Scoreboard board;
        private Objective o;
        private HashMap<String, Integer> kills = new HashMap<String, Integer>();
        public void onEnable() {
           
                Bukkit.getServer().getPluginManager().registerEvents(this, this);
              
                board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
            
                o = board.registerNewObjective("test", "dummy");
                o.setDisplayName(ChatColor.WHITE + "Stats");
                o.setDisplaySlot(DisplaySlot.SIDEBAR);
              
                Score score = o.getScore(ChatColor.WHITE + "Kills:");
                score.setScore(0);
        }
              
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) {
              
            Player eventPlayer = playerJoinEvent.getPlayer();
              
            eventPlayer.setScoreboard(board);
        }
      
        @EventHandler
        public void onEntityDeath(EntityDeathEvent e) {
            Entity en = e.getEntity();
            if (en instanceof Zombie) {
                if (((Zombie) en).getKiller() instanceof Player) {
                    Player p = ((Zombie) en).getKiller();
                        kills.put(p.getName(), kills.get(p.getName()) + 1);
                }
            }
        }
    }
    Please help me !
     
  2. Offline

    Konato_K

    @xFoundation the stack trace seems a bit offset, anyway, you're using kills.get() to ge the previous value, however, assuming it's the first time the player kills a zombie this will return null, causing an NPE
     
  3. Offline

    caderape

    @xFoundation i'm not sure how work this event. If it's called when a player kill an entity or just when an entity die. If it's the second option, the method getKiller might return null cuz it returns always a player.
     
  4. Anyone have bug fixes plz ?

    ? Please

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page