This commit is contained in:
Brianna O'Keefe 2019-03-09 00:30:00 -05:00
parent 1c9e35cccd
commit 11e0d7e631
4 changed files with 12 additions and 10 deletions

View File

@ -91,7 +91,7 @@ public class GUIPunish extends AbstractGUI {
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick"),
"",
plugin.getLocale().getMessage("gui.punish.type.duration.current"),
"&6" + (duration == Long.MAX_VALUE ? plugin.getLocale().getMessage("gui.general.permanent") : Methods.makeReadable(duration)));
"&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent") : Methods.makeReadable(duration)));
}
createButton(34, Material.PAPER, plugin.getLocale().getMessage("gui.punish.type.reason"),
@ -176,13 +176,13 @@ public class GUIPunish extends AbstractGUI {
ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(duration == Long.MAX_VALUE || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
item.setItemMeta(meta);
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
gui.open();
} else {
duration = Long.MAX_VALUE;
duration = -1;
constructGUI();
}
}));

View File

@ -107,15 +107,17 @@ public class GUIPunishments extends AbstractGUI {
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) {
lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.duration"));
lore.add("&7" + Methods.makeReadable(appliedPunishment.getDuration()));
lore.add("&7" + (appliedPunishment.getDuration() != -1 ? Methods.makeReadable(appliedPunishment.getDuration()) : plugin.getLocale().getMessage("gui.general.permanent")));
lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher"));
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
if (activity == Activity.ACTIVE) {
lore.add("");
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining"));
lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining()));
lore.add("");
if (appliedPunishment.getDuration() != -1) {
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining"));
lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining()));
lore.add("");
}
lore.add(plugin.getLocale().getMessage("gui.punishments.click"));
registerClickable(currentSlot, ((player1, inventory1, cursor, slot, type) -> {

View File

@ -42,7 +42,7 @@ public class AppliedPunishment extends Punishment {
}
public void expire() {
this.expiration = System.currentTimeMillis();
this.expiration = -1;
}
public long getTimeRemaining() {

View File

@ -87,7 +87,7 @@ public class PlayerPunishData {
private void audit(boolean forced, PunishmentType punishmentType) {
List<AppliedPunishment> expired = activePunishments.stream().filter(appliedPunishment ->
(appliedPunishment.getDuration() != -1 || forced)
(appliedPunishment.getDuration() != -1 || forced || appliedPunishment.getExpiration() == -1)
&& (appliedPunishment.getPunishmentType() == punishmentType || punishmentType == PunishmentType.ALL)
&& appliedPunishment.getExpiration() <= System.currentTimeMillis()).collect(Collectors.toList());
@ -102,6 +102,6 @@ public class PlayerPunishData {
appliedPunishment.expire();
toAudit.add(appliedPunishment);
});
toAudit.stream().forEach(appliedPunishment -> this.audit(true, type));
toAudit.forEach(appliedPunishment -> this.audit(true, type));
}
}