Updated this via browser, sorry if something broke xD

This commit is contained in:
Alexander Söderberg 2016-02-10 22:23:49 +01:00
parent 893c2b3088
commit ca73addc88

View File

@ -137,43 +137,20 @@ public class BukkitPlayer extends PlotPlayer {
@Override @Override
public void setAttribute(String key) { public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key; setPersistentMeta("attrib_" + key, new byte[]{(byte) 1});
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
setMeta(key, true);
return;
}
EconHandler.manager.setPermission(getName(), key, true);
} }
@Override @Override
public boolean getAttribute(String key) { public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key; if (!hasPersistentMeta(key)) {
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) { return false;
final Object v = getMeta(key);
return v == null ? false : (Boolean) v;
} }
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key); return getPersistentMeta("attrib_" + key)[0] == 1;
if (perm == null) {
try {
perm = new Permission(key, PermissionDefault.FALSE);
Bukkit.getServer().getPluginManager().addPermission(perm);
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
}
catch (Exception e) {
e.printStackTrace();
}
}
return player.hasPermission(key);
} }
@Override @Override
public void removeAttribute(String key) { public void removeAttribute(String key) {
key = "plotsquared_user_attributes." + key; removePersistentMeta("attrib_" + key);
if ((EconHandler.manager == null) || player.hasPermission("plotsquared_user_attributes.*")) {
deleteMeta(key);
return;
}
EconHandler.manager.setPermission(getName(), key, false);
} }
@Override @Override