mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-06 22:13:05 +00:00
Punishment logging!
This commit is contained in:
@ -1,9 +1,14 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -14,7 +19,7 @@ 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> [reason] [-nrb]")
|
||||
@CommandParameters(description = "Bans a player", usage = "/<command> <username> [reason] [-nrb]")
|
||||
public class Command_gtfo extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -26,12 +31,51 @@ public class Command_gtfo extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
return true;
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
@ -52,78 +96,68 @@ public class Command_gtfo extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
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 (!cancelRollback)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("CoreProtect"))
|
||||
if (!plugin.cpb.isEnabled())
|
||||
{
|
||||
// Undo WorldEdits
|
||||
try
|
||||
{
|
||||
plugin.web.undo(player, 15);
|
||||
}
|
||||
catch (NoClassDefFoundError ex)
|
||||
catch (NoClassDefFoundError | NullPointerException ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Rollback
|
||||
plugin.rb.rollback(player.getName());
|
||||
plugin.rb.rollback(username);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.cpb.rollback(player.getName());
|
||||
plugin.cpb.rollback(username);
|
||||
}
|
||||
}
|
||||
|
||||
// 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++)
|
||||
if (player != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
}
|
||||
|
||||
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
// Broadcast
|
||||
final StringBuilder bcast = new StringBuilder()
|
||||
.append(ChatColor.RED)
|
||||
.append(sender.getName())
|
||||
.append(" - Banning ")
|
||||
.append(player.getName())
|
||||
.append(", IP: ")
|
||||
.append(ip);
|
||||
.append(" - ")
|
||||
.append("Banning: ")
|
||||
.append(username)
|
||||
.append(", IPs: ")
|
||||
.append(StringUtils.join(ips, ", "));
|
||||
if (reason != null)
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.colorize(reason));
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
FUtil.bcastMsg(bcast.toString());
|
||||
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayerFuzzy(player, sender, null, reason);
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
|
||||
// Kick player
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
}
|
||||
|
||||
// Log ban
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user