diff --git a/lib/Privileges.jar b/lib/Privileges.jar
index 561d583..54aea70 100644
Binary files a/lib/Privileges.jar and b/lib/Privileges.jar differ
diff --git a/pom.xml b/pom.xml
index 71ff8de..8906ff3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
net.krinsoft.privileges
Privileges
- 1.4.0b45
+ 1.7b127
system
${project.basedir}/lib/Privileges.jar
diff --git a/src/net/milkbowl/vault/permission/plugins/Permission_Privileges.java b/src/net/milkbowl/vault/permission/plugins/Permission_Privileges.java
index 18bb025..323369d 100644
--- a/src/net/milkbowl/vault/permission/plugins/Permission_Privileges.java
+++ b/src/net/milkbowl/vault/permission/plugins/Permission_Privileges.java
@@ -2,12 +2,9 @@ package net.milkbowl.vault.permission.plugins;
import net.krinsoft.privileges.Privileges;
import net.krinsoft.privileges.groups.Group;
-import net.krinsoft.privileges.groups.GroupManager;
import net.milkbowl.vault.permission.Permission;
-
import org.bukkit.Bukkit;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -16,21 +13,22 @@ import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
+import java.util.HashSet;
+import java.util.Set;
+
public class Permission_Privileges extends Permission {
private final String name = "";
- private GroupManager perms;
private Privileges privs;
public Permission_Privileges(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load service in case it was loaded before
- if (perms == null) {
+ if (privs == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Privileges");
if (perms != null && perms.isEnabled()) {
this.privs = (Privileges) perms;
- this.perms = privs.getGroupManager();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
@@ -45,13 +43,12 @@ public class Permission_Privileges extends Permission {
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
- if (permission.perms == null) {
+ if (permission.privs == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("SimplyPerms");
if (perms != null) {
if (perms.isEnabled()) {
permission.privs = (Privileges) perms;
- permission.perms = permission.privs.getGroupManager();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
}
}
@@ -60,9 +57,8 @@ public class Permission_Privileges extends Permission {
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
- if (permission.perms != null) {
+ if (permission.privs != null) {
if (event.getPlugin().getDescription().getName().equals("SimplyPerms")) {
- permission.perms = null;
permission.privs = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
}
@@ -83,7 +79,7 @@ public class Permission_Privileges extends Permission {
@Override
public boolean playerHas(String world, String player, String permission) {
Player p = plugin.getServer().getPlayer(player);
- return p != null ? p.hasPermission(permission) : false;
+ return p != null && p.hasPermission(permission);
}
@Override
@@ -100,77 +96,65 @@ public class Permission_Privileges extends Permission {
@Override
public boolean groupHas(String world, String group, String permission) {
- ConfigurationSection priv = privs.getGroupNode(group);
- if (priv == null) {
- return false;
- } else {
- return priv.getBoolean(permission);
- }
+ Group g = privs.getGroupManager().getGroup(group);
+ return g != null && g.hasPermission(permission, world);
}
@Override
public boolean groupAdd(String world, String group, String permission) {
- throw new UnsupportedOperationException("Privileges does not support modifying permissions.");
+ Group g = privs.getGroupManager().getGroup(group);
+ return g != null && g.addPermission(world, permission);
}
@Override
public boolean groupRemove(String world, String group, String permission) {
- throw new UnsupportedOperationException("Privileges does not support modifying permissions.");
+ Group g = privs.getGroupManager().getGroup(group);
+ return g != null && g.removePermission(world, permission);
}
@Override
public boolean playerInGroup(String world, String player, String group) {
- Player p = Bukkit.getPlayer(player);
- if (p == null) {
- throw new UnsupportedOperationException("Privileges does not support offline players.");
- }
- Group g = perms.getGroup(p);
- return g != null && g.getName().equalsIgnoreCase(group);
+ OfflinePlayer p = Bukkit.getOfflinePlayer(player);
+ Group g = privs.getGroupManager().getGroup(p);
+ return g != null && g.getGroupTree().contains(group);
}
@Override
public boolean playerAddGroup(String world, String player, String group) {
- if (world != null) {
- return false;
- }
- perms.setGroup(player, group);
+ privs.getGroupManager().setGroup(player, group);
return true;
}
@Override
public boolean playerRemoveGroup(String world, String player, String group) {
- Group g = perms.getDefaultGroup();
- if (g == null) {
- return false;
- }
- return playerAddGroup(world, player, g.getName());
+ Group g = privs.getGroupManager().getDefaultGroup();
+ return g != null && playerAddGroup(world, player, g.getName());
}
@Override
public String[] getPlayerGroups(String world, String player) {
- Player p = Bukkit.getPlayer(player);
+ OfflinePlayer p = Bukkit.getOfflinePlayer(player);
if (p == null) {
throw new UnsupportedOperationException("Privileges does not support offline players.");
}
- Group g = perms.getGroup(p);
- return g != null ? new String[] { g.getName() } : null;
+ Group g = privs.getGroupManager().getGroup(p);
+ return g != null ? g.getGroupTree().toArray(new String[g.getGroupTree().size()]) : null;
}
@Override
public String getPrimaryGroup(String world, String player) {
- Player p = Bukkit.getPlayer(player);
- if (p == null) {
- throw new UnsupportedOperationException("Privileges does not support offline players.");
- }
- Group g = perms.getGroup(p);
+ OfflinePlayer p = Bukkit.getOfflinePlayer(player);
+ Group g = privs.getGroupManager().getGroup(p);
return g != null ? g.getName() : null;
}
@Override
public String[] getGroups() {
- FileConfiguration file = privs.getGroups();
- ConfigurationSection groups = file.getConfigurationSection("groups");
- return groups != null ? groups.getKeys(false).toArray(new String[0]) : null;
+ Set groups = new HashSet();
+ for (Group g : privs.getGroupManager().getGroups()) {
+ groups.add(g.getName());
+ }
+ return groups.toArray(new String[groups.size()]);
}
@Override