diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId5 new file mode 100644 index 0000000..bfbd7ab Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId5 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId13 new file mode 100644 index 0000000..cb71c74 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId13 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId7 new file mode 100644 index 0000000..f5b2622 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId7 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId2 new file mode 100644 index 0000000..146f0de Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId9 new file mode 100644 index 0000000..540101a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId9 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 new file mode 100644 index 0000000..0dd76ff Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId10 b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId10 new file mode 100644 index 0000000..b8ab886 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId10 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId11 b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId11 new file mode 100644 index 0000000..eff2eda Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId11 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId8 new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId8 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId3 new file mode 100644 index 0000000..ef78745 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId3 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId12 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId12 new file mode 100644 index 0000000..6ce948a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId12 differ diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 75e5841..29ae4cf 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -77,7 +77,8 @@ public final class CoswayUtil extends JavaPlugin implements Listener { getServer().getPluginManager().registerEvents(new PhantomDodge(this), this); // Register the WitherContract listener getServer().getPluginManager().registerEvents(new WitherContract(this), this); - + Bukkit.getPluginManager().registerEvents(new MobLevitationWand(this), this); + this.getCommand("getwand").setExecutor(new GiveWandCommand()); } @Override diff --git a/src/main/java/CoswayUtil/GiveWandCommand.java b/src/main/java/CoswayUtil/GiveWandCommand.java new file mode 100644 index 0000000..f15ba07 --- /dev/null +++ b/src/main/java/CoswayUtil/GiveWandCommand.java @@ -0,0 +1,23 @@ +package CoswayUtil; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class GiveWandCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player player = (Player) sender; + ItemStack wand = MobLevitationWand.createWand(); // Calls the wand creation method + player.getInventory().addItem(wand); + player.sendMessage("You have received the Levitation Wand!"); + return true; + } + sender.sendMessage("Only players can use this command!"); + return false; + } +} diff --git a/src/main/java/CoswayUtil/MobLevitationWand.java b/src/main/java/CoswayUtil/MobLevitationWand.java new file mode 100644 index 0000000..547e037 --- /dev/null +++ b/src/main/java/CoswayUtil/MobLevitationWand.java @@ -0,0 +1,111 @@ +package CoswayUtil; + +import org.bukkit.*; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.UUID; + +public class MobLevitationWand implements Listener { + private final NamespacedKey wandKey = new NamespacedKey("your_plugin", "levitation_wand"); + private final HashMap levitatedMobs = new HashMap<>(); + private final CoswayUtil plugin; + + public MobLevitationWand(CoswayUtil plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onPlayerUseWand(PlayerInteractEvent event) { + Player player = event.getPlayer(); + ItemStack item = player.getInventory().getItemInMainHand(); + + // Check if the player is holding the custom wand + if (!isLevitationWand(item)) return; + + event.setCancelled(true); // Prevent default interaction + + UUID playerId = player.getUniqueId(); + + // If already holding a mob, release it + if (levitatedMobs.containsKey(playerId)) { + releaseMob(player); + return; + } + + // Try to pick up a nearby mob + Entity target = getNearestEntity(player); + if (target != null) { + levitatedMobs.put(playerId, target); + target.setGravity(false); + target.setInvulnerable(true); + startLevitating(player, target); + } else { + player.sendMessage(ChatColor.RED + "No entity found to pick up!"); + } + } + + private boolean isLevitationWand(ItemStack item) { + if (item == null || item.getType() != Material.STICK || !item.hasItemMeta()) return false; + ItemMeta meta = item.getItemMeta(); + return meta.getPersistentDataContainer().has(wandKey, PersistentDataType.STRING); + } + + private Entity getNearestEntity(Player player) { + return player.getNearbyEntities(5, 5, 5).stream() + .filter(entity -> entity instanceof LivingEntity && !(entity instanceof Player)) + .findFirst() + .orElse(null); + } + + private void startLevitating(Player player, Entity entity) { + new BukkitRunnable() { + @Override + public void run() { + if (!levitatedMobs.containsKey(player.getUniqueId()) || !player.isOnline()) { + releaseMob(player); + cancel(); + return; + } + + Vector direction = player.getLocation().getDirection().normalize().multiply(5); + Location newLocation = player.getLocation().add(direction); + + entity.teleport(newLocation); + + // Spawn particle chain + for (double i = 0; i <= 1; i += 0.1) { + double x = player.getLocation().getX() + (newLocation.getX() - player.getLocation().getX()) * i; + double y = player.getLocation().getY() + (newLocation.getY() - player.getLocation().getY()) * i; + double z = player.getLocation().getZ() + (newLocation.getZ() - player.getLocation().getZ()) * i; + player.getWorld().spawnParticle(Particle.SOUL_FIRE_FLAME, new Location(player.getWorld(), x, y, z), 2, 0, 0, 0, 0); + } + } + }.runTaskTimer(plugin, 0L, 2L); + } + + private void releaseMob(Player player) { + Entity entity = levitatedMobs.remove(player.getUniqueId()); + if (entity != null) { + entity.setGravity(true); + entity.setInvulnerable(false); + } + } + + public static ItemStack createWand() { + ItemStack wand = new ItemStack(Material.STICK); + ItemMeta meta = wand.getItemMeta(); + meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Levitation Wand"); + meta.getPersistentDataContainer().set(new NamespacedKey("CoswayUtil", "levitation_wand"), PersistentDataType.STRING, "true"); + wand.setItemMeta(meta); + return wand; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8cdd307..d3f5f8b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -16,4 +16,8 @@ commands: gravitygauntlet: description: "Gives the player a Gravity Gauntlet" usage: "/gravitygauntlet" - permission: CoswayUtil.GravityGauntlet \ No newline at end of file + permission: CoswayUtil.GravityGauntlet + getwand: + description: "Gives player a levitation wand" + usage: "/getwand" + permission: CoswayUtil.wand \ No newline at end of file