mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-26 05:49:00 +02:00
Sponge support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package me.lucko.luckperms;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.api.implementation.ApiProvider;
|
||||
import me.lucko.luckperms.api.vault.VaultHook;
|
||||
@@ -15,6 +16,7 @@ import me.lucko.luckperms.tracks.TrackManager;
|
||||
import me.lucko.luckperms.users.BukkitUserManager;
|
||||
import me.lucko.luckperms.users.UserManager;
|
||||
import me.lucko.luckperms.utils.LPConfiguration;
|
||||
import me.lucko.luckperms.utils.LogUtil;
|
||||
import me.lucko.luckperms.utils.UuidCache;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -40,7 +42,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("Loading configuration...");
|
||||
getLog().info("Loading configuration...");
|
||||
configuration = new BukkitConfig(this);
|
||||
|
||||
// register events
|
||||
@@ -48,40 +50,40 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
pm.registerEvents(new PlayerListener(this), this);
|
||||
|
||||
// register commands
|
||||
getLogger().info("Registering commands...");
|
||||
CommandManagerBukkit commandManager = new CommandManagerBukkit(this);
|
||||
getLog().info("Registering commands...");
|
||||
BukkitCommand commandManager = new BukkitCommand(this);
|
||||
PluginCommand main = getServer().getPluginCommand("luckperms");
|
||||
main.setExecutor(commandManager);
|
||||
main.setTabCompleter(commandManager);
|
||||
main.setAliases(Arrays.asList("perms", "lp", "permissions", "p", "perm"));
|
||||
|
||||
getLogger().info("Detecting storage method...");
|
||||
getLog().info("Detecting storage method...");
|
||||
final String storageMethod = configuration.getStorageMethod();
|
||||
if (storageMethod.equalsIgnoreCase("mysql")) {
|
||||
getLogger().info("Using MySQL as storage method.");
|
||||
getLog().info("Using MySQL as storage method.");
|
||||
datastore = new MySQLDatastore(this, configuration.getDatabaseValues());
|
||||
} else if (storageMethod.equalsIgnoreCase("sqlite")) {
|
||||
getLogger().info("Using SQLite as storage method.");
|
||||
getLog().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.");
|
||||
getLog().info("Using Flatfile (JSON) as storage method.");
|
||||
datastore = new FlatfileDatastore(this, getDataFolder());
|
||||
} else {
|
||||
getLogger().severe("Storage method '" + storageMethod + "' was not recognised. Using SQLite as fallback.");
|
||||
getLog().severe("Storage method '" + storageMethod + "' was not recognised. Using SQLite as fallback.");
|
||||
datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite"));
|
||||
}
|
||||
|
||||
getLogger().info("Initialising datastore...");
|
||||
getLog().info("Initialising datastore...");
|
||||
datastore.init();
|
||||
|
||||
getLogger().info("Loading internal permission managers...");
|
||||
getLog().info("Loading internal permission managers...");
|
||||
uuidCache = new UuidCache(getConfiguration().getOnlineMode());
|
||||
userManager = new BukkitUserManager(this);
|
||||
groupManager = new GroupManager(this);
|
||||
trackManager = new TrackManager();
|
||||
|
||||
// Run update task to refresh any online users
|
||||
getLogger().info("Scheduling Update Task to refresh any online users.");
|
||||
getLog().info("Scheduling Update Task to refresh any online users.");
|
||||
try {
|
||||
new UpdateTask(this).run();
|
||||
} catch (Exception e) {
|
||||
@@ -95,33 +97,33 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
}
|
||||
|
||||
// Provide vault support
|
||||
getLogger().info("Attempting to hook into Vault...");
|
||||
getLog().info("Attempting to hook into Vault...");
|
||||
try {
|
||||
if (getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
VaultHook.hook(this);
|
||||
getLogger().info("Registered Vault permission & chat hook.");
|
||||
getLog().info("Registered Vault permission & chat hook.");
|
||||
} else {
|
||||
getLogger().info("Vault not found.");
|
||||
getLog().info("Vault not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Error occurred whilst hooking into Vault.");
|
||||
getLog().severe("Error occurred whilst hooking into Vault.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getLogger().info("Registering API...");
|
||||
getLog().info("Registering API...");
|
||||
final ApiProvider provider = new ApiProvider(this);
|
||||
LuckPerms.registerProvider(provider);
|
||||
getServer().getServicesManager().register(LuckPermsApi.class, provider, this, ServicePriority.Normal);
|
||||
|
||||
getLogger().info("Successfully loaded.");
|
||||
getLog().info("Successfully loaded.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Closing datastore...");
|
||||
getLog().info("Closing datastore...");
|
||||
datastore.shutdown();
|
||||
|
||||
getLogger().info("Unregistering API...");
|
||||
getLog().info("Unregistering API...");
|
||||
LuckPerms.unregisterProvider();
|
||||
getServer().getServicesManager().unregisterAll(this);
|
||||
}
|
||||
@@ -136,6 +138,11 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
Bukkit.getScheduler().runTask(this, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLog() {
|
||||
return LogUtil.wrap(getLogger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return getDescription().getVersion();
|
||||
|
Reference in New Issue
Block a user