diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index a135086b1..2b9a21900 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -202,22 +202,6 @@ public class EssentialsPlayerListener implements Listener { dUser.updateActivity(false); dUser.stopTransaction(); - IText tempInput = null; - - if (!ess.getSettings().isCommandDisabled("motd")) { - try { - tempInput = new TextInput(dUser.getSource(), "motd", true, ess); - } catch (IOException ex) { - if (ess.getSettings().isDebug()) { - LOGGER.log(Level.WARNING, ex.getMessage(), ex); - } else { - LOGGER.log(Level.WARNING, ex.getMessage()); - } - } - } - - final IText input = tempInput; - class DelayJoinTask implements Runnable { @Override public void run() { @@ -262,10 +246,12 @@ public class EssentialsPlayerListener implements Listener { ess.getServer().broadcastMessage(message); } - if (input != null && user.isAuthorized("essentials.motd")) { - final IText output = new KeywordReplacer(input, user.getSource(), ess); - final TextPager pager = new TextPager(output, true); - pager.showPage("1", null, "motd", user.getSource()); + int motdDelay = ess.getSettings().getMotdDelay() / 50; + DelayMotdTask motdTask = new DelayMotdTask(user); + if (motdDelay > 0) { + ess.scheduleSyncDelayedTask(motdTask, motdDelay); + } else { + motdTask.run(); } if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail")) { @@ -302,6 +288,39 @@ public class EssentialsPlayerListener implements Listener { user.stopTransaction(); } + + class DelayMotdTask implements Runnable { + private User user; + + public DelayMotdTask(User user) { + this.user = user; + } + + @Override + public void run() { + IText tempInput = null; + + if (!ess.getSettings().isCommandDisabled("motd")) { + try { + tempInput = new TextInput(user.getSource(), "motd", true, ess); + } catch (IOException ex) { + if (ess.getSettings().isDebug()) { + LOGGER.log(Level.WARNING, ex.getMessage(), ex); + } else { + LOGGER.log(Level.WARNING, ex.getMessage()); + } + } + } + + final IText input = tempInput; + + if (input != null && user.isAuthorized("essentials.motd")) { + final IText output = new KeywordReplacer(input, user.getSource(), ess); + final TextPager pager = new TextPager(output, true); + pager.showPage("1", null, "motd", user.getSource()); + } + } + } } ess.scheduleSyncDelayedTask(new DelayJoinTask()); diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 57f45ea02..4e3376370 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -279,4 +279,6 @@ public interface ISettings extends IConf { boolean isAddingSuffixInPlayerlist(); int getNotifyPlayerOfMailCooldown(); + + int getMotdDelay(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index bfe4c7bd0..39b41403f 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -24,7 +24,6 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.*; -import java.util.Locale.Category; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; @@ -33,8 +32,6 @@ import static com.earth2me.essentials.I18n.tl; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import com.google.common.base.Preconditions; - public class Settings implements net.ess3.api.ISettings { private final transient EssentialsConf config; @@ -1414,4 +1411,9 @@ public class Settings implements net.ess3.api.ISettings { public int getNotifyPlayerOfMailCooldown() { return config.getInt("notify-player-of-mail-cooldown", 0); } + + @Override + public int getMotdDelay() { + return config.getInt("delay-motd", 0); + } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 8d51688ab..3834950c5 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -542,6 +542,10 @@ pastebin-createkit: true # This is useful when a sign sells or buys one item at a time and the player wants to sell a bunch at once. allow-bulk-buy-sell: true +# Delay for the MOTD display for players on join, in milliseconds. +# This has no effect if the MOTD command or permission are disabled. +delay-motd: 0 + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | #