From 1cb593dba3977c23a94d4517c90315d17a8dd541 Mon Sep 17 00:00:00 2001 From: Khyperia Date: Sat, 3 Dec 2011 12:13:42 -0500 Subject: Added per-world permissions for /world --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 21 ++++++++++++++------- .../earth2me/essentials/commands/Commandworld.java | 9 +++++++++ Essentials/src/config.yml | 4 ++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index d7764ed16..41e99c29c 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -140,4 +140,6 @@ public interface ISettings extends IConf boolean getUpdateBedAtDaytime(); boolean getRepairEnchanted(); + + boolean getIsWorldTeleportPermissions(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index b65d53616..1683fd7ef 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -29,7 +29,7 @@ public class Settings implements ISettings { return config.getBoolean("respawn-at-home", false); } - + @Override public boolean getUpdateBedAtDaytime() { @@ -332,7 +332,7 @@ public class Settings implements ISettings public void reloadConfig() { config.load(); - noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds",Collections.emptyList())); + noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds", Collections.emptyList())); } @Override @@ -535,13 +535,12 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } - - Set noGodWorlds = new HashSet(); + Set noGodWorlds = new HashSet(); + @Override public Set getNoGodWorlds() { return noGodWorlds; - } @Override @@ -549,8 +548,16 @@ public class Settings implements ISettings { this.debug = debug; } - - public boolean getRepairEnchanted() { + + @Override + public boolean getRepairEnchanted() + { return config.getBoolean("repair-enchanted", true); } + + @Override + public boolean getIsWorldTeleportPermissions() + { + return config.getBoolean("world-teleport-permissions", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index 7380b23ae..b62276cf8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -53,6 +53,15 @@ public class Commandworld extends EssentialsCommand } } + if (ess.getSettings().getIsWorldTeleportPermissions()) + { + if (!user.isAuthorized("essentials.world." + world.getName())) + { + user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation + throw new NoChargeException(); + } + } + double factor; if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL) { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 2f43cde1e..2bb8dbd0c 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -220,6 +220,10 @@ death-messages: true no-god-in-worlds: # - world_nether +# Set to true to enable per-world permissions for teleporting with /world +# Give someone permission to teleport to a world with essentials.world. +world-teleport-permissions: false + # Oversized stacks are stacks that ignore the normal max stacksize. # They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission. # How many items should be in a oversized stack? -- cgit v1.2.3