Merge branch 'development' into FS-24-Round-2

This commit is contained in:
Video 2021-06-17 05:25:42 -06:00 committed by GitHub
commit 5b6d8b01a4
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,15 +56,16 @@ 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
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason); {
String adminNotice = ChatColor.RED + String adminNotice = ChatColor.RED +
sender.getName() + sender.getName() +
" - " + " - " +
@ -71,7 +75,9 @@ public class Command_warn extends FreedomCommand
ChatColor.YELLOW + ChatColor.YELLOW +
warnReason; warnReason;
plugin.al.messageAllAdmins(adminNotice); plugin.al.messageAllAdmins(adminNotice);
plugin.pl.getPlayer(player).incrementWarnings();
msg("You have successfully warned " + player.getName() + ".");
}
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();
if (!quiet)
{
p.getWorld().strikeLightning(p.getLocation()); 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
} }