diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 49b9d5120..44cc49ac1 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -538,7 +538,7 @@ public class User extends UserData implements Comparable, IMessageRecipien setMuteTimeout(0); sendMessage(tl("canTalkAgain")); setMuted(false); - setMuteReason (""); + setMuteReason(null); return true; } } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index da73c6dfb..090326927 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -73,7 +73,7 @@ public abstract class UserData extends PlayerExtension implements IConf { godmode = _getGodModeEnabled(); muted = _getMuted(); muteTimeout = _getMuteTimeout(); - muteReason = _getMuteReason (); + muteReason = _getMuteReason(); jailed = _getJailed(); jailTimeout = _getJailTimeout(); lastLogin = _getLastLogin(); @@ -518,27 +518,22 @@ public abstract class UserData extends PlayerExtension implements IConf { } public String getMuteReason() { - if (muteReason != null) { - return muteReason; - } - else { - return ""; - } + return muteReason; } public void setMuteReason(String reason) { - if (reason.equals("")) { - config.removeProperty ("muteReason"); + if (reason == null) { + config.removeProperty("muteReason"); muteReason = null; } else { muteReason = reason; - config.setProperty ("muteReason", reason); + config.setProperty("muteReason", reason); } config.save(); } public boolean hasMuteReason(){ - return !getMuteReason().equals(""); + return muteReason != null; } private long muteTimeout; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index 63567b5e3..ac59284d9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -54,19 +54,19 @@ public class Commandmute extends EssentialsCommand { String muteReason; try { muteTimestamp = DateUtil.parseDateDiff(time, true); - muteReason = getFinalArg (args, 2); + muteReason = getFinalArg(args, 2); } catch (Exception e) { - user.setMuted ((!user.getMuted ())); - muteReason = getFinalArg (args, 1); + user.setMuted((!user.getMuted())); + muteReason = getFinalArg(args, 1); } - user.setMuteReason (muteReason); + user.setMuteReason(muteReason.isEmpty() ? null : muteReason); user.setMuted(true); } else { user.setMuted(!user.getMuted()); - if (!user.getMuted ()) { - user.setMuteReason (""); + if (!user.getMuted()) { + user.setMuteReason(null); } } user.setMuteTimeout(muteTimestamp); @@ -79,7 +79,7 @@ public class Commandmute extends EssentialsCommand { if (muted) { if (muteTimestamp > 0) { - if (user.getMuteReason ().equals ("")) { + if (!user.hasMuteReason()) { sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime)); user.sendMessage(tl("playerMutedFor", muteTime)); } else { @@ -87,31 +87,26 @@ public class Commandmute extends EssentialsCommand { user.sendMessage(tl("playerMutedForReason", muteTime, user.getMuteReason())); } } else { - if (user.getMuteReason ().equals ("")) { + if (!user.hasMuteReason()) { sender.sendMessage(tl("mutedPlayer", user.getDisplayName())); - /** Send the player a message, why they were muted **/ user.sendMessage(tl("playerMuted")); - } - else { + } else { sender.sendMessage(tl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason())); - /** Send the player a message, why they were muted **/ user.sendMessage(tl("playerMutedReason", user.getMuteReason())); } } final String message; if (muteTimestamp > 0) { - if (user.getMuteReason ().equals ("")) { + if (!user.hasMuteReason()) { message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime); - } - else { - message = (tl("muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason())); + } else { + message = tl("muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason()); } } else { - if (user.getMuteReason ().equals ("")) { + if (!user.hasMuteReason()) { message = tl("muteNotify", sender.getSender().getName(), user.getName()); - } - else { - message = (tl("muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason())); + } else { + message = tl("muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason()); } } server.getLogger().log(Level.INFO, message); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index afaf903ab..11c26ba4c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -117,8 +117,12 @@ public class Commandseen extends EssentialsCommand { sender.sendMessage(tl("whoisJail", (user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true")))); } if (user.isMuted()) { - sender.sendMessage(user.hasMuteReason() ? (tl("whoisMutedReason", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true")), user.getMuteReason())) : - tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true")))); + long muteTimeout = user.getMuteTimeout(); + if (!user.hasMuteReason()) { + sender.sendMessage(tl("whoisMuted", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")))); + } else { + sender.sendMessage(tl("whoisMutedReason", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")), user.getMuteReason())); + } } final String location = user.getGeoLocation(); if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) { @@ -160,6 +164,15 @@ public class Commandseen extends EssentialsCommand { } } + if (user.isMuted()) { + long muteTimeout = user.getMuteTimeout(); + if (!user.hasMuteReason()) { + sender.sendMessage(tl("whoisMuted", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")))); + } else { + sender.sendMessage(tl("whoisMutedReason", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")), user.getMuteReason())); + } + } + final String location = user.getGeoLocation(); if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) { sender.sendMessage(tl("whoisGeoLocation", location)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index c92059358..c62812d90 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -56,9 +56,14 @@ 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")))); - sender.sendMessage(user.hasMuteReason() ? tl("whoisMutedReason", (user.isMuted() ? user.getMuteTimeout() > 0 ? - DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false")),user.getMuteReason()) : tl("whoisMuted", (user.isMuted() ? - user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false")))); + + long muteTimeout = user.getMuteTimeout(); + if (!user.hasMuteReason()) { + sender.sendMessage(tl("whoisMuted", (user.isMuted() ? (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")) : tl("false")))); + } else { + sender.sendMessage(tl("whoisMutedReason", (user.isMuted() ? (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")) : tl("false")), + user.getMuteReason())); + } } @Override