diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 7443208..a29a217 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 6d2999e..7045657 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 5e27a75..1fbcc1c 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 160d0fa..b17145e 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 5511bf1..523a199 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 7c32ee2..5aa7e59 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$1.class index fc79f98..742c7c6 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$1.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$1.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 1a750e9..2e14d2f 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 7719ed0..dcc03e6 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 dc66162..c390690 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.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class index 7db1127..ba05ae9 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 d9c9e5c..3a57492 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.7-BETA.jar b/build/libs/CoswayUtil-1.7-BETA.jar index 48115bb..27290a4 100644 Binary files a/build/libs/CoswayUtil-1.7-BETA.jar and b/build/libs/CoswayUtil-1.7-BETA.jar differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml index 178f9b2..e984af8 100644 --- a/build/resources/main/plugin.yml +++ b/build/resources/main/plugin.yml @@ -9,7 +9,7 @@ commands: scale: permission: cosway.admin usage: "/scale " - clearanchors: - description: Clears all active anchor shields - usage: /clearanchors - permission: cosway.clearanchors \ No newline at end of file + throw: + description: Throws nearest player in a 10 block radius of you + usage: "/throw" + permission: cosway.throw \ No newline at end of file diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 index fc79f98..742c7c6 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId6 similarity index 91% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId5 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId6 index 1a750e9..2e14d2f 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId5 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId6 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 index 7719ed0..dcc03e6 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId3 deleted file mode 100644 index dc66162..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId3 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId4 deleted file mode 100644 index 15c7f69..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId4 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 index d9c9e5c..3a57492 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index f024eb0..d97dd27 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 04adad8..52d3176 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -16,6 +16,7 @@ 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.jetbrains.annotations.NotNull; import org.bukkit.potion.PotionEffectType; import org.bukkit.block.data.type.RespawnAnchor; @@ -72,10 +73,16 @@ public final class CoswayUtil extends JavaPlugin { setScale(player, Float.parseFloat(args[0])); } } - if (cmd.getName().equalsIgnoreCase("clearanchors") && sender instanceof Player) { + if (cmd.getName().equalsIgnoreCase("throw") && sender instanceof Player) { Player player = (Player) sender; - //AnchorShield.clearAnchors(); - serverMessage("&6this does not work yet..."); + Player Target = getNearestPlayer(player,10); + if(Target == null) { + returnMsg(player,"&cNo players in radius"); + } else { + throwEntityAway(Target, player.getLocation(), 6); + returnMsg(Target,"&cYou were thrown by "+player.getName()); + returnMsg(player,"&aYou threw "+Target.getName()); + } } return true; } @@ -83,6 +90,9 @@ public final class CoswayUtil extends JavaPlugin { public String prefix() { return ColorKey("[&7Cosway Utility&r] "); } + public void returnMsg(Player p,String msg) { + p.sendMessage(ColorKey(msg)); + } public void setScale(Player player, float value) { RayTraceResult result = player.getWorld().rayTraceEntities( player.getEyeLocation(), @@ -121,6 +131,32 @@ public final class CoswayUtil extends JavaPlugin { public void serverMessage(String msg) { getServer().broadcastMessage(prefix()+ColorKey(msg)); } + private void throwEntityAway(Entity entity, Location source, double power) { + if (entity == null || source == null) return; + + Location entityLoc = entity.getLocation(); + Vector knockbackDirection = entityLoc.toVector().subtract(source.toVector()).normalize(); + + // Apply velocity in the opposite direction + entity.setVelocity(knockbackDirection.multiply(power).setY(1)); + } + private Player getNearestPlayer(Player sender, double radius) { + Location senderLoc = sender.getLocation(); + Player nearestPlayer = null; + double closestDistance = radius; + + for (Player player : sender.getWorld().getPlayers()) { + if (player.equals(sender)) continue; // Skip the sender + + double distance = senderLoc.distance(player.getLocation()); + if (distance <= radius && distance < closestDistance) { + closestDistance = distance; + nearestPlayer = player; + } + } + return nearestPlayer; // Returns null if no player is found + } + //------------------------------------------------------------------------ public class AnchorShield implements Listener { private final Map activeAnchors = new HashMap<>(); @@ -227,7 +263,16 @@ public final class CoswayUtil extends JavaPlugin { 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(); + throwEntityAway(mob,loc,6); + new BukkitRunnable() { + @Override + public void run() { + if (mob.getLocation().distance(loc) <= RING_RADIUS) { + mob.remove(); + } + } + }.runTaskLater(CoswayUtil.this,30); + } }); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index dbb67c5..3a25abc 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,7 @@ commands: scale: permission: cosway.admin usage: "/scale " - clearanchors: - description: Clears all active anchor shields - usage: /clearanchors - permission: cosway.clearanchors \ No newline at end of file + throw: + description: Throws nearest player in a 10 block radius of you + usage: "/throw" + permission: cosway.throw \ No newline at end of file