mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-06-10 07:21:45 +00:00
a8a2651fd9
Build has a critical error where sql data is being interpreted incorrectly which is odd considering no sql changes were made.
78 lines
2.9 KiB
Java
78 lines
2.9 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import me.totalfreedom.totalfreedommod.command.handling.*;
|
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@Intercept("warn")
|
|
@CommandPermissions(permission = "warn", source = SourceType.BOTH)
|
|
@CommandParameters(description = "Warns the specified player.", usage = "/<command> [-q] <player> <reason>")
|
|
public class Command_warn extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
boolean quiet = args[0].equalsIgnoreCase("-q");
|
|
if (quiet)
|
|
{
|
|
args = org.apache.commons.lang3.ArrayUtils.subarray(args, 1, args.length);
|
|
|
|
if (args.length < 1)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
Player player = getPlayer(args[0]);
|
|
if (player == null)
|
|
{
|
|
msg(PLAYER_NOT_FOUND);
|
|
return true;
|
|
}
|
|
|
|
if (playerSender == player)
|
|
{
|
|
msgNew("<red>Please, don't try to warn yourself.");
|
|
return true;
|
|
}
|
|
|
|
if (plugin.al.isAdmin(player))
|
|
{
|
|
msgNew("<red>You can't warn other admins!");
|
|
return true;
|
|
}
|
|
|
|
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
|
FUtil.playerTitle(player, "<red>You have been warned.", "<yellow>Reason: <reason>", Placeholder.unparsed("reason", warnReason));
|
|
msgNew("<red>[WARNING] You received a warning from <sender>: <reason>", Placeholder.unparsed("sender", sender.getName()), Placeholder.unparsed("reason", warnReason));
|
|
plugin.pl.getPlayer(player).incrementWarnings(quiet);
|
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
|
|
|
|
if (quiet)
|
|
{
|
|
msgNew("You have successfully warned <player> quietly.", Placeholder.unparsed("player", player.getName()));
|
|
} else
|
|
{
|
|
plugin.cm.messageAllAdmins("<red><sender> - Warning: <player> - Reason: <yellow><reason> ",
|
|
Placeholder.unparsed("sender", sender.getName()),
|
|
Placeholder.unparsed("player", player.getName()),
|
|
Placeholder.unparsed("reason", warnReason));
|
|
|
|
msgNew("You have successfully warned <player>.", Placeholder.unparsed("player", player.getName()));
|
|
}
|
|
return true;
|
|
}
|
|
} |