From 4873beb100f999e6a839a36d8ccce4e65ecc4931 Mon Sep 17 00:00:00 2001 From: md678685 Date: Fri, 15 Jun 2018 19:20:06 +0100 Subject: [PATCH] Allow updating the compass target to be optional (#1937) If `compass-towards-home-perm` is enabled in the EssentialsX config, then the permission `essentials.home.compass` is checked before changing the player's compass target. Closes #1918. --- .../essentials/EssentialsPlayerListener.java | 3 +++ .../com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 12 ++++++++++++ Essentials/src/config.yml | 19 +++++++++++++------ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index b4f080e05..57a5b620e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -353,7 +353,10 @@ public class EssentialsPlayerListener implements Listener { } // Makes the compass item ingame always point to the first essentials home. #EasterEgg + // EssentialsX: This can now optionally require a permission to enable, if set in the config. private void updateCompass(final User user) { + if (ess.getSettings().isCompassTowardsHomePerm() && !user.isAuthorized("essentials.home.compass")) return; + Location loc = user.getHome(user.getLocation()); if (loc == null) { loc = user.getBase().getBedSpawnLocation(); diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 367b4dbae..77b800836 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -306,4 +306,6 @@ public interface ISettings extends IConf { List getDefaultEnabledConfirmCommands(); boolean isConfirmCommandEnabledByDefault(String commandName); + + boolean isCompassTowardsHomePerm(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 56b4e50d5..cb1dbe2f4 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -533,6 +533,7 @@ public class Settings implements net.ess3.api.ISettings { currencyFormat = _getCurrencyFormat(); unprotectedSigns = _getUnprotectedSign(); defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands(); + isCompassTowardsHomePerm = _isCompassTowardsHomePerm(); } private List itemSpawnBl = new ArrayList(); @@ -1439,4 +1440,15 @@ public class Settings implements net.ess3.api.ISettings { public boolean isConfirmCommandEnabledByDefault(String commandName) { return getDefaultEnabledConfirmCommands().contains(commandName.toLowerCase()); } + + private boolean isCompassTowardsHomePerm; + + private boolean _isCompassTowardsHomePerm() { + return config.getBoolean("compass-towards-home-perm", false); + } + + @Override + public boolean isCompassTowardsHomePerm() { + return isCompassTowardsHomePerm; + } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 28fcf6ca1..24b8af5e7 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -522,6 +522,13 @@ default-enabled-confirm-commands: #- pay #- clearinventory +# Set the timeout, in seconds for players to accept a tpa before the request is cancelled. +# Set to 0 for no timeout. +tpa-accept-cancellation: 120 + +# Allow players to set hats by clicking on their helmet slot. +allow-direct-hat: true + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | # @@ -551,12 +558,12 @@ sethome-multiple: # In this example someone with 'essentials.sethome.multiple' and 'essentials.sethome.multiple.vip' will have 5 homes. # Remember, they MUST have both permission nodes in order to be able to set multiple homes. -# Set the timeout, in seconds for players to accept a tpa before the request is cancelled. -# Set to 0 for no timeout. -tpa-accept-cancellation: 120 - -# Allow players to set hats by clicking on their helmet slot. -allow-direct-hat: true +# Controls whether players need the permission "essentials.home.compass" in order to point +# the player's compass at their first home. +# +# Leaving this as false will retain Essentials' original behaviour, which is to always +# change the compass' direction to point towards their first home. +compass-towards-home-perm: false ############################################################ # +------------------------------------------------------+ #