mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +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!
|
||||
#Mon Aug 25 14:06:59 CEST 2014
|
||||
build.number=924
|
||||
#Tue Aug 26 18:22:59 CEST 2014
|
||||
build.number=934
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
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.";
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
|
@ -68,15 +68,16 @@ public class Command_glist extends TFM_Command
|
||||
else
|
||||
{
|
||||
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();
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, username));
|
||||
String[] ip_address_parts = ip.split("\\.");
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", username));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(TFM_Util.getFuzzyIp(ip), 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));
|
||||
for (String ip : ips)
|
||||
{
|
||||
|
@ -22,7 +22,6 @@ public class Command_nickclean extends TFM_Command
|
||||
ChatColor.UNDERLINE,
|
||||
ChatColor.BLACK
|
||||
};
|
||||
|
||||
private static final Pattern REGEX = Pattern.compile("\\u00A7[" + StringUtils.join(BLOCKED, "") + "]");
|
||||
|
||||
@Override
|
||||
|
@ -112,14 +112,13 @@ public class Command_tag extends TFM_Command
|
||||
final String inputTag = StringUtils.join(args, " ", 1, args.length);
|
||||
final String outputTag = TFM_Util.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag),
|
||||
new String[]
|
||||
{
|
||||
"" + ChatColor.COLOR_CHAR, "&k"
|
||||
},
|
||||
{
|
||||
"" + ChatColor.COLOR_CHAR, "&k"
|
||||
},
|
||||
new String[]
|
||||
{
|
||||
"", ""
|
||||
}
|
||||
)) + ChatColor.RESET;
|
||||
{
|
||||
"", ""
|
||||
})) + ChatColor.RESET;
|
||||
|
||||
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 NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||
|
||||
protected TotalFreedomMod plugin;
|
||||
protected Server server;
|
||||
private CommandSender commandSender;
|
||||
|
@ -733,7 +733,8 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||
{
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||
@ -752,7 +753,8 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||
{
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||
@ -774,36 +776,45 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
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);
|
||||
|
||||
// Handle PlayerList entry (persistent)
|
||||
if (TFM_PlayerList.existsEntry(player))
|
||||
{
|
||||
final TFM_Player entry = TFM_PlayerList.getEntry(player);
|
||||
entry.setLastLoginUnix(TFM_Util.getUnixTime());
|
||||
entry.setLastLoginName(player.getName());
|
||||
entry.save();
|
||||
playerEntry = TFM_PlayerList.getEntry(player);
|
||||
playerEntry.setLastLoginUnix(TFM_Util.getUnixTime());
|
||||
playerEntry.setLastLoginName(player.getName());
|
||||
playerEntry.addIp(ip);
|
||||
playerEntry.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_PlayerList.getEntry(player);
|
||||
playerEntry = TFM_PlayerList.getEntry(player);
|
||||
TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
|
||||
}
|
||||
|
||||
// GGenerate PlayerData (non-persistent)
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setSuperadminIdVerified(false);
|
||||
|
||||
// Verify strict IP match
|
||||
if (TFM_AdminList.isSuperAdmin(player))
|
||||
{
|
||||
TFM_BanManager.unbanIp(ip);
|
||||
TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(ip));
|
||||
for (String storedIp : playerEntry.getIps())
|
||||
{
|
||||
TFM_BanManager.unbanIp(storedIp);
|
||||
TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp));
|
||||
}
|
||||
|
||||
TFM_BanManager.unbanUuid(TFM_Util.getUniqueId(player));
|
||||
|
||||
player.setOp(true);
|
||||
|
||||
// Verify strict IP match
|
||||
if (!TFM_AdminList.isIdentityMatched(player))
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
@ -166,4 +166,47 @@ public class TFM_Ban
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (uuidBans.contains(ban))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (unbannableUUIDs.contains(UUID.fromString(ban.getSubject())))
|
||||
{
|
||||
return;
|
||||
@ -248,6 +253,11 @@ public class TFM_BanManager
|
||||
return;
|
||||
}
|
||||
|
||||
if (ipBans.contains(ban))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ipBans.add(ban);
|
||||
save();
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
{
|
||||
lastRan = System.currentTimeMillis();
|
||||
|
||||
final boolean doAwayKickCheck
|
||||
= TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
|
||||
final boolean doAwayKickCheck = TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
|
||||
&& TFM_EssentialsBridge.isEssentialsEnabled()
|
||||
&& ((server.getOnlinePlayers().length / server.getMaxPlayers()) > TFM_ConfigEntry.AUTOKICK_THRESHOLD.getDouble());
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
Loading…
Reference in New Issue
Block a user