Merge remote-tracking branch 'magnarisa/final_mute_reason_issue#385' into final_mute_reason_issue#385

Updated my local repos for testing purposes
This commit is contained in:
CreedTheFreak 2017-12-16 19:43:56 -08:00
commit 62d5dd3516
35 changed files with 120 additions and 17 deletions

View file

@ -80,7 +80,14 @@ public class EssentialsPlayerListener implements Listener {
final User user = ess.getUser(event.getPlayer());
if (user.isMuted()) {
event.setCancelled(true);
user.sendMessage(tl("voiceSilenced"));
if (user.getMuteReason().equals ("")) {
user.sendMessage(tl("voiceSilenced"));
}
else {
user.sendMessage(tl("voiceSilenced") + tl("muteReason", user.getMuteReason ()));
}
LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage()));
}
try {

View file

@ -538,6 +538,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setMuteTimeout(0);
sendMessage(tl("canTalkAgain"));
setMuted(false);
setMuteReason ("");
return true;
}
}

View file

@ -73,6 +73,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
godmode = _getGodModeEnabled();
muted = _getMuted();
muteTimeout = _getMuteTimeout();
muteReason = _getMuteReason ();
jailed = _getJailed();
jailTimeout = _getJailTimeout();
lastLogin = _getLastLogin();
@ -492,6 +493,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
}
private boolean muted;
private String muteReason;
public boolean _getMuted() {
return config.getBoolean("muted", false);
@ -511,6 +513,34 @@ public abstract class UserData extends PlayerExtension implements IConf {
config.save();
}
public String _getMuteReason() {
return config.getString("muteReason");
}
public String getMuteReason() {
if (muteReason != null) {
return muteReason;
}
else {
return "";
}
}
public void setMuteReason(String reason) {
if (reason.equals("")) {
config.removeProperty ("muteReason");
muteReason = null;
} else {
muteReason = reason;
config.setProperty ("muteReason", reason);
}
config.save();
}
public boolean hasMuteReason(){
return getMuteReason().equals("");
}
private long muteTimeout;
private long _getMuteTimeout() {

View file

@ -51,7 +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()) {
throw new Exception(tl("voiceSilenced"));
throw new Exception(tl("voiceSilenced") + (sender.hasMuteReason() ?
tl("muteReason", sender.getMuteReason()) : ""));
}
if (!sender.isAuthorized("essentials.afk.message")) {
throw new Exception(tl("noPermToAFKMessage"));

View file

@ -48,7 +48,8 @@ public class Commandmail extends EssentialsCommand {
}
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ?
tl("muteReason", user.getMuteReason()) : ""));
}
User u = getPlayer(server, args[1], true, true);

View file

@ -24,7 +24,8 @@ public class Commandme extends EssentialsCommand {
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ?
tl("muteReason", user.getMuteReason()) : ""));
}
if (args.length < 1) {

View file

@ -50,11 +50,24 @@ public class Commandmute extends EssentialsCommand {
long muteTimestamp = 0;
if (args.length > 1) {
final String time = getFinalArg(args, 1);
muteTimestamp = DateUtil.parseDateDiff(time, true);
final String time = args[1];
String muteReason;
try {
muteTimestamp = DateUtil.parseDateDiff(time, true);
muteReason = getFinalArg (args, 2);
} catch (Exception e) {
user.setMuted ((!user.getMuted ()));
muteReason = getFinalArg (args, 1);
}
user.setMuteReason (muteReason);
user.setMuted(true);
} else {
user.setMuted(!user.getMuted());
if (!user.getMuted ()) {
user.setMuteReason ("");
}
}
user.setMuteTimeout(muteTimestamp);
final boolean muted = user.getMuted();
@ -66,17 +79,40 @@ public class Commandmute extends EssentialsCommand {
if (muted) {
if (muteTimestamp > 0) {
sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime));
user.sendMessage(tl("playerMutedFor", muteTime));
if (user.getMuteReason ().equals ("")) {
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()));
}
} else {
sender.sendMessage(tl("mutedPlayer", user.getDisplayName()));
user.sendMessage(tl("playerMuted"));
if (user.getMuteReason ().equals ("")) {
sender.sendMessage(tl("mutedPlayer", user.getDisplayName()));
/** Send the player a message, why they were muted **/
user.sendMessage(tl("playerMuted"));
}
else {
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()));
}
}
final String message;
if (muteTimestamp > 0) {
message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime);
if (user.getMuteReason ().equals ("")) {
message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime);
}
else {
message = (tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime) + tl("muteReason",user.getMuteReason()));
}
} else {
message = tl("muteNotify", sender.getSender().getName(), user.getName());
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()));
}
}
server.getLogger().log(Level.INFO, message);
ess.broadcastMessage("essentials.mute.notify", message);

View file

@ -28,7 +28,8 @@ public class Commandr extends EssentialsCommand {
User user = ess.getUser(sender.getPlayer());
if (user.isMuted()) {
throw new Exception(tl("voiceSilenced"));
throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ?
tl("muteReason", user.getMuteReason()) : ""));
}
message = FormatUtil.formatMessage(user, "essentials.msg", message);

View file

@ -117,7 +117,8 @@ public class Commandseen extends EssentialsCommand {
sender.sendMessage(tl("whoisJail", (user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true"))));
}
if (user.isMuted()) {
sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))));
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"))) {

View file

@ -56,8 +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"))));
sender.sendMessage(tl("whoisMuted", (user.isMuted() ? user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false"))));
throw new Exception(tl("voiceSilenced") + (user.hasMuteReason() ?
tl("muteReason", user.getMuteReason()) : ""));
}
@Override

View file

@ -601,3 +601,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -590,3 +590,4 @@ createKitFailed=\u00a74Beim Erstellen des Kits ist ein Fehler aufgetreten {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Erstelltes Kit: \u00a7f{0}\n\u00a76Verz\u00F6gerung: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Kopiere Inhalte aus dem oben stehenden Link in deine config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -592,3 +592,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Ocurrio un error durante la creacion del kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Kit creado: \u00a7f{0}\n\u00a76Tiempo de espera: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copia el contenido del link de arriba en tu archivo config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -600,3 +600,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -599,3 +599,4 @@ createKitFailed=\u00a74Si \u00E8 verificato un errore creando il kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Kit Creato: \u00a7f{0}\n\u00a76Attesa: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copia i contenuti nel link sopra nella tua config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -591,3 +591,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Wyst\u0105pi\u0142 b\u0142\u0105d podczas tworzenia zesta
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Stworzono zestaw: \u00a7f{0}\n\u00a76Czas odnowienia: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Skopiuj zawarto\u015B\u0107 linku do config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -584,3 +584,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -584,3 +584,4 @@ createKitFailed=\u00a74Um erro ocorreu ao criar o kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Kit criado: \u00a7f{0}\n\u00a76Tempo: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copie o conte\u00FAdo do link acima para a config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -599,3 +599,4 @@ createKitFailed=\u00a74\u521b\u5efa\u793c\u5305\u51fa\u9519 {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76\u521b\u5efa\u793c\u5305: \u00a7f{0}\n\u00a76\u4f7f\u7528\u6b21\u6570: \u00a7f{1}\n\u00a76\u4fe1\u606f: \u00a7f{2}\n\u00a76\u590d\u5236\u4e0b\u9762\u7684\u4fe1\u606f\u5230config\u91cc\u9762.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -587,3 +587,4 @@ createKitFailed=\u00a74Error occurred whilst creating kit {0}.
createKitSeparator=\u00a7m-----------------------
createKitSuccess=\u00a76Created Kit: \u00a7f{0}\n\u00a76Delay: \u00a7f{1}\n\u00a76Link: \u00a7f{2}\n\u00a76Copy contents in the link above into your config.yml.
whoisUuid=\u00a76 - UUID\:\u00a7r {0}
muteReason=\u00a76Reason: \u00a7c{0}

View file

@ -265,7 +265,7 @@ commands:
aliases: [emsgtoggle]
mute:
description: Mutes or unmutes a player.
usage: /<command> <player> [datediff]
usage: /<command> <player> [datediff] [reason]
aliases: [emute,silence,esilence]
near:
description: Lists the players near by or around a player.