From b82c63a3ed6ae6a715123d1730fca7f7b9e8f54e Mon Sep 17 00:00:00 2001 From: mathiascode Date: Thu, 19 Sep 2019 00:35:11 +0300 Subject: [PATCH] Simplify code --- .../kaboom/extras/modules/entity/EntitySpawn.java | 4 ---- .../extras/modules/player/PlayerCommand.java | 8 ++++---- .../extras/modules/server/ServerCommand.java | 14 +++++++------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java index a44dd7a..1b88315 100644 --- a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java +++ b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java @@ -144,7 +144,6 @@ class EntitySpawn implements Listener { if (dragonCount > 25) { event.setCancelled(true); - return; } } else if (event.getEntityType() == EntityType.MAGMA_CUBE) { final MagmaCube magmacube = (MagmaCube) event.getEntity(); @@ -279,7 +278,6 @@ class EntitySpawn implements Listener { if (dragonCount > 25) { event.setCancelled(true); - return; } } } @@ -312,7 +310,6 @@ class EntitySpawn implements Listener { } } catch (Exception exception) { event.setCancelled(true); - return; } } @@ -323,7 +320,6 @@ class EntitySpawn implements Listener { if (block.getBlockData().getMaterial() == Material.SPAWNER) { event.setCancelled(true); - return; } } } 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 f0938f7..ecc242d 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java @@ -41,11 +41,11 @@ class PlayerCommand implements Listener { if (("/minecraft:execute".equals(arr[0].toLowerCase()) || "/execute".equals(arr[0].toLowerCase())) && - arr.length >= 1) { + arr.length >= 2) { final StringBuilder stringBuilder = new StringBuilder(); for (int i = 1; i < arr.length; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } if (stringBuilder.toString().toLowerCase().contains("run execute") || stringBuilder.toString().toLowerCase().contains("run gamerule randomtickspeed") || @@ -68,11 +68,11 @@ class PlayerCommand implements Listener { final StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 9; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } stringBuilder.append("10 "); for (int i = 10; i < arr.length; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } event.setMessage(stringBuilder.toString()); 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 c30645c..36c4d53 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -21,13 +21,15 @@ class ServerCommand implements Listener { final String[] arr = event.getCommand().split(" "); final String command = event.getCommand(); - if (("minecraft:execute".equals(arr[0].toLowerCase()) || + if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) { + event.setCancelled(true); + } else if (("minecraft:execute".equals(arr[0].toLowerCase()) || "execute".equals(arr[0].toLowerCase())) && - arr.length >= 1) { + arr.length >= 2) { final StringBuilder stringBuilder = new StringBuilder(); for (int i = 1; i < arr.length; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } if (stringBuilder.toString().toLowerCase().contains("run execute") || stringBuilder.toString().toLowerCase().contains("run gamerule randomtickspeed") || @@ -36,8 +38,6 @@ class ServerCommand implements Listener { stringBuilder.toString().toLowerCase().contains("run stop")) { event.setCancelled(true); } - } else if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) { - event.setCancelled(true); } else if (("minecraft:gamerule".equalsIgnoreCase(arr[0]) || "gamerule".equalsIgnoreCase(arr[0])) && arr.length >= 3) { @@ -52,11 +52,11 @@ class ServerCommand implements Listener { final StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 9; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } stringBuilder.append("10 "); for (int i = 10; i < arr.length; i++) { - stringBuilder.append(arr[i] + " "); + stringBuilder.append(arr[i]).append(" "); } event.setCommand(stringBuilder.toString());