Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
DefaultPermissions.java
1 package org.bukkit.util.permissions;
2 
3 import java.util.Map;
4 import org.bukkit.Bukkit;
7 
8 public final class DefaultPermissions {
9  private static final String ROOT = "craftbukkit";
10  private static final String LEGACY_PREFIX = "craft";
11 
12  private DefaultPermissions() {}
13 
14  public static Permission registerPermission(Permission perm) {
15  return registerPermission(perm, true);
16  }
17 
18  public static Permission registerPermission(Permission perm, boolean withLegacy) {
19  Permission result = perm;
20 
21  try {
23  } catch (IllegalArgumentException ex) {
24  result = Bukkit.getPluginManager().getPermission(perm.getName());
25  }
26 
27  if (withLegacy) {
28  Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
29  legacy.getChildren().put(result.getName(), true);
30  registerPermission(perm, false);
31  }
32 
33  return result;
34  }
35 
36  public static Permission registerPermission(Permission perm, Permission parent) {
37  parent.getChildren().put(perm.getName(), true);
38  return registerPermission(perm);
39  }
40 
41  public static Permission registerPermission(String name, String desc) {
42  Permission perm = registerPermission(new Permission(name, desc));
43  return perm;
44  }
45 
46  public static Permission registerPermission(String name, String desc, Permission parent) {
47  Permission perm = registerPermission(name, desc);
48  parent.getChildren().put(perm.getName(), true);
49  return perm;
50  }
51 
52  public static Permission registerPermission(String name, String desc, PermissionDefault def) {
53  Permission perm = registerPermission(new Permission(name, desc, def));
54  return perm;
55  }
56 
57  public static Permission registerPermission(String name, String desc, PermissionDefault def, Permission parent) {
58  Permission perm = registerPermission(name, desc, def);
59  parent.getChildren().put(perm.getName(), true);
60  return perm;
61  }
62 
63  public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children) {
64  Permission perm = registerPermission(new Permission(name, desc, def, children));
65  return perm;
66  }
67 
68  public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children, Permission parent) {
69  Permission perm = registerPermission(name, desc, def, children);
70  parent.getChildren().put(perm.getName(), true);
71  return perm;
72  }
73 
74  public static void registerCorePermissions() {
75  Permission parent = registerPermission(ROOT, "Gives the user the ability to use all CraftBukkit utilities and commands");
76 
77  CommandPermissions.registerPermissions(parent);
78  BroadcastPermissions.registerPermissions(parent);
79 
80  parent.recalculatePermissibles();
81  }
82 }
Map< String, Boolean > getChildren()
Definition: Permission.java:86
void addPermission(Permission perm)
static PluginManager getPluginManager()
Definition: Bukkit.java:208
Permission getPermission(String name)