mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-17 21:06:11 +00:00
tban with incomplete names
This commit is contained in:
parent
a926f72b67
commit
b3f785beb9
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
@ -8,23 +10,25 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.Ips;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <player> [reason]", aliases = "noob")
|
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <username> [reason]", aliases = "noob")
|
||||||
public class Command_tban extends FreedomCommand
|
public class Command_tban extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -33,49 +37,63 @@ public class Command_tban extends FreedomCommand
|
|||||||
final List<String> ips = new ArrayList<>();
|
final List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
|
||||||
|
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getUsername();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
|
|
||||||
String reason;
|
|
||||||
if (args.length > 1)
|
|
||||||
{
|
|
||||||
reason = StringUtils.join(args, " ", 1, args.length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reason = "You have been temporarily banned for 5 minutes.";
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
}
|
username = player.getName();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
|
||||||
// strike with lightning effect:
|
// Strike with lightning
|
||||||
final Location targetPos = player.getLocation();
|
final Location targetPos = player.getLocation();
|
||||||
for (int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
{
|
{
|
||||||
for (int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
{
|
{
|
||||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
targetPos.getWorld().strikeLightning(strike_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
// Kill player
|
||||||
|
player.setHealth(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(sender.getName() + " - Tempbanning: " + player.getName() + " for 5 minutes", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
Ban ban = Ban.forPlayerName(username, sender, FUtil.parseDateOffset("5m"), reason);
|
Ban ban = Ban.forPlayerName(username, sender, FUtil.parseDateOffset("5m"), reason);
|
||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
ban.addIp(ip);
|
ban.addIp(ip);
|
||||||
}
|
}
|
||||||
plugin.bm.addBan(ban);
|
plugin.bm.addBan(ban);
|
||||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
// Kick player
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log ban
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user