From 3027e2a18cc8316fc7ce574c932ca81a436bbd29 Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 16 Jun 2021 17:29:57 -0600 Subject: [PATCH] Two fixes, one commit To kill two birds with one stone, I've done two fixes in this commit. - Fixes issue that caused quiet warns to behave improperly (e.g. the warnings wouldn't increment if quiet) - Added WARN to the PunishmentType list. --- .../totalfreedommod/command/Command_warn.java | 34 +++++++++++-------- .../totalfreedommod/player/FPlayer.java | 9 +++-- .../punishments/PunishmentType.java | 3 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java index 827a5b04..17be800f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java @@ -1,6 +1,9 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.punishments.Punishment; +import me.totalfreedom.totalfreedommod.punishments.PunishmentType; import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; @@ -53,25 +56,28 @@ public class Command_warn extends FreedomCommand String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60); - msg(ChatColor.GREEN + "You have successfully warned " + player.getName()); + msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason); + plugin.pl.getPlayer(player).incrementWarnings(quiet); + plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason)); if (quiet) { - msg("Warned " + player.getName() + " quietly"); - return true; + msg("You have successfully warned " + player.getName() + " quietly."); } + else + { + String adminNotice = ChatColor.RED + + sender.getName() + + " - " + + "Warning: " + + player.getName() + + " - Reason: " + + ChatColor.YELLOW + + warnReason; + plugin.al.messageAllAdmins(adminNotice); - msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason); - String adminNotice = ChatColor.RED + - sender.getName() + - " - " + - "Warning: " + - player.getName() + - " - Reason: " + - ChatColor.YELLOW + - warnReason; - plugin.al.messageAllAdmins(adminNotice); - plugin.pl.getPlayer(player).incrementWarnings(); + msg("You have successfully warned " + player.getName() + "."); + } return true; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java index 4e1febc4..b0ea8bc1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java @@ -429,14 +429,19 @@ public class FPlayer this.warningCount = warningCount; } - public void incrementWarnings() + public void incrementWarnings(boolean quiet) { this.warningCount++; if (this.warningCount % 2 == 0) { Player p = getPlayer(); - p.getWorld().strikeLightning(p.getLocation()); + + if (!quiet) + { + p.getWorld().strikeLightning(p.getLocation()); + } + FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString()); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java b/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java index 705fd928..e7b82e85 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java @@ -7,5 +7,6 @@ public enum PunishmentType KICK, TEMPBAN, BAN, - DOOM + DOOM, + WARN }