diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 6bcbcfa73..85b98dcbb 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -536,6 +536,10 @@ public abstract class UserData extends PlayerExtension implements IConf { config.save(); } + public boolean hasMuteReason(){ + return getMuteReason().equals(""); + } + private long muteTimeout; private long _getMuteTimeout() { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index c431482fe..0206dd00e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -51,12 +51,8 @@ public class Commandafk extends EssentialsCommand { private void toggleAfk(User sender, User user, String message) throws Exception { if (message != null && sender != null) { if (sender.isMuted()) { - if (sender.getMuteReason ().equals ("")) { - throw new Exception(tl("voiceSilenced")); - } - else { - throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", sender.getMuteReason ())); - } + throw new Exception(tl("voiceSilenced") + (sender.hasMuteReason() ? + tl("muteReason", sender.getMuteReason()) : "")); } if (!sender.isAuthorized("essentials.afk.message")) { throw new Exception(tl("noPermToAFKMessage")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index b9f524251..5e4e5bbf3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -48,12 +48,8 @@ public class Commandmail extends EssentialsCommand { } if (user.isMuted()) { - if (user.getMuteReason ().equals ("")) { - throw new Exception(tl("voiceSilenced")); - } - else { - throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); - } + throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? + tl("muteReason", user.getMuteReason()) : "")); } User u = getPlayer(server, args[1], true, true); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index c8814a450..f41f09d0e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -24,12 +24,8 @@ public class Commandme extends EssentialsCommand { @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { if (user.isMuted()) { - if (user.getMuteReason ().equals ("")) { - throw new Exception(tl("voiceSilenced")); - } - else { - throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); - } + throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? + tl("muteReason", user.getMuteReason()) : "")); } if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index 64a5693de..9b997ca1f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -28,12 +28,8 @@ public class Commandr extends EssentialsCommand { User user = ess.getUser(sender.getPlayer()); if (user.isMuted()) { - if (user.getMuteReason ().equals ("")) { - throw new Exception(tl("voiceSilenced")); - } - else { - throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); - } + throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? + tl("muteReason", user.getMuteReason()) : "")); } message = FormatUtil.formatMessage(user, "essentials.msg", message); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index b42de1370..41a8f0501 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -117,12 +117,8 @@ public class Commandseen extends EssentialsCommand { sender.sendMessage(tl("whoisJail", (user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true")))); } if (user.isMuted()) { - if (user.getMuteReason ().equals ("")) { - sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true")))); - } - else { - sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + " " + tl("muteReason", user.getMuteReason ())); - } + throw new Exception(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + (user.hasMuteReason() ? + tl("muteReason", user.getMuteReason()) : "")); } final String location = user.getGeoLocation(); if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 4fc96d04e..d9598f77c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -56,12 +56,8 @@ public class Commandwhois extends EssentialsCommand { sender.sendMessage(tl("whoisAFK", tl("false"))); } sender.sendMessage(tl("whoisJail", (user.isJailed() ? user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true") : tl("false")))); - if (user.getMuteReason ().equals ("")) { - sender.sendMessage(tl("whoisMuted", (user.isMuted() ? user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false")))); - } - else { - sender.sendMessage(tl("whoisMuted", (user.isMuted() ? user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false")) + " " + tl("muteReason", user.getMuteReason ()))); - } + throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? + tl("muteReason", user.getMuteReason()) : "")); } @Override