added basic GM group stuff.

This commit is contained in:
Sleaker 2012-01-31 08:17:36 -08:00
parent 8bead8b358
commit 84e6419498

View File

@ -110,12 +110,14 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean playerAdd(String worldName, String playerName, String permission) { public boolean playerAdd(String worldName, String playerName, String permission) {
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName); OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) if (owh == null) {
return false; return false;
}
User user = owh.getUser(playerName); User user = owh.getUser(playerName);
if (user == null) if (user == null) {
return false; return false;
}
user.addPermission(permission); user.addPermission(permission);
return true; return true;
@ -124,12 +126,14 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean playerRemove(String worldName, String playerName, String permission) { public boolean playerRemove(String worldName, String playerName, String permission) {
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName); OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) if (owh == null) {
return false; return false;
}
User user = owh.getUser(playerName); User user = owh.getUser(playerName);
if (user == null) if (user == null) {
return false; return false;
}
user.removePermission(permission); user.removePermission(permission);
return true; return true;
@ -138,12 +142,14 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean groupHas(String worldName, String groupName, String permission) { public boolean groupHas(String worldName, String groupName, String permission) {
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName); OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) if (owh == null) {
return false; return false;
}
Group group = owh.getGroup(groupName); Group group = owh.getGroup(groupName);
if (group == null) if (group == null) {
return false; return false;
}
return group.hasSamePermissionNode(permission); return group.hasSamePermissionNode(permission);
} }
@ -151,12 +157,14 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean groupAdd(String worldName, String groupName, String permission) { public boolean groupAdd(String worldName, String groupName, String permission) {
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName); OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) if (owh == null) {
return false; return false;
}
Group group = owh.getGroup(groupName); Group group = owh.getGroup(groupName);
if (group == null) if (group == null) {
return false; return false;
}
group.addPermission(permission); group.addPermission(permission);
return true; return true;
@ -165,12 +173,14 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean groupRemove(String worldName, String groupName, String permission) { public boolean groupRemove(String worldName, String groupName, String permission) {
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName); OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) if (owh == null) {
return false; return false;
}
Group group = owh.getGroup(groupName); Group group = owh.getGroup(groupName);
if (group == null) if (group == null) {
return false; return false;
}
group.removePermission(permission); group.removePermission(permission);
return true; return true;
@ -183,12 +193,46 @@ public class Permission_GroupManager extends Permission {
@Override @Override
public boolean playerAddGroup(String worldName, String playerName, String groupName) { public boolean playerAddGroup(String worldName, String playerName, String groupName) {
return false; OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) {
return false;
}
User user = owh.getUser(playerName);
if (user == null) {
return false;
}
Group group = owh.getGroup(groupName);
if (group == null) {
return false;
}
if (user.getGroup().equals(owh.getDefaultGroup())) {
user.setGroup(group);
} else {
user.addSubGroup(group);
}
return true;
} }
@Override @Override
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) { public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
return false; OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(worldName);
if (owh == null) {
return false;
}
User user = owh.getUser(playerName);
if (user == null) {
return false;
}
if (user.getGroup().getName().equalsIgnoreCase(groupName)) {
user.setGroup(owh.getDefaultGroup());
return true;
} else {
Group group = owh.getGroup(groupName);
if (group == null) {
return false;
}
return user.removeSubGroup(group);
}
} }
@Override @Override