mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 20:36:12 +00:00
2443d3eaca
Adds Futil.strictcolorize (that filters Banned colors on smite and gtfo) Adds Actual Server-TFM features Adds Wipewarps adds wipecoreprotectdata adds spectator adds rainbownick adds rainbowtag
120 lines
3.7 KiB
Java
120 lines
3.7 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import net.pravian.aero.util.Ips;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import static org.bukkit.Bukkit.getServer;
|
|
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 = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
|
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
|
|
public class Command_gtfo extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
final Player player = getPlayer(args[0]);
|
|
|
|
if (player == null)
|
|
{
|
|
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
String reason = null;
|
|
if (args.length >= 2)
|
|
{
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
|
}
|
|
|
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
|
|
|
//checks if there is CoreProtect loaded and installed , if not it skips the rollback and uses coreprotect directly
|
|
if (!getServer().getPluginManager().isPluginEnabled("CoreProtect"))
|
|
{
|
|
// Undo WorldEdits
|
|
try
|
|
{
|
|
plugin.web.undo(player, 15);
|
|
}
|
|
catch (NoClassDefFoundError ex)
|
|
{
|
|
}
|
|
|
|
// Rollback
|
|
plugin.rb.rollback(player.getName());
|
|
|
|
}
|
|
|
|
if (getServer().getPluginManager().isPluginEnabled("CoreProtect"))
|
|
{
|
|
try
|
|
{
|
|
server.dispatchCommand(sender, "co rollback t:1d r:#global #silent u:" + player.getName());
|
|
}
|
|
catch (NoClassDefFoundError ex)
|
|
{
|
|
}
|
|
}
|
|
|
|
// Deop
|
|
player.setOp(false);
|
|
|
|
// Gamemode suvival
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
|
|
// Clear inventory
|
|
player.getInventory().clear();
|
|
|
|
// Strike with lightning
|
|
final Location targetPos = player.getLocation();
|
|
for (int x = -1; x <= 1; x++)
|
|
{
|
|
for (int z = -1; z <= 1; z++)
|
|
{
|
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
|
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
|
}
|
|
}
|
|
|
|
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
|
|
|
|
// Broadcast
|
|
final StringBuilder bcast = new StringBuilder()
|
|
.append(ChatColor.RED)
|
|
.append("Banning: ")
|
|
.append(player.getName())
|
|
.append(", IP: ")
|
|
.append(ip);
|
|
if (reason != null)
|
|
{
|
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.StrictColorize(reason));
|
|
}
|
|
FUtil.bcastMsg(bcast.toString());
|
|
|
|
// Ban player
|
|
plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
|
|
|
|
// Kill player
|
|
player.setHealth(0.0);
|
|
|
|
// Kick player
|
|
player.kickPlayer(ChatColor.RED + "GTFO");
|
|
|
|
return true;
|
|
}
|
|
} |