mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
misc refactoring
This commit is contained in:
parent
4fd89e6a34
commit
505a10a8b1
@ -25,10 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit;
|
package me.lucko.luckperms.bukkit;
|
||||||
|
|
||||||
import lombok.Getter;
|
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -40,24 +39,20 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter {
|
||||||
public class BukkitConfigAdapter implements ConfigurationAdapter {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final LPBukkitPlugin plugin;
|
|
||||||
|
|
||||||
|
private final File file;
|
||||||
private YamlConfiguration configuration;
|
private YamlConfiguration configuration;
|
||||||
|
|
||||||
|
public BukkitConfigAdapter(LuckPermsPlugin plugin, File file) {
|
||||||
|
super(plugin);
|
||||||
|
this.file = file;
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void reload() {
|
||||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
if (!configFile.exists()) {
|
|
||||||
configFile.getParentFile().mkdirs();
|
|
||||||
plugin.saveResource("config.yml", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration = YamlConfiguration.loadConfiguration(configFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,8 +44,8 @@ import me.lucko.luckperms.bukkit.processors.ChildPermissionProvider;
|
|||||||
import me.lucko.luckperms.bukkit.processors.DefaultsProvider;
|
import me.lucko.luckperms.bukkit.processors.DefaultsProvider;
|
||||||
import me.lucko.luckperms.bukkit.vault.VaultHookManager;
|
import me.lucko.luckperms.bukkit.vault.VaultHookManager;
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiRegistrationUtil;
|
||||||
import me.lucko.luckperms.common.api.ApiSingletonUtils;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
@ -59,6 +59,7 @@ import me.lucko.luckperms.common.contexts.ContextManager;
|
|||||||
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
||||||
import me.lucko.luckperms.common.dependencies.Dependency;
|
import me.lucko.luckperms.common.dependencies.Dependency;
|
||||||
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
||||||
|
import me.lucko.luckperms.common.event.EventFactory;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
||||||
@ -124,7 +125,8 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
private FileWatcher fileWatcher = null;
|
private FileWatcher fileWatcher = null;
|
||||||
private ExtendedMessagingService messagingService = null;
|
private ExtendedMessagingService messagingService = null;
|
||||||
private UuidCache uuidCache;
|
private UuidCache uuidCache;
|
||||||
private ApiProvider apiProvider;
|
private LuckPermsApiProvider apiProvider;
|
||||||
|
private EventFactory eventFactory;
|
||||||
private Logger log;
|
private Logger log;
|
||||||
private DefaultsProvider defaultsProvider;
|
private DefaultsProvider defaultsProvider;
|
||||||
private ChildPermissionProvider childPermissionProvider;
|
private ChildPermissionProvider childPermissionProvider;
|
||||||
@ -182,16 +184,17 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
private void enable() {
|
private void enable() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
sendStartupBanner(getConsoleSender());
|
||||||
verboseHandler = new VerboseHandler(scheduler.asyncBukkit(), getVersion());
|
verboseHandler = new VerboseHandler(scheduler.asyncBukkit(), getVersion());
|
||||||
permissionVault = new PermissionVault(scheduler.asyncBukkit());
|
permissionVault = new PermissionVault(scheduler.asyncBukkit());
|
||||||
logDispatcher = new LogDispatcher(this);
|
logDispatcher = new LogDispatcher(this);
|
||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new AbstractConfiguration(this, new BukkitConfigAdapter(this));
|
configuration = new AbstractConfiguration(this, new BukkitConfigAdapter(this, resolveConfig("config.yml")));
|
||||||
configuration.init();
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
StorageFactory storageFactory = new StorageFactory(this);
|
||||||
|
Set<StorageType> storageTypes = storageFactory.getRequiredTypes(StorageType.H2);
|
||||||
dependencyManager.loadStorageDependencies(storageTypes);
|
dependencyManager.loadStorageDependencies(storageTypes);
|
||||||
|
|
||||||
// setup the Bukkit defaults hook
|
// setup the Bukkit defaults hook
|
||||||
@ -211,7 +214,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialise datastore
|
// initialise datastore
|
||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = storageFactory.getInstance(StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
messagingService = new BukkitMessagingFactory(this).getInstance();
|
messagingService = new BukkitMessagingFactory(this).getInstance();
|
||||||
@ -256,8 +259,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
tryVaultHook(false);
|
tryVaultHook(false);
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
apiProvider = new ApiProvider(this);
|
apiProvider = new LuckPermsApiProvider(this);
|
||||||
ApiSingletonUtils.registerProvider(apiProvider);
|
|
||||||
|
// setup event factory
|
||||||
|
eventFactory = new EventFactory(this, apiProvider);
|
||||||
|
|
||||||
|
ApiRegistrationUtil.registerProvider(apiProvider);
|
||||||
getServer().getServicesManager().register(LuckPermsApi.class, apiProvider, this, ServicePriority.Normal);
|
getServer().getServicesManager().register(LuckPermsApi.class, apiProvider, this, ServicePriority.Normal);
|
||||||
|
|
||||||
|
|
||||||
@ -373,7 +380,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
messagingService.close();
|
messagingService.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiSingletonUtils.unregisterProvider();
|
ApiRegistrationUtil.unregisterProvider();
|
||||||
getServer().getServicesManager().unregisterAll(this);
|
getServer().getServicesManager().unregisterAll(this);
|
||||||
|
|
||||||
if (vaultHookManager != null) {
|
if (vaultHookManager != null) {
|
||||||
@ -419,6 +426,17 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File resolveConfig(String file) {
|
||||||
|
File configFile = new File(getDataFolder(), file);
|
||||||
|
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
getDataFolder().mkdirs();
|
||||||
|
saveResource("config.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configFile;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ExtendedMessagingService> getMessagingService() {
|
public Optional<ExtendedMessagingService> getMessagingService() {
|
||||||
return Optional.ofNullable(messagingService);
|
return Optional.ofNullable(messagingService);
|
||||||
|
@ -86,7 +86,7 @@ public class BukkitConnectionListener implements Listener {
|
|||||||
- setting up cached data. */
|
- setting up cached data. */
|
||||||
try {
|
try {
|
||||||
User user = LoginHelper.loadUser(plugin, e.getUniqueId(), e.getName(), false);
|
User user = LoginHelper.loadUser(plugin, e.getUniqueId(), e.getName(), false);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserLoginProcess(e.getUniqueId(), e.getName(), user);
|
plugin.getEventFactory().handleUserLoginProcess(e.getUniqueId(), e.getName(), user);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().severe("Exception occured whilst loading data for " + e.getUniqueId() + " - " + e.getName());
|
plugin.getLog().severe("Exception occured whilst loading data for " + e.getUniqueId() + " - " + e.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -25,10 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bungee;
|
package me.lucko.luckperms.bungee;
|
||||||
|
|
||||||
import lombok.Getter;
|
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
|
||||||
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
@ -36,42 +35,29 @@ import net.md_5.bungee.config.YamlConfiguration;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter {
|
||||||
public class BungeeConfigAdapter implements ConfigurationAdapter {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final LPBungeePlugin plugin;
|
|
||||||
|
|
||||||
|
private final File file;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
public BungeeConfigAdapter(LuckPermsPlugin plugin, File file) {
|
||||||
private File makeFile(String file) throws IOException {
|
super(plugin);
|
||||||
File configFile = new File(plugin.getDataFolder(), file);
|
this.file = file;
|
||||||
|
reload();
|
||||||
if (!configFile.exists()) {
|
|
||||||
plugin.getDataFolder().mkdir();
|
|
||||||
try (InputStream is = plugin.getResourceAsStream(file)) {
|
|
||||||
Files.copy(is, configFile.toPath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return configFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void reload() {
|
||||||
try {
|
try {
|
||||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(makeFile("config.yml"));
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ import me.lucko.luckperms.bungee.listeners.BungeePermissionCheckListener;
|
|||||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
||||||
import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
|
import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiRegistrationUtil;
|
||||||
import me.lucko.luckperms.common.api.ApiSingletonUtils;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
@ -53,6 +53,7 @@ import me.lucko.luckperms.common.contexts.ContextManager;
|
|||||||
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
||||||
import me.lucko.luckperms.common.dependencies.Dependency;
|
import me.lucko.luckperms.common.dependencies.Dependency;
|
||||||
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
||||||
|
import me.lucko.luckperms.common.event.EventFactory;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
||||||
@ -83,7 +84,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -108,7 +111,8 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
private FileWatcher fileWatcher = null;
|
private FileWatcher fileWatcher = null;
|
||||||
private ExtendedMessagingService messagingService = null;
|
private ExtendedMessagingService messagingService = null;
|
||||||
private UuidCache uuidCache;
|
private UuidCache uuidCache;
|
||||||
private ApiProvider apiProvider;
|
private LuckPermsApiProvider apiProvider;
|
||||||
|
private EventFactory eventFactory;
|
||||||
private Logger log;
|
private Logger log;
|
||||||
private LocaleManager localeManager;
|
private LocaleManager localeManager;
|
||||||
private DependencyManager dependencyManager;
|
private DependencyManager dependencyManager;
|
||||||
@ -137,16 +141,17 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
sendStartupBanner(getConsoleSender());
|
||||||
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
||||||
permissionVault = new PermissionVault(scheduler.async());
|
permissionVault = new PermissionVault(scheduler.async());
|
||||||
logDispatcher = new LogDispatcher(this);
|
logDispatcher = new LogDispatcher(this);
|
||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new AbstractConfiguration(this, new BungeeConfigAdapter(this));
|
configuration = new AbstractConfiguration(this, new BungeeConfigAdapter(this, resolveConfig("config.yml")));
|
||||||
configuration.init();
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
StorageFactory storageFactory = new StorageFactory(this);
|
||||||
|
Set<StorageType> storageTypes = storageFactory.getRequiredTypes(StorageType.H2);
|
||||||
dependencyManager.loadStorageDependencies(storageTypes);
|
dependencyManager.loadStorageDependencies(storageTypes);
|
||||||
|
|
||||||
// register events
|
// register events
|
||||||
@ -159,7 +164,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialise datastore
|
// initialise datastore
|
||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = storageFactory.getInstance(StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
messagingService = new BungeeMessagingFactory(this).getInstance();
|
messagingService = new BungeeMessagingFactory(this).getInstance();
|
||||||
@ -197,8 +202,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
apiProvider = new ApiProvider(this);
|
apiProvider = new LuckPermsApiProvider(this);
|
||||||
ApiSingletonUtils.registerProvider(apiProvider);
|
|
||||||
|
// setup event factory
|
||||||
|
eventFactory = new EventFactory(this, apiProvider);
|
||||||
|
|
||||||
|
ApiRegistrationUtil.registerProvider(apiProvider);
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
||||||
@ -241,7 +250,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
messagingService.close();
|
messagingService.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiSingletonUtils.unregisterProvider();
|
ApiRegistrationUtil.unregisterProvider();
|
||||||
|
|
||||||
getLog().info("Shutting down internal scheduler...");
|
getLog().info("Shutting down internal scheduler...");
|
||||||
scheduler.shutdown();
|
scheduler.shutdown();
|
||||||
@ -251,6 +260,21 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
getLog().info("Goodbye!");
|
getLog().info("Goodbye!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File resolveConfig(String file) {
|
||||||
|
File configFile = new File(getDataFolder(), file);
|
||||||
|
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
getDataFolder().mkdirs();
|
||||||
|
try (InputStream is = getResourceAsStream(file)) {
|
||||||
|
Files.copy(is, configFile.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return configFile;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ExtendedMessagingService> getMessagingService() {
|
public Optional<ExtendedMessagingService> getMessagingService() {
|
||||||
return Optional.ofNullable(messagingService);
|
return Optional.ofNullable(messagingService);
|
||||||
|
@ -82,7 +82,7 @@ public class BungeeConnectionListener implements Listener {
|
|||||||
- setting up cached data. */
|
- setting up cached data. */
|
||||||
try {
|
try {
|
||||||
User user = LoginHelper.loadUser(plugin, c.getUniqueId(), c.getName(), true);
|
User user = LoginHelper.loadUser(plugin, c.getUniqueId(), c.getName(), true);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
|
plugin.getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().severe("Exception occured whilst loading data for " + c.getUniqueId() + " - " + c.getName());
|
plugin.getLog().severe("Exception occured whilst loading data for " + c.getUniqueId() + " - " + c.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -47,7 +47,7 @@ public class LogDispatcher {
|
|||||||
.filter(CommandPermission.LOG_NOTIFY::isAuthorized)
|
.filter(CommandPermission.LOG_NOTIFY::isAuthorized)
|
||||||
.filter(s -> {
|
.filter(s -> {
|
||||||
boolean shouldCancel = LogNotify.isIgnoring(plugin, s.getUuid()) || (sender != null && s.getUuid().equals(sender.getUuid()));
|
boolean shouldCancel = LogNotify.isIgnoring(plugin, s.getUuid()) || (sender != null && s.getUuid().equals(sender.getUuid()));
|
||||||
return !plugin.getApiProvider().getEventFactory().handleLogNotify(shouldCancel, entry, origin, s);
|
return !plugin.getEventFactory().handleLogNotify(shouldCancel, entry, origin, s);
|
||||||
})
|
})
|
||||||
.forEach(s -> Message.LOG.send(s,
|
.forEach(s -> Message.LOG.send(s,
|
||||||
entry.getActorFriendlyString(),
|
entry.getActorFriendlyString(),
|
||||||
@ -59,7 +59,7 @@ public class LogDispatcher {
|
|||||||
|
|
||||||
public void dispatch(ExtendedLogEntry entry, Sender sender) {
|
public void dispatch(ExtendedLogEntry entry, Sender sender) {
|
||||||
// set the event to cancelled if the sender is import
|
// set the event to cancelled if the sender is import
|
||||||
if (!plugin.getApiProvider().getEventFactory().handleLogPublish(sender.isImport(), entry)) {
|
if (!plugin.getEventFactory().handleLogPublish(sender.isImport(), entry)) {
|
||||||
plugin.getStorage().logAction(entry);
|
plugin.getStorage().logAction(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,13 +74,13 @@ public class LogDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||||
if (!plugin.getApiProvider().getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) {
|
if (!plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) {
|
||||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL, sender);
|
broadcast(entry, LogBroadcastEvent.Origin.LOCAL, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchFromApi(ExtendedLogEntry entry) {
|
public void dispatchFromApi(ExtendedLogEntry entry) {
|
||||||
if (!plugin.getApiProvider().getEventFactory().handleLogPublish(false, entry)) {
|
if (!plugin.getEventFactory().handleLogPublish(false, entry)) {
|
||||||
try {
|
try {
|
||||||
plugin.getStorage().logAction(entry).get();
|
plugin.getStorage().logAction(entry).get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -95,14 +95,14 @@ public class LogDispatcher {
|
|||||||
plugin.getMessagingService().ifPresent(extendedMessagingService -> extendedMessagingService.pushLog(entry));
|
plugin.getMessagingService().ifPresent(extendedMessagingService -> extendedMessagingService.pushLog(entry));
|
||||||
|
|
||||||
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||||
if (!plugin.getApiProvider().getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) {
|
if (!plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) {
|
||||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispatchFromRemote(ExtendedLogEntry entry) {
|
public void dispatchFromRemote(ExtendedLogEntry entry) {
|
||||||
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.BROADCAST_RECEIVED_LOG_ENTRIES) || !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
boolean shouldCancel = !plugin.getConfiguration().get(ConfigKeys.BROADCAST_RECEIVED_LOG_ENTRIES) || !plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||||
if (!plugin.getApiProvider().getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) {
|
if (!plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) {
|
||||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.api.LuckPermsApi;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class ApiSingletonUtils {
|
public class ApiRegistrationUtil {
|
||||||
private static final Method REGISTER;
|
private static final Method REGISTER;
|
||||||
private static final Method UNREGISTER;
|
private static final Method UNREGISTER;
|
||||||
static {
|
static {
|
@ -50,8 +50,6 @@ import me.lucko.luckperms.common.api.delegates.misc.ApiActionLogger;
|
|||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiMetaStackFactory;
|
import me.lucko.luckperms.common.api.delegates.misc.ApiMetaStackFactory;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiNodeFactory;
|
import me.lucko.luckperms.common.api.delegates.misc.ApiNodeFactory;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiPlatformInfo;
|
import me.lucko.luckperms.common.api.delegates.misc.ApiPlatformInfo;
|
||||||
import me.lucko.luckperms.common.event.EventFactory;
|
|
||||||
import me.lucko.luckperms.common.event.LuckPermsEventBus;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -61,7 +59,7 @@ import java.util.function.Function;
|
|||||||
/**
|
/**
|
||||||
* Implements the LuckPerms API using the plugin instance
|
* Implements the LuckPerms API using the plugin instance
|
||||||
*/
|
*/
|
||||||
public class ApiProvider implements LuckPermsApi {
|
public class LuckPermsApiProvider implements LuckPermsApi {
|
||||||
|
|
||||||
@Getter(AccessLevel.NONE)
|
@Getter(AccessLevel.NONE)
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
@ -70,28 +68,20 @@ public class ApiProvider implements LuckPermsApi {
|
|||||||
private final UserManager userManager;
|
private final UserManager userManager;
|
||||||
private final GroupManager groupManager;
|
private final GroupManager groupManager;
|
||||||
private final TrackManager trackManager;
|
private final TrackManager trackManager;
|
||||||
private final LuckPermsEventBus eventBus;
|
|
||||||
private final ActionLogger actionLogger;
|
private final ActionLogger actionLogger;
|
||||||
private final ContextManager contextManager;
|
private final ContextManager contextManager;
|
||||||
private final MetaStackFactory metaStackFactory;
|
private final MetaStackFactory metaStackFactory;
|
||||||
private final EventFactory eventFactory;
|
|
||||||
|
|
||||||
public ApiProvider(LuckPermsPlugin plugin) {
|
public LuckPermsApiProvider(LuckPermsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.platformInfo = new ApiPlatformInfo(plugin);
|
this.platformInfo = new ApiPlatformInfo(plugin);
|
||||||
this.userManager = new ApiUserManager(plugin, plugin.getUserManager());
|
this.userManager = new ApiUserManager(plugin, plugin.getUserManager());
|
||||||
this.groupManager = new ApiGroupManager(plugin.getGroupManager());
|
this.groupManager = new ApiGroupManager(plugin.getGroupManager());
|
||||||
this.trackManager = new ApiTrackManager(plugin.getTrackManager());
|
this.trackManager = new ApiTrackManager(plugin.getTrackManager());
|
||||||
this.eventBus = new LuckPermsEventBus(plugin);
|
|
||||||
this.actionLogger = new ApiActionLogger(plugin);
|
this.actionLogger = new ApiActionLogger(plugin);
|
||||||
this.contextManager = new ApiContextManager(plugin, plugin.getContextManager());
|
this.contextManager = new ApiContextManager(plugin, plugin.getContextManager());
|
||||||
this.metaStackFactory = new ApiMetaStackFactory(plugin);
|
this.metaStackFactory = new ApiMetaStackFactory(plugin);
|
||||||
this.eventFactory = new EventFactory(eventBus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventFactory getEventFactory() {
|
|
||||||
return eventFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,7 +111,7 @@ public class ApiProvider implements LuckPermsApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventBus getEventBus() {
|
public EventBus getEventBus() {
|
||||||
return eventBus;
|
return plugin.getEventFactory().getEventBus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -138,7 +138,7 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserDemote(user, track, old, null);
|
plugin.getEventFactory().handleUserDemote(user, track, old, null);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserDemote(user, track, old, previousGroup.getName());
|
plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName());
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +60,12 @@ public class UserInfo extends SubCommand<User> {
|
|||||||
return CommandResult.NO_PERMISSION;
|
return CommandResult.NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message status = plugin.isPlayerOnline(plugin.getUuidCache().getExternalUUID(user.getUuid())) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE;
|
||||||
|
|
||||||
Message.USER_INFO_GENERAL.send(sender,
|
Message.USER_INFO_GENERAL.send(sender,
|
||||||
user.getName().orElse("Unknown"),
|
user.getName().orElse("Unknown"),
|
||||||
user.getUuid(),
|
user.getUuid(),
|
||||||
plugin.getPlayerStatus(user.getUuid()).asString(plugin.getLocaleManager()),
|
status.asString(plugin.getLocaleManager()),
|
||||||
user.getPrimaryGroup().getValue(),
|
user.getPrimaryGroup().getValue(),
|
||||||
user.getOwnNodes().size(),
|
user.getOwnNodes().size(),
|
||||||
user.getOwnNodes().stream().filter(n -> !(n.isGroupNode() || n.isPrefix() || n.isSuffix() || n.isMeta())).mapToInt(n -> 1).sum(),
|
user.getOwnNodes().stream().filter(n -> !(n.isGroupNode() || n.isPrefix() || n.isSuffix() || n.isMeta())).mapToInt(n -> 1).sum(),
|
||||||
|
@ -125,7 +125,7 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserPromote(user, track, null, first);
|
plugin.getEventFactory().handleUserPromote(user, track, null, first);
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserPromote(user, track, old, nextGroup.getName());
|
plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName());
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import com.github.benmanes.caffeine.cache.Caffeine;
|
|||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiConfiguration;
|
import me.lucko.luckperms.common.api.delegates.misc.ApiConfiguration;
|
||||||
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
import me.lucko.luckperms.common.config.keys.EnduringKey;
|
import me.lucko.luckperms.common.config.keys.EnduringKey;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
@ -78,21 +79,15 @@ public class AbstractConfiguration implements LuckPermsConfiguration, CacheLoade
|
|||||||
contextsFile.load();
|
contextsFile.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
adapter.init();
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
init();
|
adapter.reload();
|
||||||
|
|
||||||
Set<ConfigKey<?>> toInvalidate = cache.asMap().keySet().stream().filter(k -> !(k instanceof EnduringKey)).collect(Collectors.toSet());
|
Set<ConfigKey<?>> toInvalidate = cache.asMap().keySet().stream().filter(k -> !(k instanceof EnduringKey)).collect(Collectors.toSet());
|
||||||
cache.invalidateAll(toInvalidate);
|
cache.invalidateAll(toInvalidate);
|
||||||
|
|
||||||
loadAll();
|
loadAll();
|
||||||
getPlugin().getApiProvider().getEventFactory().handleConfigReload();
|
getPlugin().getEventFactory().handleConfigReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.config;
|
package me.lucko.luckperms.common.config;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a key in the configuration.
|
* Represents a key in the configuration.
|
||||||
*
|
*
|
||||||
|
@ -54,11 +54,6 @@ public interface LuckPermsConfiguration {
|
|||||||
*/
|
*/
|
||||||
ContextsFile getContextsFile();
|
ContextsFile getContextsFile();
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialises the configuration.
|
|
||||||
*/
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads the configuration.
|
* Reloads the configuration.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.config.adapter;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public abstract class AbstractConfigurationAdapter implements ConfigurationAdapter {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
|
}
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.config;
|
package me.lucko.luckperms.common.config.adapter;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public interface ConfigurationAdapter {
|
|||||||
|
|
||||||
LuckPermsPlugin getPlugin();
|
LuckPermsPlugin getPlugin();
|
||||||
|
|
||||||
void init();
|
void reload();
|
||||||
|
|
||||||
boolean contains(String path);
|
boolean contains(String path);
|
||||||
|
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
@AllArgsConstructor(staticName = "of")
|
||||||
public class BooleanKey implements ConfigKey<Boolean> {
|
public class BooleanKey implements ConfigKey<Boolean> {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
@AllArgsConstructor(staticName = "of")
|
||||||
public class IntegerKey implements ConfigKey<Integer> {
|
public class IntegerKey implements ConfigKey<Integer> {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
@AllArgsConstructor(staticName = "of")
|
||||||
public class LowercaseStringKey implements ConfigKey<String> {
|
public class LowercaseStringKey implements ConfigKey<String> {
|
||||||
|
@ -30,7 +30,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
@AllArgsConstructor(staticName = "of")
|
||||||
public class StaticKey<T> implements ConfigKey<T> {
|
public class StaticKey<T> implements ConfigKey<T> {
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.config.keys;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
@AllArgsConstructor(staticName = "of")
|
||||||
public class StringKey implements ConfigKey<String> {
|
public class StringKey implements ConfigKey<String> {
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.event;
|
package me.lucko.luckperms.common.event;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
@ -38,6 +36,7 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
|
|||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||||
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.event.impl.EventConfigReload;
|
import me.lucko.luckperms.common.event.impl.EventConfigReload;
|
||||||
import me.lucko.luckperms.common.event.impl.EventGroupCacheLoad;
|
import me.lucko.luckperms.common.event.impl.EventGroupCacheLoad;
|
||||||
@ -75,16 +74,24 @@ import me.lucko.luckperms.common.model.Group;
|
|||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public final class EventFactory {
|
public final class EventFactory {
|
||||||
private final LuckPermsEventBus eventBus;
|
private final LuckPermsEventBus eventBus;
|
||||||
|
|
||||||
|
public EventFactory(LuckPermsPlugin plugin, LuckPermsApiProvider apiProvider) {
|
||||||
|
this.eventBus = new LuckPermsEventBus(plugin, apiProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuckPermsEventBus getEventBus() {
|
||||||
|
return eventBus;
|
||||||
|
}
|
||||||
|
|
||||||
private void fireEventAsync(LuckPermsEvent event) {
|
private void fireEventAsync(LuckPermsEvent event) {
|
||||||
eventBus.fireEventAsync(event);
|
eventBus.fireEventAsync(event);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import me.lucko.luckperms.api.event.Cancellable;
|
|||||||
import me.lucko.luckperms.api.event.EventBus;
|
import me.lucko.luckperms.api.event.EventBus;
|
||||||
import me.lucko.luckperms.api.event.EventHandler;
|
import me.lucko.luckperms.api.event.EventHandler;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -47,6 +48,9 @@ public class LuckPermsEventBus implements EventBus {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
|
private final LuckPermsApiProvider apiProvider;
|
||||||
|
|
||||||
private final Map<Class<? extends LuckPermsEvent>, Set<LuckPermsEventHandler<?>>> handlerMap = new ConcurrentHashMap<>();
|
private final Map<Class<? extends LuckPermsEvent>, Set<LuckPermsEventHandler<?>>> handlerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -91,7 +95,7 @@ public class LuckPermsEventBus implements EventBus {
|
|||||||
|
|
||||||
public void fireEvent(LuckPermsEvent event) {
|
public void fireEvent(LuckPermsEvent event) {
|
||||||
if (event instanceof AbstractEvent) {
|
if (event instanceof AbstractEvent) {
|
||||||
((AbstractEvent) event).setApi(plugin.getApiProvider());
|
((AbstractEvent) event).setApi(apiProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<Class<? extends LuckPermsEvent>, Set<LuckPermsEventHandler<?>>> ent : handlerMap.entrySet()) {
|
for (Map.Entry<Class<? extends LuckPermsEvent>, Set<LuckPermsEventHandler<?>>> ent : handlerMap.entrySet()) {
|
||||||
|
@ -95,7 +95,7 @@ public abstract class AbstractMessagingService implements ExtendedMessagingServi
|
|||||||
|
|
||||||
plugin.getLog().info("[" + name + " Messaging] Received update ping with id: " + requestId.toString());
|
plugin.getLog().info("[" + name + " Messaging] Received update ping with id: " + requestId.toString());
|
||||||
|
|
||||||
if (plugin.getApiProvider().getEventFactory().handleNetworkPreSync(false, requestId)) {
|
if (plugin.getEventFactory().handleNetworkPreSync(false, requestId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public abstract class AbstractMessagingService implements ExtendedMessagingServi
|
|||||||
|
|
||||||
plugin.getLog().info("[" + name + " Messaging] Received user update ping for '" + user.getFriendlyName() + "' with id: " + uuidToString(requestId));
|
plugin.getLog().info("[" + name + " Messaging] Received user update ping for '" + user.getFriendlyName() + "' with id: " + uuidToString(requestId));
|
||||||
|
|
||||||
if (plugin.getApiProvider().getEventFactory().handleNetworkPreSync(false, requestId)) {
|
if (plugin.getEventFactory().handleNetworkPreSync(false, requestId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ public abstract class AbstractMessagingService implements ExtendedMessagingServi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleLogReceive(requestId, entry.getValue());
|
plugin.getEventFactory().handleLogReceive(requestId, entry.getValue());
|
||||||
plugin.getLogDispatcher().dispatchFromRemote(entry.getValue());
|
plugin.getLogDispatcher().dispatchFromRemote(entry.getValue());
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
@ -197,7 +197,7 @@ public abstract class AbstractMessagingService implements ExtendedMessagingServi
|
|||||||
UUID requestId = generatePingId();
|
UUID requestId = generatePingId();
|
||||||
String strId = uuidToString(requestId);
|
String strId = uuidToString(requestId);
|
||||||
|
|
||||||
if (plugin.getApiProvider().getEventFactory().handleLogNetworkPublish(!plugin.getConfiguration().get(ConfigKeys.PUSH_LOG_ENTRIES), requestId, logEntry)) {
|
if (plugin.getEventFactory().handleLogNetworkPublish(!plugin.getConfiguration().get(ConfigKeys.PUSH_LOG_ENTRIES), requestId, logEntry)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
|
|
||||||
this.refreshBuffer = new GroupRefreshBuffer(plugin, this);
|
this.refreshBuffer = new GroupRefreshBuffer(plugin, this);
|
||||||
this.cachedData = new GroupCachedData(this);
|
this.cachedData = new GroupCachedData(this);
|
||||||
getPlugin().getApiProvider().getEventFactory().handleGroupCacheLoad(this, cachedData);
|
getPlugin().getEventFactory().handleGroupCacheLoad(this, cachedData);
|
||||||
|
|
||||||
// invalidate out caches when data is updated
|
// invalidate out caches when data is updated
|
||||||
getStateListeners().add(() -> refreshBuffer.request());
|
getStateListeners().add(() -> refreshBuffer.request());
|
||||||
@ -121,7 +121,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
return CompletableFuture.allOf(
|
return CompletableFuture.allOf(
|
||||||
cachedData.reloadPermissions(),
|
cachedData.reloadPermissions(),
|
||||||
cachedData.reloadMeta()
|
cachedData.reloadMeta()
|
||||||
).thenAccept(n -> getPlugin().getApiProvider().getEventFactory().handleGroupDataRecalculate(this, cachedData));
|
).thenAccept(n -> getPlugin().getEventFactory().handleGroupDataRecalculate(this, cachedData));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class GroupRefreshBuffer extends BufferedRequest<Void> {
|
private static final class GroupRefreshBuffer extends BufferedRequest<Void> {
|
||||||
|
@ -514,7 +514,7 @@ public abstract class PermissionHolder {
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
|
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +940,7 @@ public abstract class PermissionHolder {
|
|||||||
ImmutableSet<Node> after = ImmutableSet.copyOf(getOwnNodesSet());
|
ImmutableSet<Node> after = ImmutableSet.copyOf(getOwnNodesSet());
|
||||||
|
|
||||||
for (Node r : removed) {
|
for (Node r : removed) {
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeRemove(r, this, before, after);
|
plugin.getEventFactory().handleNodeRemove(r, this, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1023,7 +1023,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(node, this, before, after);
|
plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1060,7 +1060,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(newNode, this, before, after);
|
plugin.getEventFactory().handleNodeAdd(newNode, this, before, after);
|
||||||
return Maps.immutableEntry(DataMutateResult.SUCCESS, newNode);
|
return Maps.immutableEntry(DataMutateResult.SUCCESS, newNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1087,7 +1087,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(node, this, before, after);
|
plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
||||||
return Maps.immutableEntry(DataMutateResult.SUCCESS, node);
|
return Maps.immutableEntry(DataMutateResult.SUCCESS, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1123,7 +1123,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
ImmutableCollection<Node> after = getTransientNodes().values();
|
ImmutableCollection<Node> after = getTransientNodes().values();
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeAdd(node, this, before, after);
|
plugin.getEventFactory().handleNodeAdd(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,7 +1149,7 @@ public abstract class PermissionHolder {
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
|
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeRemove(node, this, before, after);
|
plugin.getEventFactory().handleNodeRemove(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1175,7 +1175,7 @@ public abstract class PermissionHolder {
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
|
|
||||||
ImmutableCollection<Node> after = getTransientNodes().values();
|
ImmutableCollection<Node> after = getTransientNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeRemove(node, this, before, after);
|
plugin.getEventFactory().handleNodeRemove(node, this, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1207,7 +1207,7 @@ public abstract class PermissionHolder {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1227,7 +1227,7 @@ public abstract class PermissionHolder {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,7 +1250,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,7 +1277,7 @@ public abstract class PermissionHolder {
|
|||||||
}
|
}
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,7 +1295,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1319,7 +1319,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1338,7 +1338,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1362,7 +1362,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
ImmutableCollection<Node> after = getEnduringNodes().values();
|
ImmutableCollection<Node> after = getEnduringNodes().values();
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1383,7 +1383,7 @@ public abstract class PermissionHolder {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
|
plugin.getEventFactory().handleNodeClear(this, before, after);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public class Track implements Identifiable<String> {
|
|||||||
groups.add(group.getName());
|
groups.add(group.getName());
|
||||||
List<String> after = ImmutableList.copyOf(groups);
|
List<String> after = ImmutableList.copyOf(groups);
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackAddGroup(this, group.getName(), before, after);
|
plugin.getEventFactory().handleTrackAddGroup(this, group.getName(), before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ public class Track implements Identifiable<String> {
|
|||||||
groups.add(position, group.getName());
|
groups.add(position, group.getName());
|
||||||
List<String> after = ImmutableList.copyOf(groups);
|
List<String> after = ImmutableList.copyOf(groups);
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackAddGroup(this, group.getName(), before, after);
|
plugin.getEventFactory().handleTrackAddGroup(this, group.getName(), before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ public class Track implements Identifiable<String> {
|
|||||||
groups.remove(group);
|
groups.remove(group);
|
||||||
List<String> after = ImmutableList.copyOf(groups);
|
List<String> after = ImmutableList.copyOf(groups);
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackRemoveGroup(this, group, before, after);
|
plugin.getEventFactory().handleTrackRemoveGroup(this, group, before, after);
|
||||||
return DataMutateResult.SUCCESS;
|
return DataMutateResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +250,6 @@ public class Track implements Identifiable<String> {
|
|||||||
public void clearGroups() {
|
public void clearGroups() {
|
||||||
List<String> before = ImmutableList.copyOf(groups);
|
List<String> before = ImmutableList.copyOf(groups);
|
||||||
groups.clear();
|
groups.clear();
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackClear(this, before);
|
plugin.getEventFactory().handleTrackClear(this, before);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
|||||||
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
|
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
|
||||||
|
|
||||||
this.cachedData = new UserCachedData(this);
|
this.cachedData = new UserCachedData(this);
|
||||||
getPlugin().getApiProvider().getEventFactory().handleUserCacheLoad(this, cachedData);
|
getPlugin().getEventFactory().handleUserCacheLoad(this, cachedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(UUID uuid, String name, LuckPermsPlugin plugin) {
|
public User(UUID uuid, String name, LuckPermsPlugin plugin) {
|
||||||
@ -98,7 +98,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
|||||||
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
|
this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this);
|
||||||
|
|
||||||
this.cachedData = new UserCachedData(this);
|
this.cachedData = new UserCachedData(this);
|
||||||
getPlugin().getApiProvider().getEventFactory().handleUserCacheLoad(this, cachedData);
|
getPlugin().getEventFactory().handleUserCacheLoad(this, cachedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -192,7 +192,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
|||||||
return CompletableFuture.allOf(
|
return CompletableFuture.allOf(
|
||||||
cachedData.reloadPermissions(),
|
cachedData.reloadPermissions(),
|
||||||
cachedData.reloadMeta()
|
cachedData.reloadMeta()
|
||||||
).thenAccept(n -> getPlugin().getApiProvider().getEventFactory().handleUserDataRecalculate(this, cachedData));
|
).thenAccept(n -> getPlugin().getEventFactory().handleUserDataRecalculate(this, cachedData));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.common.plugin;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.platform.PlatformType;
|
import me.lucko.luckperms.api.platform.PlatformType;
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
@ -39,8 +39,8 @@ import me.lucko.luckperms.common.commands.utils.CommandUtils;
|
|||||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
||||||
|
import me.lucko.luckperms.common.event.EventFactory;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
|
||||||
import me.lucko.luckperms.common.logging.Logger;
|
import me.lucko.luckperms.common.logging.Logger;
|
||||||
import me.lucko.luckperms.common.managers.GroupManager;
|
import me.lucko.luckperms.common.managers.GroupManager;
|
||||||
import me.lucko.luckperms.common.managers.TrackManager;
|
import me.lucko.luckperms.common.managers.TrackManager;
|
||||||
@ -126,12 +126,19 @@ public interface LuckPermsPlugin {
|
|||||||
*/
|
*/
|
||||||
UuidCache getUuidCache();
|
UuidCache getUuidCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event factory
|
||||||
|
*
|
||||||
|
* @return the event factory
|
||||||
|
*/
|
||||||
|
EventFactory getEventFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the class implementing the LuckPermsAPI on this platform.
|
* Returns the class implementing the LuckPermsAPI on this platform.
|
||||||
*
|
*
|
||||||
* @return the api
|
* @return the api
|
||||||
*/
|
*/
|
||||||
ApiProvider getApiProvider();
|
LuckPermsApiProvider getApiProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the command manager
|
* Gets the command manager
|
||||||
@ -285,17 +292,6 @@ public interface LuckPermsPlugin {
|
|||||||
*/
|
*/
|
||||||
InputStream getResourceStream(String path);
|
InputStream getResourceStream(String path);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a colored string indicating the status of a player
|
|
||||||
*
|
|
||||||
* @param uuid The player's uuid
|
|
||||||
* @return a formatted status string
|
|
||||||
*/
|
|
||||||
default Message getPlayerStatus(UUID uuid) {
|
|
||||||
UUID external = getUuidCache().getExternalUUID(uuid);
|
|
||||||
return isPlayerOnline(external) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a player object linked to this User. The returned object must be the same type
|
* Gets a player object linked to this User. The returned object must be the same type
|
||||||
* as the instance used in the platforms {@link ContextManager}
|
* as the instance used in the platforms {@link ContextManager}
|
||||||
@ -398,13 +394,13 @@ public interface LuckPermsPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendStartupBanner(Sender sender, LuckPermsPlugin plugin) {
|
default void sendStartupBanner(Sender sender) {
|
||||||
sender.sendMessage(CommandUtils.color("&b __ &3 __ ___ __ __ "));
|
sender.sendMessage(CommandUtils.color("&b __ &3 __ ___ __ __ "));
|
||||||
sender.sendMessage(CommandUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
|
sender.sendMessage(CommandUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` "));
|
||||||
sender.sendMessage(CommandUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
|
sender.sendMessage(CommandUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ "));
|
||||||
sender.sendMessage(CommandUtils.color(" "));
|
sender.sendMessage(CommandUtils.color(" "));
|
||||||
sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + plugin.getVersion() + "&2 on " + plugin.getServerType().getFriendlyName() + " - " + plugin.getServerBrand()));
|
sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + getVersion() + "&2 on " + getServerType().getFriendlyName() + " - " + getServerBrand()));
|
||||||
sender.sendMessage(CommandUtils.color("&8 Running on server version " + plugin.getServerVersion()));
|
sender.sendMessage(CommandUtils.color("&8 Running on server version " + getServerVersion()));
|
||||||
sender.sendMessage(CommandUtils.color(" "));
|
sender.sendMessage(CommandUtils.color(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class AbstractStorage implements Storage {
|
|||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
User user = dao.loadUser(uuid, username);
|
User user = dao.loadUser(uuid, username);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
plugin.getApiProvider().getEventFactory().handleUserLoad(user);
|
plugin.getEventFactory().handleUserLoad(user);
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
@ -185,7 +185,7 @@ public class AbstractStorage implements Storage {
|
|||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
Group group = dao.createAndLoadGroup(name);
|
Group group = dao.createAndLoadGroup(name);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
plugin.getApiProvider().getEventFactory().handleGroupCreate(group, cause);
|
plugin.getEventFactory().handleGroupCreate(group, cause);
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
});
|
});
|
||||||
@ -196,7 +196,7 @@ public class AbstractStorage implements Storage {
|
|||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
Optional<Group> group = dao.loadGroup(name);
|
Optional<Group> group = dao.loadGroup(name);
|
||||||
if (group.isPresent()) {
|
if (group.isPresent()) {
|
||||||
plugin.getApiProvider().getEventFactory().handleGroupLoad(group.get());
|
plugin.getEventFactory().handleGroupLoad(group.get());
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
});
|
});
|
||||||
@ -206,7 +206,7 @@ public class AbstractStorage implements Storage {
|
|||||||
public CompletableFuture<Void> loadAllGroups() {
|
public CompletableFuture<Void> loadAllGroups() {
|
||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
dao.loadAllGroups();
|
dao.loadAllGroups();
|
||||||
plugin.getApiProvider().getEventFactory().handleGroupLoadAll();
|
plugin.getEventFactory().handleGroupLoadAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ public class AbstractStorage implements Storage {
|
|||||||
public CompletableFuture<Void> deleteGroup(Group group, DeletionCause cause) {
|
public CompletableFuture<Void> deleteGroup(Group group, DeletionCause cause) {
|
||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
dao.deleteGroup(group);
|
dao.deleteGroup(group);
|
||||||
plugin.getApiProvider().getEventFactory().handleGroupDelete(group, cause);
|
plugin.getEventFactory().handleGroupDelete(group, cause);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ public class AbstractStorage implements Storage {
|
|||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
Track track = dao.createAndLoadTrack(name);
|
Track track = dao.createAndLoadTrack(name);
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackCreate(track, cause);
|
plugin.getEventFactory().handleTrackCreate(track, cause);
|
||||||
}
|
}
|
||||||
return track;
|
return track;
|
||||||
});
|
});
|
||||||
@ -244,7 +244,7 @@ public class AbstractStorage implements Storage {
|
|||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
Optional<Track> track = dao.loadTrack(name);
|
Optional<Track> track = dao.loadTrack(name);
|
||||||
if (track.isPresent()) {
|
if (track.isPresent()) {
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackLoad(track.get());
|
plugin.getEventFactory().handleTrackLoad(track.get());
|
||||||
}
|
}
|
||||||
return track;
|
return track;
|
||||||
});
|
});
|
||||||
@ -254,7 +254,7 @@ public class AbstractStorage implements Storage {
|
|||||||
public CompletableFuture<Void> loadAllTracks() {
|
public CompletableFuture<Void> loadAllTracks() {
|
||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
dao.loadAllTracks();
|
dao.loadAllTracks();
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackLoadAll();
|
plugin.getEventFactory().handleTrackLoadAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ public class AbstractStorage implements Storage {
|
|||||||
public CompletableFuture<Void> deleteTrack(Track track, DeletionCause cause) {
|
public CompletableFuture<Void> deleteTrack(Track track, DeletionCause cause) {
|
||||||
return makeFuture(() -> {
|
return makeFuture(() -> {
|
||||||
dao.deleteTrack(track);
|
dao.deleteTrack(track);
|
||||||
plugin.getApiProvider().getEventFactory().handleTrackDelete(track, cause);
|
plugin.getEventFactory().handleTrackDelete(track, cause);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.storage;
|
package me.lucko.luckperms.common.storage;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@ -50,10 +50,12 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@UtilityClass
|
@AllArgsConstructor
|
||||||
public class StorageFactory {
|
public class StorageFactory {
|
||||||
|
|
||||||
public static Set<StorageType> getRequiredTypes(LuckPermsPlugin plugin, StorageType defaultMethod) {
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
|
public Set<StorageType> getRequiredTypes(StorageType defaultMethod) {
|
||||||
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
||||||
return plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS).entrySet().stream()
|
return plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS).entrySet().stream()
|
||||||
.map(e -> {
|
.map(e -> {
|
||||||
@ -77,7 +79,7 @@ public class StorageFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Storage getInstance(LuckPermsPlugin plugin, StorageType defaultMethod) {
|
public Storage getInstance(StorageType defaultMethod) {
|
||||||
Storage storage;
|
Storage storage;
|
||||||
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
||||||
plugin.getLog().info("Loading storage provider... [SPLIT STORAGE]");
|
plugin.getLog().info("Loading storage provider... [SPLIT STORAGE]");
|
||||||
@ -94,7 +96,7 @@ public class StorageFactory {
|
|||||||
|
|
||||||
Map<StorageType, AbstractDao> backing = mappedTypes.values().stream()
|
Map<StorageType, AbstractDao> backing = mappedTypes.values().stream()
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(ImmutableCollectors.toEnumMap(StorageType.class, e -> e, e -> makeDao(e, plugin)));
|
.collect(ImmutableCollectors.toEnumMap(StorageType.class, e -> e, this::makeDao));
|
||||||
|
|
||||||
storage = AbstractStorage.create(plugin, new SplitStorageDao(plugin, backing, mappedTypes));
|
storage = AbstractStorage.create(plugin, new SplitStorageDao(plugin, backing, mappedTypes));
|
||||||
|
|
||||||
@ -106,18 +108,18 @@ public class StorageFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLog().info("Loading storage provider... [" + type.name() + "]");
|
plugin.getLog().info("Loading storage provider... [" + type.name() + "]");
|
||||||
storage = makeInstance(type, plugin);
|
storage = makeInstance(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.init();
|
storage.init();
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Storage makeInstance(StorageType type, LuckPermsPlugin plugin) {
|
private Storage makeInstance(StorageType type) {
|
||||||
return AbstractStorage.create(plugin, makeDao(type, plugin));
|
return AbstractStorage.create(plugin, makeDao(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AbstractDao makeDao(StorageType method, LuckPermsPlugin plugin) {
|
private AbstractDao makeDao(StorageType method) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case MARIADB:
|
case MARIADB:
|
||||||
return new SqlDao(plugin, new MariaDbConnectionFactory(
|
return new SqlDao(plugin, new MariaDbConnectionFactory(
|
||||||
|
@ -54,7 +54,7 @@ public class UpdateTask implements Runnable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (plugin.getApiProvider().getEventFactory().handlePreSync(false)) {
|
if (plugin.getEventFactory().handlePreSync(false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +76,6 @@ public class UpdateTask implements Runnable {
|
|||||||
|
|
||||||
plugin.onPostUpdate();
|
plugin.onPostUpdate();
|
||||||
|
|
||||||
plugin.getApiProvider().getEventFactory().handlePostSync();
|
plugin.getEventFactory().handlePostSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class LoginHelper {
|
|||||||
cache.addToCache(u, uuid);
|
cache.addToCache(u, uuid);
|
||||||
} else {
|
} else {
|
||||||
// No previous data for this player
|
// No previous data for this player
|
||||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
plugin.getEventFactory().handleUserFirstLogin(u, username);
|
||||||
cache.addToCache(u, u);
|
cache.addToCache(u, u);
|
||||||
CompletableFuture<Void> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
CompletableFuture<Void> future = plugin.getStorage().noBuffer().saveUUIDData(u, username);
|
||||||
if (joinUuidSave) {
|
if (joinUuidSave) {
|
||||||
@ -61,7 +61,7 @@ public class LoginHelper {
|
|||||||
} else {
|
} else {
|
||||||
String name = plugin.getStorage().noBuffer().getName(u).join();
|
String name = plugin.getStorage().noBuffer().getName(u).join();
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
plugin.getEventFactory().handleUserFirstLogin(u, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Online mode, no cache needed. This is just for name -> uuid lookup.
|
// Online mode, no cache needed. This is just for name -> uuid lookup.
|
||||||
|
@ -33,8 +33,8 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.api.platform.PlatformType;
|
import me.lucko.luckperms.api.platform.PlatformType;
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiRegistrationUtil;
|
||||||
import me.lucko.luckperms.common.api.ApiSingletonUtils;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.backup.DummySender;
|
import me.lucko.luckperms.common.backup.DummySender;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
@ -49,6 +49,7 @@ import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
|||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
|
||||||
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
import me.lucko.luckperms.common.dependencies.DependencyManager;
|
||||||
|
import me.lucko.luckperms.common.event.EventFactory;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
import me.lucko.luckperms.common.locale.NoopLocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
import me.lucko.luckperms.common.locale.SimpleLocaleManager;
|
||||||
@ -108,7 +109,9 @@ import org.spongepowered.api.service.permission.PermissionService;
|
|||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.AbstractCollection;
|
import java.util.AbstractCollection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -145,7 +148,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ConfigDir(sharedRoot = false)
|
@ConfigDir(sharedRoot = false)
|
||||||
private Path configDir;
|
private Path configDirectory;
|
||||||
|
|
||||||
private Scheduler spongeScheduler = Sponge.getScheduler();
|
private Scheduler spongeScheduler = Sponge.getScheduler();
|
||||||
|
|
||||||
@ -173,7 +176,8 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
private FileWatcher fileWatcher = null;
|
private FileWatcher fileWatcher = null;
|
||||||
private ExtendedMessagingService messagingService = null;
|
private ExtendedMessagingService messagingService = null;
|
||||||
private UuidCache uuidCache;
|
private UuidCache uuidCache;
|
||||||
private ApiProvider apiProvider;
|
private LuckPermsApiProvider apiProvider;
|
||||||
|
private EventFactory eventFactory;
|
||||||
private me.lucko.luckperms.common.logging.Logger log;
|
private me.lucko.luckperms.common.logging.Logger log;
|
||||||
private LuckPermsService service;
|
private LuckPermsService service;
|
||||||
private LocaleManager localeManager;
|
private LocaleManager localeManager;
|
||||||
@ -197,16 +201,17 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
log = new SenderLogger(this, getConsoleSender());
|
log = new SenderLogger(this, getConsoleSender());
|
||||||
dependencyManager = new DependencyManager(this);
|
dependencyManager = new DependencyManager(this);
|
||||||
|
|
||||||
LuckPermsPlugin.sendStartupBanner(getConsoleSender(), this);
|
sendStartupBanner(getConsoleSender());
|
||||||
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
|
||||||
permissionVault = new PermissionVault(scheduler.async());
|
permissionVault = new PermissionVault(scheduler.async());
|
||||||
logDispatcher = new LogDispatcher(this);
|
logDispatcher = new LogDispatcher(this);
|
||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new AbstractConfiguration(this, new SpongeConfigAdapter(this));
|
configuration = new AbstractConfiguration(this, new SpongeConfigAdapter(this, resolveConfig("luckperms.conf")));
|
||||||
configuration.init();
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
StorageFactory storageFactory = new StorageFactory(this);
|
||||||
|
Set<StorageType> storageTypes = storageFactory.getRequiredTypes(StorageType.H2);
|
||||||
dependencyManager.loadStorageDependencies(storageTypes);
|
dependencyManager.loadStorageDependencies(storageTypes);
|
||||||
|
|
||||||
// register events
|
// register events
|
||||||
@ -219,7 +224,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialise datastore
|
// initialise datastore
|
||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = storageFactory.getInstance(StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
messagingService = new SpongeMessagingFactory(this).getInstance();
|
messagingService = new SpongeMessagingFactory(this).getInstance();
|
||||||
@ -265,8 +270,12 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
apiProvider = new ApiProvider(this);
|
apiProvider = new LuckPermsApiProvider(this);
|
||||||
ApiSingletonUtils.registerProvider(apiProvider);
|
|
||||||
|
// setup event factory
|
||||||
|
eventFactory = new EventFactory(this, apiProvider);
|
||||||
|
|
||||||
|
ApiRegistrationUtil.registerProvider(apiProvider);
|
||||||
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
@ -325,7 +334,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
messagingService.close();
|
messagingService.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiSingletonUtils.unregisterProvider();
|
ApiRegistrationUtil.unregisterProvider();
|
||||||
|
|
||||||
getLog().info("Shutting down internal scheduler...");
|
getLog().info("Shutting down internal scheduler...");
|
||||||
scheduler.shutdown();
|
scheduler.shutdown();
|
||||||
@ -343,6 +352,23 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
service.invalidateAllCaches(LPSubject.CacheLevel.PARENT);
|
service.invalidateAllCaches(LPSubject.CacheLevel.PARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Path resolveConfig(String file) {
|
||||||
|
Path path = configDirectory.resolve(file);
|
||||||
|
|
||||||
|
if (!Files.exists(path)) {
|
||||||
|
try {
|
||||||
|
Files.createDirectories(configDirectory);
|
||||||
|
try (InputStream is = getClass().getClassLoader().getResourceAsStream(file)) {
|
||||||
|
Files.copy(is, path);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ExtendedMessagingService> getMessagingService() {
|
public Optional<ExtendedMessagingService> getMessagingService() {
|
||||||
return Optional.ofNullable(messagingService);
|
return Optional.ofNullable(messagingService);
|
||||||
@ -354,15 +380,15 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getDataDirectory() {
|
public File getDataDirectory() {
|
||||||
File base = configDir.toFile().getParentFile().getParentFile();
|
File serverRoot = configDirectory.toFile().getParentFile().getParentFile();
|
||||||
File luckPermsDir = new File(base, "luckperms");
|
File dataDirectory = new File(serverRoot, "luckperms");
|
||||||
luckPermsDir.mkdirs();
|
dataDirectory.mkdirs();
|
||||||
return luckPermsDir;
|
return dataDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getConfigDirectory() {
|
public File getConfigDirectory() {
|
||||||
return configDir.toFile();
|
return configDirectory.toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,12 +25,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.sponge;
|
package me.lucko.luckperms.sponge;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
|
||||||
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
import ninja.leaping.configurate.SimpleConfigurationNode;
|
import ninja.leaping.configurate.SimpleConfigurationNode;
|
||||||
@ -38,48 +37,32 @@ import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
|||||||
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
||||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
public class SpongeConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter {
|
||||||
public class SpongeConfigAdapter implements ConfigurationAdapter {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final LPSpongePlugin plugin;
|
|
||||||
|
|
||||||
|
private final Path path;
|
||||||
private ConfigurationNode root;
|
private ConfigurationNode root;
|
||||||
|
|
||||||
private Path makeFile(Path file) throws IOException {
|
public SpongeConfigAdapter(LuckPermsPlugin plugin, Path path) {
|
||||||
File cfg = file.toFile();
|
super(plugin);
|
||||||
//noinspection ResultOfMethodCallIgnored
|
this.path = path;
|
||||||
cfg.getParentFile().mkdirs();
|
reload();
|
||||||
|
|
||||||
if (!cfg.exists()) {
|
|
||||||
try (InputStream is = plugin.getClass().getClassLoader().getResourceAsStream("luckperms.conf")) {
|
|
||||||
Files.copy(is, cfg.toPath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg.toPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void reload() {
|
||||||
try {
|
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setPath(path).build();
|
||||||
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder()
|
|
||||||
.setPath(makeFile(plugin.getConfigDir().resolve("luckperms.conf")))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
|
try {
|
||||||
root = loader.load();
|
root = loader.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class SpongeConnectionListener {
|
|||||||
- setting up cached data. */
|
- setting up cached data. */
|
||||||
try {
|
try {
|
||||||
User user = LoginHelper.loadUser(plugin, p.getUniqueId(), username, false);
|
User user = LoginHelper.loadUser(plugin, p.getUniqueId(), username, false);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
|
plugin.getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
|
plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user