diff --git a/src/main/java/fantasypvp/kand_smp/events/DashItemListener.java b/src/main/java/fantasypvp/kand_smp/events/DashItemListener.java index c9940bb..794a780 100644 --- a/src/main/java/fantasypvp/kand_smp/events/DashItemListener.java +++ b/src/main/java/fantasypvp/kand_smp/events/DashItemListener.java @@ -10,8 +10,10 @@ import org.bukkit.World; 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.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -19,23 +21,19 @@ public class DashItemListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + Player player = event.getPlayer(); ItemStack item = event.getItem(); // Get the item the player interacted with - if (item != null && item.isSimilar(new DashItem().createDashItem())) { - - Player player = event.getPlayer(); - - Location location = player.getLocation(); - - Vector direction = location.getDirection(); - - player.setVelocity(direction.multiply(2.0)); - - player.playSound(location, Sound.ENTITY_DRAGON_FIREBALL_EXPLODE, 1.0f, 1.0f); - - World world = player.getWorld(); - - world.spawnParticle(Particle.EXPLOSION_LARGE,location,1); + // Check if the interaction was a right-click and the item is in the main hand + if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (item != null && item.isSimilar(new DashItem().createDashItem()) && event.getHand() == EquipmentSlot.HAND) { + Location location = player.getLocation(); + Vector direction = location.getDirection(); + player.setVelocity(direction.multiply(5.0)); + player.playSound(location, Sound.ENTITY_DRAGON_FIREBALL_EXPLODE, 1.0f, 1.0f); + World world = player.getWorld(); + world.spawnParticle(Particle.EXPLOSION_HUGE, location, 1); + } } } @@ -47,7 +45,7 @@ public class DashItemListener implements Listener { ItemStack itemInMainHand = player.getInventory().getItemInMainHand(); - if (itemInMainHand.isSimilar(new DashItem().createDashItem())) { + if (itemInMainHand.isSimilar(new DashItem().createDashItem()) && event.getCause() == EntityDamageEvent.DamageCause.FALL) { event.setCancelled(true); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c3846e1..6c4f889 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -24,3 +24,6 @@ permissions: setSpawnTp: description: allows player to run /setSpawnTp default: op + giveDashItem: + description: allows the player to run /dashstick + default: op