@@ -577,31 +577,8 @@ public void loadTabComplete() {
577577 public void reload () {
578578 ArrayList <String > players = new ArrayList <>();
579579
580- // Prefer UUIDs from storage; names come from UuidLookup cache (seeded at
581- // startup)
582- for (String uuid : getUserManager ().getAllUUIDs ()) {
583- String name = UuidLookup .getInstance ().getCachedName (uuid );
584- if (name == null || name .isEmpty ()) {
585- // Fallback: try to read from user data without DB lookup
586- try {
587- AdvancedCoreUser user = getUserManager ().getUser (UUID .fromString (uuid ), false );
588- if (user != null ) {
589- String stored = user .getData ().getString ("PlayerName" , UserDataFetchMode .NO_DB_LOOKUP );
590- if (stored != null && !stored .isEmpty ()
591- && !stored .equalsIgnoreCase ("Error getting name" )
592- && !stored .equalsIgnoreCase ("null" )) {
593- UuidLookup .getInstance ().cacheMapping (uuid , stored );
594- name = stored ;
595- }
596- }
597- } catch (Exception ignored ) {
598- }
599- }
600-
601- if (name != null && !name .isEmpty () && !players .contains (name )) {
602- players .add (name );
603- }
604- }
580+ // fetch all cached names; this avoids hitting the DB
581+ players .addAll (UuidLookup .getInstance ().getAllCachedNames ());
605582
606583 // Always include currently online players
607584 for (Player p : Bukkit .getOnlinePlayers ()) {
@@ -615,6 +592,7 @@ public void reload() {
615592
616593 @ Override
617594 public void updateReplacements () {
595+ // ensure new online players are added to the replacement list
618596 for (Player player : Bukkit .getOnlinePlayers ()) {
619597 if (!getReplace ().contains (player .getName ())) {
620598 getReplace ().add (player .getName ());
0 commit comments