Merge pull request #78 from AtlasMediaGroup/FS-207

Two fixes, one commit (FS-207)
This commit is contained in:
Video 2021-06-17 04:58:26 -06:00 committed by GitHub
commit 96bc83cead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 17 deletions

View File

@ -1,6 +1,9 @@
package me.totalfreedom.totalfreedommod.command; 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.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -53,25 +56,28 @@ public class Command_warn extends FreedomCommand
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); 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); 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) if (quiet)
{ {
msg("Warned " + player.getName() + " quietly"); msg("You have successfully warned " + player.getName() + " quietly.");
return true;
} }
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); msg("You have successfully warned " + player.getName() + ".");
String adminNotice = ChatColor.RED + }
sender.getName() +
" - " +
"Warning: " +
player.getName() +
" - Reason: " +
ChatColor.YELLOW +
warnReason;
plugin.al.messageAllAdmins(adminNotice);
plugin.pl.getPlayer(player).incrementWarnings();
return true; return true;
} }
} }

View File

@ -429,14 +429,19 @@ public class FPlayer
this.warningCount = warningCount; this.warningCount = warningCount;
} }
public void incrementWarnings() public void incrementWarnings(boolean quiet)
{ {
this.warningCount++; this.warningCount++;
if (this.warningCount % 2 == 0) if (this.warningCount % 2 == 0)
{ {
Player p = getPlayer(); 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()); 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());
} }
} }

View File

@ -7,5 +7,6 @@ public enum PunishmentType
KICK, KICK,
TEMPBAN, TEMPBAN,
BAN, BAN,
DOOM DOOM,
WARN
} }