[SOLVED] Need help with ENTITY_DEATH

Discussion in 'Plugin Development' started by Wolf7115, Dec 18, 2011.

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

    Wolf7115

    EDIT: I have no idea what the issue was, but I managed to solve it at some point.
     
  2. Offline

    user_43347

    Post the code for your "gainXP" function.
     
  3. Offline

    Wolf7115

    Whoops. Here it is:

    I know it's a lot of code, but hopefully someone can spot a small issue somewhere.

    One question though, am I not suppost to check int and double values with each other?

    Still can't find the issue btw. If anyone can find it, I would be happy.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  4. Offline

    KaiBB

    Try looking at the code I have in here from one of my plugins, should help:
    Code:
    public void onEntityDeath(EntityDeathEvent event){
            plugin.log.info("An entity just died!");
    
            if (!(event.getEntity() instanceof Player)) {
                return;
                }
    
                Player victim = (Player)event.getEntity();
                if (killStreak.containsKey(victim)){
                    if (killStreak.get(victim) > plugin.getConfig().getInt("KillstreakAmount")){
                        plugin.getServer().broadcastMessage("The killstreak of " + killStreak.get(victim) +
                                " by " + victim.getName() + " has ended!");
                    }
                    killStreak.put(victim, 0);
                }
    Hope you can salvage some of the code I have here :p
     
  5. Offline

    Wolf7115

    Thanks. I'll be sure to look the code over.
     
  6. Offline

    KaiBB

    If it helps at all, thank Rahazan (I think that's his name), he wrote all of that part.
     
  7. Offline

    Wolf7115

    The problem with my code that yours doesn't have is that I call another function to which I edit the HashMaps there. If for some reason you cannot call functions within a Bukkit event and I have not known about this, I do have some other solutions that I could do which would require a ton more code.
     
  8. Offline

    KaiBB

    So, if I get this right, your trying to call a HashMap in two different places?
     
  9. Offline

    Wolf7115

    No, I'm calling the HashMap within the plugin.gainXP function. What you might have seen that makes your code similar to mine is the plugin.pvprank HashMap. I'm using gainXP(xpType, xpAmount, Player) to tell my gainXP function what type of XP to give, how much, and to whom to give it to.
     
  10. Offline

    KaiBB

    So your calling the HashMap from a different class then where you wrote it?
     
  11. Offline

    Wolf7115

    No. I'm calling the function which is in the main class. The HashMaps are all in the main class also.
     
  12. Offline

    KaiBB

    I'm a bit confused now. I think your best bet is to ask @Rahazan about it, he taught me nearly everything I know
     
  13. Offline

    Rahazan

    @KaiBB Programming is not about rewriting existing code. You should get a grasp of the basics of Java and Bukkit programming.
     
  14. Offline

    Wolf7115

    I still get this issue whenever EntityDeathEvent gets run if anyone can help me spot this issue.
     
  15. Offline

    KaiBB

    Not exactly the basics here ;)
     
Thread Status:
Not open for further replies.

Share This Page