diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 11566ca0459..8f5ddc42e1d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -429,6 +429,8 @@ public interface ISettings extends IConf { boolean isConfirmHomeOverwrite(); + boolean isStrictHomeLimit(); + boolean infoAfterDeath(); boolean isRespawnAtBed(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index fbec7ea904a..add3b3a1cc5 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -2157,6 +2157,11 @@ public boolean isConfirmHomeOverwrite() { return config.getBoolean("confirm-home-overwrite", false); } + @Override + public boolean isStrictHomeLimit() { + return config.getBoolean("strict-home-limit", false); + } + @Override public boolean infoAfterDeath() { return config.getBoolean("send-info-after-death", false); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java index 8dca6262081..40beb2e587d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java @@ -40,6 +40,13 @@ public void run(final Server server, final User user, final String commandLabel, } } } + if (ess.getSettings().isStrictHomeLimit() && user.equals(player) + && !user.isAuthorized("essentials.sethome.multiple.unlimited")) { + final int limit = ess.getSettings().getHomeLimit(user); + if (user.getHomes().size() > limit) { + throw new TranslatableException("strictHomeLimitExceeded", limit); + } + } try { if ("bed".equalsIgnoreCase(homeName)) { if (!user.isAuthorized("essentials.home.bed")) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsethome.java index a3f446bdd80..c11146d4984 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsethome.java @@ -90,6 +90,9 @@ private boolean checkHomeLimit(final User user, final User usersHome, final Stri if (!user.isAuthorized("essentials.sethome.multiple.unlimited")) { final int limit = ess.getSettings().getHomeLimit(user); if (usersHome.getHomes().size() >= limit) { + if (ess.getSettings().isStrictHomeLimit() && user.equals(usersHome) && usersHome.getHomes().size() > limit) { + throw new TranslatableException("strictHomeLimitExceeded", limit); + } if (usersHome.getHomes().contains(name)) { return false; } diff --git a/Essentials/src/main/resources/config.yml b/Essentials/src/main/resources/config.yml index eb441235b6b..caa0f9cae79 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -837,6 +837,10 @@ spawn-if-no-home: true # Should players be asked to provide confirmation for homes they attempt to overwrite? confirm-home-overwrite: false +# Block /sethome and /home for players over their home limit, suggesting /delhome usage +# When set to false, players with more homes than permitted can overwrite existing home names and still use /home. +strict-home-limit: false + ############################################################ # +------------------------------------------------------+ # # | Economy | # diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 85f1d20dc36..0ee5ac8068a 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -1268,6 +1268,7 @@ speedCommandUsage2=/ [player] speedCommandUsage2Description=Sets either the specified type of speed to the given speed for you or another player if specified stonecutterCommandDescription=Opens up a stonecutter. stonecutterCommandUsage=/ +strictHomeLimitExceeded=You are above your home limit of {0}. Use /delhome to remove homes before using this command. sudoCommandDescription=Make another user perform a command. sudoCommandUsage=/ sudoCommandUsage1=/ [args]