TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java

84 lines
2.6 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
2011-10-19 00:37:00 +00:00
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
2011-10-19 00:37:00 +00: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;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
2011-10-19 00:37:00 +00:00
public class Command_gtfo extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
Player p;
try
2011-10-19 00:37:00 +00:00
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits:
TFM_WorldEditBridge.getInstance().undo(p, 15);
2013-07-02 18:31:22 +00:00
// rollback
TFM_RollbackManager.rollback(p);
2011-10-19 00:37:00 +00:00
// deop
p.setOp(false);
2011-10-19 00:37:00 +00:00
// set gamemode to survival:
p.setGameMode(GameMode.SURVIVAL);
2011-10-19 00:37:00 +00:00
// clear inventory:
p.getInventory().clear();
2011-10-19 00:37:00 +00:00
// strike with lightning effect:
final Location target_pos = p.getLocation();
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
2011-10-24 02:43:52 +00:00
{
final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
target_pos.getWorld().strikeLightning(strike_pos);
2011-10-24 02:43:52 +00:00
}
2011-10-19 00:37:00 +00:00
}
// ban IP address:
String user_ip = p.getAddress().getAddress().getHostAddress();
String[] ip_parts = user_ip.split("\\.");
if (ip_parts.length == 4)
2011-10-19 00:37:00 +00:00
{
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
2011-10-19 00:37:00 +00:00
}
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
TFM_ServerInterface.banIP(user_ip, null, null, null);
2011-10-19 00:37:00 +00:00
// ban username:
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
// kick Player:
p.kickPlayer("GTFO");
2011-10-19 00:37:00 +00:00
return true;
2011-10-19 00:37:00 +00:00
}
}