diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock index 7bdf644..a2de09c 100644 Binary files a/.gradle/8.8/checksums/checksums.lock and b/.gradle/8.8/checksums/checksums.lock differ diff --git a/.gradle/8.8/checksums/md5-checksums.bin b/.gradle/8.8/checksums/md5-checksums.bin index 37092b7..ad40401 100644 Binary files a/.gradle/8.8/checksums/md5-checksums.bin and b/.gradle/8.8/checksums/md5-checksums.bin differ diff --git a/.gradle/8.8/checksums/sha1-checksums.bin b/.gradle/8.8/checksums/sha1-checksums.bin index 4c274e3..54b0187 100644 Binary files a/.gradle/8.8/checksums/sha1-checksums.bin and b/.gradle/8.8/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 3ed939d..dbf629e 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.bin and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 81fa61d..0defb11 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index cfcce41..af41f20 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.bin and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index 96d28f6..7bc589a 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin index a98e975..250d96b 100644 Binary files a/.gradle/8.8/fileHashes/resourceHashesCache.bin and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 180fbe9..7e1d7d7 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index fbe433b..96bc042 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer$1.class b/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer$1.class new file mode 100644 index 0000000..b1153f1 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer$1.class differ diff --git a/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer.class b/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer.class new file mode 100644 index 0000000..25b6bff Binary files /dev/null and b/build/classes/java/main/CoswayUtil/BowTrajectoryVisualizer.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$2.class b/build/classes/java/main/CoswayUtil/CoswayUtil$2.class index 994d828..c90aaac 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$2.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$2.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class index 66f97ab..e3b1330 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class index 419bf5e..9d7d4fe 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class index d27e0b6..9e6264f 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class index 721a7b7..054f867 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class index 3423ee5..52a8793 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil.class b/build/classes/java/main/CoswayUtil/CoswayUtil.class index c522da6..931771f 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil.class and b/build/classes/java/main/CoswayUtil/CoswayUtil.class differ diff --git a/build/classes/java/main/CoswayUtil/TracerArrowListener$1.class b/build/classes/java/main/CoswayUtil/TracerArrowListener$1.class new file mode 100644 index 0000000..4440ea5 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/TracerArrowListener$1.class differ diff --git a/build/classes/java/main/CoswayUtil/TracerArrowListener.class b/build/classes/java/main/CoswayUtil/TracerArrowListener.class new file mode 100644 index 0000000..51a999e Binary files /dev/null and b/build/classes/java/main/CoswayUtil/TracerArrowListener.class differ diff --git a/build/libs/CoswayUtil-1.13-RELEASE.jar b/build/libs/CoswayUtil-1.13-RELEASE.jar index 0fb0e01..13d6831 100644 Binary files a/build/libs/CoswayUtil-1.13-RELEASE.jar and b/build/libs/CoswayUtil-1.13-RELEASE.jar differ diff --git a/build/resources/main/config.yml b/build/resources/main/config.yml index bb92d3c..b946cab 100644 --- a/build/resources/main/config.yml +++ b/build/resources/main/config.yml @@ -157,6 +157,15 @@ shop: display_name: "Mace Of Storms" available: true tool_id: 7 + utils7: + items: + tracerbow: + material: KOWLEDGE_BOOK + price: 54000 + quantity: 1 + display_name: "Tracer Bow" + available: true + tool_id: 8 poor: "you're too poor for that, get gooder..." inventory_full: "you got too much clutter, cant fit your purchase into that mess..." pagination: diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer$1.class.uniqueId18 b/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer$1.class.uniqueId18 new file mode 100644 index 0000000..b1153f1 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer$1.class.uniqueId18 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer.class.uniqueId2 new file mode 100644 index 0000000..25b6bff Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/BowTrajectoryVisualizer.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CheckCommand.class.uniqueId11 b/build/tmp/compileJava/compileTransaction/stash-dir/CheckCommand.class.uniqueId11 new file mode 100644 index 0000000..8311673 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CheckCommand.class.uniqueId11 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId15 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId4 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId15 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId3 similarity index 94% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId5 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId3 index 994d828..459fa94 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId5 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId3 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId1 deleted file mode 100644 index 66f97ab..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId1 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId13 similarity index 93% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId3 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId13 index 419bf5e..60ae852 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId3 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId13 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId7 new file mode 100644 index 0000000..5701f20 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.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.uniqueId20 similarity index 93% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId2 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId20 index 721a7b7..686154d 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId2 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId20 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 deleted file mode 100644 index 3423ee5..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 deleted file mode 100644 index c522da6..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId19 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId19 new file mode 100644 index 0000000..a2ce3a8 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId19 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId17 b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId17 new file mode 100644 index 0000000..8dc28e1 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId17 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId5 new file mode 100644 index 0000000..d11403e Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId5 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId8 new file mode 100644 index 0000000..446d49a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId8 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MaceOfStorms.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/MaceOfStorms.class.uniqueId1 new file mode 100644 index 0000000..8eb3560 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/MaceOfStorms.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio$1.class.uniqueId14 b/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio$1.class.uniqueId14 new file mode 100644 index 0000000..88fdf67 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio$1.class.uniqueId14 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio.class.uniqueId6 new file mode 100644 index 0000000..4cf4a9c Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/NoteStudio.class.uniqueId6 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId9 new file mode 100644 index 0000000..7d55222 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId9 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId4 new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId4 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain$1.class.uniqueId16 b/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain$1.class.uniqueId16 new file mode 100644 index 0000000..b2edd36 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain$1.class.uniqueId16 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain.class.uniqueId0 new file mode 100644 index 0000000..bac3dcd Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/TreasureFountain.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId10 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId10 new file mode 100644 index 0000000..ef78745 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId10 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/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 7364ad8..8785d34 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/CoswayUtil/BowTrajectoryVisualizer.java b/src/main/java/CoswayUtil/BowTrajectoryVisualizer.java new file mode 100644 index 0000000..2f8ff90 --- /dev/null +++ b/src/main/java/CoswayUtil/BowTrajectoryVisualizer.java @@ -0,0 +1,106 @@ +package CoswayUtil; + +import org.bukkit.*; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public class BowTrajectoryVisualizer implements Listener { + + private final CoswayUtil plugin; + private final Map activeTrajectories = new HashMap<>(); + + public BowTrajectoryVisualizer(CoswayUtil plugin) { + this.plugin = plugin; + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void onPlayerDrawBow(PlayerInteractEvent event) { + Player player = event.getPlayer(); + if(Objects.equals(getpdc(player,"bow_trail"),"true")) { + ItemStack item = player.getInventory().getItemInMainHand(); + + // Ensure the player is holding a bow + if (item.getType().toString().contains("BOW") && event.getAction().toString().contains("RIGHT_CLICK")) { + startTrajectory(player); + } + } + } + + @EventHandler + public void onArrowShoot(EntityShootBowEvent event) { + if (event.getEntity() instanceof Player player) { + if(Objects.equals(getpdc(player,"bow_trail"),"true")) { + stopTrajectory(player); + } + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + if(event instanceof Player player) { + if (Objects.equals(getpdc(player, "bow_trail"), "true")) { + stopTrajectory(event.getPlayer()); + } + } + } + + private void startTrajectory(Player player) { + stopTrajectory(player); // Ensure only one trajectory is active + + BukkitRunnable task = new BukkitRunnable() { + @Override + public void run() { + if (!player.isOnline() || !player.isHandRaised()) { + stopTrajectory(player); + return; + } + + Location eyeLocation = player.getEyeLocation(); + Vector direction = eyeLocation.getDirection().normalize().multiply(3.5); // Max bow power velocity + Location particleLocation = eyeLocation.clone(); + + double velX = direction.getX(); + double velY = direction.getY(); + double velZ = direction.getZ(); + + for (int i = 0; i < 100; i++) { // Simulating up to ~5 seconds of flight + particleLocation.add(velX, velY, velZ); + player.getWorld().spawnParticle(Particle.DUST, particleLocation, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.ORANGE, 1)); + + velY -= 0.08; // Corrected gravity application + velX *= 0.99; // Air resistance + velY *= 0.99; + velZ *= 0.99; + } + } + }; + task.runTaskTimer(plugin, 0L, 2L); + activeTrajectories.put(player, task); + } + public String getpdc(Player player, String key) { + NamespacedKey thiskey = new NamespacedKey(plugin, key); + String value = player.getPersistentDataContainer().get(thiskey, PersistentDataType.STRING); + return value; + } + private void stopTrajectory(Player player) { + if (activeTrajectories.containsKey(player)) { + activeTrajectories.get(player).cancel(); + activeTrajectories.remove(player); + } + } +} diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 3afe17e..b6dd6fa 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -89,6 +89,10 @@ public final class CoswayUtil extends JavaPlugin implements Listener { // Register TotemShield new TotemShield(this); registration("Totem Shield",3); + // register bow trejectory visualizer + new BowTrajectoryVisualizer(this); + getServer().getPluginManager().registerEvents(new BowTrajectoryVisualizer(this), this); + registration("Bow Trajectory Vistualizer",3); // Register the ShadowStep listener new MobLevitationWand(this); registration("Levitation Wand",2); @@ -131,6 +135,9 @@ public final class CoswayUtil extends JavaPlugin implements Listener { NoteStudio.init(this); registration("Note Studio",1); new TreasureFountain(this); + new TracerArrowListener(this); + getServer().getPluginManager().registerEvents(new TracerArrowListener(this), this); + registration("Tracer Arrows",3); getServer().getPluginManager().registerEvents(new TreasureFountain(this), this); registration("Treasure Fountain (W.I.P.)",3); new BankingSystem(this,economy); @@ -182,7 +189,10 @@ public final class CoswayUtil extends JavaPlugin implements Listener { if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Illumination Wand")) { player.getInventory().addItem(IlluminationWand.getIlluminationWand()); } - } + if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Tracer Bow")) { + player.getInventory().addItem(TracerArrowListener.getTracer()); + } + } } }.runTaskTimer(this,0,2); new IlluminationWand(this); diff --git a/src/main/java/CoswayUtil/TracerArrowListener.java b/src/main/java/CoswayUtil/TracerArrowListener.java new file mode 100644 index 0000000..fd500b0 --- /dev/null +++ b/src/main/java/CoswayUtil/TracerArrowListener.java @@ -0,0 +1,77 @@ +package CoswayUtil; + +import org.bukkit.*; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import java.util.Comparator; +import java.util.List; + +public class TracerArrowListener implements Listener { + + private final CoswayUtil plugin; + + public TracerArrowListener(CoswayUtil plugin) { + this.plugin = plugin; + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void onArrowShoot(ProjectileLaunchEvent event) { + if (!(event.getEntity() instanceof Arrow arrow)) return; + if (!(arrow.getShooter() instanceof Player player)) return; + if (!player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.LOYALTY)) return; + + new BukkitRunnable() { + @Override + public void run() { + if (arrow.isDead() || arrow.isInBlock()) { + cancel(); + return; + } + + LivingEntity target = getNearestEntity(arrow); + if (target == null) return; + + // Adjust trajectory to aim at target + Vector newVelocity = target.getLocation().toVector().subtract(arrow.getLocation().toVector()).normalize().multiply(3.0); + arrow.setVelocity(newVelocity); + + // Visual and sound feedback + arrow.getWorld().spawnParticle(Particle.DUST, arrow.getLocation(), 5, 0.1, 0.1, 0.1, 0, new Particle.DustOptions(Color.ORANGE, 1)); + arrow.getWorld().playSound(arrow.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.5f, 1.5f); + } + }.runTaskTimer(plugin, 5L, 2L); // Starts after 5 ticks, updates every 2 ticks + } + public static ItemStack getTracer() { + ItemStack wand = new ItemStack(Material.BOW); + ItemMeta meta = wand.getItemMeta(); + if (meta != null) { + meta.setDisplayName(ChatColor.YELLOW + "Tracer Bow"); + meta.setLore(java.util.Arrays.asList(ChatColor.GOLD + "Automatically home on hostiles", ChatColor.GRAY + "Homing Range: 25 blocks")); + meta.setUnbreakable(true); + meta.addEnchant(Enchantment.LOYALTY,1,true); + meta.setEnchantable(10); + wand.setItemMeta(meta); + } + return wand; + } + private LivingEntity getNearestEntity(Arrow arrow) { + List entities = arrow.getNearbyEntities(25, 25, 25); + + return entities.stream() + .filter(e -> e instanceof LivingEntity && !(e instanceof Player) && (e instanceof Monster)) + .map(e -> (LivingEntity) e) + .min(Comparator.comparingDouble(e -> e.getLocation().distanceSquared(arrow.getLocation()))) + .orElse(null); + } +} + + diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bb92d3c..b946cab 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -157,6 +157,15 @@ shop: display_name: "Mace Of Storms" available: true tool_id: 7 + utils7: + items: + tracerbow: + material: KOWLEDGE_BOOK + price: 54000 + quantity: 1 + display_name: "Tracer Bow" + available: true + tool_id: 8 poor: "you're too poor for that, get gooder..." inventory_full: "you got too much clutter, cant fit your purchase into that mess..." pagination: