Could not pass event EntityDeathEvent to Plugin

Discussion in 'Plugin Help/Development/Requests' started by Nathat23, Dec 23, 2014.

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

    Nathat23

    Hello! When someone kills a zombie, its supposed to give them a set amount of money in the config, but instead it just puts the error "Could not pass event EntityDeathEvent to Plugin"

    Code:
    Code:
    package me.Nathat23;
    
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    
    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;
    
    public class Rewards implements Listener{
        public static Economy econ = null;
        KillerRewards configGetter;
        KillerRewards economy;
    
        public Rewards(KillerRewards plugin){
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
            configGetter = plugin;
            economy = plugin;
        }
      
        @EventHandler
        public void killZombie(EntityDeathEvent ZombieDeath){
            Entity deadEntity = ZombieDeath.getEntity();
            Entity killer = ZombieDeath.getEntity().getKiller();
            if (killer instanceof Player && deadEntity instanceof Zombie){
                Player player = (Player) killer;
                int zombieReward = configGetter.getConfig().getInt("ZombieKill");
                EconomyResponse r = econ.depositPlayer(player, zombieReward);
                if(r.transactionSuccess()) {
                    player.sendMessage(ChatColor.GREEN + "You just killed a " + ChatColor.GOLD + ZombieDeath.getEntity() + ChatColor.GREEN + " and recived " + ChatColor.GOLD + "$" + zombieReward);
                } else {
                    player.sendMessage(String.format("An error occured: %s", r.errorMessage));
                }
            }
              
        }
    }
    
    Error:
    Show Spoiler
    Code:
    [12:22:26] [Server thread/ERROR]: Could not pass event EntityDeathEvent to KillerRewards v0.0.1
    org.bukkit.event.EventException
       at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:379) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.EntityLiving.die(EntityLiving.java:810) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.EntityLiving.damageEntity(EntityLiving.java:745) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.EntityMonster.damageEntity(EntityMonster.java:48) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.EntityZombie.damageEntity(EntityZombie.java:164) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.EntityHuman.attack(EntityHuman.java:950) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:1204) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:37) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.PacketPlayInUseEntity.handle(PacketPlayInUseEntity.java:49) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
    Caused by: java.lang.NullPointerException
       at me.Nathat23.Rewards.killZombie(Rewards.java:32) ~[?:?]
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
       at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
       at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[NewSpigot.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
       ... 19 more
    
     
    Last edited by a moderator: Dec 23, 2014
  2. Offline

    mrCookieSlime

    Moved to Alternatives Section.
     
  3. Offline

    nverdier

    @Nathat23 The error is saying that something on the following line has the value of null:
    Code:
    EconomyResponse r = econ.depositPlayer(player, zombieReward);
    In this case it is 'econ' as you define it as 'null' at the top and never re-define it... Why do you have 'configGetter' as well as 'economy' if they are both set to the same thing? You have just change it to 'main' or something and use 1 instance.
     
  4. Offline

    Nathat23

    Because it gets them from the other class, or does it?
     
  5. Offline

    nverdier

    Because you set it to null when you defined it...
     
  6. Offline

    Nathat23

    Solved the issue, mods please lock
     
  7. Offline

    mrCookieSlime

    Locked on Request.

    @Nathat23
    Please use the report button if you want us to lock your Thread.
     
Thread Status:
Not open for further replies.

Share This Page