Avoid errors in checker

This commit is contained in:
mathiascode 2019-09-18 23:17:45 +03:00
parent bb082a614d
commit def1b6b32f
4 changed files with 36 additions and 15 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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);
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());
if (millisDifference < 150) {
event.setCancelled(true);
}
}
}

View file

@ -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])) &&