diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index 86b6d0a..595bb14 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 5d2c303..f41268d 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 6676182..86fd29c 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 45fb135..95c4869 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId1 deleted file mode 100644 index 62f671d..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId1 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 deleted file mode 100644 index ef893d3..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 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.uniqueId3 deleted file mode 100644 index 0360541..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId3 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 deleted file mode 100644 index 2e070ac..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 deleted file mode 100644 index b54d872..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 deleted file mode 100644 index 226d6e9..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 deleted file mode 100644 index 3d2d5a7..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 deleted file mode 100644 index 959ddf2..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 deleted file mode 100644 index b63243a..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 and /dev/null differ diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 38c2bd8..4d3a7d4 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -69,6 +69,8 @@ public final class CoswayUtil extends JavaPlugin implements Listener { this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand()); // Register the PhantomDodge listener getServer().getPluginManager().registerEvents(new PhantomDodge(this), this); + // Register the WitherContract listener + getServer().getPluginManager().registerEvents(new WitherContract(this), this); } diff --git a/src/main/java/CoswayUtil/GravityGauntlet.java b/src/main/java/CoswayUtil/GravityGauntlet.java index 0a376f0..2a450dd 100644 --- a/src/main/java/CoswayUtil/GravityGauntlet.java +++ b/src/main/java/CoswayUtil/GravityGauntlet.java @@ -18,7 +18,7 @@ import java.util.UUID; public class GravityGauntlet implements Listener { private final CoswayUtil plugin; // Reference to the main plugin private final Map cooldowns = new HashMap<>(); - private static final long COOLDOWN_TIME = 10 * 1000; // 5 seconds in milliseconds + private static final long COOLDOWN_TIME = 15 * 1000; // 5 seconds in milliseconds public GravityGauntlet(CoswayUtil plugin) { this.plugin = plugin; diff --git a/src/main/java/CoswayUtil/WitherContract.java b/src/main/java/CoswayUtil/WitherContract.java new file mode 100644 index 0000000..5542a7c --- /dev/null +++ b/src/main/java/CoswayUtil/WitherContract.java @@ -0,0 +1,97 @@ +package CoswayUtil; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.World; +import org.bukkit.Location; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class WitherContract implements Listener { + + private final CoswayUtil plugin; + + public WitherContract(CoswayUtil plugin) { + this.plugin = plugin; + } + + // Event handler for Wither Skull placed on Soul Sand + @EventHandler + public void onWitherSkullPlace(BlockPlaceEvent event) { + // Check if the block placed is Wither Skull on Soul Sand + Block block = event.getBlockPlaced(); + if (block.getType() == Material.SOUL_SAND && event.getItemInHand().getType() == Material.WITHER_SKELETON_SKULL) { + Player player = event.getPlayer(); + World world = block.getWorld(); + + // Find a random hostile mob within 30 blocks + LivingEntity target = findRandomHostileEntity(block.getLocation(), 30); + if (target != null) { + // Apply Wither Curse to the found mob + applyWitherCurse(target); + player.sendMessage("Wither Contract activated on " + target.getName()); + } else { + player.sendMessage("No nearby hostile mobs found to mark."); + } + } + } + + // Find a random hostile entity within the specified radius of the location + private LivingEntity findRandomHostileEntity(Location location, double radius) { + List hostileEntities = new ArrayList<>(); + for (Entity entity : location.getWorld().getEntities()) { + if (entity instanceof LivingEntity && entity instanceof Monster) { + LivingEntity livingEntity = (LivingEntity) entity; + if (livingEntity.getLocation().distance(location) <= radius) { + hostileEntities.add(livingEntity); + } + } + } + if (hostileEntities.isEmpty()) { + return null; + } + // Return a random entity from the list + Random rand = new Random(); + return hostileEntities.get(rand.nextInt(hostileEntities.size())); + } + + // Apply Wither Curse: Damage over time and handle spread when the mob dies + private void applyWitherCurse(LivingEntity target) { + // Damage over time effect (every second) + new BukkitRunnable() { + @Override + public void run() { + if (target.isDead()) { + cancel(); // Stop task if the mob is dead + } else { + target.damage(1); // Deal 1 damage per tick (20 ticks = 1 second) + } + } + }.runTaskTimer(plugin, 0, 20); // Run every 20 ticks (1 second) + + // Listen for the mob's death and apply curse to nearby mobs + target.getServer().getPluginManager().registerEvents(new Listener() { + @EventHandler + public void onEntityDeath(EntityDeathEvent deathEvent) { + if (deathEvent.getEntity() == target) { + // When the marked mob dies, spread the curse + LivingEntity nextTarget = findRandomHostileEntity(target.getLocation(), 30); + if (nextTarget != null) { + applyWitherCurse(nextTarget); + } + } + } + }, plugin); + } +} \ No newline at end of file