This commit is contained in:
RayzsYT committed 2024-05-16 23:28:00 +02:00
1 parent f74339f2d1
commit 5918df2dc0
3 files changed
+17 -21

No files matched your search

@@ -31,16 +31,17 @@ public class BukkitBlockCommandListener implements Listener {
if(rawCommand.equals("/")) return;
World world = player.getWorld();
String worldName = world.getName(), alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%world%", worldName);
if(Storage.isPluginsCommand(command) && Storage.USE_CUSTOM_PLUGINS && !PermissionUtil.hasBypassPermission(player, command)) {
for (String line : Storage.CUSTOM_PLUGINS) MessageTranslator.send(player, line.replace("%command%", rawCommand.replaceFirst("/", "")));
final World world = player.getWorld();
final String worldName = world.getName(), alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%world%", worldName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> Bukkit.getServer().getPlayer(uuid) != null).forEach(uuid -> {
Player target = Bukkit.getServer().getPlayer(uuid);
MessageTranslator.send(target, alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
event.setCancelled(true);
return;
}
@@ -63,13 +64,11 @@ public class BukkitBlockCommandListener implements Listener {
for (String line : Storage.CANCEL_COMMANDS_MESSAGE) MessageTranslator.send(player, line.replace("%command%", rawCommand.replaceFirst("/", "")));
final World world = player.getWorld();
final String worldName = world.getName(), alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%world%", worldName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> Bukkit.getServer().getPlayer(uuid) != null).forEach(uuid -> {
Player target = Bukkit.getServer().getPlayer(uuid);
MessageTranslator.send(target, alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
event.setCancelled(true);
}
}
@@ -24,19 +24,20 @@ public class BungeeBlockCommandListener implements Listener {
String rawCommand = event.getMessage(), command = rawCommand.replaceFirst("/", "").toLowerCase();
if(rawCommand.equals("/")) return;
ServerInfo serverInfo = player.getServer().getInfo();
String serverName = serverInfo != null ? serverInfo.getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%server%", serverName);
if(Storage.isPluginsCommand(command) && Storage.USE_CUSTOM_PLUGINS && !PermissionUtil.hasBypassPermission(player, command)) {
for (String line : Storage.CUSTOM_PLUGINS) MessageTranslator.send(player, line.replace("%command%", rawCommand.replaceFirst("/", "")));
event.setCancelled(true);
final ServerInfo serverInfo = player.getServer().getInfo();
final String serverName = serverInfo != null ? serverInfo.getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%server%", serverName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> ProxyServer.getInstance().getPlayer(uuid) != null).forEach(uuid -> {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(uuid);
MessageTranslator.send(target, alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
return;
}
@@ -57,14 +58,11 @@ public class BungeeBlockCommandListener implements Listener {
if(!Storage.isCommandBlocked(command) || PermissionUtil.hasBypassPermission(player, command)) return;
for (String line : Storage.CANCEL_COMMANDS_MESSAGE) MessageTranslator.send(player, line.replace("%command%", rawCommand.replaceFirst("/", "")));
final ServerInfo serverInfo = player.getServer().getInfo();
final String serverName = serverInfo != null ? serverInfo.getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getName()).replace("%command%", command).replace("%server%", serverName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> ProxyServer.getInstance().getPlayer(uuid) != null).forEach(uuid -> {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(uuid);
MessageTranslator.send(target, alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
event.setCancelled(true);
}
}
@@ -27,17 +27,18 @@ public class VelocityBlockCommandListener {
if(!(commandSource instanceof Player)) return;
Player player = (Player) commandSource;
String command = event.getCommand();
String command = event.getCommand(),
serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getUsername()).replace("%command%", command).replace("%server%", serverName);
if(Storage.isPluginsCommand(command) && Storage.USE_CUSTOM_PLUGINS && !PermissionUtil.hasBypassPermission(player, command)) {
for (String line : Storage.CUSTOM_PLUGINS) MessageTranslator.send(player, line.replace("%command%", command.replaceFirst("/", "")));
event.setResult(CommandExecuteEvent.CommandResult.denied());
final String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getUsername()).replace("%command%", command).replace("%server%", serverName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> server.getPlayer(uuid).isPresent() && server.getPlayer(uuid).get().isActive()).forEach(uuid -> {
MessageTranslator.send(server.getPlayer(uuid).get(), alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) Logger.info(alertMessage);
return;
}
@@ -58,13 +59,11 @@ public class VelocityBlockCommandListener {
if(!Storage.isCommandBlocked(command) || PermissionUtil.hasBypassPermission(player, command)) return;
for (String line : Storage.CANCEL_COMMANDS_MESSAGE) MessageTranslator.send(player, line.replace("%command%", command.replaceFirst("/", "")));
final String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown",
alertMessage = Storage.NOTIFY_ALERT.replace("%player%", player.getUsername()).replace("%command%", command).replace("%server%", serverName);
if(Storage.CONSOLE_NOTIFICATION_ENABLED) MessageTranslator.send(server.getConsoleCommandSource(), alertMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> server.getPlayer(uuid).isPresent() && server.getPlayer(uuid).get().isActive()).forEach(uuid -> {
MessageTranslator.send(server.getPlayer(uuid).get(), alertMessage);
});
if(Storage.CONSOLE_NOTIFICATION_ENABLED) MessageTranslator.send(server.getConsoleCommandSource(), alertMessage);
event.setResult(CommandExecuteEvent.CommandResult.denied());
}
}