Start of the MV Permissions Handler... centralise all Permission

checks and fall back to isOP().
This commit is contained in:
Rigby 2011-03-14 01:57:10 +00:00
parent 30e9b991b7
commit 0d64b59851

View File

@ -9,6 +9,10 @@ public class MVPermissions {
private MultiVerseCore plugin; private MultiVerseCore plugin;
/**
* Constructor FTW
* @param plugin Pass along the Core Plugin.
*/
public MVPermissions(MultiVerseCore plugin){ public MVPermissions(MultiVerseCore plugin){
this.plugin = plugin; this.plugin = plugin;
} }
@ -26,14 +30,16 @@ public class MVPermissions {
boolean returnValue = true; boolean returnValue = true;
if (blackList.size() == 0) if (blackList.size() == 0) {
returnValue = true; returnValue = true;
}
for (int i = 0; i < blackList.size(); i++) for (int i = 0; i < blackList.size(); i++) {
if (blackList.get(i).equalsIgnoreCase(p.getWorld().getName())) { if (blackList.get(i).equalsIgnoreCase(p.getWorld().getName())) {
returnValue = false; returnValue = false;
break; break;
} }
}
return returnValue; return returnValue;
} }
@ -45,14 +51,22 @@ public class MVPermissions {
* @return * @return
*/ */
public Boolean canEnterWorld(Player p, World w) { public Boolean canEnterWorld(Player p, World w) {
// First check if we've got the Permissions plugin, we can't perform the group checks without it.
if(MultiVerseCore.Permissions==null) {
return true; // If we don't have it we must return true otherwise we are forcing people to use the Permissions plugin.
}
List<String> whiteList = this.plugin.worlds.get(w.getName()).joinWhitelist; List<String> whiteList = this.plugin.worlds.get(w.getName()).joinWhitelist;
List<String> blackList = this.plugin.worlds.get(w.getName()).joinBlacklist; List<String> blackList = this.plugin.worlds.get(w.getName()).joinBlacklist;
@SuppressWarnings("deprecation")
String group = MultiVerseCore.Permissions.getGroup(p.getName()); String group = MultiVerseCore.Permissions.getGroup(p.getName());
boolean returnValue = true; boolean returnValue = true;
if (whiteList.size() > 0) // TODO: Not sure if I want this.
if (whiteList.size() > 0) {
returnValue = false; returnValue = false;
}
for (int i = 0; i < whiteList.size(); i++){ for (int i = 0; i < whiteList.size(); i++){
if (whiteList.get(i).contains("g:") && group.equalsIgnoreCase(whiteList.get(i).split(":")[1])) { if (whiteList.get(i).contains("g:") && group.equalsIgnoreCase(whiteList.get(i).split(":")[1])) {
@ -81,6 +95,7 @@ public class MVPermissions {
break; break;
} }
} }
return returnValue; return returnValue;
} }
} }