mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
Fixed duplicate ban entries
Bans are equal when: a) The ban-type matches b) The ban-subject matches Small changes
This commit is contained in:
parent
3c6e706c98
commit
15650b84cf
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Mon Aug 25 14:06:59 CEST 2014
|
#Tue Aug 26 18:22:59 CEST 2014
|
||||||
build.number=924
|
build.number=934
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
public class Command_cake extends TFM_Command
|
public class Command_cake extends TFM_Command
|
||||||
{
|
{
|
||||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,15 +68,16 @@ public class Command_glist extends TFM_Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
username = player.getName();
|
username = player.getName();
|
||||||
ips.add(player.getAddress().getAddress().getHostAddress());
|
final TFM_Player entry = TFM_PlayerList.getEntry(TFM_Util.getUniqueId(player));
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
|
|
||||||
String mode = args[0].toLowerCase();
|
String mode = args[0].toLowerCase();
|
||||||
if (mode.equalsIgnoreCase("ban"))
|
if (mode.equalsIgnoreCase("ban"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
|
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
|
|
||||||
Player target = getPlayer(username, true);
|
final Player target = getPlayer(username, true);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUniqueId(target), target.getName()));
|
TFM_BanManager.addUuidBan(new TFM_Ban(TFM_Util.getUniqueId(target), target.getName()));
|
||||||
@ -90,13 +91,12 @@ public class Command_glist extends TFM_Command
|
|||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, username));
|
TFM_BanManager.addIpBan(new TFM_Ban(ip, username));
|
||||||
String[] ip_address_parts = ip.split("\\.");
|
TFM_BanManager.addIpBan(new TFM_Ban(TFM_Util.getFuzzyIp(ip), username));
|
||||||
TFM_BanManager.addIpBan(new TFM_Ban(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", username));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode.equalsIgnoreCase("unban") || mode.equalsIgnoreCase("pardon"))
|
else if (mode.equalsIgnoreCase("unban"))
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
|
TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
TFM_BanManager.unbanUuid(TFM_Util.getUniqueId(username));
|
TFM_BanManager.unbanUuid(TFM_Util.getUniqueId(username));
|
||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,6 @@ public class Command_nickclean extends TFM_Command
|
|||||||
ChatColor.UNDERLINE,
|
ChatColor.UNDERLINE,
|
||||||
ChatColor.BLACK
|
ChatColor.BLACK
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Pattern REGEX = Pattern.compile("\\u00A7[" + StringUtils.join(BLOCKED, "") + "]");
|
private static final Pattern REGEX = Pattern.compile("\\u00A7[" + StringUtils.join(BLOCKED, "") + "]");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,14 +112,13 @@ public class Command_tag extends TFM_Command
|
|||||||
final String inputTag = StringUtils.join(args, " ", 1, args.length);
|
final String inputTag = StringUtils.join(args, " ", 1, args.length);
|
||||||
final String outputTag = TFM_Util.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag),
|
final String outputTag = TFM_Util.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag),
|
||||||
new String[]
|
new String[]
|
||||||
{
|
{
|
||||||
"" + ChatColor.COLOR_CHAR, "&k"
|
"" + ChatColor.COLOR_CHAR, "&k"
|
||||||
},
|
},
|
||||||
new String[]
|
new String[]
|
||||||
{
|
{
|
||||||
"", ""
|
"", ""
|
||||||
}
|
})) + ChatColor.RESET;
|
||||||
)) + ChatColor.RESET;
|
|
||||||
|
|
||||||
if (!TFM_AdminList.isSuperAdmin(sender))
|
if (!TFM_AdminList.isSuperAdmin(sender))
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@ public abstract class TFM_Command
|
|||||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||||
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||||
|
|
||||||
protected TotalFreedomMod plugin;
|
protected TotalFreedomMod plugin;
|
||||||
protected Server server;
|
protected Server server;
|
||||||
private CommandSender commandSender;
|
private CommandSender commandSender;
|
||||||
|
@ -733,7 +733,8 @@ public class TFM_PlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||||
{
|
{
|
||||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||||
@ -752,7 +753,8 @@ public class TFM_PlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||||
{
|
{
|
||||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||||
@ -774,36 +776,45 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String ip = TFM_Util.getIp(player);
|
final String ip = TFM_Util.getIp(player);
|
||||||
|
final TFM_Player playerEntry;
|
||||||
|
|
||||||
TFM_Log.info("[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true);
|
TFM_Log.info("[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true);
|
||||||
|
|
||||||
|
// Handle PlayerList entry (persistent)
|
||||||
if (TFM_PlayerList.existsEntry(player))
|
if (TFM_PlayerList.existsEntry(player))
|
||||||
{
|
{
|
||||||
final TFM_Player entry = TFM_PlayerList.getEntry(player);
|
playerEntry = TFM_PlayerList.getEntry(player);
|
||||||
entry.setLastLoginUnix(TFM_Util.getUnixTime());
|
playerEntry.setLastLoginUnix(TFM_Util.getUnixTime());
|
||||||
entry.setLastLoginName(player.getName());
|
playerEntry.setLastLoginName(player.getName());
|
||||||
entry.save();
|
playerEntry.addIp(ip);
|
||||||
|
playerEntry.save();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_PlayerList.getEntry(player);
|
playerEntry = TFM_PlayerList.getEntry(player);
|
||||||
TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
|
TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GGenerate PlayerData (non-persistent)
|
||||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||||
playerdata.setSuperadminIdVerified(false);
|
playerdata.setSuperadminIdVerified(false);
|
||||||
|
|
||||||
// Verify strict IP match
|
|
||||||
if (TFM_AdminList.isSuperAdmin(player))
|
if (TFM_AdminList.isSuperAdmin(player))
|
||||||
{
|
{
|
||||||
TFM_BanManager.unbanIp(ip);
|
for (String storedIp : playerEntry.getIps())
|
||||||
TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(ip));
|
{
|
||||||
|
TFM_BanManager.unbanIp(storedIp);
|
||||||
|
TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp));
|
||||||
|
}
|
||||||
|
|
||||||
TFM_BanManager.unbanUuid(TFM_Util.getUniqueId(player));
|
TFM_BanManager.unbanUuid(TFM_Util.getUniqueId(player));
|
||||||
|
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
|
|
||||||
|
// Verify strict IP match
|
||||||
if (!TFM_AdminList.isIdentityMatched(player))
|
if (!TFM_AdminList.isIdentityMatched(player))
|
||||||
{
|
{
|
||||||
playerdata.setSuperadminIdVerified(false);
|
playerdata.setSuperadminIdVerified(false);
|
||||||
|
|
||||||
TFM_Util.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
|
TFM_Util.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -166,4 +166,47 @@ public class TFM_Ban
|
|||||||
{
|
{
|
||||||
return subject + ":" + lastLoginName + ":" + by + ":" + expireUnix + ":" + TFM_Util.decolorize(reason);
|
return subject + ":" + lastLoginName + ":" + by + ":" + expireUnix + ":" + TFM_Util.decolorize(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object)
|
||||||
|
{
|
||||||
|
if (object == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(object instanceof TFM_Ban))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final TFM_Ban ban = (TFM_Ban) object;
|
||||||
|
|
||||||
|
if (toString().equals(ban.toString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getType() != ban.getType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getSubject().equals(ban.getSubject()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
final int prime = 37;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + getType().hashCode();
|
||||||
|
result = prime * result + getSubject().hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +222,11 @@ public class TFM_BanManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uuidBans.contains(ban))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (unbannableUUIDs.contains(UUID.fromString(ban.getSubject())))
|
if (unbannableUUIDs.contains(UUID.fromString(ban.getSubject())))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -248,6 +253,11 @@ public class TFM_BanManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ipBans.contains(ban))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ipBans.add(ban);
|
ipBans.add(ban);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ public class TFM_Heartbeat extends BukkitRunnable
|
|||||||
{
|
{
|
||||||
lastRan = System.currentTimeMillis();
|
lastRan = System.currentTimeMillis();
|
||||||
|
|
||||||
final boolean doAwayKickCheck
|
final boolean doAwayKickCheck = TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
|
||||||
= TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
|
|
||||||
&& TFM_EssentialsBridge.isEssentialsEnabled()
|
&& TFM_EssentialsBridge.isEssentialsEnabled()
|
||||||
&& ((server.getOnlinePlayers().length / server.getMaxPlayers()) > TFM_ConfigEntry.AUTOKICK_THRESHOLD.getDouble());
|
&& ((server.getOnlinePlayers().length / server.getMaxPlayers()) > TFM_ConfigEntry.AUTOKICK_THRESHOLD.getDouble());
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
Loading…
Reference in New Issue
Block a user