diff --git a/src/com/onarandombox/MultiverseCore/MVPermissions.java b/src/com/onarandombox/MultiverseCore/MVPermissions.java index f2b36be7..95d87bd0 100644 --- a/src/com/onarandombox/MultiverseCore/MVPermissions.java +++ b/src/com/onarandombox/MultiverseCore/MVPermissions.java @@ -18,7 +18,7 @@ public class MVPermissions implements PermissionsInterface { /** * Constructor FTW - * + * * @param plugin Pass along the Core Plugin. */ public MVPermissions(MultiverseCore plugin) { @@ -32,7 +32,7 @@ public class MVPermissions implements PermissionsInterface { /** * Check if a Player can teleport to the Destination world from there current world. This checks against the Worlds Blacklist - * + * * @param p * @param w * @return @@ -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; @@ -58,61 +54,34 @@ public class MVPermissions implements PermissionsInterface { /** * Check if the Player has the permissions to enter this world. - * + * * @param p * @param w * @return */ public Boolean canEnterWorld(Player p, MVWorld w) { - - List whiteList = w.getPlayerWhitelist(); - List 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. - * - * @param player The player to check + * 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 + * @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) { - + return this.permissions.inGroup(worldName, player.getName(), group); } else { return player.isOp(); } } - + + @Deprecated public List getGroups(String worldName, String name) { return Arrays.asList(this.permissions.getGroups(worldName, name)); } diff --git a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java index fbf463fc..871ff8ae 100644 --- a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java +++ b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java @@ -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; + } + } + } } diff --git a/src/com/onarandombox/MultiverseCore/MVWorld.java b/src/com/onarandombox/MultiverseCore/MVWorld.java index c79b3438..ab0796a2 100644 --- a/src/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/com/onarandombox/MultiverseCore/MVWorld.java @@ -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())); - this.getPlayerBlacklist().addAll(config.getStringList("worlds." + this.name + ".playerblacklist", new ArrayList())); this.getWorldBlacklist().addAll(config.getStringList("worlds." + this.name + ".worldblacklist", new ArrayList())); this.getBlockBlacklist().addAll(config.getIntList("worlds." + this.name + ".blockblacklist", new ArrayList())); this.translateTempSpawn(config); @@ -196,8 +194,6 @@ public class MVWorld { this.masterList = new HashMap>(); this.blockBlacklist = new ArrayList(); // Only int list, we don't need to add it to the masterlist - this.masterList.put("playerwhitelist", new ArrayList()); - this.masterList.put("playerblacklist", new ArrayList()); this.masterList.put("worldblacklist", new ArrayList()); this.masterList.put("animals", new ArrayList()); this.masterList.put("monsters", new ArrayList()); @@ -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 getPlayerWhitelist() { - return this.masterList.get("playerwhitelist"); - } - - public List getPlayerBlacklist() { - return this.masterList.get("playerblacklist"); - } - public List getWorldBlacklist() { return this.masterList.get("worldblacklist"); } diff --git a/src/com/onarandombox/MultiverseCore/commands/TeleportCommand.java b/src/com/onarandombox/MultiverseCore/commands/TeleportCommand.java index 42c8b0b0..a5480052 100644 --- a/src/com/onarandombox/MultiverseCore/commands/TeleportCommand.java +++ b/src/com/onarandombox/MultiverseCore/commands/TeleportCommand.java @@ -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;