Why wont it detect the entitys help please

Discussion in 'Plugin Development' started by IcyRelic, Jan 31, 2012.

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

    IcyRelic

    ok im using EntityDeathEvent here is my code
    Code:
        @EventHandler(priority = EventPriority.MONITOR)
        public void PlayerDied(EntityDeathEvent event) {
            //remove default death message
            if (event instanceof PlayerDeathEvent) {
                PlayerDeathEvent e = (PlayerDeathEvent) event;
                e.setDeathMessage(null);
            //send new one and pay
            if (event.getEntity() instanceof Player){
                Player p = (Player)event.getEntity();
                if(PaidToKill.permission.has(p, "Paid2Kill.Collect")){
                    if(p.getKiller() instanceof Player){
                        //the killer is a player
                    }else{
                        //send other messages that are mobs blocks and other
                        if(p.getKiller() == null){
                         
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "CONTACT"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Blocks.Cactus"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "BLOCK_EXPLOSION"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Blocks.TnT"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "DROWNING"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Drown"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "FALL"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Fall"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "FIRE"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Fire"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "SUFFOCATION"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Suffocation"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "VOID"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Void"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "STARVATION"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Starvation"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "SUICIDE"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Suicide"));
                            }
                            if(event.getEntity().getLastDamageCause().getCause().toString() == "MAGIC"){
                            p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Other.Potion"));
                            }
                            LivingEntity entity = (LivingEntity) event.getEntity();
                            if (!(entity instanceof Animals))
                            {
                                if (entity instanceof CraftZombie)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Zombie"));
     
                                }
                                if (entity instanceof CraftSpider)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Spider"));
     
                                }
                                if (entity instanceof CraftSkeleton)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Skeleton"));
                                }
                                if (entity instanceof CraftCreeper)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Creeper"));
     
                                }
                                if (entity instanceof CraftWolf)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Wolf"));
     
                                }
                                if (entity instanceof CraftBlaze)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Blaze"));
                                }                         
                                if (entity instanceof CraftEnderman)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Enderman"));
     
                                }
                                if (entity instanceof CraftPigZombie)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Pigman"));
     
                                }
                                if (entity instanceof CraftMagmaCube)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.MagmaCube"));
                                }
                            }
     
     
                    }
                    }
                }else{
                    p.sendMessage(ChatColor.RED + "You Dont Have Permission To Collect Money!");
                }
            }
         
        }
     
    }

    here is were its not working
    Code:
    LivingEntity entity = (LivingEntity) event.getEntity();
                            if (!(entity instanceof Animals))
                            {
                                if (entity instanceof CraftZombie)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Zombie"));
     
                                }
                                if (entity instanceof CraftSpider)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Spider"));
     
                                }
                                if (entity instanceof CraftSkeleton)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Skeleton"));
                                }
                                if (entity instanceof CraftCreeper)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Creeper"));
     
                                }
                                if (entity instanceof CraftWolf)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Wolf"));
     
                                }
                                if (entity instanceof CraftBlaze)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Blaze"));
                                }                         
                                if (entity instanceof CraftEnderman)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Enderman"));
     
                                }
                                if (entity instanceof CraftPigZombie)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.Pigman"));
     
                                }
                                if (entity instanceof CraftMagmaCube)
                                {
                                    p.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("Paid2Kill.Messages.Mobs.MagmaCube"));
                                }
                            }
     
     
                    }
    
    the top half works fine but this one doesnt help me please possible another method? of doing this?
     
  2. Remove the "Craft" part e.g. change "CraftZombie" to "Zombie"
     
  3. And it's "Animal", not "Animals".
     
  4. No, you are wrong

    But he should change it to "Creature", hostile mobs are not animals
     
  5. Offline

    nisovin

    Or just remove that check completely, as it's not necessary.
     
  6. That's against the usual naming conventions then.
     
  7. Offline

    IcyRelic

    i have removed that check and i have changed CraftZombie to Zoimbie i have tryed them both
     
  8. Offline

    coldandtired

    Not quite what you asked for, but this: if(event.getEntity().getLastDamageCause().getCause().toString() == "CONTACT") won't work. You can't compare strings that way.

    You should be doing it like this: if (event.getEntity().getLastDamageCause().getCause() == DamageCause.CONTACT)
     
  9. Offline

    IcyRelic

    im not talking about that that works fine i need to get the mob
     
  10. Offline

    IcyRelic

    Still need help
     
Thread Status:
Not open for further replies.

Share This Page