First, Sorry for not good English. The problem is When I use this code and hit player with barrage, Damager got 1 hit and attacker get two times EntityDamageByEntityEvent.. Code (Text): public void onEntityDamage(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 10); } } Specifically, I got two orb sound when I hit player once. How to fix it. I tried to use this code too Code (Text): public void onEntityDamage(EntityDamageByEntityEvent event) { Entity damager = event.getEntity(); if(damager instanceof Player && event.getDamage() <= 0) { } else { if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 10); } } } But didn't fix. Main class is public void onEnable() { getServer().getPluginManager().registerEvents(new AAA(), this); getServer().getPluginManager().registerEvents(new BBB(), this); getCommand("kit").setExecutor(new Cmds(this)); } If I didn't spam with swor, There is no bugs. Please your opinions!!
https://www.spigotmc.org/threads/one-hit-to-get-two-damage-event-how-to-fix-it.417304/ A second post with same problem doesnt solve it faster Post literally everything you have -Full main class -Full AAA class -Full BBB class Everything including imports and all
I forgot password old account, so i posted again.. AND Main class Code (Text): package kit.plugin; import org.bukkit.plugin.java.JavaPlugin; public class Core extends JavaPlugin { public void onDisable() { super.onDisable(); } public void onEnable() { getServer().getPluginManager().registerEvents(new AAA(), this); getServer().getPluginManager().registerEvents(new BBB(), this); getCommand("kit").setExecutor(new Cmds(this)); super.onEnable(); } } Code (Text): package kit.plugin; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; public class BBB implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); ItemStack hand = player.getItemInHand(); if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (hand.getType() == Material.DIAMOND_SWORD || hand.getType() == Material.IRON_SWORD || hand.getType() == Material.GOLD_SWORD || hand.getType() == Material.STONE_SWORD || hand.getType() == Material.WOOD_SWORD) { player.getWorld().playSound(player.getLocation(), Sound.LEVEL_UP, 10, 20); } } } } Code (Text): package kit.plugin; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class AAA implements Listener { @EventHandler public void onEntityDamage(EntityDamageByEntityEvent event) { Entity damager = event.getEntity(); if(damager instanceof Player && event.getDamage() <= 0) { } else { if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 10); } } }
Remove the super.onEnable(), it may be causing your onEnable to run twice and therefore register your events twice. Plus the actual super method is empty so there's no point in calling it.
Another sound was same, and I tried to display message.I got twice messages.. ill try what do you mean
If this is indeed 1.8 I'm not sure why else it would do it. In 1.9 it could be triggering for both hands independently
The super.onEnable() does not trigger your code twice. Since the super-method is empty, you should remove it. Makes stuff more clear.
I meant the method in the actual org.bukkit JavaPlugin class has an empty onEnable() method in it but that's simply so you aren't required to specify it when you create a plugin. I tested it and you are correct that super.onEnable() wouldn't be the cause of that, that was just the only thing I noticed was out of place at the moment.
Well lets get everything out first Is there any plugin that can affect the pvp? Some may alter how the damage is sent and stuff