2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.banning.FBan;
|
|
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import net.pravian.aero.util.Ips;
|
2014-11-29 19:16:00 +00:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
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;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_gtfo extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2013-07-29 18:44:18 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2014-04-14 19:11:41 +00:00
|
|
|
String reason = null;
|
2013-07-29 18:44:18 +00:00
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2014-04-14 19:11:41 +00:00
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
2013-07-29 18:44:18 +00:00
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Undo WorldEdits
|
2014-04-15 13:43:07 +00:00
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
plugin.web.undo(player, 15);
|
2014-04-15 13:43:07 +00:00
|
|
|
}
|
|
|
|
catch (NoClassDefFoundError ex)
|
|
|
|
{
|
|
|
|
}
|
2013-07-02 18:31:22 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Rollback
|
|
|
|
plugin.rb.rollback(player.getName());
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Deop
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setOp(false);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Gamemode suvival
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Clear inventory
|
2013-08-14 14:01:42 +00:00
|
|
|
player.getInventory().clear();
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Strike with lightning
|
2013-08-14 14:55:37 +00:00
|
|
|
final Location targetPos = player.getLocation();
|
2012-11-24 01:22:52 +00:00
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
{
|
|
|
|
for (int z = -1; z <= 1; z++)
|
2011-10-24 02:43:52 +00:00
|
|
|
{
|
2013-08-14 14:55:37 +00:00
|
|
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
|
|
|
targetPos.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
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
|
2014-08-02 15:14:37 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Broadcast
|
2014-08-25 12:07:47 +00:00
|
|
|
final StringBuilder bcast = new StringBuilder()
|
|
|
|
.append(ChatColor.RED)
|
|
|
|
.append("Banning: ")
|
|
|
|
.append(player.getName())
|
|
|
|
.append(", IP: ")
|
|
|
|
.append(ip);
|
2014-08-02 15:14:37 +00:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2014-08-18 20:48:52 +00:00
|
|
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
2014-08-02 15:14:37 +00:00
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(bcast.toString());
|
2014-08-25 12:07:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Ban player
|
|
|
|
plugin.bm.addBan(FBan.forPlayerFuzzy(player, sender, null, reason));
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
// Kick player
|
|
|
|
player.kickPlayer(ChatColor.RED + "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
|
|
|
}
|
|
|
|
}
|