2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2013-07-03 20:11:57 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
2012-12-09 03:42:29 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
2011-10-19 00:37:00 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
2013-07-03 20:11:57 +00:00
|
|
|
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;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
Player p;
|
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
p = getPlayer(args[0]);
|
|
|
|
}
|
|
|
|
catch (CantFindPlayerException ex)
|
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg(ex.getMessage(), ChatColor.RED);
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2013-07-03 20:11:57 +00:00
|
|
|
// Undo WorldEdits:
|
|
|
|
TFM_WorldEditBridge.getInstance().undo(p, 15);
|
2013-07-02 18:31:22 +00:00
|
|
|
|
2013-07-03 20:11:57 +00:00
|
|
|
// rollback
|
|
|
|
TFM_RollbackManager.rollback(p);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
// deop
|
|
|
|
p.setOp(false);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
// set gamemode to survival:
|
|
|
|
p.setGameMode(GameMode.SURVIVAL);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
// clear inventory:
|
|
|
|
p.getInventory().clear();
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +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
|
|
|
{
|
2012-11-24 01:22: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
|
|
|
}
|
2012-11-24 01:22:52 +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
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
|
2012-12-09 03:42:29 +00:00
|
|
|
TFM_ServerInterface.banIP(user_ip, null, null, null);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
// ban username:
|
2012-12-09 03:42:29 +00:00
|
|
|
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
|
|
|
// kick Player:
|
|
|
|
p.kickPlayer("GTFO");
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|