Added Dash Stick

This commit is contained in:
Dan E
2024-05-06 15:36:19 +01:00
parent 4914255c40
commit 36afcf5e89
2 changed files with 17 additions and 16 deletions
@@ -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);
+3
View File
@@ -24,3 +24,6 @@ permissions:
setSpawnTp:
description: allows player to run /setSpawnTp
default: op
giveDashItem:
description: allows the player to run /dashstick
default: op