mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-10-31 21:47:10 +00:00
Merge pull request #136 from AtlasMediaGroup/multiple-birds-one-stone
Multiple fixes, one commit
This commit is contained in:
commit
aebe1acec2
6
pom.xml
6
pom.xml
@ -132,12 +132,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.speedxx</groupId>
|
||||
<artifactId>Mojangson</artifactId>
|
||||
<version>1957eef8d6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
|
@ -1,17 +1,16 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||
import com.google.common.collect.Multimap;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R3.NBTTagList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -20,6 +19,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class MovementValidator extends FreedomService
|
||||
{
|
||||
@ -133,55 +133,49 @@ public class MovementValidator extends FreedomService
|
||||
|
||||
private Boolean exploitItem(ItemStack item)
|
||||
{
|
||||
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
MojangsonCompound compound = new MojangsonCompound();
|
||||
boolean foundNegative = false;
|
||||
boolean foundPositive = false;
|
||||
try
|
||||
if (item == null)
|
||||
{
|
||||
String mod = modifiers.toString();
|
||||
String fancy = ("{" + (mod.substring(1, mod.length() - 1).replace("{", "").replace("}", "")) + "}");
|
||||
compound.read(fancy);
|
||||
for (String key : compound.keySet())
|
||||
{
|
||||
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
List<MojangsonValue> values = compound.get(key);
|
||||
for (MojangsonValue<?> val : values)
|
||||
{
|
||||
if (val.getValue().toString().equals("Infinityd"))
|
||||
{
|
||||
foundPositive = true;
|
||||
}
|
||||
if (val.getValue().toString().equals("-Infinityd"))
|
||||
{
|
||||
foundNegative = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MojangsonParseException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return foundNegative && foundPositive;
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null)
|
||||
{
|
||||
Multimap<Attribute, AttributeModifier> attributes = meta.getAttributeModifiers();
|
||||
if (attributes != null)
|
||||
{
|
||||
Map<Attribute, Collection<AttributeModifier>> attrMap = attributes.asMap();
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R3.ItemStack stack)
|
||||
// For every attribute...
|
||||
for (Attribute attr : attributes.keySet())
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
// Default values
|
||||
boolean posInf = false;
|
||||
boolean negInf = false;
|
||||
|
||||
// For every AttributeModifier...
|
||||
for (AttributeModifier modifier : attrMap.get(attr))
|
||||
{
|
||||
stack.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
|
||||
if (attr == null)
|
||||
// Are they ∞ or -∞?
|
||||
if (modifier.getAmount() == Double.POSITIVE_INFINITY)
|
||||
{
|
||||
stack.getTag().set("AttributeModifiers", new NBTTagList());
|
||||
posInf = true;
|
||||
}
|
||||
return stack.getTag().getList("AttributeModifiers", 10);
|
||||
else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
|
||||
{
|
||||
negInf = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Are both values set as true?
|
||||
if (posInf && negInf)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -60,28 +60,39 @@ public class Command_ban extends FreedomCommand
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
final String ip;
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
// Gets the IP using Essentials data if available
|
||||
if (plugin.esb.isEnabled() && plugin.esb.getEssentialsUser(args[0]) != null)
|
||||
{
|
||||
User essUser = plugin.esb.getEssentialsUser(args[0]);
|
||||
//
|
||||
username = essUser.getName();
|
||||
ip = essUser.getLastLoginAddress();
|
||||
}
|
||||
// Last resort - Getting the first result from the username itself
|
||||
else
|
||||
{
|
||||
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.");
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = entry.getName();
|
||||
ip = entry.getIps().get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
username = player.getName();
|
||||
//ips.addAll(entry.getIps());/
|
||||
ips.add(FUtil.getIp(player));
|
||||
ip = FUtil.getIp(player);
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
@ -126,7 +137,6 @@ public class Command_ban extends FreedomCommand
|
||||
|
||||
// Ban player
|
||||
Ban ban;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ban = Ban.forPlayer(player, sender, null, reason);
|
||||
@ -135,12 +145,8 @@ public class Command_ban extends FreedomCommand
|
||||
{
|
||||
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||
}
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||
}
|
||||
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
|
||||
@ -154,7 +160,7 @@ public class Command_ban extends FreedomCommand
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + ip);
|
||||
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||
}
|
||||
|
||||
@ -172,7 +178,7 @@ public class Command_ban extends FreedomCommand
|
||||
}
|
||||
|
||||
// Log ban
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||
plugin.pul.logPunishment(new Punishment(username, ip, sender.getName(), PunishmentType.BAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -43,7 +42,7 @@ public class Command_doom extends FreedomCommand
|
||||
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||
|
||||
final String ip = Objects.requireNonNull(player.getAddress()).getAddress().getHostAddress().trim();
|
||||
final String ip = FUtil.getIp(player);
|
||||
|
||||
// Remove from admin
|
||||
Admin admin = getAdmin(player);
|
||||
@ -76,10 +75,7 @@ public class Command_doom extends FreedomCommand
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayer(player, sender);
|
||||
ban.setReason((reason == null ? "FUCKOFF" : reason));
|
||||
for (String playerIp : plugin.pl.getData(player).getIps())
|
||||
{
|
||||
ban.addIp(playerIp);
|
||||
}
|
||||
ban.addIp(ip);
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
// Set gamemode to survival
|
||||
|
@ -1,143 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> [-q] <username> [reason]", aliases = "noob")
|
||||
public class Command_tban extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||
if (quiet)
|
||||
{
|
||||
args = org.apache.commons.lang3.ArrayUtils.subarray(args, 1, args.length);
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final String username;
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry;
|
||||
if (player == null)
|
||||
{
|
||||
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.getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
}
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
|
||||
String reason = null;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
}
|
||||
|
||||
StringBuilder kick = new StringBuilder()
|
||||
.append(ChatColor.RED)
|
||||
.append("You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
|
||||
if (!quiet)
|
||||
{
|
||||
// Strike with lightning
|
||||
if (player != null)
|
||||
{
|
||||
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);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
|
||||
if (reason != null)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Tempbanning " + player.getName() + " for 5 minutes - Reason: " + reason, true);
|
||||
kick.append("\n")
|
||||
.append(ChatColor.RED)
|
||||
.append("Reason: ")
|
||||
.append(ChatColor.GOLD)
|
||||
.append(reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Tempbanning " + player.getName() + " for 5 minutes", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
if (reason != null)
|
||||
{
|
||||
msg("Quietly temporarily banned " + player.getName() + " for 5 minutes.");
|
||||
kick.append("\n")
|
||||
.append(ChatColor.RED)
|
||||
.append("Reason: ")
|
||||
.append(ChatColor.GOLD)
|
||||
.append(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ban player
|
||||
Ban ban = Ban.forPlayerName(username, sender, FUtil.parseDateOffset("5m"), reason);
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
// Kick player
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(kick.toString());
|
||||
}
|
||||
|
||||
// Log ban
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -21,7 +21,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [-q] <username> [duration] [reason]")
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [-q] <username> [duration] [reason]", aliases = "tban,noob")
|
||||
public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -47,49 +47,72 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
final String ip;
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry;
|
||||
PlayerData entry;
|
||||
if (player == null)
|
||||
{
|
||||
// Gets the IP using Essentials data if available
|
||||
if (plugin.esb.isEnabled() && plugin.esb.getEssentialsUser(args[0]) != null)
|
||||
{
|
||||
User essUser = plugin.esb.getEssentialsUser(args[0]);
|
||||
//
|
||||
username = essUser.getName();
|
||||
ip = essUser.getLastLoginAddress();
|
||||
}
|
||||
// Last resort - Getting the first result from the username itself
|
||||
else
|
||||
{
|
||||
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.");
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = plugin.pl.getData(player);
|
||||
username = entry.getName();
|
||||
ip = entry.getIps().get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
username = player.getName();
|
||||
ips.add(FUtil.getIp(player));
|
||||
ip = FUtil.getIp(player);
|
||||
}
|
||||
|
||||
final StringBuilder message = new StringBuilder("Temporarily banned " + username);
|
||||
|
||||
Date expires = FUtil.parseDateOffset("30m");
|
||||
// Default expiration date is 5 minutes
|
||||
Date expires = FUtil.parseDateOffset("5m");
|
||||
|
||||
// Parses what comes after as a duration
|
||||
if (args.length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
expires = FUtil.parseDateOffset(args[1]);
|
||||
}
|
||||
catch (NumberFormatException error)
|
||||
{
|
||||
msg("Invalid duration: " + args[1], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
message.append(" until ").append(date_format.format(expires));
|
||||
|
||||
// If a reason appears to exist, set it.
|
||||
String reason = null;
|
||||
if (args.length >= 2)
|
||||
if (args.length > 2)
|
||||
{
|
||||
Date parsed_offset = FUtil.parseDateOffset(args[1]);
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, parsed_offset == null ? 1 : 2, args.length), " ") + " (" + sender.getName() + ")";
|
||||
if (parsed_offset != null)
|
||||
{
|
||||
expires = parsed_offset;
|
||||
}
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ") + " (" + sender.getName() + ")";
|
||||
message.append(", Reason: \"").append(reason).append("\"");
|
||||
}
|
||||
|
||||
Ban ban;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ban = Ban.forPlayer(player, sender, expires, reason);
|
||||
@ -98,11 +121,8 @@ public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
ban = Ban.forPlayerName(username, sender, expires, reason);
|
||||
}
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
}
|
||||
|
||||
plugin.bm.addBan(ban);
|
||||
|
||||
if (!quiet)
|
||||
@ -119,6 +139,8 @@ public class Command_tempban extends FreedomCommand
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightningEffect(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), message.toString(), true);
|
||||
@ -128,19 +150,15 @@ public class Command_tempban extends FreedomCommand
|
||||
msg("Quietly temporarily banned " + username + ".");
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||
if (FUtil.getIp(p).equals(ip))
|
||||
{
|
||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
plugin.pul.logPunishment(new Punishment(username, ip, sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import com.earth2me.essentials.User;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,20 +19,33 @@ public class Command_unban extends FreedomCommand
|
||||
if (args.length > 0)
|
||||
{
|
||||
String username;
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
String ip;
|
||||
|
||||
// Gets the IP using Essentials data if available
|
||||
if (plugin.esb.isEnabled() && plugin.esb.getEssentialsUser(args[0]) != null)
|
||||
{
|
||||
User essUser = plugin.esb.getEssentialsUser(args[0]);
|
||||
//
|
||||
username = essUser.getName();
|
||||
ip = essUser.getLastLoginAddress();
|
||||
}
|
||||
// Secondary method - using Essentials if available
|
||||
else
|
||||
{
|
||||
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.");
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getName();
|
||||
final List<String> ips = new ArrayList<>(entry.getIps());
|
||||
ip = entry.getIps().get(0);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
|
||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||
plugin.bm.removeBan(plugin.bm.getByIp(ip));
|
||||
msg(username + " has been unbanned along with the IP: " + ip);
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
@ -45,20 +55,6 @@ public class Command_unban extends FreedomCommand
|
||||
msg("Restored edits for: " + username);
|
||||
}
|
||||
}
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
Ban ban = plugin.bm.getByIp(ip);
|
||||
if (ban != null)
|
||||
{
|
||||
plugin.bm.removeBan(ban);
|
||||
}
|
||||
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
||||
if (ban != null)
|
||||
{
|
||||
plugin.bm.removeBan(ban);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user