diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index b2c5ec4..6fd506d 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 7220365..f537498 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 d8b56e6..878cf03 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 edf415c..15b6a23 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 b9fbb2c..73275c5 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 ff1a4e2..aaf215e 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 525b598..3c5057c 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.idea/MCPluginDebugger.xml b/.idea/MCPluginDebugger.xml new file mode 100644 index 0000000..36d3edc --- /dev/null +++ b/.idea/MCPluginDebugger.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 02e3c16..3639135 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'com.newt-tech' -version = '1.3-BETA' +version = '1.4-BETA' repositories { mavenCentral() diff --git a/build/classes/java/main/CoswayUtil/AnchorShield$1.class b/build/classes/java/main/CoswayUtil/AnchorShield$1.class new file mode 100644 index 0000000..43c0311 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/AnchorShield$1.class differ diff --git a/build/classes/java/main/CoswayUtil/AnchorShield$2.class b/build/classes/java/main/CoswayUtil/AnchorShield$2.class new file mode 100644 index 0000000..449bf4c Binary files /dev/null and b/build/classes/java/main/CoswayUtil/AnchorShield$2.class differ diff --git a/build/classes/java/main/CoswayUtil/AnchorShield.class b/build/classes/java/main/CoswayUtil/AnchorShield.class new file mode 100644 index 0000000..32016a9 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/AnchorShield.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 e93e9eb..594fa58 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 3cf2392..91f85f1 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 85ea478..6cbf5d2 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 f55f68a..93ec2f9 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.2-BETA copy.jar b/build/libs/CoswayUtil-1.2-BETA copy.jar new file mode 100644 index 0000000..5597ae6 Binary files /dev/null and b/build/libs/CoswayUtil-1.2-BETA copy.jar differ diff --git a/build/libs/CoswayUtil-1.3-BETA.jar b/build/libs/CoswayUtil-1.3-BETA.jar index f3100e9..bcec9fd 100644 Binary files a/build/libs/CoswayUtil-1.3-BETA.jar and b/build/libs/CoswayUtil-1.3-BETA.jar differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml index a3509e5..8ffe209 100644 --- a/build/resources/main/plugin.yml +++ b/build/resources/main/plugin.yml @@ -1,5 +1,5 @@ -CoswayUtilname: CoswayUtil -version: '1.3-BETA' +name: CoswayUtil +version: '1.4-BETA' main: CoswayUtil.CoswayUtil description: "utility plugin for Cosway servers, a yescraft network server" api-version: '1.21' diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId0 index 9479b77..af582ce 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 b2b2f9a..1ac19ca 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/AnchorShield.java b/src/main/java/CoswayUtil/AnchorShield.java new file mode 100644 index 0000000..42e5719 --- /dev/null +++ b/src/main/java/CoswayUtil/AnchorShield.java @@ -0,0 +1,138 @@ +package CoswayUtil; + +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.RayTraceResult; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; +public class AnchorShield implements Listener { + private final Map activeAnchors = new HashMap<>(); + private final int RING_RADIUS = 15; + private final int FUEL_DECREASE_TIME = 5 * 60 * 20; // 5 minutes in ticks + + public void startDetectionLoop() { + new BukkitRunnable() { + @Override + public void run() { + for (World world : Bukkit.getWorlds()) { + for (Chunk chunk : world.getLoadedChunks()) { + for (BlockState state : chunk.getTileEntities()) { + if (state.getBlock().getType() == Material.RESPAWN_ANCHOR) { + Location anchorLoc = state.getLocation(); + if (isMultiBlock(anchorLoc)) { + manageAnchor(anchorLoc); + } + } + } + } + } + } + }.runTaskTimer(Bukkit.getPluginManager().getPlugin("CoswayUtil"), 0, 100); // Run every 5 seconds + } + + 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.NETHERITE_BLOCK; // Assuming Heavy Core + } + + private void manageAnchor(Location loc) { + if (!activeAnchors.containsKey(loc)) { + 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); + } + } + + private ArmorStand spawnMarker(Location loc) { + ArmorStand marker = loc.getWorld().spawn(loc.add(0.5, 1, 0.5), ArmorStand.class); + marker.setInvisible(true); + marker.setInvulnerable(true); + marker.setMarker(true); + return marker; + } + + private void createParticleRing(Location loc) { + for (int i = 0; i < 360; i += 10) { + 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)); + } + } + + private void killHostileMobs(Location loc) { + loc.getWorld().getEntitiesByClass(Monster.class).forEach(mob -> { + if (mob.getLocation().distance(loc) <= RING_RADIUS) { + mob.remove(); + } + }); + } + + private void startFuelTimer(Location loc) { + new BukkitRunnable() { + @Override + public void run() { + if (!activeAnchors.containsKey(loc)) { + cancel(); + return; + } + + Block block = loc.getBlock(); + if (block.getType() != Material.RESPAWN_ANCHOR) { + removeMarker(loc); + cancel(); + return; + } + + int fuelLevel = block.getBlockData().getAsString().contains("charges=") ? + Integer.parseInt(block.getBlockData().getAsString().split("charges=")[1].substring(0, 1)) : 0; + + if (fuelLevel > 0) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "data merge block " + loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ() + " {Charges:" + (fuelLevel - 1) + "}"); + } else { + removeMarker(loc); + cancel(); + } + } + }.runTaskTimer(Bukkit.getPluginManager().getPlugin("CoswayUtil"), FUEL_DECREASE_TIME, FUEL_DECREASE_TIME); + } + + private void removeMarker(Location loc) { + if (activeAnchors.containsKey(loc)) { + activeAnchors.get(loc).remove(); + activeAnchors.remove(loc); + } + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) { + Location loc = event.getBlock().getLocation(); + if (activeAnchors.containsKey(loc) || isMultiBlock(loc)) { + removeMarker(loc); + } + } +} \ No newline at end of file diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index fc5e2b5..21d5a83 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -15,16 +15,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.RayTraceResult; -import org.bukkit.util.Vector; -import org.bukkit.*; -import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; -import java.util.*; - import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -37,7 +27,6 @@ public final class CoswayUtil extends JavaPlugin { serverMessage(ColorKey("&aaw sheit here we go again....")); Bukkit.getPluginManager().registerEvents(new AnchorShield(), this); - } @Override @@ -57,7 +46,7 @@ public final class CoswayUtil extends JavaPlugin { } public String prefix() { - return "[Cosway Utility] "; + return ColorKey("[&7Cosway Utility&r] "); } public void setScale(Player player, float value) { RayTraceResult result = player.getWorld().rayTraceEntities( @@ -97,8 +86,7 @@ public final class CoswayUtil extends JavaPlugin { public void serverMessage(String msg) { getServer().broadcastMessage(prefix()+msg); } - - + //------------------------------------------------------------------------ public class AnchorShield implements Listener { private final Map activeAnchors = new HashMap<>(); private final int RING_RADIUS = 15; @@ -127,7 +115,7 @@ 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.NETHERITE_BLOCK; // Assuming Heavy Core + loc.clone().add(0, 2, 0).getBlock().getType() == Material.HEAVY_CORE; // Assuming Heavy Core } private void manageAnchor(Location loc) { @@ -216,5 +204,5 @@ public final class CoswayUtil extends JavaPlugin { } } } - } + diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a3509e5..8ffe209 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ -CoswayUtilname: CoswayUtil -version: '1.3-BETA' +name: CoswayUtil +version: '1.4-BETA' main: CoswayUtil.CoswayUtil description: "utility plugin for Cosway servers, a yescraft network server" api-version: '1.21'