Make message for consoleonly feature configurable. [TICKET DBO 711]

This commit is contained in:
asofold 2014-03-15 15:57:29 +01:00
parent d130a3d583
commit f8d72eb591
4 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
/**
* Configurations specific for the "chat" checks. Every world gets one of these assigned to it, or if a world doesn't
@ -120,6 +121,7 @@ public class ChatConfig extends AsyncCheckConfig {
public final long loginsStartupDelay;
public final boolean consoleOnlyCheck;
public final String consoleOnlyMessage;
public final boolean relogCheck;
@ -214,6 +216,7 @@ public class ChatConfig extends AsyncCheckConfig {
relogActions = config.getOptimizedActionList(ConfPaths.CHAT_RELOG_ACTIONS, Permissions.CHAT_RELOG);
consoleOnlyCheck = config.getBoolean(ConfPaths.PROTECT_COMMANDS_CONSOLEONLY_ACTIVE);
consoleOnlyMessage = ColorUtil.replaceColors(config.getString(ConfPaths.PROTECT_COMMANDS_CONSOLEONLY_MSG));
}

View File

@ -173,7 +173,7 @@ public class ChatListener extends CheckListener implements INotifyReload, JoinLe
// Prevent /op and /deop commands from being used by players.
if (cc.consoleOnlyCheck && consoleOnlyCommands.hasAnyPrefixWords(lcMessage, lcAltMessage)) {
if (command == null || command.testPermission(player)){
player.sendMessage(ChatColor.RED + "I'm sorry, but this command can't be executed in chat. Use the console instead!");
player.sendMessage(cc.consoleOnlyMessage);
}
event.setCancelled(true);
return;

View File

@ -84,6 +84,7 @@ public abstract class ConfPaths {
private static final String PROTECT_COMMANDS = PROTECT + "commands.";
private static final String PROTECT_COMMANDS_CONSOLEONLY = PROTECT_COMMANDS + "consoleonly.";
public static final String PROTECT_COMMANDS_CONSOLEONLY_ACTIVE = PROTECT_COMMANDS_CONSOLEONLY + "active";
public static final String PROTECT_COMMANDS_CONSOLEONLY_MSG = PROTECT_COMMANDS_CONSOLEONLY + "message";
public static final String PROTECT_COMMANDS_CONSOLEONLY_CMDS = PROTECT_COMMANDS_CONSOLEONLY + "commands";
// Plugins settings.
private static final String PROTECT_PLUGINS = PROTECT + "plugins.";

View File

@ -71,6 +71,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.PROTECT_PLUGINS_HIDE_NOCOMMAND_CMDS, new LinkedList<String>());
// Commands (other).
set(ConfPaths.PROTECT_COMMANDS_CONSOLEONLY_ACTIVE, false);
set(ConfPaths.PROTECT_COMMANDS_CONSOLEONLY_MSG, "&cI'm sorry, but this command can't be executed in chat. Use the console instead!");
set(ConfPaths.PROTECT_COMMANDS_CONSOLEONLY_CMDS, Arrays.asList("op", "deop"));
// Client motd.
set(ConfPaths.PROTECT_CLIENTS_MOTD_ACTIVE, true);