From e8bfac0790e5fff9ccbe266b790bd04e0049ca0f Mon Sep 17 00:00:00 2001 From: delbertina Date: Sat, 16 Dec 2017 23:26:09 -0600 Subject: [PATCH 1/4] Added space when adding reason to string. Dirty :/ --- .../com/earth2me/essentials/commands/Commandafk.java | 2 +- .../earth2me/essentials/commands/Commandmail.java | 2 +- .../com/earth2me/essentials/commands/Commandme.java | 2 +- .../earth2me/essentials/commands/Commandmute.java | 12 ++++++------ .../com/earth2me/essentials/commands/Commandr.java | 2 +- .../earth2me/essentials/commands/Commandseen.java | 2 +- .../earth2me/essentials/commands/Commandwhois.java | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index 2d78628a3..c431482fe 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -55,7 +55,7 @@ public class Commandafk extends EssentialsCommand { throw new Exception(tl("voiceSilenced")); } else { - throw new Exception(tl("voiceSilenced") + tl("muteReason", sender.getMuteReason ())); + throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", sender.getMuteReason ())); } } if (!sender.isAuthorized("essentials.afk.message")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index b69568497..b9f524251 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -52,7 +52,7 @@ public class Commandmail extends EssentialsCommand { throw new Exception(tl("voiceSilenced")); } else { - throw new Exception(tl("voiceSilenced") + tl("muteReason", user.getMuteReason ())); + throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index 40796abf6..c8814a450 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -28,7 +28,7 @@ public class Commandme extends EssentialsCommand { throw new Exception(tl("voiceSilenced")); } else { - throw new Exception(tl("voiceSilenced") + tl("muteReason", user.getMuteReason ())); + throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index 1fa988832..b87ecc07d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -83,8 +83,8 @@ public class Commandmute extends EssentialsCommand { sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime)); user.sendMessage(tl("playerMutedFor", muteTime)); } else { - sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime) + tl("muteReason",user.getMuteReason())); - user.sendMessage(tl("playerMutedFor", muteTime) + tl("muteReason",user.getMuteReason())); + sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime) + " " + tl("muteReason",user.getMuteReason())); + user.sendMessage(tl("playerMutedFor", muteTime) + " " + tl("muteReason",user.getMuteReason())); } } else { if (user.getMuteReason ().equals ("")) { @@ -93,9 +93,9 @@ public class Commandmute extends EssentialsCommand { user.sendMessage(tl("playerMuted")); } else { - sender.sendMessage(tl("mutedPlayer", user.getDisplayName()) + tl("muteReason",user.getMuteReason())); + sender.sendMessage(tl("mutedPlayer", user.getDisplayName()) + " " + tl("muteReason",user.getMuteReason())); /** Send the player a message, why they were muted **/ - user.sendMessage(tl("playerMuted")+ tl("muteReason",user.getMuteReason())); + user.sendMessage(tl("playerMuted") + " " + tl("muteReason",user.getMuteReason())); } } final String message; @@ -104,14 +104,14 @@ public class Commandmute extends EssentialsCommand { message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime); } else { - message = (tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime) + tl("muteReason",user.getMuteReason())); + message = (tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime) + " " + tl("muteReason",user.getMuteReason())); } } else { if (user.getMuteReason ().equals ("")) { message = tl("muteNotify", sender.getSender().getName(), user.getName()); } else { - message = (tl("muteNotify", sender.getSender().getName(), user.getName()) + tl("muteReason",user.getMuteReason())); + message = (tl("muteNotify", sender.getSender().getName(), user.getName()) + " " + tl("muteReason",user.getMuteReason())); } } server.getLogger().log(Level.INFO, message); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index 0542581d2..64a5693de 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -32,7 +32,7 @@ public class Commandr extends EssentialsCommand { throw new Exception(tl("voiceSilenced")); } else { - throw new Exception(tl("voiceSilenced") + tl("muteReason", user.getMuteReason ())); + throw new Exception(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index cbd83c2fb..b42de1370 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -121,7 +121,7 @@ public class Commandseen extends EssentialsCommand { 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 ())); + sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + " " + tl("muteReason", user.getMuteReason ())); } } final String location = user.getGeoLocation(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 1db31e831..4fc96d04e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -60,7 +60,7 @@ public class Commandwhois extends EssentialsCommand { 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 ()))); + sender.sendMessage(tl("whoisMuted", (user.isMuted() ? user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false")) + " " + tl("muteReason", user.getMuteReason ()))); } } From 034ffbd0bcdbac9367a09aa03addc41d48f15b53 Mon Sep 17 00:00:00 2001 From: delbertina Date: Sun, 17 Dec 2017 00:16:06 -0600 Subject: [PATCH 2/4] Added space when adding reason to string. --- Essentials/src/com/earth2me/essentials/commands/Commandafk.java | 2 +- .../src/com/earth2me/essentials/commands/Commandmail.java | 2 +- Essentials/src/com/earth2me/essentials/commands/Commandme.java | 2 +- Essentials/src/com/earth2me/essentials/commands/Commandr.java | 2 +- .../src/com/earth2me/essentials/commands/Commandseen.java | 2 +- .../src/com/earth2me/essentials/commands/Commandwhois.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java index 0206dd00e..df5847274 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java @@ -52,7 +52,7 @@ public class Commandafk extends EssentialsCommand { if (message != null && sender != null) { if (sender.isMuted()) { throw new Exception(tl("voiceSilenced") + (sender.hasMuteReason() ? - tl("muteReason", sender.getMuteReason()) : "")); + (" " + 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 5e4e5bbf3..a9e188a93 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -49,7 +49,7 @@ public class Commandmail extends EssentialsCommand { if (user.isMuted()) { throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? - tl("muteReason", user.getMuteReason()) : "")); + (" " + 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 f41f09d0e..8e954e927 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -25,7 +25,7 @@ public class Commandme extends EssentialsCommand { public void run(Server server, User user, String commandLabel, String[] args) throws Exception { if (user.isMuted()) { throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? - tl("muteReason", user.getMuteReason()) : "")); + (" " + 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 9b997ca1f..2e251c666 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -29,7 +29,7 @@ public class Commandr extends EssentialsCommand { if (user.isMuted()) { throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? - tl("muteReason", user.getMuteReason()) : "")); + (" " + 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 41a8f0501..6366649bf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -118,7 +118,7 @@ public class Commandseen extends EssentialsCommand { } if (user.isMuted()) { throw new Exception(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + (user.hasMuteReason() ? - tl("muteReason", user.getMuteReason()) : "")); + (" " + 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 d9598f77c..876a0f58a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -57,7 +57,7 @@ public class Commandwhois extends EssentialsCommand { } sender.sendMessage(tl("whoisJail", (user.isJailed() ? user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true") : tl("false")))); throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? - tl("muteReason", user.getMuteReason()) : "")); + (" " + tl("muteReason", user.getMuteReason())) : "")); } @Override From afe0ff0ca72bacb2f9b28753c95ea12c5a2ceb1c Mon Sep 17 00:00:00 2001 From: delbertina Date: Sun, 17 Dec 2017 01:46:43 -0600 Subject: [PATCH 3/4] Added space before reason when a muted player tries to talk. --- .../src/com/earth2me/essentials/EssentialsPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 3a6b5868b..5f6e7543c 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -85,7 +85,7 @@ public class EssentialsPlayerListener implements Listener { user.sendMessage(tl("voiceSilenced")); } else { - user.sendMessage(tl("voiceSilenced") + tl("muteReason", user.getMuteReason ())); + user.sendMessage(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); } LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage())); From e3ee9cb4c77e62eb794a6728950d7c84c70f1262 Mon Sep 17 00:00:00 2001 From: delbertina Date: Mon, 18 Dec 2017 20:37:34 -0600 Subject: [PATCH 4/4] Fixed logic error in hasMuteReason and errors being thrown from seen and whois. --- .../com/earth2me/essentials/EssentialsPlayerListener.java | 8 ++------ Essentials/src/com/earth2me/essentials/UserData.java | 2 +- .../src/com/earth2me/essentials/commands/Commandseen.java | 2 +- .../com/earth2me/essentials/commands/Commandwhois.java | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 5f6e7543c..c52d9631e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -81,12 +81,8 @@ public class EssentialsPlayerListener implements Listener { if (user.isMuted()) { event.setCancelled(true); - if (user.getMuteReason().equals ("")) { - user.sendMessage(tl("voiceSilenced")); - } - else { - user.sendMessage(tl("voiceSilenced") + " " + tl("muteReason", user.getMuteReason ())); - } + user.sendMessage(tl("voiceSilenced") + (user.hasMuteReason() ? + (" " + tl("muteReason", user.getMuteReason())) : "")); LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage())); } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 85b98dcbb..58fd43b44 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -537,7 +537,7 @@ public abstract class UserData extends PlayerExtension implements IConf { } public boolean hasMuteReason(){ - return getMuteReason().equals(""); + return !getMuteReason().equals(""); } private long muteTimeout; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index 6366649bf..601044f97 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -117,7 +117,7 @@ public class Commandseen extends EssentialsCommand { sender.sendMessage(tl("whoisJail", (user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true")))); } if (user.isMuted()) { - throw new Exception(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + (user.hasMuteReason() ? + sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))) + (user.hasMuteReason() ? (" " + tl("muteReason", user.getMuteReason())) : "")); } final String location = user.getGeoLocation(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 876a0f58a..be4d65c78 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -56,7 +56,7 @@ 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")))); - throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ? + sender.sendMessage(tl("whoisMuted") + (user.hasMuteReason() ? (" " + tl("muteReason", user.getMuteReason())) : "")); }