diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock index a97a3a7..90d6c55 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 0e6e8fe..5e7bcf2 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 2ada271..2f61906 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 a5f4f4d..5c6ea84 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 60713ba..9886b51 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 e6e35a7..d944862 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 00fb199..97803d2 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 0df6137..e173c64 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 118932b..06ff37a 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 5cda6d4..66361be 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index df918ae..1659231 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/build.gradle b/build.gradle index 37be30d..6a38145 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'com.newt-tech' -version = '1.5-BETA' +version = '1.6-BETA' repositories { mavenCentral() diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class index 93f1dd5..1e950dd 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 b4cf1b3..54c1c31 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.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class index 6e97bdf..f59b75c 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 f2b0abc..b12cbde 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/libs/CoswayUtil-1.5-BETA.jar b/build/libs/CoswayUtil-1.5-BETA.jar index b21e3d4..247ba87 100644 Binary files a/build/libs/CoswayUtil-1.5-BETA.jar and b/build/libs/CoswayUtil-1.5-BETA.jar differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml index 45ef721..edc13a4 100644 --- a/build/resources/main/plugin.yml +++ b/build/resources/main/plugin.yml @@ -1,5 +1,5 @@ name: CoswayUtil -version: '1.5-BETA' +version: '1.6-BETA' main: CoswayUtil.CoswayUtil description: "utility plugin for Cosway servers, a yescraft network server" api-version: '1.21' @@ -8,4 +8,8 @@ website: "ycs.Newt-Tech.com" commands: scale: permission: cosway.admin - usage: "/scale " \ No newline at end of file + usage: "/scale " + clearanchors: + description: Clears all active anchor shields + usage: /clearanchors + permission: cosway.clearanchors \ No newline at end of file diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId3 deleted file mode 100644 index 93f1dd5..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId3 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId1 index b4cf1b3..54c1c31 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId1 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId2 deleted file mode 100644 index 397724d..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId2 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 index f2b0abc..b12cbde 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 5d7518a..1c1a1b5 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/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 5a2916b..e832019 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -21,6 +21,8 @@ import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; + + public final class CoswayUtil extends JavaPlugin { @Override @@ -29,6 +31,7 @@ public final class CoswayUtil extends JavaPlugin { Bukkit.getPluginManager().registerEvents(new AnchorShield(), this); // Start the detection loop when the plugin is enabled new AnchorShield().startDetectionLoop(); + //getCommand("clearanchors").setExecutor(new ClearAnchorsCommand(this, anchorShield)); } @Override @@ -44,8 +47,10 @@ public final class CoswayUtil extends JavaPlugin { setScale(player, Float.parseFloat(args[0])); } } - if (cmd.getName().equalsIgnoreCase("scale") && sender instanceof Player) { + if (cmd.getName().equalsIgnoreCase("clearanchors") && sender instanceof Player) { Player player = (Player) sender; + //AnchorShield.clearAnchors(); + serverMessage("&6this does not work yet..."); } return true; } @@ -97,6 +102,16 @@ public final class CoswayUtil extends JavaPlugin { private final int RING_RADIUS = 15; private final int FUEL_DECREASE_TIME = 5 * 60 * 20; // 5 minutes in ticks + public void clearActiveAnchors() { + for (ArmorStand marker : activeAnchors.values()) { + if (marker != null && !marker.isDead()) { + marker.remove(); // Remove the ArmorStand from the world + } + } + activeAnchors.clear(); // Clear the HashMap + } + + public void startDetectionLoop() { new BukkitRunnable() { @Override @@ -104,7 +119,7 @@ public final class CoswayUtil extends JavaPlugin { for (World world : Bukkit.getWorlds()) { for (Chunk chunk : world.getLoadedChunks()) { for (BlockState state : chunk.getTileEntities()) { - if (state.getBlock().getType() == Material.RESPAWN_ANCHOR) { + if (state.getBlock().getType() == Material.HEAVY_CORE) { Location anchorLoc = state.getLocation(); if (isMultiBlock(anchorLoc)) { manageAnchor(anchorLoc); @@ -118,9 +133,9 @@ public final class CoswayUtil extends JavaPlugin { } private boolean isMultiBlock(Location loc) { - return loc.getBlock().getType() == Material.RESPAWN_ANCHOR && - loc.clone().add(0, 1, 0).getBlock().getType() == Material.LIGHTNING_ROD && - loc.clone().add(0, 2, 0).getBlock().getType() == Material.HEAVY_CORE; // Assuming Heavy Core + return loc.getBlock().getType() == Material.HEAVY_CORE && + loc.clone().add(0, -1, 0).getBlock().getType() == Material.LIGHTNING_ROD && + loc.clone().add(0, -2, 0).getBlock().getType() == Material.RESPAWN_ANCHOR; // Assuming Heavy Core } private void manageAnchor(Location loc) { @@ -128,39 +143,51 @@ public final class CoswayUtil extends JavaPlugin { ArmorStand marker = spawnMarker(loc); activeAnchors.put(loc, marker); startFuelTimer(loc); - } - - int fuelLevel = loc.getBlock().getBlockData().getAsString().contains("charges=") ? - Integer.parseInt(loc.getBlock().getBlockData().getAsString().split("charges=")[1].substring(0, 1)) : 0; - - if (fuelLevel > 0) { - createParticleRing(loc); - killHostileMobs(loc); + startParticleEffect(loc); // Start repeated particle and mob clearing } } private ArmorStand spawnMarker(Location loc) { - ArmorStand marker = loc.getWorld().spawn(loc.add(0.5, 0, 0.5), ArmorStand.class); + ArmorStand marker = loc.getWorld().spawn(loc.clone().add(0.5, 1, 0.5), ArmorStand.class); marker.setInvisible(true); marker.setInvulnerable(true); marker.setMarker(true); - serverMessage("anchor shield created"); + serverMessage("Anchor shield created"); + marker.getWorld().playEffect(marker.getLocation(),Effect.END_PORTAL_CREATED_IN_OVERWORLD,1); return marker; } + private void startParticleEffect(Location loc) { + new BukkitRunnable() { + @Override + public void run() { + if (!activeAnchors.containsKey(loc)) { + cancel(); + return; + } + createParticleRing(loc); + killHostileMobs(loc); + } + }.runTaskTimer(CoswayUtil.this, 20, 20); // Run every second + } + private void createParticleRing(Location loc) { - for (int i = 0; i < 360; i += 10) { + for (int i = 0; i < 360; i += 5) { double radians = Math.toRadians(i); double x = loc.getX() + RING_RADIUS * Math.cos(radians); double z = loc.getZ() + RING_RADIUS * Math.sin(radians); - Location particleLoc = new Location(loc.getWorld(), x, loc.getY() + 1, z); - loc.getWorld().spawnParticle(Particle.CRIT, particleLoc, 1, new Particle.DustOptions(Color.RED, 1)); + Location particleLoc = new Location(loc.getWorld(), x + 0.5, loc.getY() - 1, z + 0.5); + loc.getWorld().spawnParticle(Particle.DUST, particleLoc, 1, new Particle.DustOptions(Color.RED, 1)); } + Location centered = new Location(loc.getWorld(),loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5); + loc.getWorld().spawnParticle(Particle.REVERSE_PORTAL, centered,10,0); } private void killHostileMobs(Location loc) { loc.getWorld().getEntitiesByClass(Monster.class).forEach(mob -> { if (mob.getLocation().distance(loc) <= RING_RADIUS) { + mob.getWorld().playEffect(mob.getLocation(),Effect.TRIAL_SPAWNER_DETECT_PLAYER_OMINOUS,1); + mob.getWorld().playSound(mob.getLocation(),Sound.ENTITY_BREEZE_JUMP,10,0); mob.remove(); } }); @@ -205,8 +232,16 @@ public final class CoswayUtil extends JavaPlugin { @EventHandler public void onBlockBreak(BlockBreakEvent event) { Location loc = event.getBlock().getLocation(); - if (activeAnchors.containsKey(loc) || isMultiBlock(loc)) { - removeMarker(loc); + + for (Location anchorLoc : activeAnchors.keySet()) { + if (isMultiBlock(anchorLoc) && ( + loc.equals(anchorLoc) || + loc.equals(anchorLoc.clone().add(0, -1, 0)) || + loc.equals(anchorLoc.clone().add(0, -2, 0)) + )) { + removeMarker(anchorLoc); + return; + } } } @@ -220,5 +255,6 @@ public final class CoswayUtil extends JavaPlugin { } } + } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 45ef721..edc13a4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: CoswayUtil -version: '1.5-BETA' +version: '1.6-BETA' main: CoswayUtil.CoswayUtil description: "utility plugin for Cosway servers, a yescraft network server" api-version: '1.21' @@ -8,4 +8,8 @@ website: "ycs.Newt-Tech.com" commands: scale: permission: cosway.admin - usage: "/scale " \ No newline at end of file + usage: "/scale " + clearanchors: + description: Clears all active anchor shields + usage: /clearanchors + permission: cosway.clearanchors \ No newline at end of file