mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-23 16:01:34 +01:00
Node based permissions
This commit is contained in:
parent
96fa18eab3
commit
bf51adaa3e
@ -42,10 +42,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
if (blackList.size() == 0) {
|
||||
returnValue = true;
|
||||
}
|
||||
|
||||
for (String s : blackList) {
|
||||
if (s.equalsIgnoreCase(p.getWorld().getName())) {
|
||||
returnValue = false;
|
||||
@ -64,46 +60,18 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @return
|
||||
*/
|
||||
public Boolean canEnterWorld(Player p, MVWorld w) {
|
||||
|
||||
List<String> whiteList = w.getPlayerWhitelist();
|
||||
List<String> blackList = w.getPlayerBlacklist();
|
||||
boolean returnValue = true;
|
||||
|
||||
// If there's anyone in the whitelist, then the whitelist is ACTIVE, anyone not in it is blacklisted.
|
||||
if (whiteList.size() > 0) {
|
||||
returnValue = false;
|
||||
}
|
||||
for (String bls : blackList) {
|
||||
if (bls.toLowerCase().contains("g:") && this.inGroup(p, w.getAlias(), bls.split(":")[1])) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
if (bls.equalsIgnoreCase(p.getName())) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (String wls : whiteList) {
|
||||
if (wls.toLowerCase().contains("g:") && this.inGroup(p, w.getAlias(), wls.split(":")[1])) {
|
||||
returnValue = true;
|
||||
break;
|
||||
}
|
||||
if (wls.equalsIgnoreCase(p.getName())) {
|
||||
returnValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a player is in a group.
|
||||
* Returns true if a player is in a group. DEPRECATED: We're moving away from groups. Use permissions nodes in the groups instead.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param worldName The world to check in
|
||||
* @param group The group are we checking
|
||||
* @return True if the player is in the group, false if not.
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean inGroup(Player player, String worldName, String group) {
|
||||
if (this.permissions != null) {
|
||||
|
||||
@ -113,6 +81,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getGroups(String worldName, String name) {
|
||||
return Arrays.asList(this.permissions.getGroups(worldName, name));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
|
||||
@ -122,4 +123,24 @@ public class MVPlayerListener extends PlayerListener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
MVWorld fromWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
|
||||
MVWorld toWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (toWorld != null) {
|
||||
if (!this.plugin.getPermissions().canEnterWorld(event.getPlayer(), toWorld)) {
|
||||
event.getPlayer().sendMessage("You don't have access to go here...");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fromWorld != null) {
|
||||
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
|
||||
event.getPlayer().sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,8 +123,6 @@ public class MVWorld {
|
||||
this.setMonsters(config.getBoolean("worlds." + this.name + ".monsters.spawn", true));
|
||||
this.getMobExceptions();
|
||||
|
||||
this.getPlayerWhitelist().addAll(config.getStringList("worlds." + this.name + ".playerwhitelist", new ArrayList<String>()));
|
||||
this.getPlayerBlacklist().addAll(config.getStringList("worlds." + this.name + ".playerblacklist", new ArrayList<String>()));
|
||||
this.getWorldBlacklist().addAll(config.getStringList("worlds." + this.name + ".worldblacklist", new ArrayList<String>()));
|
||||
this.getBlockBlacklist().addAll(config.getIntList("worlds." + this.name + ".blockblacklist", new ArrayList<Integer>()));
|
||||
this.translateTempSpawn(config);
|
||||
@ -196,8 +194,6 @@ public class MVWorld {
|
||||
this.masterList = new HashMap<String, List<String>>();
|
||||
this.blockBlacklist = new ArrayList<Integer>();
|
||||
// Only int list, we don't need to add it to the masterlist
|
||||
this.masterList.put("playerwhitelist", new ArrayList<String>());
|
||||
this.masterList.put("playerblacklist", new ArrayList<String>());
|
||||
this.masterList.put("worldblacklist", new ArrayList<String>());
|
||||
this.masterList.put("animals", new ArrayList<String>());
|
||||
this.masterList.put("monsters", new ArrayList<String>());
|
||||
@ -210,20 +206,12 @@ public class MVWorld {
|
||||
|
||||
this.blockBlacklist.add(49);
|
||||
|
||||
this.getPlayerWhitelist().add("fernferret");
|
||||
this.getPlayerBlacklist().add("g:Admins");
|
||||
|
||||
this.getPlayerBlacklist().add("Rigby90");
|
||||
this.getPlayerBlacklist().add("g:Banned");
|
||||
|
||||
this.getWorldBlacklist().add("world5");
|
||||
this.getWorldBlacklist().add("A world with spaces");
|
||||
|
||||
this.config.setProperty("worlds." + this.name + ".animals.exceptions", this.getAnimalList());
|
||||
this.config.setProperty("worlds." + this.name + ".monsters.exceptions", this.getMonsterList());
|
||||
this.config.setProperty("worlds." + this.name + ".blockblacklist", this.getBlockBlacklist());
|
||||
this.config.setProperty("worlds." + this.name + ".playerwhitelist", this.getPlayerWhitelist());
|
||||
this.config.setProperty("worlds." + this.name + ".playerblacklist", this.getPlayerBlacklist());
|
||||
this.config.setProperty("worlds." + this.name + ".worldblacklist", this.getWorldBlacklist());
|
||||
this.config.save();
|
||||
}
|
||||
@ -470,14 +458,6 @@ public class MVWorld {
|
||||
return this.blockBlacklist;
|
||||
}
|
||||
|
||||
public List<String> getPlayerWhitelist() {
|
||||
return this.masterList.get("playerwhitelist");
|
||||
}
|
||||
|
||||
public List<String> getPlayerBlacklist() {
|
||||
return this.masterList.get("playerblacklist");
|
||||
}
|
||||
|
||||
public List<String> getWorldBlacklist() {
|
||||
return this.masterList.get("worldblacklist");
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You can only teleport other players from the command line.");
|
||||
sender.sendMessage("From the console, you must specifiy a player to teleport");
|
||||
return;
|
||||
}
|
||||
teleporter = (Player) sender;
|
||||
|
Loading…
Reference in New Issue
Block a user