mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Add option to disable legacy cache, also add an option to return "Unknown" when a request cannot be fulfilled (old behaviour)
This should fix issues where lowercase offline mode UUIDs don't have access to their old cache.
This commit is contained in:
parent
cc168d5ae9
commit
7b97130af7
3 changed files with 27 additions and 6 deletions
|
@ -257,7 +257,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
backgroundPipeline.registerService(offlinePlayerUUIDService);
|
||||
|
||||
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService("user_cache.db");
|
||||
final SQLiteUUIDService legacyUUIDSerivce = new SQLiteUUIDService("usercache.db");
|
||||
|
||||
final SQLiteUUIDService legacyUUIDService;
|
||||
if (Settings.UUID.LEGACY_DATABASE_SUPPORT && MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "usercache.db").exists()) {
|
||||
legacyUUIDService = new SQLiteUUIDService("usercache.db");
|
||||
} else {
|
||||
legacyUUIDService = null;
|
||||
}
|
||||
|
||||
final LuckPermsUUIDService luckPermsUUIDService;
|
||||
if (Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
|
||||
|
@ -289,8 +295,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
||||
backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
||||
|
||||
impromptuPipeline.registerService(legacyUUIDSerivce);
|
||||
backgroundPipeline.registerService(legacyUUIDSerivce);
|
||||
if (legacyUUIDService != null) {
|
||||
impromptuPipeline.registerService(legacyUUIDService);
|
||||
backgroundPipeline.registerService(legacyUUIDService);
|
||||
}
|
||||
|
||||
// Plugin providers
|
||||
if (luckPermsUUIDService != null) {
|
||||
|
@ -312,8 +320,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
||||
backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
||||
|
||||
impromptuPipeline.registerService(legacyUUIDSerivce);
|
||||
backgroundPipeline.registerService(legacyUUIDSerivce);
|
||||
if (legacyUUIDService != null) {
|
||||
impromptuPipeline.registerService(legacyUUIDService);
|
||||
backgroundPipeline.registerService(legacyUUIDService);
|
||||
}
|
||||
}
|
||||
|
||||
impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);
|
||||
|
|
|
@ -248,6 +248,10 @@ public class Settings extends Config {
|
|||
public static long NON_BLOCKING_TIMEOUT = 3000L;
|
||||
@Comment("Timeout (in milliseconds) for blocking UUID requests (events)")
|
||||
public static long BLOCKING_TIMEOUT = 10L;
|
||||
@Comment("Whether or not PlotSquared should read from the legacy database")
|
||||
public static boolean LEGACY_DATABASE_SUPPORT = true;
|
||||
@Comment("Whether or not PlotSquared should return Unknown if it fails to fulfill a request")
|
||||
public static boolean UNKNOWN_AS_DEFAULT = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -324,7 +324,14 @@ public class UUIDPipeline {
|
|||
PlotSquared.log("Failed to find all usernames");
|
||||
}
|
||||
|
||||
if (Settings.UUID.UNKNOWN_AS_DEFAULT) {
|
||||
for (final UUID uuid : remainingRequests) {
|
||||
mappings.add(new UUIDMapping(uuid, Captions.UNKNOWN.getTranslated()));
|
||||
}
|
||||
return mappings;
|
||||
} else {
|
||||
throw new ServiceError("End of pipeline");
|
||||
}
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue