Skip to content

Commit

Permalink
(+) "automatic" text for LibertyBans & BetterJails
Browse files Browse the repository at this point in the history
  • Loading branch information
anvorgesa committed Jul 5, 2022
1 parent c2640ef commit 88b10fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import eu.mcdb.ban_announcer.PunishmentAction.Type;
import eu.mcdb.ban_announcer.bukkit.BanAnnouncerBukkit;
import eu.mcdb.ban_announcer.bukkit.BukkitPunishmentListener;
import eu.mcdb.ban_announcer.utils.TimeUtils;

public class BetterJailsListener extends BukkitPunishmentListener {

Expand Down Expand Up @@ -45,9 +46,16 @@ private void handle(Prisoner prisoner, boolean released) {

PunishmentAction punishment = new PunishmentAction(released ? Type.UNJAIL : Type.JAIL);

long durationMillis = prisoner.jailedUntil().toEpochMilli() - System.currentTimeMillis();

punishment.setJail(jail);
punishment.setPlayer(player);
punishment.setOperator(operator);
punishment.setDuration(TimeUtils.parseMillis(durationMillis));

if (released && durationMillis <= 0) {
punishment.setOperator(getPlugin().getAnnouncer().getConfig().getExpiredOperatorName());
}

handlePunishment(punishment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,23 @@ private void handle(Operator operator, Punishment pun, boolean isRevoked) {
: getOperatorName(operator);

punishment.setId(Long.toString(pun.getIdentifier()));
punishment.setOperator(operatorName);
punishment.setPlayer(getVictimName(pun.getVictim()));
punishment.setReason(pun.getReason());
punishment.setPermanent(pun.isPermanent());

if (punishment.isPermanent()) {
punishment.setDuration("permanent");
if (isRevoked && pun.isExpired()) {
punishment.setOperator(getAnnouncer().getConfig().getExpiredOperatorName());
} else {
punishment.setDuration(libertyBans.getFormatter().formatDuration(Duration.ofSeconds(pun.getEndDateSeconds() - pun.getStartDateSeconds())));
punishment.setOperator(operatorName);
punishment.setReason(pun.getReason());
punishment.setPermanent(pun.isPermanent());

if (punishment.isPermanent()) {
punishment.setDuration("permanent");
} else {
punishment.setDuration(libertyBans.getFormatter().formatDuration(Duration.ofSeconds(pun.getEndDateSeconds() - pun.getStartDateSeconds())));
}
}

punishment.setPlayer(getVictimName(pun.getVictim()));

switch (pun.getType()) {
case BAN:
boolean isBanIP = pun.getVictim().getType() == VictimType.ADDRESS;
Expand Down

0 comments on commit 88b10fd

Please sign in to comment.