Only broadcast off record punishments to local server

This commit is contained in:
Ashcon Partovi 2017-08-09 09:50:27 -07:00 committed by GitHub
parent 9ea38d8cdb
commit 6ccd95cb04
1 changed files with 11 additions and 2 deletions

View File

@ -105,7 +105,9 @@ public class PunishmentEnforcer implements Enableable, MessageListener {
break;
}
punishmentService.update(punishment._id(), (PunishmentDoc.Enforce) () -> true);
if(!punishment.off_record()) {
punishmentService.update(punishment._id(), (PunishmentDoc.Enforce) () -> true);
}
}
private void announce(Punishment punishment) {
@ -121,7 +123,7 @@ public class PunishmentEnforcer implements Enableable, MessageListener {
public boolean viewable(CommandSender sender, Punishment punishment, boolean announced) {
if(viewByIdentity(sender, punishment)) {
if(announced) {
return viewByType(sender, punishment) && viewBySetting(sender, punishment) && viewByIdentity(sender, punishment);
return viewByType(sender, punishment) && viewBySetting(sender, punishment) && viewByIdentity(sender, punishment) && viewByRecord(sender, punishment);
} else {
return viewByLookup(sender, punishment);
}
@ -144,6 +146,13 @@ public class PunishmentEnforcer implements Enableable, MessageListener {
return false;
}
}
private boolean viewByRecord(CommandSender sender, Punishment punishment) {
if(punishment.off_record()) {
return localServer._id().equals(punishment.server_id());
}
return true;
}
private boolean viewByType(CommandSender sender, Punishment punishment) {
switch(punishment.type()) {