Hello, i was testing a new version of my plugin "iRevenge" and i suddenly found a bug I have 6 types of revenges that a player can choose from but for some reason when he choose for example poison it will also do the confusion and hellhound revenge This is the part of the code where there is (probably) something wrong: Code:java @EventHandlerpublic void PlayerDeath(PlayerDeathEvent e){ Player killer = e.getEntity().getKiller(); if(killer instanceof Player){ }else{ return; } Player p = e.getEntity(); World w = p.getWorld(); Location victim = p.getLocation(); EntityType wolf = EntityType.WOLF; //Explosion revenge if(this.getConfig().getBoolean("explosion") == true) if(explosion.contains(p.getName())) if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.explosion")) w.createExplosion(victim, 1); //Poison revenge if(this.getConfig().getBoolean("poison") == true) if(poison.contains(p.getName())) if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.poison")) killer.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 200, 1)); //Confusion revenge if(this.getConfig().getBoolean("confusion") == true) if(confusion.contains(p.getName())) if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.confusion")); killer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 500, 1)); //Hellhound revenge if(this.getConfig().getBoolean("hellhound") == true) if(hellhound.contains(p.getName())) if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.hellhound")) p.sendMessage(ChatColor.GREEN+"[iRevenge]"+ChatColor.AQUA +"The hellhound revenge does not work properly"); w.spawnCreature(victim, wolf); //TODO: Spawn wolf that targets killer //launch revenge if(this.getConfig().getBoolean("launch") == true) if(launch.contains(p.getName())) if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.launch")){ killer.setVelocity(new Vector(killer.getVelocity().getX(), 2, killer.getVelocity().getZ())); killer.sendMessage(ChatColor.GREEN +"Woooosh!"); } //Creeper revenge if(this.getConfig().getBoolean("creeper") == true) if(creeper.contains(p.getName())); if(p.hasPermission("irevenge.*") || p.hasPermission("irevenge.creeper")) return; w.spawnCreature(victim, EntityType.CREEPER); } Thanks in advance
Its probably that the booleans are also true for confusion and hellhound. Try turning the boolean to false.
On line 30 you put a semi-colon after the if statement. That makes it useless, and the code executed after it, Code: killer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 500, 1)); executes regardless of if the if statement returns true or not. The if statement at line 36 doesn't have curly braces around the code after it, meaning only Code: p.sendMessage(ChatColor.GREEN+"[iRevenge]"+ChatColor.AQUA +"The hellhound revenge does not work properly"); executes, not Code: w.spawnCreature(victim, wolf);