001 package org.bukkit.util.permissions;
002
003 import org.bukkit.permissions.Permission;
004 import org.bukkit.permissions.PermissionDefault;
005
006 public final class CommandPermissions {
007 private static final String ROOT = "bukkit.command";
008 private static final String PREFIX = ROOT + ".";
009
010 private CommandPermissions() {}
011
012 private static Permission registerWhitelist(Permission parent) {
013 Permission whitelist = DefaultPermissions.registerPermission(PREFIX + "whitelist", "Allows the user to modify the server whitelist", PermissionDefault.OP, parent);
014
015 DefaultPermissions.registerPermission(PREFIX + "whitelist.add", "Allows the user to add a player to the server whitelist", whitelist);
016 DefaultPermissions.registerPermission(PREFIX + "whitelist.remove", "Allows the user to remove a player from the server whitelist", whitelist);
017 DefaultPermissions.registerPermission(PREFIX + "whitelist.reload", "Allows the user to reload the server whitelist", whitelist);
018 DefaultPermissions.registerPermission(PREFIX + "whitelist.enable", "Allows the user to enable the server whitelist", whitelist);
019 DefaultPermissions.registerPermission(PREFIX + "whitelist.disable", "Allows the user to disable the server whitelist", whitelist);
020 DefaultPermissions.registerPermission(PREFIX + "whitelist.list", "Allows the user to list all the users on the server whitelist", whitelist);
021
022 whitelist.recalculatePermissibles();
023
024 return whitelist;
025 }
026
027 private static Permission registerBan(Permission parent) {
028 Permission ban = DefaultPermissions.registerPermission(PREFIX + "ban", "Allows the user to ban people", PermissionDefault.OP, parent);
029
030 DefaultPermissions.registerPermission(PREFIX + "ban.player", "Allows the user to ban players", ban);
031 DefaultPermissions.registerPermission(PREFIX + "ban.ip", "Allows the user to ban IP addresses", ban);
032
033 ban.recalculatePermissibles();
034
035 return ban;
036 }
037
038 private static Permission registerUnban(Permission parent) {
039 Permission unban = DefaultPermissions.registerPermission(PREFIX + "unban", "Allows the user to unban people", PermissionDefault.OP, parent);
040
041 DefaultPermissions.registerPermission(PREFIX + "unban.player", "Allows the user to unban players", unban);
042 DefaultPermissions.registerPermission(PREFIX + "unban.ip", "Allows the user to unban IP addresses", unban);
043
044 unban.recalculatePermissibles();
045
046 return unban;
047 }
048
049 private static Permission registerOp(Permission parent) {
050 Permission op = DefaultPermissions.registerPermission(PREFIX + "op", "Allows the user to change operators", PermissionDefault.OP, parent);
051
052 DefaultPermissions.registerPermission(PREFIX + "op.give", "Allows the user to give a player operator status", op);
053 DefaultPermissions.registerPermission(PREFIX + "op.take", "Allows the user to take a players operator status", op);
054
055 op.recalculatePermissibles();
056
057 return op;
058 }
059
060 private static Permission registerSave(Permission parent) {
061 Permission save = DefaultPermissions.registerPermission(PREFIX + "save", "Allows the user to save the worlds", PermissionDefault.OP, parent);
062
063 DefaultPermissions.registerPermission(PREFIX + "save.enable", "Allows the user to enable automatic saving", save);
064 DefaultPermissions.registerPermission(PREFIX + "save.disable", "Allows the user to disable automatic saving", save);
065 DefaultPermissions.registerPermission(PREFIX + "save.perform", "Allows the user to perform a manual save", save);
066
067 save.recalculatePermissibles();
068
069 return save;
070 }
071
072 private static Permission registerTime(Permission parent) {
073 Permission time = DefaultPermissions.registerPermission(PREFIX + "time", "Allows the user to alter the time", PermissionDefault.OP, parent);
074
075 DefaultPermissions.registerPermission(PREFIX + "time.add", "Allows the user to fast-forward time", time);
076 DefaultPermissions.registerPermission(PREFIX + "time.set", "Allows the user to change the time", time);
077
078 time.recalculatePermissibles();
079
080 return time;
081 }
082
083 public static Permission registerPermissions(Permission parent) {
084 Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all CraftBukkit commands", parent);
085
086 registerWhitelist(commands);
087 registerBan(commands);
088 registerUnban(commands);
089 registerOp(commands);
090 registerSave(commands);
091 registerTime(commands);
092
093 DefaultPermissions.registerPermission(PREFIX + "kill", "Allows the user to commit suicide", PermissionDefault.TRUE, commands);
094 DefaultPermissions.registerPermission(PREFIX + "me", "Allows the user to perform a chat action", PermissionDefault.TRUE, commands);
095 DefaultPermissions.registerPermission(PREFIX + "tell", "Allows the user to privately message another player", PermissionDefault.TRUE, commands);
096 DefaultPermissions.registerPermission(PREFIX + "say", "Allows the user to talk as the console", PermissionDefault.OP, commands);
097 DefaultPermissions.registerPermission(PREFIX + "give", "Allows the user to give items to players", PermissionDefault.OP, commands);
098 DefaultPermissions.registerPermission(PREFIX + "teleport", "Allows the user to teleport players", PermissionDefault.OP, commands);
099 DefaultPermissions.registerPermission(PREFIX + "kick", "Allows the user to kick players", PermissionDefault.OP, commands);
100 DefaultPermissions.registerPermission(PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands);
101 DefaultPermissions.registerPermission(PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
102 DefaultPermissions.registerPermission(PREFIX + "help", "Allows the user to view the vanilla help menu", PermissionDefault.TRUE, commands);
103 DefaultPermissions.registerPermission(PREFIX + "plugins", "Allows the user to view the list of plugins running on this server", PermissionDefault.TRUE, commands);
104 DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
105 DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
106 DefaultPermissions.registerPermission(PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
107 DefaultPermissions.registerPermission(PREFIX + "xp", "Allows the user to give themselves or others arbitrary values of experience", PermissionDefault.OP, commands);
108 DefaultPermissions.registerPermission(PREFIX + "toggledownfall", "Allows the user to toggle rain on/off for a given world", PermissionDefault.OP, commands);
109 DefaultPermissions.registerPermission(PREFIX + "defaultgamemode", "Allows the user to change the default gamemode of the server", PermissionDefault.OP, commands);
110 DefaultPermissions.registerPermission(PREFIX + "seed", "Allows the user to view the seed of the world", PermissionDefault.OP, commands);
111 DefaultPermissions.registerPermission(PREFIX + "effect", "Allows the user to add/remove effects on players", PermissionDefault.OP, commands);
112
113 commands.recalculatePermissibles();
114
115 return commands;
116 }
117 }