Skip to content

Commit

Permalink
More on permission changes.
Browse files Browse the repository at this point in the history
* Fix color replacing in command protection (had no effect previously).
* Use "no permission" message for default bukkit command protection.
* Use command protection only, no more parsing pre process for /pl etc.
* Other tweaks (update descriptions, add shortcuts / child permissions).
  • Loading branch information
asofold committed Aug 9, 2013
1 parent 0e56338 commit 858302b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 69 deletions.
Expand Up @@ -18,7 +18,6 @@
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.TickTask;
import fr.neatmonster.nocheatplus.utilities.ds.prefixtree.SimpleCharPrefixTree;

Expand Down Expand Up @@ -150,17 +149,6 @@ public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
final String commandLabel = CommandUtil.getCommandLabel(alias, false);

final ChatConfig cc = ChatConfig.getConfig(player);

// Protect some commands to prevent players for seeing which plugins are installed.
if (cc.protectPlugins) {
// TODO: Use a prefix map and generalize this.
// TODO: Configurable message.
if ((commandLabel.equals("plugins") || commandLabel.equals("version") || commandLabel.equals("icanhasbukkit")) && !player.hasPermission(Permissions.ADMINISTRATION_PLUGINS)) {
player.sendMessage(cc.noCommandPermMessage);
event.setCancelled(true);
return;
}
}

// Prevent /op and /deop commands from being used by players.
if (cc.opInConsoleOnly && (commandLabel.equals("op") || commandLabel.equals("deop"))) {
Expand Down
Expand Up @@ -15,6 +15,7 @@
import fr.neatmonster.nocheatplus.command.CommandUtil;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;

public class PermissionUtil {

Expand Down Expand Up @@ -78,7 +79,7 @@ public static List<CommandProtectionEntry> protectCommands(Collection<String> co
* @return
*/
public static List<CommandProtectionEntry> protectCommands(String permissionBase, Collection<String> ignoredCommands, boolean invertIgnored, boolean ops){
return protectCommands(permissionBase, ignoredCommands, invertIgnored, ops, ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_MSG_NOCOMMAND));
return protectCommands(permissionBase, ignoredCommands, invertIgnored, ops, ColorUtil.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_MSG_NOCOMMAND)));
}

/**
Expand Down
Expand Up @@ -23,8 +23,6 @@ public class Permissions {
* d8888888b Y8b "88 888 888 888 888 888 888 888 888 d,dP 888 888 "88 888 888 888 "88 88" 888 888
*/
private static final String ADMINISTRATION = NOCHEATPLUS + ".admin";
// See plugins.
public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins";
// Debug permission, for player spam (not in plugin.yml, currently).
public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug";

Expand Down
Expand Up @@ -83,6 +83,7 @@
import fr.neatmonster.nocheatplus.players.PlayerMessageSender;
import fr.neatmonster.nocheatplus.updates.Updates;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
import fr.neatmonster.nocheatplus.utilities.OnDemandTickListener;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import fr.neatmonster.nocheatplus.utilities.TickTask;
Expand Down Expand Up @@ -653,7 +654,8 @@ public void undoCommandChanges() {

protected void setupCommandProtection() {
final List<CommandProtectionEntry> changedCommands = PermissionUtil.protectCommands(
Arrays.asList("plugins", "version", "icanhasbukkit"), Permissions.FILTER_COMMAND, false);
Permissions.FILTER_COMMAND, Arrays.asList("plugins", "version", "icanhasbukkit"),
true, false, ColorUtil.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.PROTECT_PLUGINS_HIDE_MSG_NOPERMISSION)));
if (this.changedCommands == null) this.changedCommands = changedCommands;
else this.changedCommands.addAll(changedCommands);
}
Expand Down
114 changes: 61 additions & 53 deletions NCPPlugin/src/main/resources/plugin.yml
Expand Up @@ -31,7 +31,7 @@ permissions:
nocheatplus:
description: Allow the player to bypass all checks and give him all administration permissions.
children:

# Check bypass permissions:
nocheatplus.checks:
description: Allow the player to bypass all checks.
children:
Expand Down Expand Up @@ -256,6 +256,7 @@ permissions:
nocheatplus.filter.command.nocheatplus:
description: Filter permission to allow using sub commands of the /nocheatplus command. This permission should not be necessary to ever be given to any player unless the permission plugin is incompatible with certain aspects of super-perms.

# Command permissions:
nocheatplus.command:
description: "All command permissions, do not give lightly - if in doubt use shortcut permissions for moderators (nocheatplus.shortcut.monitor|safeadmin ...)."
children:
Expand Down Expand Up @@ -296,24 +297,76 @@ permissions:
nocheatplus.command.commands:
description: Allow use of the ncp commands command.


# Bypass permissions (other than checks):
nocheatplus.bypass:
description: Bypass permission other than command permissions.
description: Bypass other features than checks.
children:
nocheatplus.bypass.denylogin:
description: Bypass the login denial, such as exists with the ncp tempkick command.


# Various shortcuts:
nocheatplus.shortcut:
description: 'Shortcut permissions designed to be somewhat "safe" to give (see children permissions).'
children:
nocheatplus.shortcut.info:
description: Info commands about players.
children:
nocheatplus.command.notify: true
nocheatplus.command.info: true
nocheatplus.command.exemptions: true
nocheatplus.command.kicklist: true
# TODO: commands perm.
nocheatplus.command.commands: true
# TODO: Put lag here ?
nocheatplus.shortcut.monitor:
description: All monitoring commands such as player and system info (including plugins).
children:
nocheatplus.shortcut.info: true
nocheatplus.command.version: true
nocheatplus.command.lag: true
nocheatplus.admin.plugins: true
nocheatplus.feature.command: true
nocheatplus.shortcut.safeadmin:
description: 'Permissions for "safe" administration, excluding rather critical operations like reload and action commands like ban/delay (arbitrary console commands!). Fit for "heavy" mods, include temp-kicking and exemptions, does bypass login-denial.'
children:
nocheatplus.shortcut.monitor: true
nocheatplus.command.tempkick: true
nocheatplus.command.kick: true
nocheatplus.command.unkick: true
nocheatplus.command.exempt: true
nocheatplus.command.unexempt: true
nocheatplus.command.removeplayer: true
nocheatplus.filter.command: true
nocheatplus.bypass.denylogin: true
nocheatplus.shortcut.bypass:
description: Bypass everything that can be bypassed.
children:
nocheatplus.checks
nocheatplus.bypass
nocheatplus.filter.commands
nocheatplus.mods

# Shortcut: convenient testing.
nocheatplus.tester:
description: Monitoring and debugging permissions, including removing data and exemption handling for oneself.
children:
# TODO: Might just inherit from shortcut.info.
nocheatplus.shortcut.monitor: true
nocheatplus.admin.debug: true
nocheatplus.command.exempt.self: true
nocheatplus.command.unexempt.self: true
nocheatplus.command.removeplayer.self: true

# Shortcut: full administrator without check-bypass-permissions:
nocheatplus.admin:
description: "Give the player all administration rights (does not exclude from checks), do not give lightly - if in doubt use shortcut permissions for moderators (nocheatplus.shortcut.monitor|safeadmin ...)."
children:
# TODO: move debug permission (debug.XYZ?).
nocheatplus.admin.debug:
description: Receive debugging information (or cause console logs on other occasions).

nocheatplus.bypass.denylogin: true

nocheatplus.admin.plugins:
description: Allow the player to see the list of all plugins (/plugins).

nocheatplus.filter.command: true
nocheatplus.command: true

# Left in for compatibility reasons:
Expand Down Expand Up @@ -385,49 +438,4 @@ permissions:
description: DEPRECATED, use nocheatplus.command.commands instead.
children:
nocheatplus.command.commands: true

nocheatplus.shortcut:
description: 'Shortcut permissions designed to be somewhat "safe" to give (see children permissions).'
children:
nocheatplus.shortcut.info:
description: Info commands about players.
children:
nocheatplus.command.notify: true
nocheatplus.command.info: true
nocheatplus.command.exemptions: true
nocheatplus.command.kicklist: true
# TODO: commands perm.
nocheatplus.command.commands: true
# TODO: Put lag here ?
nocheatplus.shortcut.monitor:
description: All monitoring commands such as player and system info (including plugins).
children:
nocheatplus.shortcut.info: true
nocheatplus.command.version: true
nocheatplus.command.lag: true
nocheatplus.admin.plugins: true
nocheatplus.feature.command: true
nocheatplus.shortcut.safeadmin:
description: 'Permissions for "safe" administration, excluding rather critical operations like reload and action commands like ban/delay (arbitrary console commands!). Fit for "heavy" mods, include temp-kicking and exemptions, does bypass login-denial.'
children:
nocheatplus.shortcut.monitor: true
nocheatplus.command.tempkick: true
nocheatplus.command.kick: true
nocheatplus.command.unkick: true
nocheatplus.command.exempt: true
nocheatplus.command.unexempt: true
nocheatplus.command.removeplayer: true
nocheatplus.bypass.denylogin: true
# TODO: Consider other shortcuts too: checks [so ]

nocheatplus.tester:
description: Monitoring and debugging permissions, including removing data and exemption handling for oneself.
children:
# TODO: Might just inherit from shortcut.info.
nocheatplus.shortcut.monitor: true
nocheatplus.admin.debug: true
nocheatplus.command.exempt.self: true
nocheatplus.command.unexempt.self: true
nocheatplus.command.removeplayer.self: true


0 comments on commit 858302b

Please sign in to comment.