Fixes several bugs caused by any potential issues in TFM's admin loading system

This commit is contained in:
Video 2022-09-11 06:35:32 -06:00
parent 4d98108a46
commit c0f3712c8d
2 changed files with 13 additions and 4 deletions

View File

@ -59,7 +59,7 @@ public class Admin
{
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("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n")
@ -172,7 +172,7 @@ public class Admin
setPotionSpy(false);
Server server = Bukkit.getServer();
Player player = server.getPlayer(getName());
Player player = server.getPlayer(getUuid());
if (player != null)
{

View File

@ -48,12 +48,18 @@ public class AdminList extends FreedomService
try
{
ResultSet adminSet = plugin.sql.getAdminList();
while (adminSet.next())
{
while (adminSet.next())
try
{
Admin admin = new Admin(adminSet);
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)
@ -245,7 +251,10 @@ public class AdminList extends FreedomService
activeAdmins.add(admin);
uuidTable.put(admin.getUuid(), admin);
nameTable.put(admin.getName().toLowerCase(), admin);
if (admin.getName() != null)
{
nameTable.put(admin.getName().toLowerCase(), admin);
}
for (String ip : admin.getIps())
{