diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 665ae09c3..50447dd8e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -187,7 +187,7 @@ public class EssentialsPlayerListener implements Listener { public void onPlayerQuit(final PlayerQuitEvent event) { final User user = ess.getUser(event.getPlayer()); - if (ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentquit")) { + if (hideJoinQuitMessages() || (ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentquit"))) { event.setQuitMessage(null); } else if (ess.getSettings().isCustomQuitMessage() && event.getQuitMessage() != null) { final Player player = event.getPlayer(); @@ -235,11 +235,15 @@ public class EssentialsPlayerListener implements Listener { final String joinMessage = event.getJoinMessage(); ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer(), joinMessage)); - if (ess.getSettings().allowSilentJoinQuit() || ess.getSettings().isCustomJoinMessage()) { + if (hideJoinQuitMessages() || ess.getSettings().allowSilentJoinQuit() || ess.getSettings().isCustomJoinMessage()) { event.setJoinMessage(null); } } + private boolean hideJoinQuitMessages() { + return ess.getSettings().hasJoinQuitMessagePlayerCount() && ess.getServer().getOnlinePlayers().size() > ess.getSettings().getJoinQuitMessagePlayerCount(); + } + public void delayedJoin(final Player player, final String message) { if (!player.isOnline()) { return; @@ -294,7 +298,7 @@ public class EssentialsPlayerListener implements Listener { if (user.isAuthorized("essentials.silentjoin.vanish")) { user.setVanished(true); } - } else if (message == null) { + } else if (message == null || hideJoinQuitMessages()) { //NOOP } else if (ess.getSettings().isCustomJoinMessage()) { String msg = ess.getSettings().getCustomJoinMessage() diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 9ad1045ea..14c9026bd 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -210,6 +210,10 @@ public interface ISettings extends IConf { KeepInvPolicy getBindingItemsPolicy(); + int getJoinQuitMessagePlayerCount(); + + boolean hasJoinQuitMessagePlayerCount(); + enum KeepInvPolicy { KEEP, DELETE, diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index cb74b90fa..6178af091 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -1285,6 +1285,16 @@ public class Settings implements net.ess3.api.ISettings { return isCustomQuitMessage; } + @Override + public int getJoinQuitMessagePlayerCount() { + return config.getInt("hide-join-quit-messages-above", -1); + } + + @Override + public boolean hasJoinQuitMessagePlayerCount() { + return getJoinQuitMessagePlayerCount() >= 0; + } + @Override public boolean isNotifyNoNewMail() { return config.getBoolean("notify-no-new-mail", true); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 4caeb61a1..014612aef 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -484,11 +484,17 @@ send-info-after-death: false # In addition, people with essentials.silentjoin.vanish will be vanished on join. allow-silent-join-quit: false -# You can set custom join and quit messages here. Set to "none" to use the default message or "" to disable the message entirely. +# You can set custom join and quit messages here. Set this to "none" to use the default Minecraft message, +# or set this to "" to hide the message entirely. # You may use color codes, {USERNAME} for the player's name, and {PLAYER} for the player's displayname. custom-join-message: "none" custom-quit-message: "none" +# You can disable join and quit messages when the player count reaches a certain limit. +# When the player count is below this number, join/quit messages will always be shown. +# Set this to -1 to always show join and quit messages regardless of player count. +hide-join-quit-messages-above: -1 + # Add worlds to this list, if you want to automatically disable god mode there. no-god-in-worlds: # - world_nether