mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-12-24 18:07:43 +01:00
Start of the MV Permissions Handler... centralise all Permission
checks and fall back to isOP().
This commit is contained in:
parent
30e9b991b7
commit
0d64b59851
@ -9,6 +9,10 @@ public class MVPermissions {
|
||||
|
||||
private MultiVerseCore plugin;
|
||||
|
||||
/**
|
||||
* Constructor FTW
|
||||
* @param plugin Pass along the Core Plugin.
|
||||
*/
|
||||
public MVPermissions(MultiVerseCore plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -26,14 +30,16 @@ public class MVPermissions {
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
if (blackList.size() == 0)
|
||||
if (blackList.size() == 0) {
|
||||
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())) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
@ -45,14 +51,22 @@ public class MVPermissions {
|
||||
* @return
|
||||
*/
|
||||
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> blackList = this.plugin.worlds.get(w.getName()).joinBlacklist;
|
||||
@SuppressWarnings("deprecation")
|
||||
String group = MultiVerseCore.Permissions.getGroup(p.getName());
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
if (whiteList.size() > 0)
|
||||
// TODO: Not sure if I want this.
|
||||
if (whiteList.size() > 0) {
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < whiteList.size(); i++){
|
||||
if (whiteList.get(i).contains("g:") && group.equalsIgnoreCase(whiteList.get(i).split(":")[1])) {
|
||||
@ -81,6 +95,7 @@ public class MVPermissions {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user