Merge pull request #39 from AtlasMediaGroup/Elmon11-patch-2

clearinv option in smite (FS-161)
This commit is contained in:
Ryan 2021-04-11 22:15:26 +01:00 committed by GitHub
commit 37762e5470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,21 +15,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]") @CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-c | -q]")
public class Command_smite extends FreedomCommand public class Command_smite extends FreedomCommand
{ {
public static void smite(CommandSender sender, Player player) public static void smite(CommandSender sender, Player player)
{ {
smite(sender, player, null, false); smite(sender, player, null, false, false);
} }
public static void smite(CommandSender sender, Player player, String reason) public static void smite(CommandSender sender, Player player, String reason)
{ {
smite(sender, player, reason, false); smite(sender, player, reason, false, false);
} }
public static void smite(CommandSender sender, Player player, String reason, Boolean silent) public static void smite(CommandSender sender, Player player, String reason, Boolean silent, Boolean clearinv)
{ {
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60); player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
@ -54,7 +54,10 @@ public class Command_smite extends FreedomCommand
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
// Clear inventory // Clear inventory
player.getInventory().clear(); if (clearinv)
{
player.getInventory().clear();
}
// Strike with lightning effect // Strike with lightning effect
final Location targetPos = player.getLocation(); final Location targetPos = player.getLocation();
@ -88,6 +91,7 @@ public class Command_smite extends FreedomCommand
String reason = null; String reason = null;
boolean silent = false; boolean silent = false;
boolean clearinv = false;
if (args.length >= 2) if (args.length >= 2)
{ {
if (args[args.length - 1].equalsIgnoreCase("-q")) if (args[args.length - 1].equalsIgnoreCase("-q"))
@ -102,6 +106,18 @@ public class Command_smite extends FreedomCommand
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
} }
} }
else if (args[args.length - 1].equalsIgnoreCase("-c"))
{
if (args[args.length - 1].equalsIgnoreCase("-c"))
{
clearinv = true;
}
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else else
{ {
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
@ -116,7 +132,7 @@ public class Command_smite extends FreedomCommand
return true; return true;
} }
smite(sender, player, reason, silent); smite(sender, player, reason, silent, clearinv);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason)); plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));