Fix concurrency issue, remove sqlite from Bungee version and fix join message
This commit is contained in:
@@ -41,17 +41,11 @@ public class BungeeConfig implements LPConfiguration {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return configuration.getString("server", "bungee");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return configuration.getString("prefix", "&7&l[&b&lL&a&lP&7&l] &c");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSyncTime() {
|
||||
return configuration.getInt("sql.sync-minutes", 3);
|
||||
|
||||
@@ -6,7 +6,6 @@ import me.lucko.luckperms.data.Datastore;
|
||||
import me.lucko.luckperms.data.MySQLConfiguration;
|
||||
import me.lucko.luckperms.data.methods.FlatfileDatastore;
|
||||
import me.lucko.luckperms.data.methods.MySQLDatastore;
|
||||
import me.lucko.luckperms.data.methods.SQLiteDatastore;
|
||||
import me.lucko.luckperms.groups.GroupManager;
|
||||
import me.lucko.luckperms.listeners.PlayerListener;
|
||||
import me.lucko.luckperms.runnables.UpdateTask;
|
||||
@@ -15,7 +14,6 @@ import me.lucko.luckperms.users.UserManager;
|
||||
import me.lucko.luckperms.utils.LPConfiguration;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -48,15 +46,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
configuration.getDatabaseValue("username"),
|
||||
configuration.getDatabaseValue("password")
|
||||
));
|
||||
} else if (storageMethod.equalsIgnoreCase("sqlite")) {
|
||||
getLogger().info("Using SQLite as storage method.");
|
||||
datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite"));
|
||||
} else if (storageMethod.equalsIgnoreCase("flatfile")) {
|
||||
getLogger().info("Using Flatfile (JSON) as storage method.");
|
||||
datastore = new FlatfileDatastore(this, getDataFolder());
|
||||
} else {
|
||||
getLogger().warning("Storage method '" + storageMethod + "' was not recognised. Using SQLite as fallback.");
|
||||
datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite"));
|
||||
getLogger().warning("Storage method '" + storageMethod + "' was not recognised. Using Flatfile as fallback.");
|
||||
datastore = new FlatfileDatastore(this, getDataFolder());
|
||||
}
|
||||
|
||||
datastore.init();
|
||||
|
||||
@@ -11,6 +11,9 @@ import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@@ -22,14 +25,21 @@ public class PlayerListener implements Listener {
|
||||
|
||||
plugin.getDatastore().loadOrCreateUser(player.getUniqueId(), player.getName(), success -> {
|
||||
if (!success) {
|
||||
e.getPlayer().sendMessage(new TextComponent(Util.color("&e&l[LP] &cPermissions data could not be loaded. Please contact an administrator.")));
|
||||
WeakReference<ProxiedPlayer> p = new WeakReference<>(player);
|
||||
plugin.getProxy().getScheduler().schedule(plugin, () -> {
|
||||
ProxiedPlayer pl = p.get();
|
||||
if (pl != null) {
|
||||
pl.sendMessage(new TextComponent(Util.color(Util.PREFIX + "Permissions data could not be loaded. Please contact an administrator.")));
|
||||
}
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
|
||||
} else {
|
||||
User user = plugin.getUserManager().getUser(player.getUniqueId());
|
||||
user.refreshPermissions();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getDatastore().saveUUIDData(e.getPlayer().getName(), e.getPlayer().getUniqueId(), success -> {});
|
||||
plugin.getDatastore().saveUUIDData(player.getName(), player.getUniqueId(), success -> {});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -9,12 +9,10 @@ default-group: default
|
||||
# If users on this server should have their global permissions/groups applied.
|
||||
include-global: false
|
||||
|
||||
prefix: '&7&l[&b&lL&a&lP&7&l] &c'
|
||||
|
||||
# Which storage method the plugin should use.
|
||||
# Currently supported: mysql, sqlite, flatfile
|
||||
# Currently supported: mysql & flatfile
|
||||
# Fill out connection info below if you're using MySQL
|
||||
storage-method: sqlite
|
||||
storage-method: flatfile
|
||||
|
||||
sql:
|
||||
address: localhost:3306
|
||||
|
||||
Reference in New Issue
Block a user