Merge branch 'master' of github.com:MilkBowl/Vault

This commit is contained in:
Morgan 2011-08-11 15:29:45 -04:00
commit c3689d8909
9 changed files with 744 additions and 128 deletions

Binary file not shown.

BIN
lib/iConomy6.jar Normal file

Binary file not shown.

View File

@ -29,7 +29,9 @@ import net.milkbowl.vault.economy.plugins.Economy_Essentials;
import net.milkbowl.vault.economy.plugins.Economy_iConomy4;
import net.milkbowl.vault.economy.plugins.Economy_iConomy5;
import net.milkbowl.vault.permission.Permission;
import net.milkbowl.vault.permission.plugins.Permission_Permissions;
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
import net.milkbowl.vault.permission.plugins.Permission_Permissions2;
import net.milkbowl.vault.permission.plugins.Permission_Permissions3;
import net.milkbowl.vault.permission.plugins.Permission_PermissionsEx;
import org.bukkit.command.Command;
@ -125,15 +127,34 @@ public class Vault extends JavaPlugin {
} else {
log.info(String.format("[%s][Permission] PermissionsEx not found.", getDescription().getName()));
}
// Try to load Permissions (Phoenix)
if (packageExists(new String[] { "com.nijikokun.bukkit.Permissions.Permissions" })) {
Permission nPerms = new Permission_Permissions(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, nPerms, this, ServicePriority.Lowest);
log.info(String.format("[%s][Permission] Permissions (Yetti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
//Try to load GroupManager
if(packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
Permission gPerms = new Permission_GroupManager(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, gPerms, this, ServicePriority.Normal);
log.info(String.format("[%s][Permission] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] Permissions (Yetti) not found.", getDescription().getName()));
log.info(String.format("[%s][Permission] GroupManager not found.", getDescription().getName()));
}
// Try to load Permissions (Yeti)
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
Permission nPerms = new Permission_Permissions3(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, nPerms, this, ServicePriority.Low);
log.info(String.format("[%s][Permission] Permissions (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] Permissions (Yeti) not found.", getDescription().getName()));
}
//Try to load Permissions (Phoenix)
if (packageExists(new String[] { "com.nijiko.permissions.Control"} )) {
Permission oPerms = new Permission_Permissions2(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, oPerms, this, ServicePriority.Lowest);
log.info(String.format("[%s][Permission] Permissions (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Permission] Permissions (Phoenix) not found.", getDescription().getName()));
}
}
@Override

View File

@ -0,0 +1,143 @@
package net.milkbowl.vault.economy.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.iCo6.iConomy;
import com.iCo6.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
public class Economy_iConomy6 implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "iConomy 6";
private JavaPlugin plugin = null;
private PluginManager pluginManager = null;
protected iConomy economy = null;
private Accounts accounts;
private EconomyServerListener economyServerListener = null;
public Economy_iConomy6(JavaPlugin plugin) {
this.plugin = plugin;
this.pluginManager = this.plugin.getServer().getPluginManager();
economyServerListener = new EconomyServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, economyServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, economyServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("iConomy");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.iCo6.iConomy")) {
economy = (iConomy) ec;
accounts = new Accounts();
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
private class EconomyServerListener extends ServerListener {
Economy_iConomy6 economy = null;
public EconomyServerListener(Economy_iConomy6 economy) {
this.economy = economy;
}
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("iConomy");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.iCo6.iConomy")) {
economy.economy = (iConomy) ec;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("iConomy")) {
economy.economy = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
return iConomy.format(amount);
}
@Override
public double getBalance(String playerName) {
if (accounts.exists(playerName))
return accounts.get(playerName).getHoldings().getBalance();
else
return 0;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
Account account = accounts.get(playerName);
Holdings holdings = account.getHoldings();
if (holdings.hasEnough(amount)) {
holdings.subtract(amount);
balance = holdings.getBalance();
type = EconomyResponse.ResponseType.SUCCESS;
return new EconomyResponse(balance, balance, type, errorMessage);
} else {
amount = 0;
balance = holdings.getBalance();
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "Insufficient funds";
return new EconomyResponse(balance, balance, type, errorMessage);
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
Account account = accounts.get(playerName);
Holdings holdings = account.getHoldings();
holdings.add(amount);
balance = holdings.getBalance();
type = EconomyResponse.ResponseType.SUCCESS;
return new EconomyResponse(amount, balance, type, errorMessage);
}
}

View File

@ -38,7 +38,8 @@ public abstract class Permission {
/**
* Checks if player has a permission node. (Short for playerHas(...)
* @param player Player instance
* @param worldName
* @param playerName
* @param permission Permission node
* @return Success or Failure
*/
@ -444,4 +445,6 @@ public abstract class Permission {
public String getPlayerSuffix(Player player) {
return getPlayerSuffix(player.getWorld().getName(), player.getName());
}
abstract public void setPlayerSuffix(Player player, String suffix);
}

View File

@ -0,0 +1,243 @@
package net.milkbowl.vault.permission.plugins;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import net.milkbowl.vault.permission.Permission;
public class Permission_GroupManager extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "GroupManager";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private GroupManager groupManager;
private AnjoPermissionsHandler perms;
private PermissionServerListener permissionServerListener = null;
@SuppressWarnings("deprecation")
public Permission_GroupManager(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (groupManager == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
if (perms != null) {
if (perms.isEnabled()) {
groupManager = (GroupManager) perms;
this.perms = groupManager.getPermissionHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
Permission_GroupManager permission = null;
public PermissionServerListener(Permission_GroupManager permission) {
this.permission = permission;
}
@SuppressWarnings("deprecation")
public void onPluginEnable(PluginEnableEvent event) {
if (permission.groupManager == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
if (perms != null) {
if (perms.isEnabled()) {
permission.groupManager = (GroupManager) perms;
permission.perms = groupManager.getPermissionHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (permission.groupManager != null) {
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
permission.groupManager = null;
permission.perms = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
@Override
public String getName() {
return this.name;
}
@Override
public boolean isEnabled() {
if(groupManager == null) {
return false;
} else {
return groupManager.isEnabled();
}
}
@Override
public boolean playerHas(String worldName, String playerName, String permission) {
return perms.has(plugin.getServer().getPlayer(playerName), permission);
}
@Override
public boolean playerAdd(String worldName, String playerName, String permission) {
return false;
}
@Override
public boolean playerRemove(String worldName, String playerName, String permission) {
return false;
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
return false;
}
@Override
public boolean groupAdd(String worldName, String groupName, String permission) {
return false;
}
@Override
public boolean groupRemove(String worldName, String groupName, String permission) {
return false;
}
@Override
public boolean playerInGroup(String worldName, String playerName, String groupName) {
String[] groups = perms.getGroups(playerName);
for (String group : groups)
if (group.equalsIgnoreCase(groupName))
return true;
return false;
}
@Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
return false;
}
@Override
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
return false;
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return perms.getPermissionInteger(playerName, node);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
return perms.getGroupPermissionInteger(groupName, node);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return perms.getPermissionDouble(playerName, node);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
return perms.getGroupPermissionDouble(groupName, node);
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return perms.getPermissionBoolean(playerName, node);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName,String node, boolean defaultValue) {
return perms.getGroupPermissionBoolean(groupName, node);
}
@Override
public void setGroupInfoBoolean(String world, String groupName,String node, boolean value) {
}
@Override
public String getPlayerInfoString(String world, String playerName,String node, String defaultValue) {
return perms.getPermissionString(playerName, node);
}
@Override
public void setPlayerInfoString(String world, String playerName,String node, String value) {
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
return perms.getGroupPermissionString(groupName, node);
}
@Override
public void setGroupInfoString(String world, String groupName, String node,String value) {
}
@Override
public String[] getPlayerGroups(String world, String playerName) {
return perms.getGroups(playerName);
}
@Override
public String getPrimaryGroup(String world, String playerName) {
return perms.getGroup(playerName);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return perms.getGroupPrefix(getPrimaryGroup(world, playerName));
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return perms.getGroupSuffix(getPrimaryGroup(world, playerName));
}
@Override
public void setPlayerSuffix(Player player, String suffix) {
}
}

View File

@ -0,0 +1,264 @@
package net.milkbowl.vault.permission.plugins;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import net.milkbowl.vault.permission.Permission;
@SuppressWarnings("deprecation")
public class Permission_Permissions2 extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions (Phoenix)";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions permission = null;
private PermissionServerListener permissionServerListener = null;
public Permission_Permissions2(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("2")) {
permission = (Permissions) perms;
this.perms = permission.getHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
}
private class PermissionServerListener extends ServerListener {
Permission_Permissions2 permission = null;
public PermissionServerListener(Permission_Permissions2 permission) {
this.permission = permission;
}
public void onPluginEnable(PluginEnableEvent event) {
if (permission.permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled()) {
permission.permission = (Permissions) perms;
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (permission.permission != null) {
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
permission.permission = null;
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
}
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if(permission == null) {
return false;
} else {
return permission.isEnabled();
}
}
@Override
public boolean playerHas(String worldName, String playerName, String permission) {
return this.perms.has(worldName, playerName, permission);
}
@Override
public boolean playerAdd(String worldName, String playerName, String permission) {
this.perms.addUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean playerRemove(String worldName, String playerName, String permission) {
this.perms.removeUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
//Unable to directly check group permissions in P2
return false;
}
@Override
public boolean groupAdd(String worldName, String groupName,String permission) {
//Unable to alter group permissions in P2
return false;
}
@Override
public boolean groupRemove(String worldName, String groupName, String permission) {
//Unable to alter group permissions in P2
return false;
}
@Override
public boolean playerInGroup(String worldName, String playerName, String groupName) {
return this.perms.inGroup(worldName, playerName, groupName);
}
@Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
//Unable to add groups in P2
return false;
}
@Override
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
//Unable to remove groups in P2
return false;
}
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
int i = this.perms.getPermissionInteger(world, playerName, node);
return (i == -1) ? defaultValue : i;
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
//Unable to set player info nodes in P2
}
public void setGroupInfo(String world, String groupName, String node, Object value) {
this.perms.addGroupInfo(world, groupName, node, value);
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
int i = this.perms.getGroupPermissionInteger(world, groupName, node);
return (i == -1) ? defaultValue : i;
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
double d = this.perms.getPermissionDouble(world, playerName, node);
return (d == -1) ? defaultValue : d;
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
//Unable to set player info nodes in P2
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
double d = this.perms.getGroupPermissionDouble(world, groupName, node);
return (d == -1) ? defaultValue : d;
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
//Warning does not support default value
return this.perms.getPermissionBoolean(world, playerName, node);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
//Unable to set player info nodes in P2
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
return this.perms.getGroupPermissionBoolean(world, groupName, node);
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
String s = this.perms.getPermissionString(world, playerName, node);
return (s == "" || s == null) ? defaultValue : s;
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
//Unable to set player info nodes in P2
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
String s = this.perms.getGroupPermissionString(world, groupName, node);
return (s == "" || s == null) ? defaultValue : s;
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
setGroupInfo(world, groupName, node, value);
}
@Override
public String[] getPlayerGroups(String world, String playerName) {
return this.perms.getGroups(world, playerName);
}
@Override
public String getPrimaryGroup(String world, String playerName) {
return this.perms.getGroup(world, playerName);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return this.perms.getPermissionString(world, playerName, "prefix");
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return this.perms.getPermissionString(world, playerName, "suffix");
}
@Override
public void setPlayerSuffix(Player player, String suffix) {
//Unable to set player info nodes in P2
}
}

View File

@ -33,18 +33,20 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.Group;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
public class Permission_Permissions extends Permission {
public class Permission_Permissions3 extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions (Yetti)";
private String name = "Permissions (Yeti)";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions permission = null;
private PermissionServerListener permissionServerListener = null;
public Permission_Permissions(Plugin plugin) {
public Permission_Permissions3(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
@ -57,8 +59,9 @@ public class Permission_Permissions extends Permission {
if (permission == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
if (perms != null) {
if (perms.isEnabled()) {
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
permission = (Permissions) perms;
this.perms = permission.getHandler();
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
}
}
@ -80,9 +83,9 @@ public class Permission_Permissions extends Permission {
}
private class PermissionServerListener extends ServerListener {
Permission_Permissions permission = null;
Permission_Permissions3 permission = null;
public PermissionServerListener(Permission_Permissions permission) {
public PermissionServerListener(Permission_Permissions3 permission) {
this.permission = permission;
}
@ -116,50 +119,26 @@ public class Permission_Permissions extends Permission {
@Override
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
String s = this.permission.getHandler().getInfoString(world, playerName, node, false);
if(s == null) {
return defaultValue;
} else {
try {
return Integer.parseInt(s);
} catch(NumberFormatException e) {
return defaultValue;
}
}
Integer i = this.perms.getInfoInteger(world, playerName, node, false);
return (i == null) ? defaultValue : i;
}
@Override
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
String s = this.permission.getHandler().getInfoString(world, playerName, node, false);
if(s == null) {
return defaultValue;
} else {
try {
return Double.parseDouble(s);
} catch(NumberFormatException e) {
return defaultValue;
}
}
Double d = this.perms.getInfoDouble(world, playerName, node, false);
return (d == null) ? defaultValue : d;
}
@Override
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
String s = this.permission.getHandler().getInfoString(world, playerName, node, false);
if (s == null) {
return defaultValue;
} else {
return Boolean.parseBoolean(s);
}
Boolean b = this.perms.getInfoBoolean(world, playerName, node, false);
return (b == null) ? defaultValue : b;
}
@Override
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
String s = this.permission.getHandler().getInfoString(world, playerName, node, false);
if(s == null) {
return defaultValue;
} else {
return s;
}
String s = this.perms.getInfoString(world, playerName, node, false);
return (s == null) ? defaultValue : s;
}
@Override
@ -176,152 +155,103 @@ public class Permission_Permissions extends Permission {
@Override
public boolean playerAdd(String worldName, String playerName, String permission) {
this.permission.getHandler().addUserPermission(worldName, playerName, permission);
this.perms.addUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean playerRemove(String worldName, String playerName, String permission) {
this.permission.getHandler().removeUserPermission(worldName, playerName, permission);
this.perms.removeUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean groupAdd(String worldName, String groupName, String permission) {
this.permission.getHandler().addGroupPermission(worldName, groupName, permission);
this.perms.addGroupPermission(worldName, groupName, permission);
return true;
}
@Override
public boolean groupRemove(String worldName, String groupName, String permission) {
this.permission.getHandler().removeGroupPermission(worldName, groupName, permission);
this.perms.removeGroupPermission(worldName, groupName, permission);
return true;
}
public void setPlayerInfo(String world, String playerName, String node, Object value) {
this.perms.addUserInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setPlayerInfo(world, playerName, node, value);
}
@Override
public void setPlayerInfoString(String world, String playerName, String node, String value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setPlayerInfo(world, playerName, node, value);
}
@Override
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
String s = this.permission.getHandler().getInfoString(world, groupName, node, true);
if(s == null) {
return defaultValue;
} else {
try {
return Integer.parseInt(s);
} catch(NumberFormatException e) {
return defaultValue;
}
}
Integer i = this.perms.getInfoInteger(world, groupName, node, true);
return (i == null) ? defaultValue : i;
}
public void setGroupInfo(String world, String groupName, String node, Object value) {
this.perms.addGroupInfo(world, groupName, node, value);
}
@Override
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
try {
this.permission.getHandler().safeGetGroup(world, groupName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setGroupInfo(world, groupName, node, value);
}
@Override
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
String s = this.permission.getHandler().getInfoString(world, groupName, node, true);
if(s == null) {
return defaultValue;
} else {
try {
return Double.parseDouble(s);
} catch(NumberFormatException e) {
return defaultValue;
}
}
Double d = this.perms.getInfoDouble(world, groupName, node, true);
return (d == null) ? defaultValue : d;
}
@Override
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
try {
this.permission.getHandler().safeGetGroup(world, groupName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
String s = this.permission.getHandler().getInfoString(world, groupName, node, true);
if(s == null) {
return defaultValue;
} else {
return Boolean.parseBoolean(s);
}
Boolean b = this.perms.getInfoBoolean(world, groupName, node, true);
return (b == null) ? defaultValue : b;
}
@Override
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
try {
this.permission.getHandler().safeGetGroup(world, groupName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setGroupInfo(world, groupName, node, value);
}
@Override
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
String s = this.permission.getHandler().getInfoString(world, groupName, node, true);
if(s == null) {
return defaultValue;
} else {
return s;
}
return (s == null) ? defaultValue : s;
}
@Override
public void setGroupInfoString(String world, String groupName, String node, String value) {
try {
this.permission.getHandler().safeGetGroup(world, groupName).setData(node, value);
} catch(Exception e) {
// lolwut?
}
setGroupInfo(world, groupName, node, value);
}
@Override
public boolean groupHas(String worldName, String groupName, String permission) {
try {
Group group = this.permission.getHandler().safeGetGroup(worldName, groupName);
Group group = this.perms.safeGetGroup(worldName, groupName);
return group.hasPermission(permission);
} catch (Exception e) {
// lowut?
@ -331,25 +261,30 @@ public class Permission_Permissions extends Permission {
@Override
public String[] getPlayerGroups(String world, String playerName) {
return this.permission.getHandler().getGroups(world, playerName);
return this.perms.getGroups(world, playerName);
}
public String getPrimaryGroup(String world, String playerName) {
return this.permission.getHandler().getPrimaryGroup(world, playerName);
return this.perms.getPrimaryGroup(world, playerName);
}
@Override
public boolean playerHas(String worldName, String playerName, String permission) {
return this.permission.getHandler().has(worldName, playerName, permission);
return this.perms.has(worldName, playerName, permission);
}
@Override
public String getPlayerPrefix(String world, String playerName) {
return this.permission.getHandler().getUserPrefix(world, playerName);
return this.perms.getUserPrefix(world, playerName);
}
@Override
public String getPlayerSuffix(String world, String playerName) {
return this.permission.getHandler().getUserSuffix(world, playerName);
return this.perms.getUserSuffix(world, playerName);
}
@Override
public void setPlayerSuffix(Player player, String suffix) {
this.perms.addUserInfo(player.getWorld().getName(), player.getName(), "suffix", suffix);
}
}

View File

@ -389,4 +389,11 @@ public class Permission_PermissionsEx extends Permission {
return null;
}
}
@Override
public void setPlayerSuffix(Player player, String suffix) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(player);
if (user != null)
user.setSuffix(suffix);
}
}