Merge pull request #263 from AtlasMediaGroup/FS-450

Fixes several bugs caused by potential issues in TFM's admin loading system (FS-450)
This commit is contained in:
Video 2022-09-11 11:30:37 -06:00 committed by GitHub
commit 1ddeb4b621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -59,7 +59,7 @@ public class Admin
{ {
final StringBuilder output = new StringBuilder(); final StringBuilder output = new StringBuilder();
output.append("Admin: ").append(getName()).append("\n") output.append("Admin: ").append(getName() != null ? getName() : getUuid().toString()).append("\n")
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n") .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n") .append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n") .append("- Rank: ").append(rank.getName()).append("\n")
@ -172,7 +172,7 @@ public class Admin
setPotionSpy(false); setPotionSpy(false);
Server server = Bukkit.getServer(); Server server = Bukkit.getServer();
Player player = server.getPlayer(getName()); Player player = server.getPlayer(getUuid());
if (player != null) if (player != null)
{ {

View File

@ -48,12 +48,18 @@ public class AdminList extends FreedomService
try try
{ {
ResultSet adminSet = plugin.sql.getAdminList(); ResultSet adminSet = plugin.sql.getAdminList();
{
while (adminSet.next()) while (adminSet.next())
{
try
{ {
Admin admin = new Admin(adminSet); Admin admin = new Admin(adminSet);
allAdmins.add(admin); allAdmins.add(admin);
} }
catch (Throwable ex)
{
FLog.warning("An error occurred whilst reading the admin entry at row #" + adminSet.getRow());
FLog.warning(ex);
}
} }
} }
catch (SQLException e) catch (SQLException e)
@ -245,7 +251,10 @@ public class AdminList extends FreedomService
activeAdmins.add(admin); activeAdmins.add(admin);
uuidTable.put(admin.getUuid(), admin); uuidTable.put(admin.getUuid(), admin);
if (admin.getName() != null)
{
nameTable.put(admin.getName().toLowerCase(), admin); nameTable.put(admin.getName().toLowerCase(), admin);
}
for (String ip : admin.getIps()) for (String ip : admin.getIps())
{ {