mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix /clones not including online player latest IPs
This commit is contained in:
parent
4df2aaf752
commit
96e8351a08
@ -40,6 +40,11 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
List<string> accounts = PlayerInfo.FindAccounts(message);
|
||||
// in older versions it was possible for your name to appear multiple times in DB
|
||||
if (p != null) {
|
||||
while (accounts.CaselessRemove(p.name)) { }
|
||||
}
|
||||
|
||||
if (accounts.Count == 0) {
|
||||
Player.Message(p, "No players last played with the given IP.");
|
||||
} else {
|
||||
|
@ -107,6 +107,7 @@ namespace MCGalaxy {
|
||||
InitPlayerStats(playerDb);
|
||||
} else {
|
||||
LoadPlayerStats(playerDb);
|
||||
//save(); // update IP and total logins in the DB
|
||||
}
|
||||
|
||||
Server.Background.QueueOnce(ShowAltsTask, name, TimeSpan.Zero);
|
||||
@ -223,11 +224,8 @@ namespace MCGalaxy {
|
||||
if (p == null || p.ip == "127.0.0.1" || p.disconnected) return;
|
||||
|
||||
List<string> alts = PlayerInfo.FindAccounts(p.ip);
|
||||
// Remove online accounts from the list of accounts on the IP
|
||||
for (int i = alts.Count - 1; i >= 0; i--) {
|
||||
if (PlayerInfo.FindExact(alts[i]) == null) continue;
|
||||
alts.RemoveAt(i);
|
||||
}
|
||||
// in older versions it was possible for your name to appear multiple times in DB
|
||||
while (alts.CaselessRemove(p.name)) { }
|
||||
if (alts.Count == 0) return;
|
||||
|
||||
LevelPermission adminChatRank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin);
|
||||
|
@ -160,8 +160,8 @@ namespace MCGalaxy {
|
||||
return row == null ? null : row["Name"].ToString();
|
||||
}
|
||||
|
||||
/// <summary> Retrieves from the database the names of all players whose
|
||||
/// last IP address matches the given IP address. </summary>
|
||||
/// <summary> Retrieves names of all players whose IP address matches the given IP address. </summary>
|
||||
/// <remarks> This is current IP for online players, last IP for offline players from the database. </remarks>
|
||||
public static List<string> FindAccounts(string ip) {
|
||||
DataTable clones = Database.Backend.GetRows("Players", "Name", "WHERE IP=@0", ip);
|
||||
List<string> alts = new List<string>();
|
||||
@ -171,6 +171,14 @@ namespace MCGalaxy {
|
||||
if (!alts.CaselessContains(name))
|
||||
alts.Add(name);
|
||||
}
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
if (p.ip != ip) continue;
|
||||
if (!alts.CaselessContains(p.name))
|
||||
alts.Add(p.name);
|
||||
}
|
||||
|
||||
clones.Dispose();
|
||||
return alts;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user