From c0f3712c8de9c2cfcf4ce5ca9db07e78f5dcfdcd Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 06:35:32 -0600 Subject: [PATCH] Fixes several bugs caused by any potential issues in TFM's admin loading system --- .../totalfreedom/totalfreedommod/admin/Admin.java | 4 ++-- .../totalfreedommod/admin/AdminList.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java index e90b3c5f..535b5cd3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java @@ -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) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index 639023b8..8073713c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -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()) {