Fix SQLite table creation statement and add legacy SQLite uuids as a provider

This commit is contained in:
Alexander Söderberg 2020-05-24 04:48:19 +02:00
parent d19df3b6eb
commit cc168d5ae9
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
2 changed files with 11 additions and 4 deletions

View file

@ -256,7 +256,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
impromptuPipeline.registerService(offlinePlayerUUIDService);
backgroundPipeline.registerService(offlinePlayerUUIDService);
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService();
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService("user_cache.db");
final SQLiteUUIDService legacyUUIDSerivce = new SQLiteUUIDService("usercache.db");
final LuckPermsUUIDService luckPermsUUIDService;
if (Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
@ -288,6 +289,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
impromptuPipeline.registerConsumer(sqLiteUUIDService);
backgroundPipeline.registerConsumer(sqLiteUUIDService);
impromptuPipeline.registerService(legacyUUIDSerivce);
backgroundPipeline.registerService(legacyUUIDSerivce);
// Plugin providers
if (luckPermsUUIDService != null) {
impromptuPipeline.registerService(luckPermsUUIDService);
@ -307,6 +311,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
backgroundPipeline.registerService(sqLiteUUIDService);
impromptuPipeline.registerConsumer(sqLiteUUIDService);
backgroundPipeline.registerConsumer(sqLiteUUIDService);
impromptuPipeline.registerService(legacyUUIDSerivce);
backgroundPipeline.registerService(legacyUUIDSerivce);
}
impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);

View file

@ -49,9 +49,9 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
private final SQLite sqlite;
public SQLiteUUIDService() {
public SQLiteUUIDService(final String fileName) {
this.sqlite =
new SQLite(MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "usercache.db"));
new SQLite(MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), fileName));
try {
this.sqlite.openConnection();
} catch (ClassNotFoundException | SQLException e) {
@ -59,7 +59,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
}
try (PreparedStatement stmt = getConnection().prepareStatement(
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username))")) {
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid))")) {
stmt.execute();
} catch (SQLException e) {
e.printStackTrace();