Added Dash Stick
This commit is contained in:
@@ -10,8 +10,10 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@@ -19,23 +21,19 @@ public class DashItemListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
ItemStack item = event.getItem(); // Get the item the player interacted with
|
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();
|
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);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
|||||||
@@ -24,3 +24,6 @@ permissions:
|
|||||||
setSpawnTp:
|
setSpawnTp:
|
||||||
description: allows player to run /setSpawnTp
|
description: allows player to run /setSpawnTp
|
||||||
default: op
|
default: op
|
||||||
|
giveDashItem:
|
||||||
|
description: allows the player to run /dashstick
|
||||||
|
default: op
|
||||||
|
|||||||
Reference in New Issue
Block a user