diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 857dd0ce226..b1853fd2cf2 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -427,6 +427,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 136a448ba5d..48e2abfbcdc 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -2146,6 +2146,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 34b81e265b9..cf24291acc0 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) && user.isAuthorized("essentials.home.bed")) { if (!player.getBase().isOnline() || player.getBase() instanceof OfflinePlayerStub) { 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 beb886dd867..349334006ab 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -833,6 +833,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 +# By default, 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 0c8b6bc05f3..e58edb44862 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -1264,6 +1264,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]