Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.util.permissions;
2
3import org.bukkit.permissions.Permission;
4import org.bukkit.permissions.PermissionDefault;
5
6public final class CommandPermissions {
7 private static final String ROOT = "bukkit.command";
8 private static final String PREFIX = ROOT + ".";
9
10 private CommandPermissions() {
11 }
12
13 private static Permission registerWhitelist(Permission parent) {
14 Permission whitelist = DefaultPermissions.registerPermission(PREFIX + "whitelist", "Allows the user to modify the server whitelist", PermissionDefault.OP, parent);
15
16 DefaultPermissions.registerPermission(PREFIX + "whitelist.add", "Allows the user to add a player to the server whitelist", whitelist);
17 DefaultPermissions.registerPermission(PREFIX + "whitelist.remove", "Allows the user to remove a player from the server whitelist", whitelist);
18 DefaultPermissions.registerPermission(PREFIX + "whitelist.reload", "Allows the user to reload the server whitelist", whitelist);
19 DefaultPermissions.registerPermission(PREFIX + "whitelist.enable", "Allows the user to enable the server whitelist", whitelist);
20 DefaultPermissions.registerPermission(PREFIX + "whitelist.disable", "Allows the user to disable the server whitelist", whitelist);
21 DefaultPermissions.registerPermission(PREFIX + "whitelist.list", "Allows the user to list all the users on the server whitelist", whitelist);
22
23 whitelist.recalculatePermissibles();
24
25 return whitelist;
26 }
27
28 private static Permission registerBan(Permission parent) {
29 Permission ban = DefaultPermissions.registerPermission(PREFIX + "ban", "Allows the user to ban people", PermissionDefault.OP, parent);
30
31 DefaultPermissions.registerPermission(PREFIX + "ban.player", "Allows the user to ban players", ban);
32 DefaultPermissions.registerPermission(PREFIX + "ban.ip", "Allows the user to ban IP addresses", ban);
33
34 ban.recalculatePermissibles();
35
36 return ban;
37 }
38
39 private static Permission registerUnban(Permission parent) {
40 Permission unban = DefaultPermissions.registerPermission(PREFIX + "unban", "Allows the user to unban people", PermissionDefault.OP, parent);
41
42 DefaultPermissions.registerPermission(PREFIX + "unban.player", "Allows the user to unban players", unban);
43 DefaultPermissions.registerPermission(PREFIX + "unban.ip", "Allows the user to unban IP addresses", unban);
44
45 unban.recalculatePermissibles();
46
47 return unban;
48 }
49
50 private static Permission registerOp(Permission parent) {
51 Permission op = DefaultPermissions.registerPermission(PREFIX + "op", "Allows the user to change operators", PermissionDefault.OP, parent);
52
53 DefaultPermissions.registerPermission(PREFIX + "op.give", "Allows the user to give a player operator status", op);
54 DefaultPermissions.registerPermission(PREFIX + "op.take", "Allows the user to take a players operator status", op);
55
56 op.recalculatePermissibles();
57
58 return op;
59 }
60
61 private static Permission registerSave(Permission parent) {
62 Permission save = DefaultPermissions.registerPermission(PREFIX + "save", "Allows the user to save the worlds", PermissionDefault.OP, parent);
63
64 DefaultPermissions.registerPermission(PREFIX + "save.enable", "Allows the user to enable automatic saving", save);
65 DefaultPermissions.registerPermission(PREFIX + "save.disable", "Allows the user to disable automatic saving", save);
66 DefaultPermissions.registerPermission(PREFIX + "save.perform", "Allows the user to perform a manual save", save);
67
68 save.recalculatePermissibles();
69
70 return save;
71 }
72
73 private static Permission registerTime(Permission parent) {
74 Permission time = DefaultPermissions.registerPermission(PREFIX + "time", "Allows the user to alter the time", PermissionDefault.OP, parent);
75
76 DefaultPermissions.registerPermission(PREFIX + "time.add", "Allows the user to fast-forward time", time);
77 DefaultPermissions.registerPermission(PREFIX + "time.set", "Allows the user to change the time", time);
78
79 time.recalculatePermissibles();
80
81 return time;
82 }
83
84 public static Permission registerPermissions(Permission parent) {
85 Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all Craftbukkit commands", parent);
86
87 registerWhitelist(commands);
88 registerBan(commands);
89 registerUnban(commands);
90 registerOp(commands);
91 registerSave(commands);
92 registerTime(commands);
93
94 DefaultPermissions.registerPermission(PREFIX + "kill", "Allows the user to commit suicide", PermissionDefault.TRUE, commands);
95 DefaultPermissions.registerPermission(PREFIX + "me", "Allows the user to perform a chat action", PermissionDefault.TRUE, commands);
96 DefaultPermissions.registerPermission(PREFIX + "tell", "Allows the user to privately message another player", PermissionDefault.TRUE, commands);
97 DefaultPermissions.registerPermission(PREFIX + "say", "Allows the user to talk as the console", PermissionDefault.OP, commands);
98 DefaultPermissions.registerPermission(PREFIX + "give", "Allows the user to give items to players", PermissionDefault.OP, commands);
99 DefaultPermissions.registerPermission(PREFIX + "teleport", "Allows the user to teleport players", PermissionDefault.OP, commands);
100 DefaultPermissions.registerPermission(PREFIX + "kick", "Allows the user to kick players", PermissionDefault.OP, commands);
101 DefaultPermissions.registerPermission(PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands);
102 DefaultPermissions.registerPermission(PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
103 DefaultPermissions.registerPermission(PREFIX + "help", "Allows the user to view the vanilla help menu", PermissionDefault.OP, commands);
104 DefaultPermissions.registerPermission(PREFIX + "plugins", "Allows the user to view the list of plugins running on this server", PermissionDefault.TRUE, commands);
105 DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
106 DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
107
108 commands.recalculatePermissibles();
109
110 return commands;
111 }
112}