diff --git a/lib/zPermissions.jar b/lib/zPermissions.jar deleted file mode 100644 index 018f9f1..0000000 Binary files a/lib/zPermissions.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index ce0f1bb..3b7d78f 100644 --- a/pom.xml +++ b/pom.xml @@ -114,14 +114,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms 1.7.4 true - - org.tyrannyofheaven.bukkit - zPermissions - 0.9.19-SNAPSHOT - true - system - ${project.basedir}/lib/zPermissions.jar - me.ic3d.eco ECO diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java index 7a6bb50..a19c9ea 100644 --- a/src/net/milkbowl/vault/Vault.java +++ b/src/net/milkbowl/vault/Vault.java @@ -37,7 +37,6 @@ import net.milkbowl.vault.chat.plugins.Chat_bPermissions2; import net.milkbowl.vault.chat.plugins.Chat_iChat; import net.milkbowl.vault.chat.plugins.Chat_mChat; import net.milkbowl.vault.chat.plugins.Chat_mChatSuite; -import net.milkbowl.vault.chat.plugins.Chat_zPermissions; import net.milkbowl.vault.chat.plugins.Chat_rscPermissions; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.plugins.Economy_3co; @@ -81,7 +80,6 @@ import net.milkbowl.vault.permission.plugins.Permission_SuperPerms; import net.milkbowl.vault.permission.plugins.Permission_Xperms; import net.milkbowl.vault.permission.plugins.Permission_bPermissions; import net.milkbowl.vault.permission.plugins.Permission_bPermissions2; -import net.milkbowl.vault.permission.plugins.Permission_zPermissions; import net.milkbowl.vault.permission.plugins.Permission_TotalPermissions; import net.milkbowl.vault.permission.plugins.Permission_rscPermissions; import net.milkbowl.vault.permission.plugins.Permission_KPerms; @@ -238,9 +236,6 @@ public class Vault extends JavaPlugin { // Try to load iChat hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat"); - // Try to load zPermissions - hookChat("zPermissions", Chat_zPermissions.class, ServicePriority.Normal, "org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata"); - // Try to load Privileges hookChat("Privileges", Chat_Privileges.class, ServicePriority.Normal, "net.krinsoft.privileges.Privileges"); @@ -365,9 +360,6 @@ public class Vault extends JavaPlugin { // Try to load bPermissions2 hookPermission("bPermissions 2", Permission_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.WorldManager"); - // Try to load zPermission - hookPermission("zPermissions", Permission_zPermissions.class, ServicePriority.High, "org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsPlugin"); - // Try to load Privileges hookPermission("Privileges", Permission_Privileges.class, ServicePriority.Highest, "net.krinsoft.privileges.Privileges"); diff --git a/src/net/milkbowl/vault/chat/plugins/Chat_PermissionsEx.java b/src/net/milkbowl/vault/chat/plugins/Chat_PermissionsEx.java index c4bfa30..440e7de 100644 --- a/src/net/milkbowl/vault/chat/plugins/Chat_PermissionsEx.java +++ b/src/net/milkbowl/vault/chat/plugins/Chat_PermissionsEx.java @@ -335,7 +335,7 @@ public class Chat_PermissionsEx extends Chat { @Override public String getPlayerPrefix(String world, String playerName) { - PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName); + PermissionUser user = getUser(playerName); if (user != null) { return user.getPrefix(world); } else { @@ -345,7 +345,7 @@ public class Chat_PermissionsEx extends Chat { @Override public String getPlayerSuffix(String world, String playerName) { - PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName); + PermissionUser user = getUser(playerName); if (user != null) { return user.getSuffix(world); } else { @@ -355,7 +355,7 @@ public class Chat_PermissionsEx extends Chat { @Override public void setPlayerSuffix(String world, String player, String suffix) { - PermissionUser user = PermissionsEx.getPermissionManager().getUser(player); + PermissionUser user = getUser(player); if (user != null) { user.setSuffix(suffix, world); } @@ -363,7 +363,7 @@ public class Chat_PermissionsEx extends Chat { @Override public void setPlayerPrefix(String world, String player, String prefix) { - PermissionUser user = PermissionsEx.getPermissionManager().getUser(player); + PermissionUser user = getUser(player); if (user != null) { user.setPrefix(prefix, world); } diff --git a/src/net/milkbowl/vault/chat/plugins/Chat_zPermissions.java b/src/net/milkbowl/vault/chat/plugins/Chat_zPermissions.java deleted file mode 100644 index ed195f8..0000000 --- a/src/net/milkbowl/vault/chat/plugins/Chat_zPermissions.java +++ /dev/null @@ -1,246 +0,0 @@ -/* This file is part of Vault. - - Vault is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Vault is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with Vault. If not, see . - */ -package net.milkbowl.vault.chat.plugins; - -import java.util.logging.Logger; - -import net.milkbowl.vault.chat.Chat; -import net.milkbowl.vault.permission.Permission; - -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.server.PluginDisableEvent; -import org.bukkit.event.server.PluginEnableEvent; -import org.bukkit.plugin.Plugin; -import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService; - -public class Chat_zPermissions extends Chat { - - private static final Logger log = Logger.getLogger("Minecraft"); - - private final String name = "zPermissions"; - - private final Plugin plugin; - - private ZPermissionsService service; - - public Chat_zPermissions(Plugin plugin, Permission perms) { - super(perms); - this.plugin = plugin; - Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin); - // Load service in case it was loaded before - if (service == null) { - service = plugin.getServer().getServicesManager().load(ZPermissionsService.class); - if (service != null) - log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name)); - } - } - - public class PermissionServerListener implements Listener { - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginEnable(PluginEnableEvent event) { - if (service == null && event.getPlugin().getDescription().getName().equals("zPermissions")) { - service = plugin.getServer().getServicesManager().load(ZPermissionsService.class); - if (service != null) - log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name)); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginDisable(PluginDisableEvent event) { - if (service != null) { - if (event.getPlugin().getDescription().getName().equals("zPermissions")) { - service = null; - log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), name)); - } - } - } - } - - @Override - public String getName() { - return name; - } - - @Override - public boolean isEnabled() { - return service != null; - } - - @Override - public String getPlayerPrefix(String world, String player) { - return getPlayerInfoString(world, player, "prefix", ""); - } - - @Override - public void setPlayerPrefix(String world, String player, String prefix) { - setPlayerInfoString(world, player, "prefix", prefix); - } - - @Override - public String getPlayerSuffix(String world, String player) { - return getPlayerInfoString(world, player, "suffix", ""); - } - - @Override - public void setPlayerSuffix(String world, String player, String suffix) { - setPlayerInfoString(world, player, "suffix", suffix); - } - - @Override - public String getGroupPrefix(String world, String group) { - return getGroupInfoString(world, group, "prefix", ""); - } - - @Override - public void setGroupPrefix(String world, String group, String prefix) { - setGroupInfoString(world, group, "prefix", prefix); - } - - @Override - public String getGroupSuffix(String world, String group) { - return getGroupInfoString(world, group, "suffix", ""); - } - - @Override - public void setGroupSuffix(String world, String group, String suffix) { - setGroupInfoString(world, group, "suffix", suffix); - } - - @Override - public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { - Integer result = service.getPlayerMetadata(player, node, Integer.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setPlayerInfoInteger(String world, String player, String node, int value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " metadata setint " + node + " " + value); - } - - @Override - public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { - Integer result = service.getGroupMetadata(group, node, Integer.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setGroupInfoInteger(String world, String group, String node, int value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " metadata setint " + node + " " + value); - } - - @Override - public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { - Double result = service.getPlayerMetadata(player, node, Double.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setPlayerInfoDouble(String world, String player, String node, double value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " metadata setreal " + node + " " + value); - } - - @Override - public double getGroupInfoDouble(String world, String group, String node, double defaultValue) { - Double result = service.getGroupMetadata(group, node, Double.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setGroupInfoDouble(String world, String group, String node, double value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " metadata setreal " + node + " " + value); - } - - @Override - public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { - Boolean result = service.getPlayerMetadata(player, node, Boolean.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " metadata setbool " + node + " " + value); - } - - @Override - public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { - Boolean result = service.getGroupMetadata(group, node, Boolean.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setGroupInfoBoolean(String world, String group, String node, boolean value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " metadata setbool " + node + " " + value); - } - - @Override - public String getPlayerInfoString(String world, String player, String node, String defaultValue) { - String result = service.getPlayerMetadata(player, node, String.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setPlayerInfoString(String world, String player, String node, String value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " metadata set " + node + " " + quote(value)); - } - - @Override - public String getGroupInfoString(String world, String group, String node, String defaultValue) { - String result = service.getGroupMetadata(group, node, String.class); - if (result == null) - return defaultValue; - else - return result; - } - - @Override - public void setGroupInfoString(String world, String group, String node, String value) { - plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " metadata set " + node + " " + quote(value)); - } - - private String quote(String input) { - input = input.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\""); - if (input.matches(".*\\s.*")) - return "\"" + input + "\""; // Enclose in quotes - else - return input; - } - -} diff --git a/src/net/milkbowl/vault/permission/plugins/Permission_zPermissions.java b/src/net/milkbowl/vault/permission/plugins/Permission_zPermissions.java deleted file mode 100644 index 0382d85..0000000 --- a/src/net/milkbowl/vault/permission/plugins/Permission_zPermissions.java +++ /dev/null @@ -1,247 +0,0 @@ -/* This file is part of Vault. - - Vault is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Vault is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with Vault. If not, see . - */ -package net.milkbowl.vault.permission.plugins; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.milkbowl.vault.permission.Permission; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.server.PluginDisableEvent; -import org.bukkit.event.server.PluginEnableEvent; -import org.bukkit.plugin.Plugin; -import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService; - -public class Permission_zPermissions extends Permission { - - private static final String PRIMARY_GROUP_TRACK_METADATA_KEY = "Vault.primary-group.track"; - - private final String name = "zPermissions"; - private ZPermissionsService service; - private boolean trackSupport; - - public Permission_zPermissions(Plugin plugin) { - this.plugin = plugin; - Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin); - // Load service in case it was loaded before - if (service == null) { - service = plugin.getServer().getServicesManager().load(ZPermissionsService.class); - if (service != null) { - log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name)); - detectTrackMethods(); - } - } - } - - public class PermissionServerListener implements Listener { - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginEnable(PluginEnableEvent event) { - if (service == null && event.getPlugin().getDescription().getName().equals("zPermissions")) { - service = plugin.getServer().getServicesManager().load(ZPermissionsService.class); - if (service != null) { - log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name)); - detectTrackMethods(); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginDisable(PluginDisableEvent event) { - if (service != null) { - if (event.getPlugin().getDescription().getName().equals("zPermissions")) { - service = null; - log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name)); - } - } - } - } - - @Override - public String getName() { - return name; - } - - @Override - public boolean isEnabled() { - return service != null; - } - - @Override - public boolean hasSuperPermsCompat() { - return true; - } - - @Override - public boolean playerHas(String world, String player, String permission) { - Player p = Bukkit.getServer().getPlayer(player); - if (p == null) { - Map perms = service.getPlayerPermissions(world, null, player); - Boolean value = perms.get(permission.toLowerCase()); - if (value != null) { - return value; - } - // Use default at this point - org.bukkit.permissions.Permission perm = Bukkit.getPluginManager().getPermission(permission); - if (perm != null) { - OfflinePlayer op = Bukkit.getServer().getOfflinePlayer(player); - return perm.getDefault().getValue(op != null ? op.isOp() : false); - } - // Have no clue - return false; - } else { - return playerHas(p, permission); - } - } - - @Override - public boolean playerAdd(String world, String player, String permission) { - if (world != null) { - permission = world + ":" + permission; - } - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " set " + permission); - } - - @Override - public boolean playerRemove(String world, String player, String permission) { - if (world != null) { - permission = world + ":" + permission; - } - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions player " + player + " unset " + permission); - } - - @Override - public boolean groupHas(String world, String group, String permission) { - Map perms = service.getGroupPermissions(world, null, group); - Boolean value = perms.get(permission.toLowerCase()); - if (value != null) { - return value; - } - // Use default, if possible - org.bukkit.permissions.Permission perm = Bukkit.getPluginManager().getPermission(permission); - if (perm != null) { - return perm.getDefault().getValue(false); // OP flag assumed to be false... - } - // Who knows... - return false; - } - - @Override - public boolean groupAdd(String world, String group, String permission) { - if (world != null) { - permission = world + ":" + permission; - } - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " set " + permission); - } - - @Override - public boolean groupRemove(String world, String group, String permission) { - if (world != null) { - permission = world + ":" + permission; - } - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " unset " + permission); - } - - @Override - public boolean playerInGroup(String world, String player, String group) { - Set groups = service.getPlayerGroups(player); - // Groups are case-insensitive... - for (String g : groups) { - if (g.equalsIgnoreCase(group)) { - return true; - } - } - return false; - } - - @Override - public boolean playerAddGroup(String world, String player, String group) { - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " add " + player); - } - - @Override - public boolean playerRemoveGroup(String world, String player, String group) { - return plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "permissions group " + group + " remove " + player); - } - - @Override - public String[] getPlayerGroups(String world, String player) { - return service.getPlayerGroups(player).toArray(new String[0]); - } - - @Override - public String getPrimaryGroup(String world, String player) { - try { - if (trackSupport) { - String track = service.getPlayerMetadata(player, PRIMARY_GROUP_TRACK_METADATA_KEY, String.class); - if (track != null && !"".equals(track)) { - List groups = service.getTrackGroups(track); - Collections.reverse(groups); // groups is now high rank to low - - Set trackGroups = new LinkedHashSet(groups); - trackGroups.retainAll(service.getPlayerAssignedGroups(player)); // intersection with all assigned groups - - if (!trackGroups.isEmpty()) - return trackGroups.iterator().next(); // return highest-ranked group in given track - } - } - } - catch (IllegalStateException e) { - log.warning("Bad property '" + PRIMARY_GROUP_TRACK_METADATA_KEY + "' for " + player + "; is it a string and does the track exist?"); - } - - // Has no concept of primary group... use highest-priority assigned group instead - List groups = service.getPlayerAssignedGroups(player); - if (!groups.isEmpty()) { - return groups.get(0); - } else { - return null; - } - } - - @Override - public String[] getGroups() { - return service.getAllGroups().toArray(new String[0]); - } - - @Override - public boolean hasGroupSupport() { - return true; - } - - private void detectTrackMethods() { - try { - service.getClass().getMethod("getTrackGroups", String.class); - trackSupport = true; - } - catch (SecurityException e) { - trackSupport = false; - } - catch (NoSuchMethodException e) { - trackSupport = false; - } - } - -}