6969import io .github .md5sha256 .realty .util .DateFormatter ;
7070import io .github .md5sha256 .realty .util .EssentialsNotificationService ;
7171import io .github .md5sha256 .realty .util .EssentialsSafeBlockPredicate ;
72- import io .github .md5sha256 .realty .util .PlayerNameCache ;
7372import io .github .md5sha256 .realty .util .SimpleDateFormatSerializer ;
73+ import io .github .md5sha256 .realty .util .SquirrelIdUsernameResolver ;
7474import io .github .md5sha256 .realty .util .TransientNotificationService ;
7575import io .papermc .paper .util .Tick ;
7676import net .kyori .adventure .text .Component ;
@@ -124,7 +124,7 @@ public final class Realty extends JavaPlugin {
124124 private final AtomicReference <RealtyTags > realtyTags = new AtomicReference <>();
125125 private final RegionProfileService regionProfileService = new RegionProfileService (getLogger ());
126126 private final SignCache signCache = new SignCache ();
127- private final PlayerNameCache nameCache = new PlayerNameCache ( getServer ()) ;
127+ private SquirrelIdUsernameResolver nameResolver ;
128128 private ExecutorState executorState ;
129129 private RealtyBackend logic ;
130130 private ProfileApplicator profileApplicator ;
@@ -209,6 +209,16 @@ public void onEnable() {
209209 };
210210 this .executorState = new ExecutorState (getServer ().getScheduler ()
211211 .getMainThreadExecutor (this ), Executors .newFixedThreadPool (4 , threadFactory ));
212+ try {
213+ this .nameResolver = new SquirrelIdUsernameResolver (
214+ new File (getDataFolder (), "profiles.sqlite" ),
215+ this .executorState .dbExec ());
216+ } catch (IOException ex ) {
217+ getLogger ().severe ("Failed to initialize profile cache!" );
218+ ex .printStackTrace ();
219+ getServer ().getPluginManager ().disablePlugin (this );
220+ return ;
221+ }
212222 MariaDatabase mariaDatabase = new MariaDatabase (this .databaseSettings , getLogger ());
213223 this .database = mariaDatabase ;
214224 try {
@@ -220,7 +230,7 @@ public void onEnable() {
220230 return ;
221231 }
222232 this .logic = new RealtyBackendImpl (mariaDatabase ,
223- this .nameCache ::getUsername ,
233+ this .nameResolver ::getUsername ,
224234 dateTime -> DateFormatter .format (this .settings .get (), dateTime ),
225235 () -> this .settings .get ().offerPaymentDurationSeconds ());
226236 var economyProvider = getServer ().getServicesManager ().getRegistration (Economy .class );
0 commit comments