From 81014126d04ed2b724134d15dd5d97fa330ab9b9 Mon Sep 17 00:00:00 2001 From: mathiascode Date: Fri, 11 Oct 2019 17:22:21 +0300 Subject: [PATCH] Limit spawn radius --- src/main/java/pw/kaboom/extras/commands/CommandSkin.java | 2 +- .../java/pw/kaboom/extras/commands/CommandUsername.java | 2 +- .../java/pw/kaboom/extras/modules/player/PlayerCommand.java | 6 ++++++ .../pw/kaboom/extras/modules/player/PlayerConnection.java | 3 ++- .../java/pw/kaboom/extras/modules/server/ServerCommand.java | 6 ++++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java index 072597f..de25d18 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java @@ -40,7 +40,7 @@ class CommandSkin implements CommandExecutor { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + args[0])) + .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + args[0].replace(" ", "%20"))) .build(); client.sendAsync(request, BodyHandlers.ofInputStream()) .thenAccept(response -> { diff --git a/src/main/java/pw/kaboom/extras/commands/CommandUsername.java b/src/main/java/pw/kaboom/extras/commands/CommandUsername.java index 3035ced..eb6ac75 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandUsername.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandUsername.java @@ -43,7 +43,7 @@ class CommandUsername implements CommandExecutor { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + nameShort)) + .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + nameShort.replace(" ", "%20"))) .build(); client.sendAsync(request, BodyHandlers.ofInputStream()) .thenAccept(response -> { diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java index 2275be7..101830c 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java @@ -64,6 +64,9 @@ class PlayerCommand implements Listener { Double.parseDouble(arr[i+3]) > 6) { event.setMessage(command.replaceFirst("(?i)" + "randomTickSpeed " + arr[i+3], "randomTickSpeed 6")); break; + } else if ("spawnRadius".equalsIgnoreCase(arr[i+2]) && + Double.parseDouble(arr[i+3]) > 100) { + event.setMessage(command.replaceFirst("(?i)" + "spawnRadius " + arr[i+3], "spawnRadius 100")); } } } @@ -74,6 +77,9 @@ class PlayerCommand implements Listener { if ("randomTickSpeed".equalsIgnoreCase(arr[1]) && Double.parseDouble(arr[2]) > 6) { event.setMessage(command.replaceFirst(arr[2], "6")); + } else if ("spawnRadius".equalsIgnoreCase(arr[1]) && + Double.parseDouble(arr[2]) > 100) { + event.setMessage(command.replaceFirst(arr[2], "100")); } } else if (("/minecraft:particle".equalsIgnoreCase(arr[0]) || "/particle".equalsIgnoreCase(arr[0])) && diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java index e597393..b49434f 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java @@ -55,6 +55,7 @@ class PlayerConnection implements Listener { void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) { Main.commandMillisList.remove(event.getPlayerUniqueId()); Main.interactMillisList.remove(event.getPlayerUniqueId()); + Main.usernameInProgress.remove(event.getPlayerUniqueId()); } @EventHandler @@ -114,7 +115,7 @@ class PlayerConnection implements Listener { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + player.getName())) + .uri(URI.create("https://api.ashcon.app/mojang/v2/user/" + player.getName().replace(" ", "%20"))) .build(); client.sendAsync(request, BodyHandlers.ofInputStream()) .thenAccept(response -> { diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index 72708a3..df6db5b 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -52,6 +52,9 @@ class ServerCommand implements Listener { Double.parseDouble(arr[i+3]) > 6) { event.setCommand(command.replaceFirst("(?i)" + "randomTickSpeed " + arr[i+3], "randomTickSpeed 6")); break; + } else if ("spawnRadius".equalsIgnoreCase(arr[i+2]) && + Double.parseDouble(arr[i+3]) > 100) { + event.setCommand(command.replaceFirst("(?i)" + "spawnRadius " + arr[i+3], "spawnRadius 100")); } } } @@ -62,6 +65,9 @@ class ServerCommand implements Listener { if ("randomTickSpeed".equalsIgnoreCase(arr[1]) && Double.parseDouble(arr[2]) > 6) { event.setCommand(command.replaceFirst(arr[2], "6")); + } else if ("spawnRadius".equalsIgnoreCase(arr[1]) && + Double.parseDouble(arr[2]) > 100) { + event.setCommand(command.replaceFirst(arr[2], "100")); } } else if (("minecraft:particle".equalsIgnoreCase(arr[0]) || "particle".equalsIgnoreCase(arr[0])) &&