2022-03-20 12:35:43 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.commands;
|
|
|
|
|
|
|
|
import me.StevenLawson.TotalFreedomMod.ban.Ban;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.bridge.WorldEditBridge;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
|
2014-11-29 19:16:00 +00:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2011-10-18 20:37:00 -04:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-03-19 18:05:20 -04:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2022-03-20 12:35:43 +00:00
|
|
|
public class Command_gtfo extends FreedomCommand {
|
2011-10-18 20:37:00 -04:00
|
|
|
@Override
|
2022-03-20 12:35:43 +00:00
|
|
|
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
|
|
|
if (args.length == 0) {
|
2011-10-18 20:37:00 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-26 13:55:24 +02:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 23:03:34 +02:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
if (player == null) {
|
2022-03-23 20:48:41 -03:00
|
|
|
playerMsg(sender, FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
2012-11-23 20:22:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-16 13:41:41 -04:00
|
|
|
|
2014-04-14 21:11:41 +02:00
|
|
|
String reason = null;
|
2013-07-29 14:44:18 -04:00
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2014-04-14 21:11:41 +02:00
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
2013-07-29 14:44:18 -04:00
|
|
|
}
|
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
Utilities.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
2012-09-16 13:41:41 -04:00
|
|
|
|
2013-07-03 16:11:57 -04:00
|
|
|
// Undo WorldEdits:
|
2014-04-15 15:43:07 +02:00
|
|
|
try
|
|
|
|
{
|
2022-03-20 12:35:43 +00:00
|
|
|
WorldEditBridge.undo(player, 15);
|
2014-04-15 15:43:07 +02:00
|
|
|
}
|
|
|
|
catch (NoClassDefFoundError ex)
|
|
|
|
{
|
|
|
|
}
|
2013-07-02 14:31:22 -04:00
|
|
|
|
2013-07-03 16:11:57 -04:00
|
|
|
// rollback
|
2022-03-20 12:35:43 +00:00
|
|
|
RollbackManager.rollback(player.getName());
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
// deop
|
2013-08-14 16:01:42 +02:00
|
|
|
player.setOp(false);
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
// set gamemode to survival:
|
2013-08-14 16:01:42 +02:00
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
// clear inventory:
|
2013-08-14 16:01:42 +02:00
|
|
|
player.getInventory().clear();
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
// strike with lightning effect:
|
2013-08-14 16:55:37 +02:00
|
|
|
final Location targetPos = player.getLocation();
|
2012-11-23 20:22:52 -05:00
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
{
|
|
|
|
for (int z = -1; z <= 1; z++)
|
2011-10-23 22:43:52 -04:00
|
|
|
{
|
2013-08-14 16:55:37 +02:00
|
|
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
|
|
|
targetPos.getWorld().strikeLightning(strike_pos);
|
2011-10-23 22:43:52 -04:00
|
|
|
}
|
2011-10-18 20:37:00 -04:00
|
|
|
}
|
2012-11-23 20:22:52 -05:00
|
|
|
|
|
|
|
// ban IP address:
|
2022-03-20 12:35:43 +00:00
|
|
|
String ip = Utilities.getFuzzyIp(player.getAddress().getAddress().getHostAddress());
|
2014-08-02 11:14:37 -04:00
|
|
|
|
2014-08-25 14:07:47 +02:00
|
|
|
final StringBuilder bcast = new StringBuilder()
|
|
|
|
.append(ChatColor.RED)
|
|
|
|
.append("Banning: ")
|
|
|
|
.append(player.getName())
|
|
|
|
.append(", IP: ")
|
|
|
|
.append(ip);
|
|
|
|
|
2014-08-02 11:14:37 -04:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2014-08-18 16:48:52 -04:00
|
|
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
2014-08-02 11:14:37 -04:00
|
|
|
}
|
2014-08-25 14:07:47 +02:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
Utilities.bcastMsg(bcast.toString());
|
2014-04-14 21:11:41 +02:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
BanManager.addIpBan(new Ban(ip, player.getName(), sender.getName(), null, reason));
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
// ban username:
|
2022-03-20 12:35:43 +00:00
|
|
|
BanManager.addUuidBan(new Ban(UUIDManager.getUniqueId(player), player.getName(), sender.getName(), null, reason));
|
2012-11-23 20:22:52 -05:00
|
|
|
|
|
|
|
// kick Player:
|
2014-04-14 21:11:41 +02:00
|
|
|
player.kickPlayer(ChatColor.RED + "GTFO" + (reason != null ? ("\nReason: " + ChatColor.YELLOW + reason) : ""));
|
2011-10-18 20:37:00 -04:00
|
|
|
|
2012-11-23 20:22:52 -05:00
|
|
|
return true;
|
2011-10-18 20:37:00 -04:00
|
|
|
}
|
|
|
|
}
|