From def1b6b32f81aad5fadb1e5c7a8e5123b9d14af9 Mon Sep 17 00:00:00 2001 From: mathiascode Date: Wed, 18 Sep 2019 23:17:45 +0300 Subject: [PATCH] Avoid errors in checker --- .../extras/modules/player/PlayerCommand.java | 16 +++++++++++----- .../extras/modules/player/PlayerConnection.java | 3 --- .../extras/modules/player/PlayerInteract.java | 15 +++++++++------ .../extras/modules/server/ServerCommand.java | 17 ++++++++++++++++- 4 files changed, 36 insertions(+), 15 deletions(-) mode change 100644 => 100755 src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java mode change 100644 => 100755 src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java mode change 100644 => 100755 src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java old mode 100644 new mode 100755 index 98ef97e..f0938f7 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java @@ -24,12 +24,18 @@ class PlayerCommand implements Listener { final String[] arr = event.getMessage().split(" "); final String command = event.getMessage(); final UUID playerUuid = event.getPlayer().getUniqueId(); - final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid); - + + if (main.commandMillisList.get(playerUuid) != null) { + final long millisDifference = System.currentTimeMillis() - main.commandMillisList.get(playerUuid); + + if (millisDifference < 200) { + event.setCancelled(true); + } + } + main.commandMillisList.put(playerUuid, System.currentTimeMillis()); - - if (millisDifference < 200) { - event.setCancelled(true); + + if (event.isCancelled()) { return; } diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java old mode 100644 new mode 100755 index 93f492a..29432f4 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java @@ -120,9 +120,6 @@ class PlayerConnection implements Listener { final Player player = event.getPlayer(); - main.commandMillisList.put(player.getUniqueId(), System.currentTimeMillis()); - main.interactMillisList.put(player.getUniqueId(), System.currentTimeMillis()); - event.allow(); player.setOp(true); diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java old mode 100644 new mode 100755 index 94cbfab..7f3c112 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java @@ -19,12 +19,15 @@ class PlayerInteract implements Listener { void onPlayerInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); final UUID playerUuid = event.getPlayer().getUniqueId(); - final long millisDifference = System.currentTimeMillis() - main.interactMillisList.get(playerUuid); - - main.interactMillisList.put(playerUuid, System.currentTimeMillis()); - - if (millisDifference < 150) { - event.setCancelled(true); + + if (main.interactMillisList.get(playerUuid) != null) { + final long millisDifference = System.currentTimeMillis() - main.interactMillisList.get(playerUuid); + + if (millisDifference < 150) { + event.setCancelled(true); + } } + + main.interactMillisList.put(playerUuid, System.currentTimeMillis()); } } 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 264472e..c30645c 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -21,7 +21,22 @@ class ServerCommand implements Listener { final String[] arr = event.getCommand().split(" "); final String command = event.getCommand(); - if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) { + if (("minecraft:execute".equals(arr[0].toLowerCase()) || + "execute".equals(arr[0].toLowerCase())) && + arr.length >= 1) { + final StringBuilder stringBuilder = new StringBuilder(); + + for (int i = 1; i < arr.length; i++) { + stringBuilder.append(arr[i] + " "); + } + if (stringBuilder.toString().toLowerCase().contains("run execute") || + stringBuilder.toString().toLowerCase().contains("run gamerule randomtickspeed") || + stringBuilder.toString().toLowerCase().contains("run particle") || + stringBuilder.toString().toLowerCase().contains("run save-off") || + 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])) &&