Rework parts of permissions.

Changes are mostly backwards compatible.

Fixed:
* Filter permissions were wrong (not starting with nocheatplus).

Changed:
* Commands are grouped under nocheatplus.command now.
* Notification permission is independent of the notify command,
	 changed to nocheatplus.notify.

New:
* Shortcut permissions (nocheatplus.shortcut...) for safer use.
* Shortcut permission for testers: nocheatplus.tester
This commit is contained in:
asofold 2013-08-09 18:01:51 +02:00
parent e17b14e17d
commit 84c376864e
20 changed files with 240 additions and 100 deletions

View File

@ -18,7 +18,7 @@ import fr.neatmonster.nocheatplus.players.DataManager;
public class BanCommand extends BaseCommand {
public BanCommand(JavaPlugin plugin) {
super(plugin, "ban", Permissions.ADMINISTRATION_BAN);
super(plugin, "ban", Permissions.COMMAND_BAN);
}
@Override

View File

@ -16,7 +16,7 @@ import fr.neatmonster.nocheatplus.players.DataManager;
public class KickCommand extends BaseCommand {
public KickCommand(JavaPlugin plugin) {
super(plugin, "kick", Permissions.ADMINISTRATION_KICK);
super(plugin, "kick", Permissions.COMMAND_KICK);
}
@Override

View File

@ -14,7 +14,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class KickListCommand extends BaseCommand {
public KickListCommand(JavaPlugin plugin) {
super(plugin, "kicklist", Permissions.ADMINISTRATION_KICKLIST);
super(plugin, "kicklist", Permissions.COMMAND_KICKLIST);
}
@Override

View File

@ -21,7 +21,7 @@ import fr.neatmonster.nocheatplus.utilities.ColorUtil;
public class TellCommand extends BaseCommand {
public TellCommand(JavaPlugin plugin) {
super(plugin, "tell", Permissions.ADMINISTRATION_TELL);
super(plugin, "tell", Permissions.COMMAND_TELL);
}
@Override

View File

@ -17,7 +17,7 @@ import fr.neatmonster.nocheatplus.players.DataManager;
public class TempKickCommand extends BaseCommand {
public TempKickCommand(JavaPlugin plugin) {
super(plugin, "tempkick", Permissions.ADMINISTRATION_TEMPKICK,
super(plugin, "tempkick", Permissions.COMMAND_TEMPKICK,
new String[]{"tkick", "tempban", "tban",});
}

View File

@ -13,7 +13,7 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
public class UnKickCommand extends BaseCommand {
public UnKickCommand(JavaPlugin plugin) {
super(plugin, "unkick", Permissions.ADMINISTRATION_UNKICK);
super(plugin, "unkick", Permissions.COMMAND_UNKICK);
}
@Override

View File

@ -17,7 +17,7 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
public class DelayCommand extends DelayableCommand {
public DelayCommand(JavaPlugin plugin){
super(plugin, "delay", Permissions.ADMINISTRATION_DELAY, 1, 0, true);
super(plugin, "delay", Permissions.COMMAND_DELAY, 1, 0, true);
}
@Override

View File

@ -30,7 +30,7 @@ public class CommandsCommand extends BaseCommand {
final String allCommands;
public CommandsCommand(JavaPlugin plugin) {
super(plugin, "commands", Permissions.ADMINISTRATION_COMMANDS, new String[]{"cmds"});
super(plugin, "commands", Permissions.COMMAND_COMMANDS, new String[]{"cmds"});
for (int i = 0; i < moreCommands.length; i++){
moreCommands[i] = moreCommands[i].replace("<command>", "ncp");
}

View File

@ -20,7 +20,7 @@ import fr.neatmonster.nocheatplus.players.DataManager;
public class InfoCommand extends BaseCommand {
public InfoCommand(JavaPlugin plugin) {
super(plugin, "info", Permissions.ADMINISTRATION_INFO);
super(plugin, "info", Permissions.COMMAND_INFO);
}
@Override

View File

@ -12,7 +12,7 @@ import fr.neatmonster.nocheatplus.utilities.TickTask;
public class LagCommand extends BaseCommand {
public LagCommand(JavaPlugin plugin) {
super(plugin, "lag", Permissions.ADMINISTRATION_LAG);
super(plugin, "lag", Permissions.COMMAND_LAG);
}
@Override

View File

@ -21,7 +21,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class NCPVersionCommand extends BaseCommand{
public NCPVersionCommand(JavaPlugin plugin) {
super(plugin, "version", Permissions.ADMINISTRATION_VERSION, new String[]{"versions", "ver"});
super(plugin, "version", Permissions.COMMAND_VERSION, new String[]{"versions", "ver"});
}
@Override

View File

@ -28,7 +28,7 @@ public class ReloadCommand extends BaseCommand {
private final List<INotifyReload> notifyReload;
public ReloadCommand(JavaPlugin plugin, List<INotifyReload> notifyReload) {
super(plugin, "reload", Permissions.ADMINISTRATION_RELOAD);
super(plugin, "reload", Permissions.COMMAND_RELOAD);
this.notifyReload = notifyReload;
}

View File

@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class RemovePlayerCommand extends BaseCommand {
public RemovePlayerCommand(JavaPlugin plugin) {
super(plugin, "removeplayer", Permissions.ADMINISTRATION_REMOVEPLAYER, new String[]{
super(plugin, "removeplayer", Permissions.COMMAND_REMOVEPLAYER, new String[]{
"remove",
});
}

View File

@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class ExemptCommand extends BaseCommand {
public ExemptCommand(JavaPlugin plugin) {
super(plugin, "exempt", Permissions.ADMINISTRATION_EXEMPT);
super(plugin, "exempt", Permissions.COMMAND_EXEMPT);
}
@Override

View File

@ -18,7 +18,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class ExemptionsCommand extends BaseCommand {
public ExemptionsCommand(JavaPlugin plugin) {
super(plugin, "exemptions", Permissions.ADMINISTRATION_EXEMPTIONS, new String[]{"exe"});
super(plugin, "exemptions", Permissions.COMMAND_EXEMPTIONS, new String[]{"exe"});
}
@Override

View File

@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class UnexemptCommand extends BaseCommand {
public UnexemptCommand(JavaPlugin plugin) {
super(plugin, "unexempt", Permissions.ADMINISTRATION_UNEXEMPT);
super(plugin, "unexempt", Permissions.COMMAND_UNEXEMPT);
}
@Override

View File

@ -13,7 +13,7 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
public class NotifyCommand extends BaseCommand {
public NotifyCommand(JavaPlugin plugin) {
super(plugin, "notify", Permissions.ADMINISTRATION_NOTIFY, new String[]{"alert", "alerts"});
super(plugin, "notify", Permissions.COMMAND_NOTIFY, new String[]{"alert", "alerts"});
addSubCommands(
new NotifyOffCommand(plugin),
new NotifyOnCommand(plugin)

View File

@ -23,28 +23,8 @@ 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";
public static final String ADMINISTRATION_BAN = ADMINISTRATION + ".ban";
public static final String ADMINISTRATION_DELAY = ADMINISTRATION + ".delay";
public static final String ADMINISTRATION_EXEMPT = ADMINISTRATION + ".exempt";
public static final String ADMINISTRATION_UNEXEMPT = ADMINISTRATION + ".unexempt";
public static final String ADMINISTRATION_EXEMPTIONS = ADMINISTRATION + ".exemptions";
public static final String ADMINISTRATION_INFO = ADMINISTRATION + ".info";
public static final String ADMINISTRATION_COMMANDS = ADMINISTRATION + ".commands";
public static final String ADMINISTRATION_KICK = ADMINISTRATION + ".kick";
public static final String ADMINISTRATION_KICKLIST = ADMINISTRATION + ".kicklist";
public static final String ADMINISTRATION_LAG = ADMINISTRATION + ".lag";
public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify";
public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins";
public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload";
public static final String ADMINISTRATION_REMOVEPLAYER = ADMINISTRATION + ".removeplayer";
public static final String ADMINISTRATION_TELL = ADMINISTRATION + ".tell";
public static final String ADMINISTRATION_TEMPKICK = ADMINISTRATION + ".tempkick";
public static final String ADMINISTRATION_UNKICK = ADMINISTRATION + ".unkick";
public static final String ADMINISTRATION_VERSION = ADMINISTRATION + ".version";
// 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";
@ -52,10 +32,33 @@ public class Permissions {
private final static String BYPASS = NOCHEATPLUS + ".bypass";
public static final String BYPASS_DENY_LOGIN = BYPASS + "denylogin";
private static final String FEATURE = "feature";
private static final String FEATURE = NOCHEATPLUS + ".feature";
public static final String FEATURE_COMMAND = FEATURE + ".command";
public static final String FEATURE_COMMAND_NOCHEATPLUS = FEATURE_COMMAND + ".nocheatplus";
// Notifications (in-game).
public static final String NOTIFY = NOCHEATPLUS + ".notify";
// Command permissions.
public static final String COMMAND = NOCHEATPLUS + ".command";
public static final String COMMAND_BAN = COMMAND + ".ban";
public static final String COMMAND_DELAY = COMMAND + ".delay";
public static final String COMMAND_EXEMPT = COMMAND + ".exempt";
public static final String COMMAND_UNEXEMPT = COMMAND + ".unexempt";
public static final String COMMAND_EXEMPTIONS = COMMAND + ".exemptions";
public static final String COMMAND_NOTIFY = COMMAND + ".notify";
public static final String COMMAND_INFO = COMMAND + ".info";
public static final String COMMAND_COMMANDS = COMMAND + ".commands";
public static final String COMMAND_KICK = COMMAND + ".kick";
public static final String COMMAND_KICKLIST = COMMAND + ".kicklist";
public static final String COMMAND_LAG = COMMAND + ".lag";
public static final String COMMAND_RELOAD = COMMAND + ".reload";
public static final String COMMAND_REMOVEPLAYER = COMMAND + ".removeplayer";
public static final String COMMAND_TELL = COMMAND + ".tell";
public static final String COMMAND_TEMPKICK = COMMAND + ".tempkick";
public static final String COMMAND_UNKICK = COMMAND + ".unkick";
public static final String COMMAND_VERSION = COMMAND + ".version";
// Permissions for the individual checks.

View File

@ -121,7 +121,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
//////////////////
/** Names of players with a certain permission. */
protected final NameSetPermState nameSetPerms = new NameSetPermState(Permissions.ADMINISTRATION_NOTIFY);
protected final NameSetPermState nameSetPerms = new NameSetPermState(Permissions.NOTIFY);
/** Lower case player name to milliseconds point of time of release */
private final Map<String, Long> denyLoginNames = Collections.synchronizedMap(new HashMap<String, Long>());
@ -290,7 +290,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
* @return
*/
public int sendAdminNotifyMessageStored(final String message){
final Set<String> names = nameSetPerms.getPlayers(Permissions.ADMINISTRATION_NOTIFY);
final Set<String> names = nameSetPerms.getPlayers(Permissions.NOTIFY);
if (names == null) return 0;
int done = 0;
for (final String name : names){
@ -313,11 +313,11 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
* @return
*/
public int sendAdminNotifyMessageSubscriptions(final String message){
final Set<Permissible> permissibles = Bukkit.getPluginManager().getPermissionSubscriptions(Permissions.ADMINISTRATION_NOTIFY);
final Set<String> names = nameSetPerms.getPlayers(Permissions.ADMINISTRATION_NOTIFY);
final Set<Permissible> permissibles = Bukkit.getPluginManager().getPermissionSubscriptions(Permissions.NOTIFY);
final Set<String> names = nameSetPerms.getPlayers(Permissions.NOTIFY);
final Set<String> done = new HashSet<String>(permissibles.size() + (names == null ? 0 : names.size()));
for (final Permissible permissible : permissibles){
if (permissible instanceof CommandSender && permissible.hasPermission(Permissions.ADMINISTRATION_NOTIFY)){
if (permissible instanceof CommandSender && permissible.hasPermission(Permissions.NOTIFY)){
final CommandSender sender = (CommandSender) permissible;
if ((sender instanceof Player) && hasTurnedOffNotifications(((Player) sender).getName())){
continue;
@ -332,7 +332,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
for (final String name : names){
if (!done.contains(name)){
final Player player = DataManager.getPlayerExact(name);
if (player != null && player.hasPermission(Permissions.ADMINISTRATION_NOTIFY)){
if (player != null && player.hasPermission(Permissions.NOTIFY)){
if (hasTurnedOffNotifications(player.getName())){
continue;
}
@ -1089,7 +1089,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
protected void onJoinLow(final Player player){
final String playerName = player.getName();
if (nameSetPerms.hasPermission(playerName, Permissions.ADMINISTRATION_NOTIFY)){
if (nameSetPerms.hasPermission(playerName, Permissions.NOTIFY)){
// Login notifications...
final PlayerData data = DataManager.getPlayerData(playerName, true);
// // Update available.

View File

@ -31,57 +31,7 @@ permissions:
nocheatplus:
description: Allow the player to bypass all checks and give him all administration permissions.
children:
nocheatplus.admin:
description: Give the player all administration rights.
children:
nocheatplus.admin.notify:
description: Allow the player to see the alerts in the in-game chat.
nocheatplus.admin.plugins:
description: Allow the player to see the list of all plugins (/plugins).
nocheatplus.admin.reload:
description: Allow the player to reload NoCheatPlus configuration.
nocheatplus.admin.info:
description: Allow to see violation info about a player.
nocheatplus.admin.exemptions:
description: Allow to see exemptions for a player.
nocheatplus.admin.exempt:
description: Allow to add exemptions for a player.
nocheatplus.admin.unexempt:
description: Allow to remove exemptions from a player.
nocheatplus.admin.ban:
description: Allow use of the ncp ban command.
nocheatplus.admin.kick:
description: Allow use of the ncp kick command.
nocheatplus.admin.kicklist:
description: Allow use of the ncp kicklist command.
nocheatplus.admin.lag:
description: Allow use of the ncp lag command.
nocheatplus.admin.tell:
description: Allow use of the ncp tell command.
nocheatplus.admin.delay:
description: Allow use of the ncp delay command.
nocheatplus.admin.tempkick:
description: Allow use of the ncp tempkick command.
nocheatplus.admin.unkick:
description: Allow use of the ncp unkick command.
nocheatplus.admin.version:
description: Allow use of the ncp version command.
nocheatplus.admin.removeplayer:
description: Allow use of the ncp removeplayer command.
nocheatplus.admin.commands:
description: Allow use of the ncp commands command.
nocheatplus.admin.debug:
description: Allow to receive debug information.
nocheatplus.bypass:
description: Bypass permission other than command permissions.
children:
nocheatplus.bypass.denylogin:
description: Bypass the login denial, such as exists with the ncp tempkick command.
nocheatplus.feature.command:
description: Allows use of all commands protected by the command protection, like the ncp root command. Does not give functionality but allow seeing usage and tab-completion of the command. In future there can be many children not listed in this config.
children:
nocheatplus.feature.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 aspects of super-perms.
nocheatplus.checks:
description: Allow the player to bypass all checks.
children:
@ -230,6 +180,7 @@ permissions:
description: Allow the player to sprint backwards.
nocheatplus.checks.moving.survivalfly.step:
description: Allow the player to use the 'step' functionality of his client.
nocheatplus.mods:
description: Allow the player to use all the client mods.
children:
@ -294,4 +245,190 @@ permissions:
nocheatplus.mods.zombe.fly:
description: Allow the player to use Zombe's fly mod.
nocheatplus.mods.zombe.noclip:
description: Allow the player to use Zombe's noclip.
description: Allow the player to use Zombe's noclip.
nocheatplus.notify:
description: Receive notifications about violations in-game.
nocheatplus.feature.command:
# TODO: Adapt permission to new config section for this feature.
description: Allows use of all commands protected by the command protection, like the ncp root command. Does not give functionality but allow seeing usage and tab-completion of the command. In future there can be many children not listed in this config.
children:
nocheatplus.feature.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 aspects of super-perms.
nocheatplus.command:
description: "All command permissions, do not give lightly - if in doubt use shortcut permissions for moderators (nocheatplus.shortcut.monitor|safeadmin ...)."
children:
nocheatplus.command.notify:
description: Allow toggling notifications.
children:
nocheatplus.notify: true
nocheatplus.command.reload:
description: Allow the player to reload NoCheatPlus configuration.
nocheatplus.command.info:
description: Allow to see violation info about a player.
nocheatplus.command.exemptions:
description: Allow to see exemptions for a player.
nocheatplus.command.exempt:
description: Allow to add exemptions for a player.
nocheatplus.command.unexempt:
description: Allow to remove exemptions from a player.
nocheatplus.command.ban:
description: Allow use of the ncp ban command.
nocheatplus.command.kick:
description: Allow use of the ncp kick command.
nocheatplus.command.kicklist:
description: Allow use of the ncp kicklist command.
nocheatplus.command.lag:
description: Allow use of the ncp lag command.
nocheatplus.command.tell:
description: Allow use of the ncp tell command.
nocheatplus.command.delay:
description: Allow use of the ncp delay command.
nocheatplus.command.tempkick:
description: Allow use of the ncp tempkick command.
nocheatplus.command.unkick:
description: Allow use of the ncp unkick command.
nocheatplus.command.version:
description: Allow use of the ncp version command.
nocheatplus.command.removeplayer:
description: Allow use of the ncp removeplayer command.
nocheatplus.command.commands:
description: Allow use of the ncp commands command.
nocheatplus.bypass:
description: Bypass permission other than command permissions.
children:
nocheatplus.bypass.denylogin:
description: Bypass the login denial, such as exists with the ncp tempkick command.
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:
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.command: true
# Left in for compatibility reasons:
nocheatplus.admin.notify:
description: DEPRECATED, use nocheatplus.command.notify and/or nocheatplus.notify instead.
children:
nocheatplus.command.notify: true
nocheatplus.admin.reload:
description: DEPRECATED, use nocheatplus.command.reload instead.
children:
nocheatplus.command.reload: true
nocheatplus.admin.info:
description: DEPRECATED, use nocheatplus.command.info instead.
children:
nocheatplus.command.info: true
nocheatplus.admin.exemptions:
description: DEPRECATED, use nocheatplus.command.exemptions instead.
children:
nocheatplus.command.exemptions: true
nocheatplus.admin.exempt:
description: DEPRECATED, use nocheatplus.command.exempt instead.
children:
nocheatplus.command.exempt: true
nocheatplus.admin.unexempt:
description: DEPRECATED, use nocheatplus.command.unexempt instead.
children:
nocheatplus.command.unexempt: true
nocheatplus.admin.ban:
description: DEPRECATED, use nocheatplus.command.ban instead.
children:
nocheatplus.command.ban: true
nocheatplus.admin.kick:
description: DEPRECATED, use nocheatplus.command.kick instead.
children:
nocheatplus.command.kick: true
nocheatplus.admin.kicklist:
description: DEPRECATED, use nocheatplus.command.kicklist instead.
children:
nocheatplus.command.kicklist: true
nocheatplus.admin.lag:
description: DEPRECATED, use nocheatplus.command.lag instead.
children:
nocheatplus.command.lag: true
nocheatplus.admin.tell:
description: DEPRECATED, use nocheatplus.command.tell instead.
children:
nocheatplus.command.tell: true
nocheatplus.admin.delay:
description: DEPRECATED, use nocheatplus.command.delay instead.
children:
nocheatplus.command.delay: true
nocheatplus.admin.tempkick:
description: DEPRECATED, use nocheatplus.command.tempkick instead.
children:
nocheatplus.command.tempkick: true
nocheatplus.admin.unkick:
description: DEPRECATED, use nocheatplus.command.unkick instead.
children:
nocheatplus.command.unkick: true
nocheatplus.admin.version:
description: DEPRECATED, use nocheatplus.command.version instead.
children:
nocheatplus.command.version: true
nocheatplus.admin.removeplayer:
description: DEPRECATED, use nocheatplus.command.removeplayer instead.
children:
nocheatplus.command.removeplayer: true
nocheatplus.admin.commands:
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