diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 6177373..837e302 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 acc7089..9c43beb 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 da7fa74..86b6d0a 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 134f200..5d2c303 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 b88ac5e..6676182 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 d4fd82c..45fb135 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class index 4982122..70e123c 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 e3c8d77..388fc16 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 e1c28ee..b5b7b04 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 c78f10c..0d1fbef 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 3cbf3c2..94457d4 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 517cc11..b98a2f6 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/PhantomDodge$1.class b/build/classes/java/main/CoswayUtil/PhantomDodge$1.class new file mode 100644 index 0000000..b8ab886 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/PhantomDodge$1.class differ diff --git a/build/classes/java/main/CoswayUtil/PhantomDodge.class b/build/classes/java/main/CoswayUtil/PhantomDodge.class new file mode 100644 index 0000000..eff2eda Binary files /dev/null and b/build/classes/java/main/CoswayUtil/PhantomDodge.class differ diff --git a/build/classes/java/main/CoswayUtil/ShadowStep.class b/build/classes/java/main/CoswayUtil/ShadowStep.class new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/classes/java/main/CoswayUtil/ShadowStep.class differ diff --git a/build/classes/java/main/CoswayUtil/TotemShield$1.class b/build/classes/java/main/CoswayUtil/TotemShield$1.class new file mode 100644 index 0000000..c321548 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/TotemShield$1.class differ diff --git a/build/classes/java/main/CoswayUtil/TotemShield.class b/build/classes/java/main/CoswayUtil/TotemShield.class new file mode 100644 index 0000000..b84c586 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/TotemShield.class differ diff --git a/build/libs/CoswayUtil-1.9-RELEASE.jar b/build/libs/CoswayUtil-1.9-RELEASE.jar deleted file mode 100644 index 5357409..0000000 Binary files a/build/libs/CoswayUtil-1.9-RELEASE.jar and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 similarity index 91% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 index 4982122..ef893d3 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId8 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 index e3c8d77..0360541 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.uniqueId3 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 similarity index 88% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 index e1c28ee..2e070ac 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId6 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 index c78f10c..b54d872 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 similarity index 85% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 index 3cbf3c2..226d6e9 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId7 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 index 517cc11..3d2d5a7 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 index 30aedee..959ddf2 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 and b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId5 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 53df2be..a827f5e 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 9c66e46..38c2bd8 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -61,8 +61,15 @@ public final class CoswayUtil extends JavaPlugin implements Listener { }.runTaskTimer(this, 0, 2); // Runs every 10 ticks (0.5 seconds) // Register Gravity Gauntlet new GravityGauntlet(this); + // Register TotemShield + new TotemShield(this); + // Register the ShadowStep listener + getServer().getPluginManager().registerEvents(new ShadowStep(this), this); // Register command this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand()); + // Register the PhantomDodge listener + getServer().getPluginManager().registerEvents(new PhantomDodge(this), this); + } @Override diff --git a/src/main/java/CoswayUtil/PhantomDodge.java b/src/main/java/CoswayUtil/PhantomDodge.java new file mode 100644 index 0000000..8bba279 --- /dev/null +++ b/src/main/java/CoswayUtil/PhantomDodge.java @@ -0,0 +1,75 @@ +package CoswayUtil; + +import org.bukkit.entity.Player; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.entity.EntityType; +import org.bukkit.Location; +import org.bukkit.event.EventPriority; + +public class PhantomDodge implements Listener { + + private final CoswayUtil plugin; + + public PhantomDodge(CoswayUtil plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerAttack(EntityDamageByEntityEvent event) { + // Check if the entity being attacked is a player + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + + // Check if player is sprinting and jumping + if (player.isSprinting() && player.isFlying() && isValidPlayerMove(player)) { + // Momentarily turn invisible + makeInvisible(player); + + // Spawn the phantom version of the player + spawnPhantom(player); + + // Prevent damage for a short period while the phantom is active + event.setCancelled(true); + } + } + } + + // Check if player is jumping, indicating Phantom Dodge + private boolean isValidPlayerMove(Player player) { + return player.getVelocity().getY() > 0.2; // Check if the player is jumping (based on Y velocity) + } + + // Make the player invisible for 1 second + private void makeInvisible(Player player) { + player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 20, 1)); // 1 second of invisibility + } + + // Spawn the phantom version of the player + private void spawnPhantom(Player player) { + Location playerLocation = player.getLocation(); + Entity phantom = player.getWorld().spawnEntity(playerLocation, EntityType.PLAYER); + + // Set phantom's name and appearance to confuse enemies (could customize more here) + phantom.setCustomName(player.getName() + " Phantom"); + phantom.setCustomNameVisible(true); + phantom.setInvisible(true); // Make phantom invisible + + // Phantom will despawn after 1 second + new BukkitRunnable() { + @Override + public void run() { + phantom.remove(); // Remove the phantom after 1 second + } + }.runTaskLater(plugin, 20); // Delay of 1 second (20 ticks) + } +} diff --git a/src/main/java/CoswayUtil/ShadowStep.java b/src/main/java/CoswayUtil/ShadowStep.java new file mode 100644 index 0000000..5148e0c --- /dev/null +++ b/src/main/java/CoswayUtil/ShadowStep.java @@ -0,0 +1,86 @@ +package CoswayUtil; + +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +public class ShadowStep implements Listener { + + private final CoswayUtil plugin; + + public ShadowStep(CoswayUtil plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerUseEnderPearl(PlayerInteractEvent event) { + Player player = event.getPlayer(); + // Check if player is sneaking and right-clicking with Ender Pearl + if (player.isSneaking() && event.getAction().toString().contains("RIGHT_CLICK") && + player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL) { + + // Cancel the event to prevent the pearl from being thrown + event.setCancelled(true); + + // Find the nearest enemy (Player or Hostile Mob) + Entity nearestEnemy = findNearestEnemy(player); + if (nearestEnemy != null) { + teleportBehindEnemy(player, nearestEnemy); + applyBlindnessEffect(nearestEnemy); + } + } + } + + private Entity findNearestEnemy(Player player) { + Entity nearestEnemy = null; + double closestDistance = 10.0; + for (Entity entity : player.getWorld().getEntities()) { + if (entity != player && isHostile(entity)) { + double distance = player.getLocation().distance(entity.getLocation()); + if (distance <= closestDistance) { + closestDistance = distance; + nearestEnemy = entity; + } + } + } + return nearestEnemy; + } + + // Check if the entity is a hostile mob or player + private boolean isHostile(Entity entity) { + if (entity instanceof Player) { + return true; // Players are considered hostile for this mechanic + } + if (entity instanceof Monster) { + return true; // Check if the entity is a hostile mob (Monster subclass) + } + return false; + } + + private void teleportBehindEnemy(Player player, Entity enemy) { + if (enemy == null) return; + Location enemyLocation = enemy.getLocation(); + Vector direction = enemyLocation.getDirection().normalize(); + Location teleportLocation = enemyLocation.subtract(direction.multiply(2)); // Teleport 2 blocks behind + player.teleport(teleportLocation); + } + + private void applyBlindnessEffect(Entity enemy) { + if (enemy instanceof Player) { + Player targetPlayer = (Player) enemy; + targetPlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100, 1)); // 5 seconds of blindness + } else if (enemy instanceof LivingEntity) { + // If it's a mob, apply blindness + LivingEntity mob = (LivingEntity) enemy; + mob.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100, 1)); // 5 seconds of blindness + } + } +} \ No newline at end of file diff --git a/src/main/java/CoswayUtil/TotemShield.java b/src/main/java/CoswayUtil/TotemShield.java new file mode 100644 index 0000000..402fa7b --- /dev/null +++ b/src/main/java/CoswayUtil/TotemShield.java @@ -0,0 +1,100 @@ +package CoswayUtil; + +import org.bukkit.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityResurrectEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +public class TotemShield implements Listener { + private final JavaPlugin plugin; + private final Random random = new Random(); + private static final double SAVE_CHANCE = 0.5; // 50% chance to not consume the Totem + + private final Set shieldedPlayers = new HashSet<>(); + private static final int SHIELD_DURATION = 100; // 5 seconds (100 ticks) + + public TotemShield(JavaPlugin plugin) { + this.plugin = plugin; + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void onPlayerDamage(EntityDamageEvent event) { + if (!(event.getEntity() instanceof Player player)) return; + + // Check if player is holding a totem + if (!hasTotem(player)) return; + + if (shieldedPlayers.contains(player)) { + event.setCancelled(true); // Cancel damage if shield is active + return; + } + + activateShield(player); + } + + private boolean hasTotem(Player player) { + ItemStack offHand = player.getInventory().getItemInOffHand(); + return offHand.getType() == Material.TOTEM_OF_UNDYING; + } + + private void activateShield(Player player) { + shieldedPlayers.add(player); + player.getWorld().playSound(player.getLocation(), Sound.ITEM_TOTEM_USE, 1.0f, 1.0f); + player.getWorld().spawnParticle(Particle.TOTEM_OF_UNDYING, player.getLocation(), 50, 1, 1, 1); + + new BukkitRunnable() { + @Override + public void run() { + shieldedPlayers.remove(player); + consumeTotem(player); + } + }.runTaskLater(plugin, SHIELD_DURATION); + } + + private void consumeTotem(Player player) { + ItemStack offHand = player.getInventory().getItemInOffHand(); + if (random.nextDouble() < SAVE_CHANCE) { + player.sendMessage("§6Your Totem activated, but was not consumed!"); + } else { + if (offHand.getType() == Material.TOTEM_OF_UNDYING) { + offHand.setAmount(offHand.getAmount() - 1); + player.sendMessage("§6Your Totem activated, and was consumed!"); + } + } + } + + @EventHandler + public void onTotemUse(EntityResurrectEvent event) { + if (!(event.getEntity() instanceof Player player)) { + return; // Ensure it's a player using the Totem + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; // Do nothing for creative/spectator mode + } + + // Random chance to prevent Totem consumption + if (random.nextDouble() < SAVE_CHANCE) { + event.setCancelled(true); // Prevents the Totem from being consumed + player.setHealth(Math.min(player.getMaxHealth(), 10.0)); // Revives with half HP + player.getWorld().playSound(player.getLocation(), Sound.ITEM_TOTEM_USE, 1.0f, 1.0f); + player.getWorld().playSound(player.getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1.5f, 0.5f); + player.getWorld().spawnParticle(Particle.TOTEM_OF_UNDYING, player.getLocation(), 50); + player.sendMessage("§6Your Totem activated, but was not consumed!"); + + } else { + player.sendMessage("§cYour Totem was consumed as usual."); + } + } + +} +