diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-04-14 15:58:12 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-04-14 15:58:12 +0100 |
commit | b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b (patch) | |
tree | 447418a07a232bb425b518d385648ec3dfc6d8b9 | |
parent | 055603b09e9d620ea2c42262461e4f453d0a1689 (diff) | |
parent | 34f5c19f997bd4c5480bacc83ecd674a5bc4cb26 (diff) | |
download | Essentials-b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b.tar Essentials-b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b.tar.gz Essentials-b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b.tar.lz Essentials-b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b.tar.xz Essentials-b3847270fa2a6c6c1e674b885aeb8b5d7d99b59b.zip |
Merge branch 'master' of github.com:essentials/Essentials
7 files changed, 44 insertions, 31 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 5a82a9fb1..8a7643b68 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -232,8 +232,11 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvents(worldListener, this); //TODO: Check if this should be here, and not above before reload() - jails = new Jails(this); - confList.add(jails); + if (settings.isJailsEnabled()) + { + jails = new Jails(this); + confList.add(jails); + } pm.registerEvents(tntListener, this); @@ -428,9 +431,16 @@ public class Essentials extends JavaPlugin implements IEssentials } @Override - public IJails getJails() + public IJails getJails() throws UnsupportedOperationException { - return jails; + if (jails == null) + { + throw new UnsupportedOperationException("Jails are not enabled in your configuration"); + } + else + { + return jails; + } } @Override diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 3e3f2fd91..51649a203 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -31,13 +31,11 @@ import org.bukkit.inventory.ItemStack; public class EssentialsPlayerListener implements Listener { private static final Logger LOGGER = Logger.getLogger("Minecraft"); - private final transient Server server; private final transient IEssentials ess; public EssentialsPlayerListener(final IEssentials parent) { this.ess = parent; - this.server = parent.getServer(); } @EventHandler(priority = EventPriority.NORMAL) @@ -218,7 +216,7 @@ public class EssentialsPlayerListener implements Listener return; } - User user = ess.getUser(event.getPlayer()); + final User user = ess.getUser(event.getPlayer()); if (user.isNPC()) { user.setNPC(false); @@ -247,8 +245,8 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { - boolean backListener = ess.getSettings().registerBackInListener(); - boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability(); + final boolean backListener = ess.getSettings().registerBackInListener(); + final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability(); if (backListener || teleportInvulnerability) { final User user = ess.getUser(event.getPlayer()); @@ -320,19 +318,16 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.MONITOR) public void onPlayerChangedWorld(final PlayerChangedWorldEvent event) { - final User user = ess.getUser(event.getPlayer()); + final User user = ess.getUser(event.getPlayer()); final String newWorld = event.getPlayer().getLocation().getWorld().getName(); user.setDisplayNick(); updateCompass(user); - if (ess.getSettings().getNoGodWorlds().contains(newWorld)) + if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) { - if (user.isGodModeEnabledRaw()) - { - user.sendMessage(_("noGodWorldWarning")); - } + user.sendMessage(_("noGodWorldWarning")); } - - if(!event.getPlayer().getWorld().getName().equals(newWorld)) + + if (!event.getPlayer().getWorld().getName().equals(newWorld)) { user.sendMessage(_("currentWorld", newWorld)); } @@ -344,11 +339,7 @@ public class EssentialsPlayerListener implements Listener switch (event.getAction()) { case RIGHT_CLICK_BLOCK: - if (event.isCancelled()) - { - return; - } - if (event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime()) + if (!event.isCancelled() && event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime()) { event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation()); } @@ -409,14 +400,12 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(final PlayerPickupItemEvent event) { - if (!ess.getSettings().getDisableItemPickupWhileAfk()) + if (ess.getSettings().getDisableItemPickupWhileAfk()) { - return; - } - final User user = ess.getUser(event.getPlayer()); - if (user.isAfk()) - { - event.setCancelled(true); + if (ess.getUser(event.getPlayer()).isAfk()) + { + event.setCancelled(true); + } } } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 83c2e7325..1b38d0dfe 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -37,7 +37,7 @@ public interface IEssentials extends Plugin BukkitScheduler getScheduler(); - IJails getJails(); + IJails getJails() throws UnsupportedOperationException; Warps getWarps(); diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 2c07ccd58..ea0354602 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -173,4 +173,6 @@ public interface ISettings extends IConf long getTeleportInvulnerability(); boolean isTeleportInvulnerability(); + + boolean isJailsEnabled(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index c4b19601f..0e36782be 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -780,4 +780,10 @@ public class Settings implements ISettings { return teleportInvulnerability; } + + @Override + public boolean isJailsEnabled() + { + return config.getBoolean("enable-jails", true); + } } diff --git a/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java b/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java index 0ea692cc9..befed005f 100644 --- a/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java +++ b/Essentials/src/com/earth2me/essentials/metrics/MetricsStarter.java @@ -172,6 +172,9 @@ public class MetricsStarter implements Runnable metrics.start(); } + catch (UnsupportedOperationException ex) + { + } catch (Exception ex) { metricsError(ex); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 70433b5b0..3227322a8 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -44,6 +44,9 @@ change-displayname: true # Don't forget to remove the # infront of the line #add-prefix-suffix: false +# Whether or not jails are activated +enable-jails: true + # The delay, in seconds, required between /home, /tp, etc. teleport-cooldown: 0 @@ -584,7 +587,7 @@ newbies: # When we spawn for the first time, which spawnpoint do we use? # Set to "none" if you want to use the spawn point of the world. spawnpoint: newbies - + # Do we want to give users anything on first join? Set to '' to disable # This kit will be given reguardless of cost, and permissions. #kit: '' |