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; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; 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 = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true) @CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/ ") public class Command_gtfo extends FreedomCommand { @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length == 0) { return false; } final Player player = getPlayer(args[0]); if (player == null) { playerMsg(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); // Undo WorldEdits try { plugin.web.undo(player, 15); } catch (NoClassDefFoundError ex) { } // Rollback plugin.rb.rollback(player.getName()); // 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().strikeLightning(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(reason); } FUtil.bcastMsg(bcast.toString()); // Ban player plugin.bm.addBan(FBan.forPlayerFuzzy(player, sender, null, reason)); // Kick player player.kickPlayer(ChatColor.RED + "GTFO"); return true; } }