mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Refactor config handling - towards #100
This commit is contained in:
parent
7430013cc3
commit
b7cf0e6bc7
@ -38,6 +38,7 @@ import me.lucko.luckperms.common.calculators.PermissionProcessor;
|
|||||||
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -57,10 +58,10 @@ public class BukkitCalculatorFactory extends AbstractCalculatorFactory {
|
|||||||
LPPermissible permissible = Injector.getPermissible(uuid);
|
LPPermissible permissible = Injector.getPermissible(uuid);
|
||||||
return permissible == null ? null : permissible.getAttachmentPermissions();
|
return permissible == null ? null : permissible.getAttachmentPermissions();
|
||||||
}));
|
}));
|
||||||
if (plugin.getConfiguration().isApplyingWildcards()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
|
||||||
processors.add(new WildcardProcessor());
|
processors.add(new WildcardProcessor());
|
||||||
}
|
}
|
||||||
if (plugin.getConfiguration().isApplyingRegex()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
|
||||||
processors.add(new RegexProcessor());
|
processors.add(new RegexProcessor());
|
||||||
}
|
}
|
||||||
processors.add(new DefaultsProcessor(contexts.isOp(), plugin.getDefaultsProvider()));
|
processors.add(new DefaultsProcessor(contexts.isOp(), plugin.getDefaultsProvider()));
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit;
|
package me.lucko.luckperms.bukkit;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -34,48 +36,45 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
class BukkitConfig extends AbstractConfiguration<LPBukkitPlugin> {
|
@RequiredArgsConstructor
|
||||||
|
public class BukkitConfig extends AbstractConfiguration {
|
||||||
|
private final LPBukkitPlugin plugin;
|
||||||
private YamlConfiguration configuration;
|
private YamlConfiguration configuration;
|
||||||
|
|
||||||
BukkitConfig(LPBukkitPlugin plugin) {
|
|
||||||
super(plugin, "global", true, "sqlite");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
public void init() {
|
||||||
File configFile = new File(getPlugin().getDataFolder(), "config.yml");
|
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||||
|
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
configFile.getParentFile().mkdirs();
|
configFile.getParentFile().mkdirs();
|
||||||
getPlugin().saveResource("config.yml", false);
|
plugin.saveResource("config.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration = YamlConfiguration.loadConfiguration(configFile);
|
configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getString(String path, String def) {
|
public String getString(String path, String def) {
|
||||||
return configuration.getString(path, def);
|
return configuration.getString(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInt(String path, int def) {
|
public int getInt(String path, int def) {
|
||||||
return configuration.getInt(path, def);
|
return configuration.getInt(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean getBoolean(String path, boolean def) {
|
public boolean getBoolean(String path, boolean def) {
|
||||||
return configuration.getBoolean(path, def);
|
return configuration.getBoolean(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getList(String path, List<String> def) {
|
public List<String> getList(String path, List<String> def) {
|
||||||
return Optional.ofNullable(configuration.getStringList(path)).orElse(def);
|
return Optional.ofNullable(configuration.getStringList(path)).orElse(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjectList(String path, List<String> def) {
|
public List<String> getObjectList(String path, List<String> def) {
|
||||||
ConfigurationSection section = configuration.getConfigurationSection(path);
|
ConfigurationSection section = configuration.getConfigurationSection(path);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return def;
|
return def;
|
||||||
@ -84,9 +83,8 @@ class BukkitConfig extends AbstractConfiguration<LPBukkitPlugin> {
|
|||||||
return Optional.ofNullable(section.getKeys(false).stream().collect(Collectors.toList())).orElse(def);
|
return Optional.ofNullable(section.getKeys(false).stream().collect(Collectors.toList())).orElse(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, String> getMap(String path, Map<String, String> def) {
|
public Map<String, String> getMap(String path, Map<String, String> def) {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
ConfigurationSection section = configuration.getConfigurationSection(path);
|
ConfigurationSection section = configuration.getConfigurationSection(path);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
|
@ -24,6 +24,7 @@ package me.lucko.luckperms.bukkit;
|
|||||||
|
|
||||||
import me.lucko.luckperms.bukkit.inject.Injector;
|
import me.lucko.luckperms.bukkit.inject.Injector;
|
||||||
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.utils.AbstractListener;
|
import me.lucko.luckperms.common.utils.AbstractListener;
|
||||||
@ -149,7 +150,7 @@ class BukkitListener extends AbstractListener implements Listener {
|
|||||||
Injector.unInject(player, true, true);
|
Injector.unInject(player, true, true);
|
||||||
|
|
||||||
// Handle auto op
|
// Handle auto op
|
||||||
if (plugin.getConfiguration().isAutoOp()) {
|
if (plugin.getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ class BukkitListener extends AbstractListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||||
if (plugin.getConfiguration().isOpsEnabled()) {
|
if (plugin.getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ import me.lucko.luckperms.common.api.ApiProvider;
|
|||||||
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;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
@ -153,6 +154,8 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new BukkitConfig(this);
|
configuration = new BukkitConfig(this);
|
||||||
|
configuration.init();
|
||||||
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
||||||
DependencyManager.loadDependencies(this, storageTypes);
|
DependencyManager.loadDependencies(this, storageTypes);
|
||||||
@ -195,11 +198,11 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise redis
|
// initialise redis
|
||||||
if (getConfiguration().isRedisEnabled()) {
|
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
getLog().info("Loading redis...");
|
getLog().info("Loading redis...");
|
||||||
redisMessaging = new RedisMessaging(this);
|
redisMessaging = new RedisMessaging(this);
|
||||||
try {
|
try {
|
||||||
redisMessaging.init(getConfiguration().getRedisAddress(), getConfiguration().getRedisPassword());
|
redisMessaging.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
||||||
getLog().info("Loaded redis successfully...");
|
getLog().info("Loaded redis successfully...");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLog().info("Couldn't load redis...");
|
getLog().info("Couldn't load redis...");
|
||||||
@ -238,7 +241,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// load internal managers
|
// load internal managers
|
||||||
getLog().info("Loading internal permission managers...");
|
getLog().info("Loading internal permission managers...");
|
||||||
uuidCache = new UuidCache(getConfiguration().isOnlineMode());
|
uuidCache = new UuidCache(this);
|
||||||
userManager = new GenericUserManager(this);
|
userManager = new GenericUserManager(this);
|
||||||
groupManager = new GenericGroupManager(this);
|
groupManager = new GenericGroupManager(this);
|
||||||
trackManager = new GenericTrackManager();
|
trackManager = new GenericTrackManager();
|
||||||
@ -250,7 +253,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
worldCalculator = new WorldCalculator(this);
|
worldCalculator = new WorldCalculator(this);
|
||||||
pm.registerEvents(worldCalculator, this);
|
pm.registerEvents(worldCalculator, this);
|
||||||
contextManager.registerCalculator(worldCalculator);
|
contextManager.registerCalculator(worldCalculator);
|
||||||
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration().getServer()));
|
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration()));
|
||||||
|
|
||||||
// Provide vault support
|
// Provide vault support
|
||||||
tryVaultHook(false);
|
tryVaultHook(false);
|
||||||
@ -263,7 +266,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
int mins = getConfiguration().getSyncTime();
|
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
||||||
if (mins > 0) {
|
if (mins > 0) {
|
||||||
long ticks = mins * 60 * 20;
|
long ticks = mins * 60 * 20;
|
||||||
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> updateTaskBuffer.request(), 40L, ticks);
|
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> updateTaskBuffer.request(), 40L, ticks);
|
||||||
@ -277,8 +280,8 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
getServer().getScheduler().runTaskTimerAsynchronously(this, new CacheHousekeepingTask(this), 2400L, 2400L);
|
getServer().getScheduler().runTaskTimerAsynchronously(this, new CacheHousekeepingTask(this), 2400L, 2400L);
|
||||||
|
|
||||||
// register permissions
|
// register permissions
|
||||||
registerPermissions(getConfiguration().isCommandsAllowOp() ? PermissionDefault.OP : PermissionDefault.FALSE);
|
registerPermissions(getConfiguration().get(ConfigKeys.COMMANDS_ALLOW_OP) ? PermissionDefault.OP : PermissionDefault.FALSE);
|
||||||
if (!getConfiguration().isOpsEnabled()) {
|
if (!getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
|
||||||
getServer().getScheduler().runTask(this, () -> getServer().getOperators().forEach(o -> o.setOp(false)));
|
getServer().getScheduler().runTask(this, () -> getServer().getOperators().forEach(o -> o.setOp(false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +327,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
Injector.unInject(player, false, false);
|
Injector.unInject(player, false, false);
|
||||||
if (getConfiguration().isAutoOp()) {
|
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +423,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshAutoOp(Player player) {
|
public void refreshAutoOp(Player player) {
|
||||||
if (getConfiguration().isAutoOp()) {
|
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||||
try {
|
try {
|
||||||
LPPermissible permissible = Injector.getPermissible(player.getUniqueId());
|
LPPermissible permissible = Injector.getPermissible(player.getUniqueId());
|
||||||
if (permissible == null) {
|
if (permissible == null) {
|
||||||
@ -492,11 +495,11 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
return new Contexts(
|
return new Contexts(
|
||||||
getContextManager().getApplicableContext(player),
|
getContextManager().getApplicableContext(player),
|
||||||
getConfiguration().isIncludingGlobalPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
getConfiguration().isIncludingGlobalWorldPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
getConfiguration().isApplyingGlobalGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
getConfiguration().isApplyingGlobalWorldGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
player.isOp()
|
player.isOp()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -537,14 +540,14 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
public Set<Contexts> getPreProcessContexts(boolean op) {
|
public Set<Contexts> getPreProcessContexts(boolean op) {
|
||||||
Set<ContextSet> c = new HashSet<>();
|
Set<ContextSet> c = new HashSet<>();
|
||||||
c.add(ContextSet.empty());
|
c.add(ContextSet.empty());
|
||||||
c.add(ContextSet.singleton("server", getConfiguration().getServer()));
|
c.add(ContextSet.singleton("server", getConfiguration().get(ConfigKeys.SERVER)));
|
||||||
|
|
||||||
// Pre process all worlds
|
// Pre process all worlds
|
||||||
c.addAll(getServer().getWorlds().stream()
|
c.addAll(getServer().getWorlds().stream()
|
||||||
.map(World::getName)
|
.map(World::getName)
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
MutableContextSet set = MutableContextSet.create();
|
MutableContextSet set = MutableContextSet.create();
|
||||||
set.add("server", getConfiguration().getServer());
|
set.add("server", getConfiguration().get(ConfigKeys.SERVER));
|
||||||
set.add("world", s);
|
set.add("world", s);
|
||||||
return set.makeImmutable();
|
return set.makeImmutable();
|
||||||
})
|
})
|
||||||
@ -552,13 +555,13 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Pre process the separate Vault server, if any
|
// Pre process the separate Vault server, if any
|
||||||
if (!getConfiguration().getServer().equals(getConfiguration().getVaultServer())) {
|
if (!getConfiguration().get(ConfigKeys.SERVER).equals(getConfiguration().get(ConfigKeys.VAULT_SERVER))) {
|
||||||
c.add(ContextSet.singleton("server", getConfiguration().getVaultServer()));
|
c.add(ContextSet.singleton("server", getConfiguration().get(ConfigKeys.VAULT_SERVER)));
|
||||||
c.addAll(getServer().getWorlds().stream()
|
c.addAll(getServer().getWorlds().stream()
|
||||||
.map(World::getName)
|
.map(World::getName)
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
MutableContextSet set = MutableContextSet.create();
|
MutableContextSet set = MutableContextSet.create();
|
||||||
set.add("server", getConfiguration().getVaultServer());
|
set.add("server", getConfiguration().get(ConfigKeys.VAULT_SERVER));
|
||||||
set.add("world", s);
|
set.add("world", s);
|
||||||
return set.makeImmutable();
|
return set.makeImmutable();
|
||||||
})
|
})
|
||||||
@ -572,25 +575,25 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
contexts.addAll(c.stream()
|
contexts.addAll(c.stream()
|
||||||
.map(set -> new Contexts(
|
.map(set -> new Contexts(
|
||||||
set,
|
set,
|
||||||
getConfiguration().isIncludingGlobalPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
getConfiguration().isIncludingGlobalWorldPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
getConfiguration().isApplyingGlobalGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
getConfiguration().isApplyingGlobalWorldGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
op
|
op
|
||||||
))
|
))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check for and include varying Vault config options
|
// Check for and include varying Vault config options
|
||||||
boolean vaultDiff = getConfiguration().isVaultIncludingGlobal() != getConfiguration().isIncludingGlobalPerms() ||
|
boolean vaultDiff = getConfiguration().get(ConfigKeys.VAULT_INCLUDING_GLOBAL) != getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS) ||
|
||||||
!getConfiguration().isIncludingGlobalWorldPerms() ||
|
!getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS) ||
|
||||||
!getConfiguration().isApplyingGlobalGroups() ||
|
!getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS) ||
|
||||||
!getConfiguration().isApplyingGlobalWorldGroups();
|
!getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS);
|
||||||
|
|
||||||
if (vaultDiff) {
|
if (vaultDiff) {
|
||||||
contexts.addAll(c.stream()
|
contexts.addAll(c.stream()
|
||||||
.map(map -> new Contexts(map, getConfiguration().isVaultIncludingGlobal(), true, true, true, true, op))
|
.map(map -> new Contexts(map, getConfiguration().get(ConfigKeys.VAULT_INCLUDING_GLOBAL), true, true, true, true, op))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -602,16 +605,16 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
public LinkedHashMap<String, Object> getExtraInfo() {
|
public LinkedHashMap<String, Object> getExtraInfo() {
|
||||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("Vault Enabled", vaultHook != null);
|
map.put("Vault Enabled", vaultHook != null);
|
||||||
map.put("Vault Server", configuration.getVaultServer());
|
map.put("Vault Server", configuration.get(ConfigKeys.VAULT_SERVER));
|
||||||
map.put("Bukkit Defaults count", defaultsProvider.size());
|
map.put("Bukkit Defaults count", defaultsProvider.size());
|
||||||
map.put("Bukkit Child Permissions count", childPermissionProvider.getPermissions().size());
|
map.put("Bukkit Child Permissions count", childPermissionProvider.getPermissions().size());
|
||||||
map.put("Vault Including Global", configuration.isVaultIncludingGlobal());
|
map.put("Vault Including Global", configuration.get(ConfigKeys.VAULT_INCLUDING_GLOBAL));
|
||||||
map.put("Vault Ignoring World", configuration.isVaultIgnoreWorld());
|
map.put("Vault Ignoring World", configuration.get(ConfigKeys.VAULT_IGNORE_WORLD));
|
||||||
map.put("Vault Primary Group Overrides", configuration.isVaultPrimaryGroupOverrides());
|
map.put("Vault Primary Group Overrides", configuration.get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES));
|
||||||
map.put("Vault Debug", configuration.isVaultDebug());
|
map.put("Vault Debug", configuration.get(ConfigKeys.VAULT_DEBUG));
|
||||||
map.put("OPs Enabled", configuration.isOpsEnabled());
|
map.put("OPs Enabled", configuration.get(ConfigKeys.OPS_ENABLED));
|
||||||
map.put("Auto OP", configuration.isAutoOp());
|
map.put("Auto OP", configuration.get(ConfigKeys.AUTO_OP));
|
||||||
map.put("Commands Allow OPs", configuration.isCommandsAllowOp());
|
map.put("Commands Allow OPs", configuration.get(ConfigKeys.COMMANDS_ALLOW_OP));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import com.google.common.collect.Maps;
|
|||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -64,6 +65,6 @@ public class WorldCalculator extends ContextCalculator<Player> implements Listen
|
|||||||
|
|
||||||
private String getWorld(Player player) {
|
private String getWorld(Player player) {
|
||||||
String world = player.getWorld().getName();
|
String world = player.getWorld().getName();
|
||||||
return plugin.getConfiguration().getWorldRewrites().getOrDefault(world, world);
|
return plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(world, world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import lombok.Setter;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -120,11 +121,11 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
public Contexts calculateContexts() {
|
public Contexts calculateContexts() {
|
||||||
return new Contexts(
|
return new Contexts(
|
||||||
plugin.getContextManager().getApplicableContext(parent),
|
plugin.getContextManager().getApplicableContext(parent),
|
||||||
plugin.getConfiguration().isIncludingGlobalPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
plugin.getConfiguration().isIncludingGlobalWorldPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
plugin.getConfiguration().isApplyingGlobalGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
plugin.getConfiguration().isApplyingGlobalWorldGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
parent.isOp()
|
parent.isOp()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.api.caching.PermissionData;
|
import me.lucko.luckperms.api.caching.PermissionData;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
@ -56,34 +57,17 @@ public class VaultPermissionHook extends Permission {
|
|||||||
|
|
||||||
private final String name = "LuckPerms";
|
private final String name = "LuckPerms";
|
||||||
|
|
||||||
private String server = "global";
|
private Function<String, String> WORLD_CORRECTION_FUNCTION = s -> isIgnoreWorld() ? null : s;
|
||||||
private boolean includeGlobal = true;
|
|
||||||
private boolean ignoreWorld = false;
|
|
||||||
private boolean pgo = false;
|
|
||||||
private boolean pgoCheckInherited = false;
|
|
||||||
private boolean pgoCheckExists = true;
|
|
||||||
private boolean pgoCheckMemberOf = true;
|
|
||||||
|
|
||||||
private Function<String, String> WORLD_CORRECTION_FUNCTION = s -> ignoreWorld ? null : s;
|
|
||||||
|
|
||||||
public VaultPermissionHook(LPBukkitPlugin plugin) {
|
public VaultPermissionHook(LPBukkitPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.scheduler = new VaultScheduler(plugin);
|
this.scheduler = new VaultScheduler(plugin);
|
||||||
|
|
||||||
super.plugin = plugin;
|
super.plugin = plugin;
|
||||||
|
|
||||||
// Config options
|
|
||||||
this.server = plugin.getConfiguration().getVaultServer();
|
|
||||||
this.includeGlobal = plugin.getConfiguration().isVaultIncludingGlobal();
|
|
||||||
this.ignoreWorld = plugin.getConfiguration().isVaultIgnoreWorld();
|
|
||||||
this.pgo = plugin.getConfiguration().isVaultPrimaryGroupOverrides();
|
|
||||||
this.pgoCheckInherited = plugin.getConfiguration().isVaultPrimaryGroupOverridesCheckInherited();
|
|
||||||
this.pgoCheckExists = plugin.getConfiguration().isVaultPrimaryGroupOverridesCheckExists();
|
|
||||||
this.pgoCheckMemberOf = plugin.getConfiguration().isVaultPrimaryGroupOverridesCheckMemberOf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String s) {
|
public void log(String s) {
|
||||||
if (plugin.getConfiguration().isVaultDebug()) {
|
if (plugin.getConfiguration().get(ConfigKeys.VAULT_DEBUG)) {
|
||||||
plugin.getLog().info("[VAULT] " + s);
|
plugin.getLog().info("[VAULT] " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,9 +93,9 @@ public class VaultPermissionHook extends Permission {
|
|||||||
return CompletableFuture.runAsync(() -> {
|
return CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
||||||
holder.setPermission(permission, true, server, world);
|
holder.setPermission(permission, true, getServer(), world);
|
||||||
} else {
|
} else {
|
||||||
holder.setPermission(permission, true, server);
|
holder.setPermission(permission, true, getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
save(holder);
|
save(holder);
|
||||||
@ -130,9 +114,9 @@ public class VaultPermissionHook extends Permission {
|
|||||||
return CompletableFuture.runAsync(() -> {
|
return CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
||||||
holder.unsetPermission(permission, server, world);
|
holder.unsetPermission(permission, getServer(), world);
|
||||||
} else {
|
} else {
|
||||||
holder.unsetPermission(permission, server);
|
holder.unsetPermission(permission, getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
save(holder);
|
save(holder);
|
||||||
@ -161,14 +145,14 @@ public class VaultPermissionHook extends Permission {
|
|||||||
if (world != null && !world.equals("")) {
|
if (world != null && !world.equals("")) {
|
||||||
context.put("world", world);
|
context.put("world", world);
|
||||||
}
|
}
|
||||||
context.put("server", server);
|
context.put("server", getServer());
|
||||||
return new Contexts(ContextSet.fromMap(context), isIncludeGlobal(), true, true, true, true, false);
|
return new Contexts(ContextSet.fromMap(context), isIncludeGlobal(), true, true, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(String world, @NonNull String player, @NonNull String permission) {
|
public boolean playerHas(String world, @NonNull String player, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Checking if player " + player + " has permission: " + permission + " on world " + world + ", server " + server);
|
log("Checking if player " + player + " has permission: " + permission + " on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
User user = plugin.getUserManager().getByUsername(player);
|
User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -184,7 +168,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean playerAdd(String world, @NonNull String player, @NonNull String permission) {
|
public boolean playerAdd(String world, @NonNull String player, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Adding permission to player " + player + ": '" + permission + "' on world " + world + ", server " + server);
|
log("Adding permission to player " + player + ": '" + permission + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getByUsername(player);
|
final User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -196,7 +180,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(String world, @NonNull String player, @NonNull String permission) {
|
public boolean playerRemove(String world, @NonNull String player, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Removing permission from player " + player + ": '" + permission + "' on world " + world + ", server " + server);
|
log("Removing permission from player " + player + ": '" + permission + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getByUsername(player);
|
final User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -208,7 +192,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean groupHas(String world, @NonNull String groupName, @NonNull String permission) {
|
public boolean groupHas(String world, @NonNull String groupName, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Checking if group " + groupName + " has permission: " + permission + " on world " + world + ", server " + server);
|
log("Checking if group " + groupName + " has permission: " + permission + " on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||||
if (group == null) return false;
|
if (group == null) return false;
|
||||||
@ -221,7 +205,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean groupAdd(String world, @NonNull String groupName, @NonNull String permission) {
|
public boolean groupAdd(String world, @NonNull String groupName, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Adding permission to group " + groupName + ": '" + permission + "' on world " + world + ", server " + server);
|
log("Adding permission to group " + groupName + ": '" + permission + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||||
if (group == null) return false;
|
if (group == null) return false;
|
||||||
@ -233,7 +217,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean groupRemove(String world, @NonNull String groupName, @NonNull String permission) {
|
public boolean groupRemove(String world, @NonNull String groupName, @NonNull String permission) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Removing permission from group " + groupName + ": '" + permission + "' on world " + world + ", server " + server);
|
log("Removing permission from group " + groupName + ": '" + permission + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
final Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||||
if (group == null) return false;
|
if (group == null) return false;
|
||||||
@ -245,7 +229,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, @NonNull String player, @NonNull String group) {
|
public boolean playerInGroup(String world, @NonNull String player, @NonNull String group) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Checking if player " + player + " is in group: " + group + " on world " + world + ", server " + server);
|
log("Checking if player " + player + " is in group: " + group + " on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getByUsername(player);
|
final User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -253,7 +237,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
String w = world; // screw effectively final
|
String w = world; // screw effectively final
|
||||||
return user.getNodes().stream()
|
return user.getNodes().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(n -> n.shouldApplyOnServer(server, isIncludeGlobal(), false))
|
.filter(n -> n.shouldApplyOnServer(getServer(), isIncludeGlobal(), false))
|
||||||
.filter(n -> n.shouldApplyOnWorld(w, true, false))
|
.filter(n -> n.shouldApplyOnWorld(w, true, false))
|
||||||
.map(Node::getGroupName)
|
.map(Node::getGroupName)
|
||||||
.anyMatch(s -> s.equalsIgnoreCase(group));
|
.anyMatch(s -> s.equalsIgnoreCase(group));
|
||||||
@ -262,7 +246,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean playerAddGroup(String world, @NonNull String player, @NonNull String groupName) {
|
public boolean playerAddGroup(String world, @NonNull String player, @NonNull String groupName) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Adding player " + player + " to group: '" + groupName + "' on world " + world + ", server " + server);
|
log("Adding player " + player + " to group: '" + groupName + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getByUsername(player);
|
final User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -274,9 +258,9 @@ public class VaultPermissionHook extends Permission {
|
|||||||
scheduler.execute(() -> {
|
scheduler.execute(() -> {
|
||||||
try {
|
try {
|
||||||
if (w != null && !w.equals("") && !w.equalsIgnoreCase("global")) {
|
if (w != null && !w.equals("") && !w.equalsIgnoreCase("global")) {
|
||||||
user.setInheritGroup(group, server, w);
|
user.setInheritGroup(group, getServer(), w);
|
||||||
} else {
|
} else {
|
||||||
user.setInheritGroup(group, server);
|
user.setInheritGroup(group, getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
save(user);
|
save(user);
|
||||||
@ -288,7 +272,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public boolean playerRemoveGroup(String world, @NonNull String player, @NonNull String groupName) {
|
public boolean playerRemoveGroup(String world, @NonNull String player, @NonNull String groupName) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Removing player " + player + " from group: '" + groupName + "' on world " + world + ", server " + server);
|
log("Removing player " + player + " from group: '" + groupName + "' on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getByUsername(player);
|
final User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
@ -300,9 +284,9 @@ public class VaultPermissionHook extends Permission {
|
|||||||
scheduler.execute(() -> {
|
scheduler.execute(() -> {
|
||||||
try {
|
try {
|
||||||
if (w != null && !w.equals("") && !w.equalsIgnoreCase("global")) {
|
if (w != null && !w.equals("") && !w.equalsIgnoreCase("global")) {
|
||||||
user.unsetInheritGroup(group, server, w);
|
user.unsetInheritGroup(group, getServer(), w);
|
||||||
} else {
|
} else {
|
||||||
user.unsetInheritGroup(group, server);
|
user.unsetInheritGroup(group, getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
save(user);
|
save(user);
|
||||||
@ -314,7 +298,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, @NonNull String player) {
|
public String[] getPlayerGroups(String world, @NonNull String player) {
|
||||||
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
world = WORLD_CORRECTION_FUNCTION.apply(world);
|
||||||
log("Getting groups of player: " + player + ", on world " + world + ", server " + server);
|
log("Getting groups of player: " + player + ", on world " + world + ", server " + getServer());
|
||||||
|
|
||||||
User user = plugin.getUserManager().getByUsername(player);
|
User user = plugin.getUserManager().getByUsername(player);
|
||||||
if (user == null) return new String[0];
|
if (user == null) return new String[0];
|
||||||
@ -322,7 +306,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
String w = world; // screw effectively final
|
String w = world; // screw effectively final
|
||||||
return user.getNodes().stream()
|
return user.getNodes().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(n -> n.shouldApplyOnServer(server, isIncludeGlobal(), false))
|
.filter(n -> n.shouldApplyOnServer(getServer(), isIncludeGlobal(), false))
|
||||||
.filter(n -> n.shouldApplyOnWorld(w, true, false))
|
.filter(n -> n.shouldApplyOnWorld(w, true, false))
|
||||||
.map(Node::getGroupName)
|
.map(Node::getGroupName)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
@ -338,12 +322,12 @@ public class VaultPermissionHook extends Permission {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pgo) {
|
if (!isPgo()) {
|
||||||
String g = user.getPrimaryGroup();
|
String g = user.getPrimaryGroup();
|
||||||
return plugin.getConfiguration().getGroupNameRewrites().getOrDefault(g, g);
|
return plugin.getConfiguration().get(ConfigKeys.GROUP_NAME_REWRITES).getOrDefault(g, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgoCheckInherited) {
|
if (isPgoCheckInherited()) {
|
||||||
PermissionData data = user.getUserData().getPermissionData(createContextForWorld(world));
|
PermissionData data = user.getUserData().getPermissionData(createContextForWorld(world));
|
||||||
for (Map.Entry<String, Boolean> e : data.getImmutableBacking().entrySet()) {
|
for (Map.Entry<String, Boolean> e : data.getImmutableBacking().entrySet()) {
|
||||||
if (!e.getValue()) {
|
if (!e.getValue()) {
|
||||||
@ -355,13 +339,13 @@ public class VaultPermissionHook extends Permission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String group = e.getKey().substring("vault.primarygroup.".length());
|
String group = e.getKey().substring("vault.primarygroup.".length());
|
||||||
if (pgoCheckExists) {
|
if (isPgoCheckExists()) {
|
||||||
if (!plugin.getGroupManager().isLoaded(group)) {
|
if (!plugin.getGroupManager().isLoaded(group)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgoCheckMemberOf) {
|
if (isPgoCheckMemberOf()) {
|
||||||
if (data.getPermissionValue("group." + group) != Tristate.TRUE) {
|
if (data.getPermissionValue("group." + group) != Tristate.TRUE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -379,7 +363,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.shouldApplyOnServer(server, isIncludeGlobal(), false)) {
|
if (!node.shouldApplyOnServer(getServer(), isIncludeGlobal(), false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,14 +372,14 @@ public class VaultPermissionHook extends Permission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String group = node.getPermission().substring("vault.primarygroup.".length());
|
String group = node.getPermission().substring("vault.primarygroup.".length());
|
||||||
if (pgoCheckExists) {
|
if (isPgoCheckExists()) {
|
||||||
if (!plugin.getGroupManager().isLoaded(group)) {
|
if (!plugin.getGroupManager().isLoaded(group)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgoCheckMemberOf) {
|
if (isPgoCheckMemberOf()) {
|
||||||
if (!user.getLocalGroups(server, world, isIncludeGlobal()).contains(group.toLowerCase())) {
|
if (!user.getLocalGroups(getServer(), world, isIncludeGlobal()).contains(group.toLowerCase())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,7 +390,7 @@ public class VaultPermissionHook extends Permission {
|
|||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
String g = user.getPrimaryGroup();
|
String g = user.getPrimaryGroup();
|
||||||
return plugin.getConfiguration().getGroupNameRewrites().getOrDefault(g, g);
|
return plugin.getConfiguration().get(ConfigKeys.GROUP_NAME_REWRITES).getOrDefault(g, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -418,4 +402,32 @@ public class VaultPermissionHook extends Permission {
|
|||||||
public boolean hasGroupSupport() {
|
public boolean hasGroupSupport() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServer() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_SERVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIncludeGlobal() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_INCLUDING_GLOBAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoreWorld() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_IGNORE_WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPgo() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPgoCheckInherited() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_INHERITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPgoCheckExists() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPgoCheckMemberOf() {
|
||||||
|
return plugin.getConfiguration().get(ConfigKeys.VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_MEMBER_OF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import me.lucko.luckperms.common.calculators.PermissionProcessor;
|
|||||||
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -43,10 +44,10 @@ public class BungeeCalculatorFactory extends AbstractCalculatorFactory {
|
|||||||
public PermissionCalculator build(Contexts contexts, User user) {
|
public PermissionCalculator build(Contexts contexts, User user) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
if (plugin.getConfiguration().isApplyingWildcards()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
|
||||||
processors.add(new WildcardProcessor());
|
processors.add(new WildcardProcessor());
|
||||||
}
|
}
|
||||||
if (plugin.getConfiguration().isApplyingRegex()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
|
||||||
processors.add(new RegexProcessor());
|
processors.add(new RegexProcessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class BungeeCommand extends Command implements TabExecutor {
|
|||||||
private final CommandManager manager;
|
private final CommandManager manager;
|
||||||
|
|
||||||
BungeeCommand(LPBungeePlugin plugin, CommandManager manager) {
|
BungeeCommand(LPBungeePlugin plugin, CommandManager manager) {
|
||||||
super("luckpermsbungee", null, "bperms", "lpb", "bpermissions", "bp", "bperm");
|
super("luckpermsbungee", null, "bperms", "lpb", "bpermissions", "bperm");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ class BungeeCommand extends Command implements TabExecutor {
|
|||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
manager.onCommand(
|
manager.onCommand(
|
||||||
plugin.getSenderFactory().wrap(sender),
|
plugin.getSenderFactory().wrap(sender),
|
||||||
"bperms",
|
"lpb",
|
||||||
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args)))
|
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bungee;
|
package me.lucko.luckperms.bungee;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
||||||
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
@ -38,20 +40,18 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
class BungeeConfig extends AbstractConfiguration<LPBungeePlugin> {
|
@RequiredArgsConstructor
|
||||||
|
public class BungeeConfig extends AbstractConfiguration {
|
||||||
|
private final LPBungeePlugin plugin;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
BungeeConfig(LPBungeePlugin plugin) {
|
|
||||||
super(plugin, "bungee", false, "flatfile");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
private File makeFile(String file) throws IOException {
|
private File makeFile(String file) throws IOException {
|
||||||
File cfg = new File(getPlugin().getDataFolder(), file);
|
File cfg = new File(plugin.getDataFolder(), file);
|
||||||
|
|
||||||
if (!cfg.exists()) {
|
if (!cfg.exists()) {
|
||||||
getPlugin().getDataFolder().mkdir();
|
plugin.getDataFolder().mkdir();
|
||||||
try (InputStream is = getPlugin().getResourceAsStream(file)) {
|
try (InputStream is = plugin.getResourceAsStream(file)) {
|
||||||
Files.copy(is, cfg.toPath());
|
Files.copy(is, cfg.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ class BungeeConfig extends AbstractConfiguration<LPBungeePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
public void init() {
|
||||||
try {
|
try {
|
||||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(makeFile("config.yml"));
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(makeFile("config.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -69,27 +69,27 @@ class BungeeConfig extends AbstractConfiguration<LPBungeePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getString(String path, String def) {
|
public String getString(String path, String def) {
|
||||||
return configuration.getString(path, def);
|
return configuration.getString(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInt(String path, int def) {
|
public int getInt(String path, int def) {
|
||||||
return configuration.getInt(path, def);
|
return configuration.getInt(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean getBoolean(String path, boolean def) {
|
public boolean getBoolean(String path, boolean def) {
|
||||||
return configuration.getBoolean(path, def);
|
return configuration.getBoolean(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getList(String path, List<String> def) {
|
public List<String> getList(String path, List<String> def) {
|
||||||
return Optional.ofNullable(configuration.getStringList(path)).orElse(def);
|
return Optional.ofNullable(configuration.getStringList(path)).orElse(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjectList(String path, List<String> def) {
|
public List<String> getObjectList(String path, List<String> def) {
|
||||||
Configuration section = configuration.getSection(path);
|
Configuration section = configuration.getSection(path);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return def;
|
return def;
|
||||||
@ -99,7 +99,7 @@ class BungeeConfig extends AbstractConfiguration<LPBungeePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, String> getMap(String path, Map<String, String> def) {
|
public Map<String, String> getMap(String path, Map<String, String> def) {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
Configuration section = configuration.getSection(path);
|
Configuration section = configuration.getSection(path);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
|
@ -24,6 +24,7 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.event.events.UserFirstLoginEvent;
|
import me.lucko.luckperms.api.event.events.UserFirstLoginEvent;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.core.UuidCache;
|
import me.lucko.luckperms.common.core.UuidCache;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
@ -75,11 +76,11 @@ public class BungeeListener extends AbstractListener implements Listener {
|
|||||||
|
|
||||||
Contexts contexts = new Contexts(
|
Contexts contexts = new Contexts(
|
||||||
plugin.getContextManager().getApplicableContext(player),
|
plugin.getContextManager().getApplicableContext(player),
|
||||||
plugin.getConfiguration().isIncludingGlobalPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
plugin.getConfiguration().isIncludingGlobalWorldPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
plugin.getConfiguration().isApplyingGlobalGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
plugin.getConfiguration().isApplyingGlobalWorldGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ public class BungeeListener extends AbstractListener implements Listener {
|
|||||||
final UuidCache cache = plugin.getUuidCache();
|
final UuidCache cache = plugin.getUuidCache();
|
||||||
final PendingConnection c = e.getConnection();
|
final PendingConnection c = e.getConnection();
|
||||||
|
|
||||||
if (!cache.isOnlineMode()) {
|
if (!plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) {
|
||||||
UUID uuid = plugin.getStorage().getUUID(c.getName()).join();
|
UUID uuid = plugin.getStorage().getUUID(c.getName()).join();
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
cache.addToCache(c.getUniqueId(), uuid);
|
cache.addToCache(c.getUniqueId(), uuid);
|
||||||
@ -126,7 +127,7 @@ public class BungeeListener extends AbstractListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
// Setup defaults for the user
|
// Setup defaults for the user
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
for (Rule rule : plugin.getConfiguration().getDefaultAssignments()) {
|
for (Rule rule : plugin.getConfiguration().get(ConfigKeys.DEFAULT_ASSIGNMENTS)) {
|
||||||
if (rule.apply(user)) {
|
if (rule.apply(user)) {
|
||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
|||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.commands.CommandManager;
|
import me.lucko.luckperms.common.commands.CommandManager;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
import me.lucko.luckperms.common.contexts.ServerCalculator;
|
||||||
@ -116,6 +117,8 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new BungeeConfig(this);
|
configuration = new BungeeConfig(this);
|
||||||
|
configuration.init();
|
||||||
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
||||||
DependencyManager.loadDependencies(this, storageTypes);
|
DependencyManager.loadDependencies(this, storageTypes);
|
||||||
@ -127,11 +130,11 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise redis
|
// initialise redis
|
||||||
if (getConfiguration().isRedisEnabled()) {
|
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
getLog().info("Loading redis...");
|
getLog().info("Loading redis...");
|
||||||
redisMessaging = new RedisMessaging(this);
|
redisMessaging = new RedisMessaging(this);
|
||||||
try {
|
try {
|
||||||
redisMessaging.init(getConfiguration().getRedisAddress(), getConfiguration().getRedisPassword());
|
redisMessaging.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
||||||
getLog().info("Loaded redis successfully...");
|
getLog().info("Loaded redis successfully...");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLog().info("Couldn't load redis...");
|
getLog().info("Couldn't load redis...");
|
||||||
@ -170,7 +173,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// load internal managers
|
// load internal managers
|
||||||
getLog().info("Loading internal permission managers...");
|
getLog().info("Loading internal permission managers...");
|
||||||
uuidCache = new UuidCache(getConfiguration().isOnlineMode());
|
uuidCache = new UuidCache(this);
|
||||||
userManager = new GenericUserManager(this);
|
userManager = new GenericUserManager(this);
|
||||||
groupManager = new GenericGroupManager(this);
|
groupManager = new GenericGroupManager(this);
|
||||||
trackManager = new GenericTrackManager();
|
trackManager = new GenericTrackManager();
|
||||||
@ -182,7 +185,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
BackendServerCalculator serverCalculator = new BackendServerCalculator();
|
BackendServerCalculator serverCalculator = new BackendServerCalculator();
|
||||||
getProxy().getPluginManager().registerListener(this, serverCalculator);
|
getProxy().getPluginManager().registerListener(this, serverCalculator);
|
||||||
contextManager.registerCalculator(serverCalculator);
|
contextManager.registerCalculator(serverCalculator);
|
||||||
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration().getServer()));
|
contextManager.registerCalculator(new ServerCalculator<>(configuration));
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
getLog().info("Registering API...");
|
getLog().info("Registering API...");
|
||||||
@ -190,7 +193,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
ApiHandler.registerProvider(apiProvider);
|
ApiHandler.registerProvider(apiProvider);
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
int mins = getConfiguration().getSyncTime();
|
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
||||||
if (mins > 0) {
|
if (mins > 0) {
|
||||||
getProxy().getScheduler().schedule(this, new UpdateTask(this), mins, mins, TimeUnit.MINUTES);
|
getProxy().getScheduler().schedule(this, new UpdateTask(this), mins, mins, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
@ -267,11 +270,11 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
return new Contexts(
|
return new Contexts(
|
||||||
getContextManager().getApplicableContext(player),
|
getContextManager().getApplicableContext(player),
|
||||||
getConfiguration().isIncludingGlobalPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
getConfiguration().isIncludingGlobalWorldPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
getConfiguration().isApplyingGlobalGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
getConfiguration().isApplyingGlobalWorldGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -312,12 +315,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
public Set<Contexts> getPreProcessContexts(boolean op) {
|
public Set<Contexts> getPreProcessContexts(boolean op) {
|
||||||
Set<ContextSet> c = new HashSet<>();
|
Set<ContextSet> c = new HashSet<>();
|
||||||
c.add(ContextSet.empty());
|
c.add(ContextSet.empty());
|
||||||
c.add(ContextSet.singleton("server", getConfiguration().getServer()));
|
c.add(ContextSet.singleton("server", getConfiguration().get(ConfigKeys.SERVER)));
|
||||||
c.addAll(getProxy().getServers().values().stream()
|
c.addAll(getProxy().getServers().values().stream()
|
||||||
.map(ServerInfo::getName)
|
.map(ServerInfo::getName)
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
MutableContextSet set = MutableContextSet.create();
|
MutableContextSet set = MutableContextSet.create();
|
||||||
set.add("server", getConfiguration().getServer());
|
set.add("server", getConfiguration().get(ConfigKeys.SERVER));
|
||||||
set.add("world", s);
|
set.add("world", s);
|
||||||
return set.makeImmutable();
|
return set.makeImmutable();
|
||||||
})
|
})
|
||||||
@ -327,11 +330,11 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
return c.stream()
|
return c.stream()
|
||||||
.map(set -> new Contexts(
|
.map(set -> new Contexts(
|
||||||
set,
|
set,
|
||||||
getConfiguration().isIncludingGlobalPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
getConfiguration().isIncludingGlobalWorldPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
getConfiguration().isApplyingGlobalGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
getConfiguration().isApplyingGlobalWorldGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
false
|
false
|
||||||
))
|
))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
@ -33,6 +33,7 @@ import me.lucko.luckperms.api.Track;
|
|||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.data.Callback;
|
import me.lucko.luckperms.api.data.Callback;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.storage.Storage;
|
import me.lucko.luckperms.common.storage.Storage;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -162,7 +163,7 @@ public class DatastoreDelegate implements Datastore {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteGroup(@NonNull Group group, Callback<Boolean> callback) {
|
public void deleteGroup(@NonNull Group group, Callback<Boolean> callback) {
|
||||||
checkGroup(group);
|
checkGroup(group);
|
||||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
registerCallback(master.force().deleteGroup(((GroupDelegate) group).getMaster()), callback);
|
registerCallback(master.force().deleteGroup(((GroupDelegate) group).getMaster()), callback);
|
||||||
@ -279,7 +280,7 @@ public class DatastoreDelegate implements Datastore {
|
|||||||
@Override
|
@Override
|
||||||
public boolean deleteGroup(@NonNull Group group) {
|
public boolean deleteGroup(@NonNull Group group) {
|
||||||
checkGroup(group);
|
checkGroup(group);
|
||||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
return master.force().deleteGroup(((GroupDelegate) group).getMaster()).join();
|
return master.force().deleteGroup(((GroupDelegate) group).getMaster()).join();
|
||||||
@ -392,7 +393,7 @@ public class DatastoreDelegate implements Datastore {
|
|||||||
@Override
|
@Override
|
||||||
public java.util.concurrent.Future<Boolean> deleteGroup(@NonNull Group group) {
|
public java.util.concurrent.Future<Boolean> deleteGroup(@NonNull Group group) {
|
||||||
checkGroup(group);
|
checkGroup(group);
|
||||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
return master.force().deleteGroup(((GroupDelegate) group).getMaster());
|
return master.force().deleteGroup(((GroupDelegate) group).getMaster());
|
||||||
|
@ -27,6 +27,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import me.lucko.luckperms.api.LPConfiguration;
|
import me.lucko.luckperms.api.LPConfiguration;
|
||||||
import me.lucko.luckperms.api.data.DatastoreConfiguration;
|
import me.lucko.luckperms.api.data.DatastoreConfiguration;
|
||||||
import me.lucko.luckperms.api.data.MySQLConfiguration;
|
import me.lucko.luckperms.api.data.MySQLConfiguration;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -39,67 +40,67 @@ public class LPConfigurationDelegate implements LPConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
return master.getServer();
|
return master.get(ConfigKeys.SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSyncTime() {
|
public int getSyncTime() {
|
||||||
return master.getSyncTime();
|
return master.get(ConfigKeys.SYNC_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultGroupNode() {
|
public String getDefaultGroupNode() {
|
||||||
return master.getDefaultGroupNode();
|
return master.get(ConfigKeys.DEFAULT_GROUP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultGroupName() {
|
public String getDefaultGroupName() {
|
||||||
return master.getDefaultGroupName();
|
return master.get(ConfigKeys.DEFAULT_GROUP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIncludeGlobalPerms() {
|
public boolean getIncludeGlobalPerms() {
|
||||||
return master.isIncludingGlobalPerms();
|
return master.get(ConfigKeys.INCLUDING_GLOBAL_PERMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIncludeGlobalWorldPerms() {
|
public boolean getIncludeGlobalWorldPerms() {
|
||||||
return master.isIncludingGlobalWorldPerms();
|
return master.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyGlobalGroups() {
|
public boolean getApplyGlobalGroups() {
|
||||||
return master.isApplyingGlobalGroups();
|
return master.get(ConfigKeys.APPLYING_GLOBAL_GROUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyGlobalWorldGroups() {
|
public boolean getApplyGlobalWorldGroups() {
|
||||||
return master.isApplyingGlobalWorldGroups();
|
return master.get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getOnlineMode() {
|
public boolean getOnlineMode() {
|
||||||
return master.isOnlineMode();
|
return master.get(ConfigKeys.ONLINE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyWildcards() {
|
public boolean getApplyWildcards() {
|
||||||
return master.isApplyingWildcards();
|
return master.get(ConfigKeys.APPLYING_WILDCARDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyRegex() {
|
public boolean getApplyRegex() {
|
||||||
return master.isApplyingRegex();
|
return master.get(ConfigKeys.APPLYING_REGEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyShorthand() {
|
public boolean getApplyShorthand() {
|
||||||
return master.isApplyingShorthand();
|
return master.get(ConfigKeys.APPLYING_SHORTHAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getLogNotify() {
|
public boolean getLogNotify() {
|
||||||
return master.isLogNotify();
|
return master.get(ConfigKeys.LOG_NOTIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,27 +110,27 @@ public class LPConfigurationDelegate implements LPConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEnableOps() {
|
public boolean getEnableOps() {
|
||||||
return master.isOpsEnabled();
|
return master.get(ConfigKeys.OPS_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getCommandsAllowOp() {
|
public boolean getCommandsAllowOp() {
|
||||||
return master.isCommandsAllowOp();
|
return master.get(ConfigKeys.COMMANDS_ALLOW_OP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAutoOp() {
|
public boolean getAutoOp() {
|
||||||
return master.isAutoOp();
|
return master.get(ConfigKeys.AUTO_OP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVaultServer() {
|
public String getVaultServer() {
|
||||||
return master.getVaultServer();
|
return master.get(ConfigKeys.VAULT_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getVaultIncludeGlobal() {
|
public boolean getVaultIncludeGlobal() {
|
||||||
return master.isVaultIncludingGlobal();
|
return master.get(ConfigKeys.VAULT_INCLUDING_GLOBAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -140,21 +141,21 @@ public class LPConfigurationDelegate implements LPConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatastoreConfiguration getDatastoreConfig() {
|
public DatastoreConfiguration getDatastoreConfig() {
|
||||||
return master.getDatabaseValues();
|
return master.get(ConfigKeys.DATABASE_VALUES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStorageMethod() {
|
public String getStorageMethod() {
|
||||||
return master.getStorageMethod();
|
return master.get(ConfigKeys.STORAGE_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getSplitStorage() {
|
public boolean getSplitStorage() {
|
||||||
return master.isSplitStorage();
|
return master.get(ConfigKeys.SPLIT_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getSplitStorageOptions() {
|
public Map<String, String> getSplitStorageOptions() {
|
||||||
return master.getSplitStorageOptions();
|
return master.get(ConfigKeys.SPLIT_STORAGE_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import me.lucko.luckperms.api.Storage;
|
|||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -134,7 +135,7 @@ public class StorageDelegate implements Storage {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> deleteGroup(Group group) {
|
public CompletableFuture<Boolean> deleteGroup(Group group) {
|
||||||
checkGroup(group);
|
checkGroup(group);
|
||||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
return master.force().deleteGroup(((GroupDelegate) group).getMaster());
|
return master.force().deleteGroup(((GroupDelegate) group).getMaster());
|
||||||
|
@ -27,6 +27,7 @@ import me.lucko.luckperms.common.commands.Arg;
|
|||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
@ -56,7 +57,7 @@ public class DeleteGroup extends SingleCommand {
|
|||||||
|
|
||||||
String groupName = args.get(0).toLowerCase();
|
String groupName = args.get(0).toLowerCase();
|
||||||
|
|
||||||
if (groupName.equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
if (groupName.equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
Message.DELETE_GROUP_ERROR_DEFAULT.send(sender);
|
Message.DELETE_GROUP_ERROR_DEFAULT.send(sender);
|
||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
@ -64,8 +65,8 @@ public class InfoCommand extends SingleCommand {
|
|||||||
plugin.getVersion(),
|
plugin.getVersion(),
|
||||||
plugin.getType().getFriendlyName(),
|
plugin.getType().getFriendlyName(),
|
||||||
plugin.getStorage().getName(),
|
plugin.getStorage().getName(),
|
||||||
c.getServer(),
|
c.get(ConfigKeys.SERVER),
|
||||||
c.getSyncTime(),
|
c.get(ConfigKeys.SYNC_TIME),
|
||||||
plugin.getPlayerCount(),
|
plugin.getPlayerCount(),
|
||||||
plugin.getUserManager().getAll().size(),
|
plugin.getUserManager().getAll().size(),
|
||||||
plugin.getGroupManager().getAll().size(),
|
plugin.getGroupManager().getAll().size(),
|
||||||
@ -75,15 +76,15 @@ public class InfoCommand extends SingleCommand {
|
|||||||
plugin.getLocaleManager().getSize(),
|
plugin.getLocaleManager().getSize(),
|
||||||
plugin.getPreProcessContexts(false).size(),
|
plugin.getPreProcessContexts(false).size(),
|
||||||
plugin.getContextManager().getCalculatorsSize(),
|
plugin.getContextManager().getCalculatorsSize(),
|
||||||
formatBoolean(c.isOnlineMode()),
|
formatBoolean(c.get(ConfigKeys.ONLINE_MODE)),
|
||||||
formatBoolean(c.isRedisEnabled()),
|
formatBoolean(c.get(ConfigKeys.REDIS_ENABLED)),
|
||||||
formatBoolean(c.isIncludingGlobalPerms()),
|
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_PERMS)),
|
||||||
formatBoolean(c.isIncludingGlobalWorldPerms()),
|
formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS)),
|
||||||
formatBoolean(c.isApplyingGlobalGroups()),
|
formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_GROUPS)),
|
||||||
formatBoolean(c.isApplyingGlobalWorldGroups()),
|
formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS)),
|
||||||
formatBoolean(c.isApplyingWildcards()),
|
formatBoolean(c.get(ConfigKeys.APPLYING_WILDCARDS)),
|
||||||
formatBoolean(c.isApplyingRegex()),
|
formatBoolean(c.get(ConfigKeys.APPLYING_REGEX)),
|
||||||
formatBoolean(c.isApplyingShorthand())
|
formatBoolean(c.get(ConfigKeys.APPLYING_SHORTHAND))
|
||||||
);
|
);
|
||||||
|
|
||||||
LinkedHashMap<String, Object> platformInfo = plugin.getExtraInfo();
|
LinkedHashMap<String, Object> platformInfo = plugin.getExtraInfo();
|
||||||
|
@ -50,7 +50,7 @@ public interface Sender {
|
|||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sender's unique id. See {@link Constants#getConsoleUUID()} for the console's UUID representation.
|
* Gets the sender's unique id. See {@link Constants#CONSOLE_UUID} for the console's UUID representation.
|
||||||
*
|
*
|
||||||
* @return the sender's uuid
|
* @return the sender's uuid
|
||||||
*/
|
*/
|
||||||
|
@ -22,168 +22,49 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.config;
|
package me.lucko.luckperms.common.config;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import lombok.Getter;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.util.concurrent.Futures;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import me.lucko.luckperms.common.config.keys.EnduringKey;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import java.util.Set;
|
||||||
import me.lucko.luckperms.common.constants.Patterns;
|
|
||||||
import me.lucko.luckperms.common.defaults.Rule;
|
|
||||||
import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
@SuppressWarnings("unchecked")
|
||||||
import java.util.Collections;
|
public abstract class AbstractConfiguration implements LPConfiguration {
|
||||||
import java.util.List;
|
private final LoadingCache<ConfigKey<?>, Object> cache = CacheBuilder.newBuilder()
|
||||||
import java.util.Map;
|
.build(new CacheLoader<ConfigKey<?>, Object>() {
|
||||||
|
@Override
|
||||||
|
public Object load(ConfigKey<?> key) {
|
||||||
|
return key.get(AbstractConfiguration.this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* A thread-safe config abstraction
|
public ListenableFuture<Object> reload(ConfigKey<?> key, Object oldValue) {
|
||||||
*
|
if (key instanceof EnduringKey) {
|
||||||
* @param <T> the plugin type
|
return Futures.immediateFuture(key);
|
||||||
*/
|
} else {
|
||||||
@Getter
|
return Futures.immediateFuture(key.get(AbstractConfiguration.this));
|
||||||
public abstract class AbstractConfiguration<T extends LuckPermsPlugin> implements LPConfiguration {
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Override
|
||||||
private final T plugin;
|
public <T> T get(ConfigKey<T> key) {
|
||||||
|
return (T) cache.getUnchecked(key);
|
||||||
|
}
|
||||||
|
|
||||||
// Values
|
@Override
|
||||||
private String server;
|
public void loadAll() {
|
||||||
private int syncTime;
|
ConfigKeys.getAllKeys().forEach(cache::getUnchecked);
|
||||||
private String defaultGroupNode;
|
}
|
||||||
private String defaultGroupName;
|
|
||||||
private boolean includingGlobalPerms;
|
|
||||||
private boolean includingGlobalWorldPerms;
|
|
||||||
private boolean applyingGlobalGroups;
|
|
||||||
private boolean applyingGlobalWorldGroups;
|
|
||||||
private boolean onlineMode;
|
|
||||||
private boolean applyingWildcards;
|
|
||||||
private boolean applyingRegex;
|
|
||||||
private boolean applyingShorthand;
|
|
||||||
private Map<String, Integer> groupWeights;
|
|
||||||
private boolean logNotify;
|
|
||||||
private boolean opsEnabled;
|
|
||||||
private boolean commandsAllowOp;
|
|
||||||
private boolean autoOp;
|
|
||||||
private String vaultServer;
|
|
||||||
private boolean vaultIncludingGlobal;
|
|
||||||
private boolean vaultIgnoreWorld;
|
|
||||||
private boolean vaultPrimaryGroupOverrides;
|
|
||||||
private boolean vaultPrimaryGroupOverridesCheckInherited;
|
|
||||||
private boolean vaultPrimaryGroupOverridesCheckExists;
|
|
||||||
private boolean vaultPrimaryGroupOverridesCheckMemberOf;
|
|
||||||
private boolean vaultDebug;
|
|
||||||
private Map<String, String> worldRewrites;
|
|
||||||
private Map<String, String> groupNameRewrites;
|
|
||||||
private List<Rule> defaultAssignments;
|
|
||||||
private DatastoreConfiguration databaseValues;
|
|
||||||
private String sqlTablePrefix;
|
|
||||||
private String storageMethod;
|
|
||||||
private boolean splitStorage;
|
|
||||||
private Map<String, String> splitStorageOptions;
|
|
||||||
private boolean redisEnabled;
|
|
||||||
private String redisAddress;
|
|
||||||
private String redisPassword;
|
|
||||||
|
|
||||||
public AbstractConfiguration(T plugin, String defaultServerName, boolean defaultIncludeGlobal, String defaultStorage) {
|
@Override
|
||||||
this.plugin = plugin;
|
public void reload() {
|
||||||
init();
|
init();
|
||||||
load(defaultServerName, defaultIncludeGlobal, defaultStorage);
|
Set<ConfigKey<?>> keys = cache.asMap().keySet();
|
||||||
}
|
keys.forEach(cache::refresh);
|
||||||
|
|
||||||
protected abstract void init();
|
|
||||||
|
|
||||||
protected abstract String getString(String path, String def);
|
|
||||||
|
|
||||||
protected abstract int getInt(String path, int def);
|
|
||||||
|
|
||||||
protected abstract boolean getBoolean(String path, boolean def);
|
|
||||||
|
|
||||||
protected abstract List<String> getList(String path, List<String> def);
|
|
||||||
|
|
||||||
protected abstract List<String> getObjectList(String path, List<String> def);
|
|
||||||
|
|
||||||
protected abstract Map<String, String> getMap(String path, Map<String, String> def);
|
|
||||||
|
|
||||||
public void load(String defaultServerName, boolean defaultIncludeGlobal, String defaultStorage) {
|
|
||||||
server = getString("server", defaultServerName);
|
|
||||||
syncTime = getInt("data.sync-minutes", 3);
|
|
||||||
defaultGroupNode = "group.default"; // constant since 2.6
|
|
||||||
defaultGroupName = "default"; // constant since 2.6
|
|
||||||
includingGlobalPerms = getBoolean("include-global", defaultIncludeGlobal);
|
|
||||||
includingGlobalWorldPerms = getBoolean("include-global-world", true);
|
|
||||||
applyingGlobalGroups = getBoolean("apply-global-groups", true);
|
|
||||||
applyingGlobalWorldGroups = getBoolean("apply-global-world-groups", true);
|
|
||||||
onlineMode = getBoolean("online-mode", true);
|
|
||||||
applyingWildcards = getBoolean("apply-wildcards", true);
|
|
||||||
applyingRegex = getBoolean("apply-regex", true);
|
|
||||||
applyingShorthand = getBoolean("apply-shorthand", true);
|
|
||||||
Map<String, String> weights = getMap("group-weight", Collections.emptyMap());
|
|
||||||
ImmutableMap.Builder<String, Integer> mb = ImmutableMap.builder();
|
|
||||||
for (Map.Entry<String, String> e : weights.entrySet()) {
|
|
||||||
try {
|
|
||||||
mb.put(e.getKey().toLowerCase(), Integer.parseInt(e.getValue()));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
groupWeights = mb.build();
|
|
||||||
logNotify = getBoolean("log-notify", true);
|
|
||||||
autoOp = getBoolean("auto-op", false);
|
|
||||||
opsEnabled = !isAutoOp() && getBoolean("enable-ops", true);
|
|
||||||
commandsAllowOp = getBoolean("commands-allow-op", true);
|
|
||||||
vaultServer = getString("vault-server", "global");
|
|
||||||
vaultIncludingGlobal = getBoolean("vault-include-global", true);
|
|
||||||
vaultIgnoreWorld = getBoolean("vault-ignore-world", false);
|
|
||||||
vaultPrimaryGroupOverrides = getBoolean("vault-primary-groups-overrides.enabled", false);
|
|
||||||
vaultPrimaryGroupOverridesCheckInherited = getBoolean("vault-primary-groups-overrides.check-inherited-permissions", false);
|
|
||||||
vaultPrimaryGroupOverridesCheckExists = getBoolean("vault-primary-groups-overrides.check-group-exists", true);
|
|
||||||
vaultPrimaryGroupOverridesCheckMemberOf = getBoolean("vault-primary-groups-overrides.check-user-member-of", true);
|
|
||||||
vaultDebug = getBoolean("vault-debug", false);
|
|
||||||
worldRewrites = ImmutableMap.copyOf(getMap("world-rewrite", Collections.emptyMap()));
|
|
||||||
groupNameRewrites = ImmutableMap.copyOf(getMap("group-name-rewrite", Collections.emptyMap()));
|
|
||||||
|
|
||||||
ImmutableList.Builder<Rule> defs = ImmutableList.builder();
|
|
||||||
List<String> ruleNames = getObjectList("default-assignments", new ArrayList<>());
|
|
||||||
for (String ruleName : ruleNames) {
|
|
||||||
String hasTrue = getString("default-assignments." + ruleName + ".if.has-true", null);
|
|
||||||
String hasFalse = getString("default-assignments." + ruleName + ".if.has-false", null);
|
|
||||||
String lacks = getString("default-assignments." + ruleName + ".if.lacks", null);
|
|
||||||
List<String> give = getList("default-assignments." + ruleName + ".give", new ArrayList<>());
|
|
||||||
List<String> take = getList("default-assignments." + ruleName + ".take", new ArrayList<>());
|
|
||||||
String pg = getString("default-assignments." + ruleName + ".set-primary-group", null);
|
|
||||||
defs.add(new Rule(hasTrue, hasFalse, lacks, give, take, pg));
|
|
||||||
}
|
|
||||||
defaultAssignments = defs.build();
|
|
||||||
|
|
||||||
databaseValues = new DatastoreConfiguration(
|
|
||||||
getString("data.address", null),
|
|
||||||
getString("data.database", null),
|
|
||||||
getString("data.username", null),
|
|
||||||
getString("data.password", null),
|
|
||||||
getInt("data.pool-size", 10)
|
|
||||||
);
|
|
||||||
sqlTablePrefix = getString("data.table_prefix", "luckperms_");
|
|
||||||
storageMethod = getString("storage-method", defaultStorage);
|
|
||||||
splitStorage = getBoolean("split-storage.enabled", false);
|
|
||||||
splitStorageOptions = ImmutableMap.<String, String>builder()
|
|
||||||
.put("user", getString("split-storage.methods.user", defaultStorage))
|
|
||||||
.put("group", getString("split-storage.methods.group", defaultStorage))
|
|
||||||
.put("track", getString("split-storage.methods.track", defaultStorage))
|
|
||||||
.put("uuid", getString("split-storage.methods.uuid", defaultStorage))
|
|
||||||
.put("log", getString("split-storage.methods.log", defaultStorage))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
redisEnabled = getBoolean("redis.enabled", false);
|
|
||||||
redisAddress = getString("redis.address", null);
|
|
||||||
redisPassword = getString("redis.password", "");
|
|
||||||
|
|
||||||
if (Patterns.NON_ALPHA_NUMERIC.matcher(getServer()).find()) {
|
|
||||||
plugin.getLog().severe("Server name defined in config.yml contains invalid characters. Server names can " +
|
|
||||||
"only contain alphanumeric characters.\nDefined server name '" + getServer() + "' will be replaced with '" +
|
|
||||||
defaultServerName + "' (the default)");
|
|
||||||
server = defaultServerName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public interface ConfigKey<T> {
|
||||||
|
|
||||||
|
T get(LPConfiguration config);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.keys.AbstractKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.BooleanKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.EnduringKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.IntegerKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.MapKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.StaticKey;
|
||||||
|
import me.lucko.luckperms.common.config.keys.StringKey;
|
||||||
|
import me.lucko.luckperms.common.defaults.Rule;
|
||||||
|
import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
||||||
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class ConfigKeys {
|
||||||
|
|
||||||
|
public static final ConfigKey<String> SERVER = StringKey.of("server", "global");
|
||||||
|
public static final ConfigKey<Integer> SYNC_TIME = EnduringKey.wrap(IntegerKey.of("data.sync-minutes", 3));
|
||||||
|
public static final ConfigKey<String> DEFAULT_GROUP_NODE = StaticKey.of("group.default"); // constant since 2.6
|
||||||
|
public static final ConfigKey<String> DEFAULT_GROUP_NAME = StaticKey.of("default"); // constant since 2.6
|
||||||
|
public static final ConfigKey<Boolean> INCLUDING_GLOBAL_PERMS = BooleanKey.of("include-global", true);
|
||||||
|
public static final ConfigKey<Boolean> INCLUDING_GLOBAL_WORLD_PERMS = BooleanKey.of("include-global-world", true);
|
||||||
|
public static final ConfigKey<Boolean> APPLYING_GLOBAL_GROUPS = BooleanKey.of("apply-global-groups", true);
|
||||||
|
public static final ConfigKey<Boolean> APPLYING_GLOBAL_WORLD_GROUPS = BooleanKey.of("apply-global-world-groups", true);
|
||||||
|
public static final ConfigKey<Boolean> ONLINE_MODE = BooleanKey.of("online-mode", true);
|
||||||
|
public static final ConfigKey<Boolean> APPLYING_WILDCARDS = EnduringKey.wrap(BooleanKey.of("apply-wildcards", true));
|
||||||
|
public static final ConfigKey<Boolean> APPLYING_REGEX = EnduringKey.wrap(BooleanKey.of("apply-regex", true));
|
||||||
|
public static final ConfigKey<Boolean> APPLYING_SHORTHAND = EnduringKey.wrap(BooleanKey.of("apply-shorthand", true));
|
||||||
|
public static final ConfigKey<Map<String, Integer>> GROUP_WEIGHTS = AbstractKey.of(c -> {
|
||||||
|
return c.getMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toImmutableMap(
|
||||||
|
e -> e.getKey().toLowerCase(),
|
||||||
|
e -> {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(e.getValue());
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
public static final ConfigKey<Boolean> LOG_NOTIFY = BooleanKey.of("log-notify", true);
|
||||||
|
public static final ConfigKey<Boolean> AUTO_OP = EnduringKey.wrap(BooleanKey.of("auto-op", false));
|
||||||
|
public static final ConfigKey<Boolean> OPS_ENABLED = EnduringKey.wrap(AbstractKey.of(c -> !AUTO_OP.get(c) && c.getBoolean("enable-ops", true)));
|
||||||
|
public static final ConfigKey<Boolean> COMMANDS_ALLOW_OP = EnduringKey.wrap(BooleanKey.of("commands-allow-op", true));
|
||||||
|
public static final ConfigKey<String> VAULT_SERVER = StringKey.of("vault-server", "global");
|
||||||
|
public static final ConfigKey<Boolean> VAULT_INCLUDING_GLOBAL = BooleanKey.of("vault-include-global", true);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_IGNORE_WORLD = BooleanKey.of("vault-ignore-world", false);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_PRIMARY_GROUP_OVERRIDES = BooleanKey.of("vault-primary-groups-overrides.enabled", false);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_INHERITED = BooleanKey.of("vault-primary-groups-overrides.check-inherited-permissions", false);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_EXISTS = BooleanKey.of("vault-primary-groups-overrides.check-group-exists", true);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_MEMBER_OF = BooleanKey.of("vault-primary-groups-overrides.check-user-member-of", true);
|
||||||
|
public static final ConfigKey<Boolean> VAULT_DEBUG = BooleanKey.of("vault-debug", false);
|
||||||
|
public static final ConfigKey<Map<String, String>> WORLD_REWRITES = MapKey.of("world-rewrite");
|
||||||
|
public static final ConfigKey<Map<String, String>> GROUP_NAME_REWRITES = MapKey.of("group-name-rewrite");
|
||||||
|
public static final ConfigKey<List<Rule>> DEFAULT_ASSIGNMENTS = AbstractKey.of(c -> {
|
||||||
|
return c.getObjectList("default-assignments", ImmutableList.of()).stream().map(name -> {
|
||||||
|
String hasTrue = c.getString("default-assignments." + name + ".if.has-true", null);
|
||||||
|
String hasFalse = c.getString("default-assignments." + name + ".if.has-false", null);
|
||||||
|
String lacks = c.getString("default-assignments." + name + ".if.lacks", null);
|
||||||
|
List<String> give = ImmutableList.copyOf(c.getList("default-assignments." + name + ".give", ImmutableList.of()));
|
||||||
|
List<String> take = ImmutableList.copyOf(c.getList("default-assignments." + name + ".take", ImmutableList.of()));
|
||||||
|
String pg = c.getString("default-assignments." + name + ".set-primary-group", null);
|
||||||
|
return new Rule(hasTrue, hasFalse, lacks, give, take, pg);
|
||||||
|
}).collect(ImmutableCollectors.toImmutableList());
|
||||||
|
});
|
||||||
|
public static final ConfigKey<DatastoreConfiguration> DATABASE_VALUES = EnduringKey.wrap(AbstractKey.of(c -> {
|
||||||
|
return new DatastoreConfiguration(
|
||||||
|
c.getString("data.address", null),
|
||||||
|
c.getString("data.database", null),
|
||||||
|
c.getString("data.username", null),
|
||||||
|
c.getString("data.password", null),
|
||||||
|
c.getInt("data.pool-size", 10)
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
public static final ConfigKey<String> SQL_TABLE_PREFIX = EnduringKey.wrap(StringKey.of("data.table_prefix", "luckperms_"));
|
||||||
|
public static final ConfigKey<String> STORAGE_METHOD = EnduringKey.wrap(StringKey.of("storage-method", "h2"));
|
||||||
|
public static final ConfigKey<Boolean> SPLIT_STORAGE = EnduringKey.wrap(BooleanKey.of("split-storage.enabled", false));
|
||||||
|
public static final ConfigKey<Map<String, String>> SPLIT_STORAGE_OPTIONS = EnduringKey.wrap(AbstractKey.of(c -> {
|
||||||
|
return ImmutableMap.<String, String>builder()
|
||||||
|
.put("user", c.getString("split-storage.methods.user", "h2"))
|
||||||
|
.put("group", c.getString("split-storage.methods.group", "h2"))
|
||||||
|
.put("track", c.getString("split-storage.methods.track", "h2"))
|
||||||
|
.put("uuid", c.getString("split-storage.methods.uuid", "h2"))
|
||||||
|
.put("log", c.getString("split-storage.methods.log", "h2"))
|
||||||
|
.build();
|
||||||
|
}));
|
||||||
|
public static final ConfigKey<Boolean> REDIS_ENABLED = EnduringKey.wrap(BooleanKey.of("redis.enabled", false));
|
||||||
|
public static final ConfigKey<String> REDIS_ADDRESS = EnduringKey.wrap(StringKey.of("redis.address", null));
|
||||||
|
public static final ConfigKey<String> REDIS_PASSWORD = EnduringKey.wrap(StringKey.of("redis.password", ""));
|
||||||
|
|
||||||
|
public static List<ConfigKey<?>> getAllKeys() {
|
||||||
|
return ImmutableList.<ConfigKey<?>>builder()
|
||||||
|
.add(SERVER)
|
||||||
|
.add(SYNC_TIME)
|
||||||
|
.add(DEFAULT_GROUP_NODE)
|
||||||
|
.add(DEFAULT_GROUP_NAME)
|
||||||
|
.add(INCLUDING_GLOBAL_PERMS)
|
||||||
|
.add(INCLUDING_GLOBAL_WORLD_PERMS)
|
||||||
|
.add(APPLYING_GLOBAL_GROUPS)
|
||||||
|
.add(APPLYING_GLOBAL_WORLD_GROUPS)
|
||||||
|
.add(ONLINE_MODE)
|
||||||
|
.add(APPLYING_WILDCARDS)
|
||||||
|
.add(APPLYING_REGEX)
|
||||||
|
.add(APPLYING_SHORTHAND)
|
||||||
|
.add(GROUP_WEIGHTS)
|
||||||
|
.add(LOG_NOTIFY)
|
||||||
|
.add(AUTO_OP)
|
||||||
|
.add(OPS_ENABLED)
|
||||||
|
.add(COMMANDS_ALLOW_OP)
|
||||||
|
.add(VAULT_SERVER)
|
||||||
|
.add(VAULT_INCLUDING_GLOBAL)
|
||||||
|
.add(VAULT_IGNORE_WORLD)
|
||||||
|
.add(VAULT_PRIMARY_GROUP_OVERRIDES)
|
||||||
|
.add(VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_INHERITED)
|
||||||
|
.add(VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_EXISTS)
|
||||||
|
.add(VAULT_PRIMARY_GROUP_OVERRIDES_CHECK_MEMBER_OF)
|
||||||
|
.add(VAULT_DEBUG)
|
||||||
|
.add(WORLD_REWRITES)
|
||||||
|
.add(GROUP_NAME_REWRITES)
|
||||||
|
.add(DEFAULT_ASSIGNMENTS)
|
||||||
|
.add(DATABASE_VALUES)
|
||||||
|
.add(SQL_TABLE_PREFIX)
|
||||||
|
.add(STORAGE_METHOD)
|
||||||
|
.add(SPLIT_STORAGE)
|
||||||
|
.add(SPLIT_STORAGE_OPTIONS)
|
||||||
|
.add(REDIS_ENABLED)
|
||||||
|
.add(REDIS_ADDRESS)
|
||||||
|
.add(REDIS_PASSWORD)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,94 +22,29 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.config;
|
package me.lucko.luckperms.common.config;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.defaults.Rule;
|
|
||||||
import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface LPConfiguration {
|
public interface LPConfiguration {
|
||||||
|
|
||||||
String getServer();
|
void init();
|
||||||
|
|
||||||
int getSyncTime();
|
void reload();
|
||||||
|
|
||||||
/**
|
void loadAll();
|
||||||
* As of 2.6, this value is a constant
|
|
||||||
*
|
|
||||||
* @return the default group node
|
|
||||||
*/
|
|
||||||
String getDefaultGroupNode();
|
|
||||||
|
|
||||||
/**
|
String getString(String path, String def);
|
||||||
* As of 2.6, this value is a constant
|
|
||||||
*
|
|
||||||
* @return the name of the default group
|
|
||||||
*/
|
|
||||||
String getDefaultGroupName();
|
|
||||||
|
|
||||||
boolean isIncludingGlobalPerms();
|
int getInt(String path, int def);
|
||||||
|
|
||||||
boolean isIncludingGlobalWorldPerms();
|
boolean getBoolean(String path, boolean def);
|
||||||
|
|
||||||
boolean isApplyingGlobalGroups();
|
List<String> getList(String path, List<String> def);
|
||||||
|
|
||||||
boolean isApplyingGlobalWorldGroups();
|
List<String> getObjectList(String path, List<String> def);
|
||||||
|
|
||||||
boolean isOnlineMode();
|
Map<String, String> getMap(String path, Map<String, String> def);
|
||||||
|
|
||||||
boolean isApplyingWildcards();
|
<T> T get(ConfigKey<T> key);
|
||||||
|
|
||||||
boolean isApplyingRegex();
|
|
||||||
|
|
||||||
boolean isApplyingShorthand();
|
|
||||||
|
|
||||||
Map<String, Integer> getGroupWeights();
|
|
||||||
|
|
||||||
boolean isLogNotify();
|
|
||||||
|
|
||||||
boolean isOpsEnabled();
|
|
||||||
|
|
||||||
boolean isCommandsAllowOp();
|
|
||||||
|
|
||||||
boolean isAutoOp();
|
|
||||||
|
|
||||||
String getVaultServer();
|
|
||||||
|
|
||||||
boolean isVaultIncludingGlobal();
|
|
||||||
|
|
||||||
boolean isVaultIgnoreWorld();
|
|
||||||
|
|
||||||
boolean isVaultPrimaryGroupOverrides();
|
|
||||||
|
|
||||||
boolean isVaultPrimaryGroupOverridesCheckInherited();
|
|
||||||
|
|
||||||
boolean isVaultPrimaryGroupOverridesCheckExists();
|
|
||||||
|
|
||||||
boolean isVaultPrimaryGroupOverridesCheckMemberOf();
|
|
||||||
|
|
||||||
boolean isVaultDebug();
|
|
||||||
|
|
||||||
Map<String, String> getWorldRewrites();
|
|
||||||
|
|
||||||
Map<String, String> getGroupNameRewrites();
|
|
||||||
|
|
||||||
List<Rule> getDefaultAssignments();
|
|
||||||
|
|
||||||
DatastoreConfiguration getDatabaseValues();
|
|
||||||
|
|
||||||
String getSqlTablePrefix();
|
|
||||||
|
|
||||||
String getStorageMethod();
|
|
||||||
|
|
||||||
boolean isSplitStorage();
|
|
||||||
|
|
||||||
Map<String, String> getSplitStorageOptions();
|
|
||||||
|
|
||||||
boolean isRedisEnabled();
|
|
||||||
|
|
||||||
String getRedisAddress();
|
|
||||||
|
|
||||||
String getRedisPassword();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class AbstractKey<T> implements ConfigKey<T> {
|
||||||
|
private final Function<LPConfiguration, T> function;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get(LPConfiguration config) {
|
||||||
|
return function.apply(config);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class BooleanKey implements ConfigKey<Boolean> {
|
||||||
|
private final String path;
|
||||||
|
private final boolean def;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean get(LPConfiguration config) {
|
||||||
|
return config.getBoolean(path, def);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.Delegate;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper class to mark a config key as enduring (doesn't change in the event of a reload)
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor(staticName = "wrap")
|
||||||
|
public class EnduringKey<T> implements ConfigKey<T> {
|
||||||
|
|
||||||
|
@Delegate
|
||||||
|
private final ConfigKey<T> delegate;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class IntegerKey implements ConfigKey<Integer> {
|
||||||
|
private final String path;
|
||||||
|
private final int def;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer get(LPConfiguration config) {
|
||||||
|
return config.getInt(path, def);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class MapKey implements ConfigKey<Map<String, String>> {
|
||||||
|
private final String path;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> get(LPConfiguration config) {
|
||||||
|
return ImmutableMap.copyOf(config.getMap(path, ImmutableMap.of()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class StaticKey<T> implements ConfigKey<T> {
|
||||||
|
private final T val;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get(LPConfiguration config) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||||
|
*
|
||||||
|
* 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.keys;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
|
@AllArgsConstructor(staticName = "of")
|
||||||
|
public class StringKey implements ConfigKey<String> {
|
||||||
|
private final String path;
|
||||||
|
private final String def;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(LPConfiguration config) {
|
||||||
|
return config.getString(path, def);
|
||||||
|
}
|
||||||
|
}
|
@ -28,21 +28,23 @@ import com.google.common.collect.Maps;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ServerCalculator<T> extends ContextCalculator<T> {
|
public class ServerCalculator<T> extends ContextCalculator<T> {
|
||||||
private final String server;
|
private final LPConfiguration config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator) {
|
public MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator) {
|
||||||
accumulator.add(Maps.immutableEntry("server", server));
|
accumulator.add(Maps.immutableEntry("server", config.get(ConfigKeys.SERVER)));
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isContextApplicable(T subject, Map.Entry<String, String> context) {
|
public boolean isContextApplicable(T subject, Map.Entry<String, String> context) {
|
||||||
return context.getKey().equals("server") && server.equalsIgnoreCase(context.getValue());
|
return context.getKey().equals("server") && config.get(ConfigKeys.SERVER).equalsIgnoreCase(context.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,52 +22,47 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.core;
|
package me.lucko.luckperms.common.core;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see me.lucko.luckperms.api.UuidCache for docs
|
* @see me.lucko.luckperms.api.UuidCache for docs
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class UuidCache {
|
public class UuidCache {
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final boolean onlineMode;
|
|
||||||
// External UUID --> Internal UUID
|
// External UUID --> Internal UUID
|
||||||
private BiMap<UUID, UUID> cache;
|
private final BiMap<UUID, UUID> cache = Maps.synchronizedBiMap(HashBiMap.create());
|
||||||
|
|
||||||
public UuidCache(boolean onlineMode) {
|
|
||||||
this.onlineMode = onlineMode;
|
|
||||||
|
|
||||||
if (!onlineMode) {
|
|
||||||
cache = Maps.synchronizedBiMap(HashBiMap.create());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUUID(UUID external) {
|
public UUID getUUID(UUID external) {
|
||||||
return onlineMode ? external : cache.getOrDefault(external, external);
|
return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? external : cache.getOrDefault(external, external);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getExternalUUID(UUID internal) {
|
public UUID getExternalUUID(UUID internal) {
|
||||||
return onlineMode ? internal : cache.inverse().getOrDefault(internal, internal);
|
return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? internal : cache.inverse().getOrDefault(internal, internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToCache(UUID external, UUID internal) {
|
public void addToCache(UUID external, UUID internal) {
|
||||||
if (onlineMode) return;
|
if (plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) return;
|
||||||
cache.forcePut(external, internal);
|
cache.forcePut(external, internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCache(UUID external) {
|
public void clearCache(UUID external) {
|
||||||
if (onlineMode) return;
|
if (plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) return;
|
||||||
cache.remove(external);
|
cache.remove(external);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return onlineMode ? 0 : cache.size();
|
return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? 0 : cache.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import lombok.ToString;
|
|||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.caching.handlers.GroupReference;
|
import me.lucko.luckperms.common.caching.handlers.GroupReference;
|
||||||
import me.lucko.luckperms.common.caching.handlers.HolderReference;
|
import me.lucko.luckperms.common.caching.handlers.HolderReference;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.utils.Identifiable;
|
import me.lucko.luckperms.common.utils.Identifiable;
|
||||||
|
|
||||||
@ToString(of = {"name"})
|
@ToString(of = {"name"})
|
||||||
@ -52,7 +53,7 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getRawDisplayName() {
|
public String getRawDisplayName() {
|
||||||
return getPlugin().getConfiguration().getGroupNameRewrites().getOrDefault(name, name);
|
return getPlugin().getConfiguration().get(ConfigKeys.GROUP_NAME_REWRITES).getOrDefault(name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
|
@ -54,6 +54,7 @@ import me.lucko.luckperms.common.caching.handlers.HolderReference;
|
|||||||
import me.lucko.luckperms.common.caching.holder.ExportNodesHolder;
|
import me.lucko.luckperms.common.caching.holder.ExportNodesHolder;
|
||||||
import me.lucko.luckperms.common.caching.holder.GetAllNodesRequest;
|
import me.lucko.luckperms.common.caching.holder.GetAllNodesRequest;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.InheritanceInfo;
|
import me.lucko.luckperms.common.core.InheritanceInfo;
|
||||||
import me.lucko.luckperms.common.core.NodeBuilder;
|
import me.lucko.luckperms.common.core.NodeBuilder;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
@ -281,8 +282,8 @@ public abstract class PermissionHolder {
|
|||||||
.map(LocalizedNode::getNode)
|
.map(LocalizedNode::getNode)
|
||||||
.filter(Node::getValue)
|
.filter(Node::getValue)
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
.filter(n -> n.shouldApplyOnServer(server, context.isApplyGlobalGroups(), plugin.getConfiguration().isApplyingRegex()))
|
.filter(n -> n.shouldApplyOnServer(server, context.isApplyGlobalGroups(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)))
|
||||||
.filter(n -> n.shouldApplyOnWorld(world, context.isApplyGlobalWorldGroups(), plugin.getConfiguration().isApplyingRegex()))
|
.filter(n -> n.shouldApplyOnWorld(world, context.isApplyGlobalWorldGroups(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)))
|
||||||
.filter(n -> n.shouldApplyWithContext(contexts.getContextSet(), false))
|
.filter(n -> n.shouldApplyWithContext(contexts.getContextSet(), false))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
@ -329,8 +330,8 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
allNodes.removeIf(node ->
|
allNodes.removeIf(node ->
|
||||||
!node.isGroupNode() && (
|
!node.isGroupNode() && (
|
||||||
!node.shouldApplyOnServer(server, context.isIncludeGlobal(), plugin.getConfiguration().isApplyingRegex()) ||
|
!node.shouldApplyOnServer(server, context.isIncludeGlobal(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ||
|
||||||
!node.shouldApplyOnWorld(world, context.isIncludeGlobalWorld(), plugin.getConfiguration().isApplyingRegex()) ||
|
!node.shouldApplyOnWorld(world, context.isIncludeGlobalWorld(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ||
|
||||||
!node.shouldApplyWithContext(contexts.getContextSet(), false)
|
!node.shouldApplyWithContext(contexts.getContextSet(), false)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -363,7 +364,7 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
perms.put(lowerCase ? node.getPermission().toLowerCase() : node.getPermission(), node.getValue());
|
perms.put(lowerCase ? node.getPermission().toLowerCase() : node.getPermission(), node.getValue());
|
||||||
|
|
||||||
if (plugin.getConfiguration().isApplyingShorthand()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND)) {
|
||||||
List<String> sh = node.resolveShorthand();
|
List<String> sh = node.resolveShorthand();
|
||||||
if (!sh.isEmpty()) {
|
if (!sh.isEmpty()) {
|
||||||
sh.stream().map(s -> lowerCase ? s.toLowerCase() : s)
|
sh.stream().map(s -> lowerCase ? s.toLowerCase() : s)
|
||||||
@ -499,8 +500,8 @@ public abstract class PermissionHolder {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
parents.removeIf(node ->
|
parents.removeIf(node ->
|
||||||
!node.shouldApplyOnServer(server, context.isApplyGlobalGroups(), plugin.getConfiguration().isApplyingRegex()) ||
|
!node.shouldApplyOnServer(server, context.isApplyGlobalGroups(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ||
|
||||||
!node.shouldApplyOnWorld(world, context.isApplyGlobalWorldGroups(), plugin.getConfiguration().isApplyingRegex()) ||
|
!node.shouldApplyOnWorld(world, context.isApplyGlobalWorldGroups(), plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ||
|
||||||
!node.shouldApplyWithContext(contexts.getContextSet(), false)
|
!node.shouldApplyWithContext(contexts.getContextSet(), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1099,7 +1100,7 @@ public abstract class PermissionHolder {
|
|||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
if (!weight.isPresent()) {
|
if (!weight.isPresent()) {
|
||||||
Integer w = plugin.getConfiguration().getGroupWeights().get(getObjectName().toLowerCase());
|
Integer w = plugin.getConfiguration().get(ConfigKeys.GROUP_WEIGHTS).get(getObjectName().toLowerCase());
|
||||||
if (w != null) {
|
if (w != null) {
|
||||||
weight = OptionalInt.of(w);
|
weight = OptionalInt.of(w);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ package me.lucko.luckperms.common.data;
|
|||||||
import me.lucko.luckperms.api.event.events.LogNotifyEvent;
|
import me.lucko.luckperms.api.event.events.LogNotifyEvent;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
@ -51,7 +52,7 @@ public class LogEntry extends me.lucko.luckperms.api.LogEntry {
|
|||||||
plugin.getStorage().logAction(this);
|
plugin.getStorage().logAction(this);
|
||||||
|
|
||||||
LogNotifyEvent event = new LogNotifyEvent(this);
|
LogNotifyEvent event = new LogNotifyEvent(this);
|
||||||
event.setCancelled(!plugin.getConfiguration().isLogNotify());
|
event.setCancelled(!plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY));
|
||||||
plugin.getApiProvider().fireEvent(event);
|
plugin.getApiProvider().fireEvent(event);
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.google.common.collect.Maps;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.storage.StorageType;
|
import me.lucko.luckperms.common.storage.StorageType;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -73,7 +74,7 @@ public class DependencyManager {
|
|||||||
dependencies.addAll(STORAGE_DEPENDENCIES.get(storageType));
|
dependencies.addAll(STORAGE_DEPENDENCIES.get(storageType));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getConfiguration().isRedisEnabled()) {
|
if (plugin.getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
dependencies.add(Dependency.APACHE_COMMONS_POOL);
|
dependencies.add(Dependency.APACHE_COMMONS_POOL);
|
||||||
dependencies.add(Dependency.JEDIS);
|
dependencies.add(Dependency.JEDIS);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import lombok.experimental.UtilityClass;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.storage.backing.AbstractBacking;
|
import me.lucko.luckperms.common.storage.backing.AbstractBacking;
|
||||||
import me.lucko.luckperms.common.storage.backing.JSONBacking;
|
import me.lucko.luckperms.common.storage.backing.JSONBacking;
|
||||||
import me.lucko.luckperms.common.storage.backing.MongoDBBacking;
|
import me.lucko.luckperms.common.storage.backing.MongoDBBacking;
|
||||||
@ -49,10 +50,10 @@ public class StorageFactory {
|
|||||||
|
|
||||||
public static Set<StorageType> getRequiredTypes(LuckPermsPlugin plugin, StorageType defaultMethod) {
|
public static Set<StorageType> getRequiredTypes(LuckPermsPlugin plugin, StorageType defaultMethod) {
|
||||||
plugin.getLog().info("Detecting storage method...");
|
plugin.getLog().info("Detecting storage method...");
|
||||||
if (plugin.getConfiguration().isSplitStorage()) {
|
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
||||||
plugin.getLog().info("Loading split storage options.");
|
plugin.getLog().info("Loading split storage options.");
|
||||||
|
|
||||||
Map<String, String> types = new HashMap<>(plugin.getConfiguration().getSplitStorageOptions());
|
Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS));
|
||||||
types.entrySet().stream()
|
types.entrySet().stream()
|
||||||
.filter(e -> StorageType.parse(e.getValue()) == null)
|
.filter(e -> StorageType.parse(e.getValue()) == null)
|
||||||
.forEach(e -> {
|
.forEach(e -> {
|
||||||
@ -66,7 +67,7 @@ public class StorageFactory {
|
|||||||
|
|
||||||
return neededTypes.stream().map(StorageType::parse).collect(ImmutableCollectors.toImmutableSet());
|
return neededTypes.stream().map(StorageType::parse).collect(ImmutableCollectors.toImmutableSet());
|
||||||
} else {
|
} else {
|
||||||
String method = plugin.getConfiguration().getStorageMethod();
|
String method = plugin.getConfiguration().get(ConfigKeys.STORAGE_METHOD);
|
||||||
StorageType type = StorageType.parse(method);
|
StorageType type = StorageType.parse(method);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
plugin.getLog().severe("Storage method '" + method + "' not recognised. Using the default instead.");
|
plugin.getLog().severe("Storage method '" + method + "' not recognised. Using the default instead.");
|
||||||
@ -80,10 +81,10 @@ public class StorageFactory {
|
|||||||
Storage storage;
|
Storage storage;
|
||||||
|
|
||||||
plugin.getLog().info("Initializing storage backings...");
|
plugin.getLog().info("Initializing storage backings...");
|
||||||
if (plugin.getConfiguration().isSplitStorage()) {
|
if (plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE)) {
|
||||||
plugin.getLog().info("Using split storage.");
|
plugin.getLog().info("Using split storage.");
|
||||||
|
|
||||||
Map<String, String> types = new HashMap<>(plugin.getConfiguration().getSplitStorageOptions());
|
Map<String, String> types = new HashMap<>(plugin.getConfiguration().get(ConfigKeys.SPLIT_STORAGE_OPTIONS));
|
||||||
types.entrySet().stream()
|
types.entrySet().stream()
|
||||||
.filter(e -> StorageType.parse(e.getValue()) == null)
|
.filter(e -> StorageType.parse(e.getValue()) == null)
|
||||||
.forEach(e -> e.setValue(defaultMethod.getIdentifiers().get(0)));
|
.forEach(e -> e.setValue(defaultMethod.getIdentifiers().get(0)));
|
||||||
@ -100,7 +101,7 @@ public class StorageFactory {
|
|||||||
storage = AbstractStorage.wrap(plugin, new SplitBacking(plugin, backing, types));
|
storage = AbstractStorage.wrap(plugin, new SplitBacking(plugin, backing, types));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String method = plugin.getConfiguration().getStorageMethod().toLowerCase();
|
String method = plugin.getConfiguration().get(ConfigKeys.STORAGE_METHOD);
|
||||||
StorageType type = StorageType.parse(method);
|
StorageType type = StorageType.parse(method);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = defaultMethod;
|
type = defaultMethod;
|
||||||
@ -121,15 +122,15 @@ public class StorageFactory {
|
|||||||
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
|
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case MYSQL:
|
case MYSQL:
|
||||||
return new SQLBacking(plugin, new MySQLProvider(plugin.getConfiguration().getDatabaseValues()), plugin.getConfiguration().getSqlTablePrefix());
|
return new SQLBacking(plugin, new MySQLProvider(plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
|
||||||
case SQLITE:
|
case SQLITE:
|
||||||
return new SQLBacking(plugin, new SQLiteProvider(new File(plugin.getDataFolder(), "luckperms.sqlite")), plugin.getConfiguration().getSqlTablePrefix());
|
return new SQLBacking(plugin, new SQLiteProvider(new File(plugin.getDataFolder(), "luckperms.sqlite")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
|
||||||
case H2:
|
case H2:
|
||||||
return new SQLBacking(plugin, new H2Provider(new File(plugin.getDataFolder(), "luckperms.db")), plugin.getConfiguration().getSqlTablePrefix());
|
return new SQLBacking(plugin, new H2Provider(new File(plugin.getDataFolder(), "luckperms.db")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
|
||||||
case POSTGRESQL:
|
case POSTGRESQL:
|
||||||
return new SQLBacking(plugin, new PostgreSQLProvider(plugin.getConfiguration().getDatabaseValues()), plugin.getConfiguration().getSqlTablePrefix());
|
return new SQLBacking(plugin, new PostgreSQLProvider(plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
|
||||||
case MONGODB:
|
case MONGODB:
|
||||||
return new MongoDBBacking(plugin, plugin.getConfiguration().getDatabaseValues());
|
return new MongoDBBacking(plugin, plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES));
|
||||||
case YAML:
|
case YAML:
|
||||||
return new YAMLBacking(plugin, plugin.getDataFolder());
|
return new YAMLBacking(plugin, plugin.getDataFolder());
|
||||||
default:
|
default:
|
||||||
|
@ -27,6 +27,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import me.lucko.luckperms.api.event.events.PostSyncEvent;
|
import me.lucko.luckperms.api.event.events.PostSyncEvent;
|
||||||
import me.lucko.luckperms.api.event.events.PreSyncEvent;
|
import me.lucko.luckperms.api.event.events.PreSyncEvent;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UpdateTask implements Runnable {
|
public class UpdateTask implements Runnable {
|
||||||
@ -43,7 +44,7 @@ public class UpdateTask implements Runnable {
|
|||||||
|
|
||||||
// Reload all groups
|
// Reload all groups
|
||||||
plugin.getStorage().loadAllGroups().join();
|
plugin.getStorage().loadAllGroups().join();
|
||||||
String defaultGroup = plugin.getConfiguration().getDefaultGroupName();
|
String defaultGroup = plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME);
|
||||||
if (!plugin.getGroupManager().isLoaded(defaultGroup)) {
|
if (!plugin.getGroupManager().isLoaded(defaultGroup)) {
|
||||||
plugin.getStorage().createAndLoadGroup(defaultGroup).join();
|
plugin.getStorage().createAndLoadGroup(defaultGroup).join();
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import lombok.AllArgsConstructor;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.event.events.UserFirstLoginEvent;
|
import me.lucko.luckperms.api.event.events.UserFirstLoginEvent;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.UuidCache;
|
import me.lucko.luckperms.common.core.UuidCache;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.defaults.Rule;
|
import me.lucko.luckperms.common.defaults.Rule;
|
||||||
@ -43,7 +44,7 @@ public class AbstractListener {
|
|||||||
final long startTime = System.currentTimeMillis();
|
final long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
final UuidCache cache = plugin.getUuidCache();
|
final UuidCache cache = plugin.getUuidCache();
|
||||||
if (!cache.isOnlineMode()) {
|
if (!plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) {
|
||||||
UUID uuid = plugin.getStorage().force().getUUID(username).join();
|
UUID uuid = plugin.getStorage().force().getUUID(username).join();
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
cache.addToCache(u, uuid);
|
cache.addToCache(u, uuid);
|
||||||
@ -70,7 +71,7 @@ public class AbstractListener {
|
|||||||
} else {
|
} else {
|
||||||
// Setup defaults for the user
|
// Setup defaults for the user
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
for (Rule rule : plugin.getConfiguration().getDefaultAssignments()) {
|
for (Rule rule : plugin.getConfiguration().get(ConfigKeys.DEFAULT_ASSIGNMENTS)) {
|
||||||
if (rule.apply(user)) {
|
if (rule.apply(user)) {
|
||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
|||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.commands.BaseCommand;
|
import me.lucko.luckperms.common.commands.BaseCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LPConfiguration;
|
import me.lucko.luckperms.common.config.LPConfiguration;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
@ -172,6 +173,8 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new SpongeConfig(this);
|
configuration = new SpongeConfig(this);
|
||||||
|
configuration.init();
|
||||||
|
configuration.loadAll();
|
||||||
|
|
||||||
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
Set<StorageType> storageTypes = StorageFactory.getRequiredTypes(this, StorageType.H2);
|
||||||
DependencyManager.loadDependencies(this, storageTypes);
|
DependencyManager.loadDependencies(this, storageTypes);
|
||||||
@ -183,11 +186,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise redis
|
// initialise redis
|
||||||
if (getConfiguration().isRedisEnabled()) {
|
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
getLog().info("Loading redis...");
|
getLog().info("Loading redis...");
|
||||||
redisMessaging = new RedisMessaging(this);
|
redisMessaging = new RedisMessaging(this);
|
||||||
try {
|
try {
|
||||||
redisMessaging.init(getConfiguration().getRedisAddress(), getConfiguration().getRedisPassword());
|
redisMessaging.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
||||||
getLog().info("Loaded redis successfully...");
|
getLog().info("Loaded redis successfully...");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLog().info("Couldn't load redis...");
|
getLog().info("Couldn't load redis...");
|
||||||
@ -225,7 +228,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// load internal managers
|
// load internal managers
|
||||||
getLog().info("Loading internal permission managers...");
|
getLog().info("Loading internal permission managers...");
|
||||||
uuidCache = new UuidCache(getConfiguration().isOnlineMode());
|
uuidCache = new UuidCache(this);
|
||||||
userManager = new SpongeUserManager(this);
|
userManager = new SpongeUserManager(this);
|
||||||
groupManager = new SpongeGroupManager(this);
|
groupManager = new SpongeGroupManager(this);
|
||||||
trackManager = new GenericTrackManager();
|
trackManager = new GenericTrackManager();
|
||||||
@ -234,7 +237,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
cachedStateManager = new CachedStateManager(this);
|
cachedStateManager = new CachedStateManager(this);
|
||||||
|
|
||||||
contextManager = new ContextManager<>();
|
contextManager = new ContextManager<>();
|
||||||
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration().getServer()));
|
contextManager.registerCalculator(new ServerCalculator<>(configuration));
|
||||||
contextManager.registerCalculator(new WorldCalculator(this));
|
contextManager.registerCalculator(new WorldCalculator(this));
|
||||||
|
|
||||||
// register the PermissionService with Sponge
|
// register the PermissionService with Sponge
|
||||||
@ -256,7 +259,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
int mins = getConfiguration().getSyncTime();
|
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
||||||
if (mins > 0) {
|
if (mins > 0) {
|
||||||
Task t = scheduler.createTaskBuilder().async().interval(mins, TimeUnit.MINUTES).execute(new UpdateTask(this))
|
Task t = scheduler.createTaskBuilder().async().interval(mins, TimeUnit.MINUTES).execute(new UpdateTask(this))
|
||||||
.submit(LPSpongePlugin.this);
|
.submit(LPSpongePlugin.this);
|
||||||
@ -367,11 +370,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
}
|
}
|
||||||
return new Contexts(
|
return new Contexts(
|
||||||
getContextManager().getApplicableContext(player),
|
getContextManager().getApplicableContext(player),
|
||||||
getConfiguration().isIncludingGlobalPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
getConfiguration().isIncludingGlobalWorldPerms(),
|
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
getConfiguration().isApplyingGlobalGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
getConfiguration().isApplyingGlobalWorldGroups(),
|
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import me.lucko.luckperms.common.calculators.PermissionProcessor;
|
|||||||
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
import me.lucko.luckperms.common.calculators.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
import me.lucko.luckperms.common.calculators.processors.RegexProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
import me.lucko.luckperms.common.calculators.processors.WildcardProcessor;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.sponge.calculators.DefaultsProcessor;
|
import me.lucko.luckperms.sponge.calculators.DefaultsProcessor;
|
||||||
import me.lucko.luckperms.sponge.calculators.SpongeWildcardProcessor;
|
import me.lucko.luckperms.sponge.calculators.SpongeWildcardProcessor;
|
||||||
@ -45,11 +46,11 @@ public class SpongeCalculatorFactory extends AbstractCalculatorFactory {
|
|||||||
public PermissionCalculator build(Contexts contexts, User user) {
|
public PermissionCalculator build(Contexts contexts, User user) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
if (plugin.getConfiguration().isApplyingWildcards()) {
|
|
||||||
processors.add(new SpongeWildcardProcessor());
|
processors.add(new SpongeWildcardProcessor());
|
||||||
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
|
||||||
processors.add(new WildcardProcessor());
|
processors.add(new WildcardProcessor());
|
||||||
}
|
}
|
||||||
if (plugin.getConfiguration().isApplyingRegex()) {
|
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
|
||||||
processors.add(new RegexProcessor());
|
processors.add(new RegexProcessor());
|
||||||
}
|
}
|
||||||
processors.add(new DefaultsProcessor(plugin.getService(), contexts.getContexts()));
|
processors.add(new DefaultsProcessor(plugin.getService(), contexts.getContexts()));
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.sponge;
|
package me.lucko.luckperms.sponge;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
||||||
@ -41,20 +43,18 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
|
@RequiredArgsConstructor
|
||||||
|
public class SpongeConfig extends AbstractConfiguration {
|
||||||
|
private final LPSpongePlugin plugin;
|
||||||
private ConfigurationNode root;
|
private ConfigurationNode root;
|
||||||
|
|
||||||
SpongeConfig(LPSpongePlugin plugin) {
|
|
||||||
super(plugin, "global", true, "sqlite");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
private Path makeFile(Path file) throws IOException {
|
private Path makeFile(Path file) throws IOException {
|
||||||
File cfg = file.toFile();
|
File cfg = file.toFile();
|
||||||
cfg.getParentFile().mkdirs();
|
cfg.getParentFile().mkdirs();
|
||||||
|
|
||||||
if (!cfg.exists()) {
|
if (!cfg.exists()) {
|
||||||
try (InputStream is = getPlugin().getClass().getClassLoader().getResourceAsStream("luckperms.conf")) {
|
try (InputStream is = plugin.getClass().getClassLoader().getResourceAsStream("luckperms.conf")) {
|
||||||
Files.copy(is, cfg.toPath());
|
Files.copy(is, cfg.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,10 +63,10 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
public void init() {
|
||||||
try {
|
try {
|
||||||
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder()
|
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder()
|
||||||
.setPath(makeFile(getPlugin().getConfigDir().resolve("luckperms.conf")))
|
.setPath(makeFile(plugin.getConfigDir().resolve("luckperms.conf")))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
root = loader.load();
|
root = loader.load();
|
||||||
@ -87,22 +87,22 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getString(String path, String def) {
|
public String getString(String path, String def) {
|
||||||
return getNode(path).getString(def);
|
return getNode(path).getString(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInt(String path, int def) {
|
public int getInt(String path, int def) {
|
||||||
return getNode(path).getInt(def);
|
return getNode(path).getInt(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean getBoolean(String path, boolean def) {
|
public boolean getBoolean(String path, boolean def) {
|
||||||
return getNode(path).getBoolean(def);
|
return getNode(path).getBoolean(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getList(String path, List<String> def) {
|
public List<String> getList(String path, List<String> def) {
|
||||||
ConfigurationNode node = getNode(path);
|
ConfigurationNode node = getNode(path);
|
||||||
if (node.isVirtual()) {
|
if (node.isVirtual()) {
|
||||||
return def;
|
return def;
|
||||||
@ -112,7 +112,7 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getObjectList(String path, List<String> def) {
|
public List<String> getObjectList(String path, List<String> def) {
|
||||||
ConfigurationNode node = getNode(path);
|
ConfigurationNode node = getNode(path);
|
||||||
if (node.isVirtual()) {
|
if (node.isVirtual()) {
|
||||||
return def;
|
return def;
|
||||||
@ -123,7 +123,7 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, String> getMap(String path, Map<String, String> def) {
|
public Map<String, String> getMap(String path, Map<String, String> def) {
|
||||||
ConfigurationNode node = getNode(path);
|
ConfigurationNode node = getNode(path);
|
||||||
if (node.isVirtual()) {
|
if (node.isVirtual()) {
|
||||||
return def;
|
return def;
|
||||||
|
@ -45,6 +45,7 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.caching.UserCache;
|
import me.lucko.luckperms.common.caching.UserCache;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
@ -255,11 +256,11 @@ public class LuckPermsService implements PermissionService {
|
|||||||
public Contexts calculateContexts(ContextSet contextSet) {
|
public Contexts calculateContexts(ContextSet contextSet) {
|
||||||
return new Contexts(
|
return new Contexts(
|
||||||
contextSet,
|
contextSet,
|
||||||
plugin.getConfiguration().isIncludingGlobalPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
plugin.getConfiguration().isIncludingGlobalWorldPerms(),
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
true,
|
true,
|
||||||
plugin.getConfiguration().isApplyingGlobalGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
plugin.getConfiguration().isApplyingGlobalWorldGroups(),
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user