Refactor config keys

This commit is contained in:
Luck 2018-09-05 20:49:37 +01:00
parent b7f8ca6658
commit eca6b09b18
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
22 changed files with 392 additions and 582 deletions

View File

@ -1,3 +1,28 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.api; package me.lucko.luckperms.api;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.bukkit; package me.lucko.luckperms.bukkit;
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -39,13 +38,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter { public class BukkitConfigAdapter implements ConfigurationAdapter {
private final LuckPermsPlugin plugin;
private final File file; private final File file;
private YamlConfiguration configuration; private YamlConfiguration configuration;
public BukkitConfigAdapter(LuckPermsPlugin plugin, File file) { public BukkitConfigAdapter(LuckPermsPlugin plugin, File file) {
super(plugin); this.plugin = plugin;
this.file = file; this.file = file;
reload(); reload();
} }
@ -61,7 +60,7 @@ public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public int getInt(String path, int def) { public int getInteger(String path, int def) {
return this.configuration.getInt(path, def); return this.configuration.getInt(path, def);
} }
@ -71,7 +70,7 @@ public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public List<String> getList(String path, List<String> def) { public List<String> getStringList(String path, List<String> def) {
List<String> ret = this.configuration.getStringList(path); List<String> ret = this.configuration.getStringList(path);
return ret == null ? def : ret; return ret == null ? def : ret;
} }
@ -88,7 +87,7 @@ public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public Map<String, String> getMap(String path, Map<String, String> def) { public Map<String, String> getStringMap(String path, Map<String, String> def) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
ConfigurationSection section = this.configuration.getConfigurationSection(path); ConfigurationSection section = this.configuration.getConfigurationSection(path);
if (section == null) { if (section == null) {
@ -101,4 +100,9 @@ public class BukkitConfigAdapter extends AbstractConfigurationAdapter implements
return map; return map;
} }
@Override
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
} }

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.bungee; package me.lucko.luckperms.bungee;
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -41,13 +40,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter { public class BungeeConfigAdapter implements ConfigurationAdapter {
private final LuckPermsPlugin plugin;
private final File file; private final File file;
private Configuration configuration; private Configuration configuration;
public BungeeConfigAdapter(LuckPermsPlugin plugin, File file) { public BungeeConfigAdapter(LuckPermsPlugin plugin, File file) {
super(plugin); this.plugin = plugin;
this.file = file; this.file = file;
reload(); reload();
} }
@ -67,7 +66,7 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public int getInt(String path, int def) { public int getInteger(String path, int def) {
return this.configuration.getInt(path, def); return this.configuration.getInt(path, def);
} }
@ -77,7 +76,7 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public List<String> getList(String path, List<String> def) { public List<String> getStringList(String path, List<String> def) {
return Optional.ofNullable(this.configuration.getStringList(path)).orElse(def); return Optional.ofNullable(this.configuration.getStringList(path)).orElse(def);
} }
@ -92,7 +91,7 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public Map<String, String> getMap(String path, Map<String, String> def) { public Map<String, String> getStringMap(String path, Map<String, String> def) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
Configuration section = this.configuration.getSection(path); Configuration section = this.configuration.getSection(path);
if (section == null) { if (section == null) {
@ -105,4 +104,9 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
return map; return map;
} }
@Override
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
} }

View File

@ -100,7 +100,7 @@ public class ApiConfiguration implements LPConfiguration {
@Nonnull @Nonnull
@Override @Override
public Object getObject(String key) { public Object getObject(String key) {
ConfigKey<?> configKey = ConfigKeys.getAllKeys().get(key.toUpperCase()); ConfigKey<?> configKey = ConfigKeys.getKeys().get(key.toUpperCase());
if (configKey == null) { if (configKey == null) {
throw new IllegalArgumentException("Unknown key: " + key); throw new IllegalArgumentException("Unknown key: " + key);
} }

View File

@ -27,11 +27,8 @@ package me.lucko.luckperms.common.config;
import me.lucko.luckperms.common.api.delegates.misc.ApiConfiguration; import me.lucko.luckperms.common.api.delegates.misc.ApiConfiguration;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.config.keys.EnduringKey;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import java.util.Map;
/** /**
* An abstract implementation of {@link LuckPermsConfiguration}. * An abstract implementation of {@link LuckPermsConfiguration}.
* *
@ -70,22 +67,18 @@ public class AbstractConfiguration implements LuckPermsConfiguration {
@Override @Override
public synchronized void load() { public synchronized void load() {
// get the map of all keys
Map<String, ConfigKey<?>> keys = ConfigKeys.getAllKeys();
// if this is a reload operation // if this is a reload operation
boolean reload = true; boolean reload = true;
// if values are null, must be loading for the first time // if values are null, must be loading for the first time
if (this.values == null) { if (this.values == null) {
this.values = new Object[keys.size()]; this.values = new Object[ConfigKeys.size()];
reload = false; reload = false;
} }
// load a value for each key. for (ConfigKey<?> key : ConfigKeys.getKeys().values()) {
for (ConfigKey<?> key : keys.values()) {
// don't reload enduring keys. // don't reload enduring keys.
if (reload && key instanceof EnduringKey) { if (reload && key instanceof ConfigKeyTypes.EnduringKey) {
continue; continue;
} }

View File

@ -1,39 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config;
public abstract class BaseConfigKey<T> implements ConfigKey<T> {
int ordinal = -1;
protected BaseConfigKey() {
}
@Override
public int ordinal() {
return this.ordinal;
}
}

View File

@ -37,8 +37,8 @@ public interface ConfigKey<T> {
/** /**
* Gets the position of this key within the {@link ConfigKeys} enum. * Gets the position of this key within the {@link ConfigKeys} enum.
* *
* <p>This is lazily set when the configuration is loaded for the first time, during the * <p>This is set shortly after the key is created, during the initialisation
* execution of {@link ConfigKeys#getAllKeys()}.</p> * of {@link ConfigKeys}.</p>
* *
* @return the position * @return the position
*/ */

View File

@ -0,0 +1,136 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import java.util.Map;
import java.util.function.Function;
public class ConfigKeyTypes {
private static final KeyFactory<Boolean> BOOLEAN = ConfigurationAdapter::getBoolean;
private static final KeyFactory<String> STRING = ConfigurationAdapter::getString;
private static final KeyFactory<String> LOWERCASE_STRING = (adapter, path, def) -> adapter.getString(path, def).toLowerCase();
private static final KeyFactory<Map<String, String>> STRING_MAP = (config, path, def) -> ImmutableMap.copyOf(config.getStringMap(path, ImmutableMap.of()));
public static BaseConfigKey<Boolean> booleanKey(String path, boolean def) {
return BOOLEAN.createKey(path, def);
}
public static BaseConfigKey<String> stringKey(String path, String def) {
return STRING.createKey(path, def);
}
public static BaseConfigKey<String> lowercaseStringKey(String path, String def) {
return LOWERCASE_STRING.createKey(path, def);
}
public static BaseConfigKey<Map<String, String>> mapKey(String path) {
return STRING_MAP.createKey(path, null);
}
public static <T> CustomKey<T> customKey(Function<ConfigurationAdapter, T> function) {
return new CustomKey<>(function);
}
public static <T> EnduringKey<T> enduringKey(ConfigKey<T> delegate) {
return new EnduringKey<>(delegate);
}
/**
* Functional interface that extracts values from a {@link ConfigurationAdapter}.
*
* @param <T> the value type.
*/
@FunctionalInterface
public interface KeyFactory<T> {
T getValue(ConfigurationAdapter config, String path, T def);
default BaseConfigKey<T> createKey(String path, T def) {
return new FunctionalKey<>(this, path, def);
}
}
public abstract static class BaseConfigKey<T> implements ConfigKey<T> {
int ordinal = -1;
BaseConfigKey() {
}
@Override
public int ordinal() {
return this.ordinal;
}
}
private static class FunctionalKey<T> extends BaseConfigKey<T> implements ConfigKey<T> {
private final KeyFactory<T> factory;
private final String path;
private final T def;
FunctionalKey(KeyFactory<T> factory, String path, T def) {
this.factory = factory;
this.path = path;
this.def = def;
}
@Override
public T get(ConfigurationAdapter adapter) {
return this.factory.getValue(adapter, this.path, this.def);
}
}
public static class CustomKey<T> extends BaseConfigKey<T> {
private final Function<ConfigurationAdapter, T> function;
private CustomKey(Function<ConfigurationAdapter, T> function) {
this.function = function;
}
@Override
public T get(ConfigurationAdapter adapter) {
return this.function.apply(adapter);
}
}
public static class EnduringKey<T> extends BaseConfigKey<T> {
private final ConfigKey<T> delegate;
private EnduringKey(ConfigKey<T> delegate) {
this.delegate = delegate;
}
@Override
public T get(ConfigurationAdapter adapter) {
return this.delegate.get(adapter);
}
}
}

View File

@ -35,12 +35,6 @@ import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.metastacking.MetaStackDefinition; import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
import me.lucko.luckperms.common.assignments.AssignmentRule; import me.lucko.luckperms.common.assignments.AssignmentRule;
import me.lucko.luckperms.common.command.utils.ArgumentParser; import me.lucko.luckperms.common.command.utils.ArgumentParser;
import me.lucko.luckperms.common.config.keys.BooleanKey;
import me.lucko.luckperms.common.config.keys.CustomKey;
import me.lucko.luckperms.common.config.keys.EnduringKey;
import me.lucko.luckperms.common.config.keys.LowercaseStringKey;
import me.lucko.luckperms.common.config.keys.MapKey;
import me.lucko.luckperms.common.config.keys.StringKey;
import me.lucko.luckperms.common.graph.TraversalAlgorithm; import me.lucko.luckperms.common.graph.TraversalAlgorithm;
import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition; import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition;
import me.lucko.luckperms.common.metastacking.StandardStackElements; import me.lucko.luckperms.common.metastacking.StandardStackElements;
@ -61,20 +55,28 @@ import java.util.EnumSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.booleanKey;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.customKey;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.enduringKey;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.lowercaseStringKey;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.mapKey;
import static me.lucko.luckperms.common.config.ConfigKeyTypes.stringKey;
/** /**
* All of the {@link ConfigKey}s used by LuckPerms. * All of the {@link ConfigKey}s used by LuckPerms.
* *
* <p>The {@link #getAllKeys()} method and associated behaviour allows this class to behave * <p>The {@link #getKeys()} method and associated behaviour allows this class
* a bit like an enum with generics.</p> * to function a bit like an enum, but with generics.</p>
*/ */
public final class ConfigKeys { public final class ConfigKeys {
/** /**
* The name of the server * The name of the server
*/ */
public static final ConfigKey<String> SERVER = CustomKey.of(c -> { public static final ConfigKey<String> SERVER = customKey(c -> {
if (c.getBoolean("use-server-properties-name", false)) { if (c.getBoolean("use-server-properties-name", false)) {
String serverName = c.getPlugin().getBootstrap().getServerName(); String serverName = c.getPlugin().getBootstrap().getServerName();
if (serverName != null && !serverName.equals("Unknown Server")) { if (serverName != null && !serverName.equals("Unknown Server")) {
@ -88,10 +90,10 @@ public final class ConfigKeys {
/** /**
* How many minutes to wait between syncs. A value <= 0 will disable syncing. * How many minutes to wait between syncs. A value <= 0 will disable syncing.
*/ */
public static final ConfigKey<Integer> SYNC_TIME = EnduringKey.wrap(CustomKey.of(c -> { public static final ConfigKey<Integer> SYNC_TIME = enduringKey(customKey(c -> {
int val = c.getInt("sync-minutes", -1); int val = c.getInteger("sync-minutes", -1);
if (val == -1) { if (val == -1) {
val = c.getInt("data.sync-minutes", -1); val = c.getInteger("data.sync-minutes", -1);
} }
return val; return val;
})); }));
@ -99,7 +101,7 @@ public final class ConfigKeys {
/** /**
* The lookup settings for contexts (care should be taken to not mutate this method) * The lookup settings for contexts (care should be taken to not mutate this method)
*/ */
public static final ConfigKey<EnumSet<LookupSetting>> LOOKUP_SETTINGS = CustomKey.of(c -> { public static final ConfigKey<EnumSet<LookupSetting>> LOOKUP_SETTINGS = customKey(c -> {
return EnumSet.copyOf(Contexts.of( return EnumSet.copyOf(Contexts.of(
ContextSet.empty(), ContextSet.empty(),
c.getBoolean("include-global", true), c.getBoolean("include-global", true),
@ -114,27 +116,27 @@ public final class ConfigKeys {
/** /**
* # If the servers own UUID cache/lookup facility should be used when there is no record for a player in the LuckPerms cache. * # If the servers own UUID cache/lookup facility should be used when there is no record for a player in the LuckPerms cache.
*/ */
public static final ConfigKey<Boolean> USE_SERVER_UUID_CACHE = BooleanKey.of("use-server-uuid-cache", false); public static final ConfigKey<Boolean> USE_SERVER_UUID_CACHE = booleanKey("use-server-uuid-cache", false);
/** /**
* If LuckPerms should allow usernames with non alphanumeric characters. * If LuckPerms should allow usernames with non alphanumeric characters.
*/ */
public static final ConfigKey<Boolean> ALLOW_INVALID_USERNAMES = BooleanKey.of("allow-invalid-usernames", false); public static final ConfigKey<Boolean> ALLOW_INVALID_USERNAMES = booleanKey("allow-invalid-usernames", false);
/** /**
* If LuckPerms should produce extra logging output when it handles logins. * If LuckPerms should produce extra logging output when it handles logins.
*/ */
public static final ConfigKey<Boolean> DEBUG_LOGINS = BooleanKey.of("debug-logins", false); public static final ConfigKey<Boolean> DEBUG_LOGINS = booleanKey("debug-logins", false);
/** /**
* If LP should cancel login attempts for players whose permission data could not be loaded. * If LP should cancel login attempts for players whose permission data could not be loaded.
*/ */
public static final ConfigKey<Boolean> CANCEL_FAILED_LOGINS = BooleanKey.of("cancel-failed-logins", false); public static final ConfigKey<Boolean> CANCEL_FAILED_LOGINS = booleanKey("cancel-failed-logins", false);
/** /**
* Controls how temporary add commands should behave * Controls how temporary add commands should behave
*/ */
public static final ConfigKey<TemporaryMergeBehaviour> TEMPORARY_ADD_BEHAVIOUR = CustomKey.of(c -> { public static final ConfigKey<TemporaryMergeBehaviour> TEMPORARY_ADD_BEHAVIOUR = customKey(c -> {
String option = c.getString("temporary-add-behaviour", "deny").toLowerCase(); String option = c.getString("temporary-add-behaviour", "deny").toLowerCase();
if (!option.equals("deny") && !option.equals("replace") && !option.equals("accumulate")) { if (!option.equals("deny") && !option.equals("replace") && !option.equals("accumulate")) {
option = "deny"; option = "deny";
@ -146,7 +148,7 @@ public final class ConfigKeys {
/** /**
* How primary groups should be calculated. * How primary groups should be calculated.
*/ */
public static final ConfigKey<String> PRIMARY_GROUP_CALCULATION_METHOD = EnduringKey.wrap(CustomKey.of(c -> { public static final ConfigKey<String> PRIMARY_GROUP_CALCULATION_METHOD = enduringKey(customKey(c -> {
String option = c.getString("primary-group-calculation", "stored").toLowerCase(); String option = c.getString("primary-group-calculation", "stored").toLowerCase();
if (!option.equals("stored") && !option.equals("parents-by-weight") && !option.equals("all-parents-by-weight")) { if (!option.equals("stored") && !option.equals("parents-by-weight") && !option.equals("all-parents-by-weight")) {
option = "stored"; option = "stored";
@ -158,7 +160,7 @@ public final class ConfigKeys {
/** /**
* A function to create primary group holder instances based upon the {@link #PRIMARY_GROUP_CALCULATION_METHOD} setting. * A function to create primary group holder instances based upon the {@link #PRIMARY_GROUP_CALCULATION_METHOD} setting.
*/ */
public static final ConfigKey<Function<User, PrimaryGroupHolder>> PRIMARY_GROUP_CALCULATION = EnduringKey.wrap(CustomKey.of(c -> { public static final ConfigKey<Function<User, PrimaryGroupHolder>> PRIMARY_GROUP_CALCULATION = enduringKey(customKey(c -> {
String option = PRIMARY_GROUP_CALCULATION_METHOD.get(c); String option = PRIMARY_GROUP_CALCULATION_METHOD.get(c);
switch (option) { switch (option) {
case "stored": case "stored":
@ -174,83 +176,83 @@ public final class ConfigKeys {
* If set to false, the plugin will allow a Users primary group to be removed with the * If set to false, the plugin will allow a Users primary group to be removed with the
* 'parent remove' command, and will set their primary group back to default. * 'parent remove' command, and will set their primary group back to default.
*/ */
public static final ConfigKey<Boolean> PREVENT_PRIMARY_GROUP_REMOVAL = BooleanKey.of("prevent-primary-group-removal", true); public static final ConfigKey<Boolean> PREVENT_PRIMARY_GROUP_REMOVAL = booleanKey("prevent-primary-group-removal", true);
/** /**
* If the plugin should check for "extra" permissions with users run LP commands * If the plugin should check for "extra" permissions with users run LP commands
*/ */
public static final ConfigKey<Boolean> USE_ARGUMENT_BASED_COMMAND_PERMISSIONS = BooleanKey.of("argument-based-command-permissions", false); public static final ConfigKey<Boolean> USE_ARGUMENT_BASED_COMMAND_PERMISSIONS = booleanKey("argument-based-command-permissions", false);
/** /**
* If the plugin should check whether senders are a member of a given group * If the plugin should check whether senders are a member of a given group
* before they're able to edit the groups permissions or add/remove it from other users. * before they're able to edit the groups permissions or add/remove it from other users.
*/ */
public static final ConfigKey<Boolean> REQUIRE_SENDER_GROUP_MEMBERSHIP_TO_MODIFY = BooleanKey.of("require-sender-group-membership-to-modify", false); public static final ConfigKey<Boolean> REQUIRE_SENDER_GROUP_MEMBERSHIP_TO_MODIFY = booleanKey("require-sender-group-membership-to-modify", false);
/** /**
* If wildcards are being applied * If wildcards are being applied
*/ */
public static final ConfigKey<Boolean> APPLYING_WILDCARDS = EnduringKey.wrap(BooleanKey.of("apply-wildcards", true)); public static final ConfigKey<Boolean> APPLYING_WILDCARDS = enduringKey(booleanKey("apply-wildcards", true));
/** /**
* If regex permissions are being applied * If regex permissions are being applied
*/ */
public static final ConfigKey<Boolean> APPLYING_REGEX = EnduringKey.wrap(BooleanKey.of("apply-regex", true)); public static final ConfigKey<Boolean> APPLYING_REGEX = enduringKey(booleanKey("apply-regex", true));
/** /**
* If shorthand permissions are being applied * If shorthand permissions are being applied
*/ */
public static final ConfigKey<Boolean> APPLYING_SHORTHAND = EnduringKey.wrap(BooleanKey.of("apply-shorthand", true)); public static final ConfigKey<Boolean> APPLYING_SHORTHAND = enduringKey(booleanKey("apply-shorthand", true));
/** /**
* If Bukkit child permissions are being applied. This setting is ignored on other platforms. * If Bukkit child permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_BUKKIT_CHILD_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-bukkit-child-permissions", true)); public static final ConfigKey<Boolean> APPLY_BUKKIT_CHILD_PERMISSIONS = enduringKey(booleanKey("apply-bukkit-child-permissions", true));
/** /**
* If Bukkit default permissions are being applied. This setting is ignored on other platforms. * If Bukkit default permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_BUKKIT_DEFAULT_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-bukkit-default-permissions", true)); public static final ConfigKey<Boolean> APPLY_BUKKIT_DEFAULT_PERMISSIONS = enduringKey(booleanKey("apply-bukkit-default-permissions", true));
/** /**
* If Bukkit attachment permissions are being applied. This setting is ignored on other platforms. * If Bukkit attachment permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_BUKKIT_ATTACHMENT_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-bukkit-attachment-permissions", true)); public static final ConfigKey<Boolean> APPLY_BUKKIT_ATTACHMENT_PERMISSIONS = enduringKey(booleanKey("apply-bukkit-attachment-permissions", true));
/** /**
* If Nukkit child permissions are being applied. This setting is ignored on other platforms. * If Nukkit child permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_NUKKIT_CHILD_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-nukkit-child-permissions", true)); public static final ConfigKey<Boolean> APPLY_NUKKIT_CHILD_PERMISSIONS = enduringKey(booleanKey("apply-nukkit-child-permissions", true));
/** /**
* If Nukkit default permissions are being applied. This setting is ignored on other platforms. * If Nukkit default permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_NUKKIT_DEFAULT_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-nukkit-default-permissions", true)); public static final ConfigKey<Boolean> APPLY_NUKKIT_DEFAULT_PERMISSIONS = enduringKey(booleanKey("apply-nukkit-default-permissions", true));
/** /**
* If Nukkit attachment permissions are being applied. This setting is ignored on other platforms. * If Nukkit attachment permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_NUKKIT_ATTACHMENT_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-nukkit-attachment-permissions", true)); public static final ConfigKey<Boolean> APPLY_NUKKIT_ATTACHMENT_PERMISSIONS = enduringKey(booleanKey("apply-nukkit-attachment-permissions", true));
/** /**
* If BungeeCord configured permissions are being applied. This setting is ignored on other platforms. * If BungeeCord configured permissions are being applied. This setting is ignored on other platforms.
*/ */
public static final ConfigKey<Boolean> APPLY_BUNGEE_CONFIG_PERMISSIONS = EnduringKey.wrap(BooleanKey.of("apply-bungee-config-permissions", false)); public static final ConfigKey<Boolean> APPLY_BUNGEE_CONFIG_PERMISSIONS = enduringKey(booleanKey("apply-bungee-config-permissions", false));
/** /**
* If Sponge's implicit permission inheritance system should be applied * If Sponge's implicit permission inheritance system should be applied
*/ */
public static final ConfigKey<Boolean> APPLY_SPONGE_IMPLICIT_WILDCARDS = EnduringKey.wrap(BooleanKey.of("apply-sponge-implicit-wildcards", true)); public static final ConfigKey<Boolean> APPLY_SPONGE_IMPLICIT_WILDCARDS = enduringKey(booleanKey("apply-sponge-implicit-wildcards", true));
/** /**
* If Sponge default subjects should be applied * If Sponge default subjects should be applied
*/ */
public static final ConfigKey<Boolean> APPLY_SPONGE_DEFAULT_SUBJECTS = EnduringKey.wrap(BooleanKey.of("apply-sponge-default-subjects", true)); public static final ConfigKey<Boolean> APPLY_SPONGE_DEFAULT_SUBJECTS = enduringKey(booleanKey("apply-sponge-default-subjects", true));
/** /**
* The algorithm LuckPerms should use when traversing the "inheritance tree" * The algorithm LuckPerms should use when traversing the "inheritance tree"
*/ */
public static final ConfigKey<TraversalAlgorithm> INHERITANCE_TRAVERSAL_ALGORITHM = CustomKey.of(c -> { public static final ConfigKey<TraversalAlgorithm> INHERITANCE_TRAVERSAL_ALGORITHM = customKey(c -> {
String value = c.getString("inheritance-traversal-algorithm", "depth-first-pre-order"); String value = c.getString("inheritance-traversal-algorithm", "depth-first-pre-order");
switch (value.toLowerCase()) { switch (value.toLowerCase()) {
case "breadth-first": case "breadth-first":
@ -265,8 +267,8 @@ public final class ConfigKeys {
/** /**
* The configured group weightings * The configured group weightings
*/ */
public static final ConfigKey<Map<String, Integer>> GROUP_WEIGHTS = CustomKey.of(c -> { public static final ConfigKey<Map<String, Integer>> GROUP_WEIGHTS = customKey(c -> {
return c.getMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toMap( return c.getStringMap("group-weight", ImmutableMap.of()).entrySet().stream().collect(ImmutableCollectors.toMap(
e -> e.getKey().toLowerCase(), e -> e.getKey().toLowerCase(),
e -> { e -> {
try { try {
@ -281,8 +283,8 @@ public final class ConfigKeys {
/** /**
* Creates a new prefix MetaStack element based upon the configured values. * Creates a new prefix MetaStack element based upon the configured values.
*/ */
public static final ConfigKey<MetaStackDefinition> PREFIX_FORMATTING_OPTIONS = CustomKey.of(l -> { public static final ConfigKey<MetaStackDefinition> PREFIX_FORMATTING_OPTIONS = customKey(l -> {
List<String> format = l.getList("meta-formatting.prefix.format", new ArrayList<>()); List<String> format = l.getStringList("meta-formatting.prefix.format", new ArrayList<>());
if (format.isEmpty()) { if (format.isEmpty()) {
format.add("highest"); format.add("highest");
} }
@ -296,8 +298,8 @@ public final class ConfigKeys {
/** /**
* Creates a new suffix MetaStack element based upon the configured values. * Creates a new suffix MetaStack element based upon the configured values.
*/ */
public static final ConfigKey<MetaStackDefinition> SUFFIX_FORMATTING_OPTIONS = CustomKey.of(l -> { public static final ConfigKey<MetaStackDefinition> SUFFIX_FORMATTING_OPTIONS = customKey(l -> {
List<String> format = l.getList("meta-formatting.suffix.format", new ArrayList<>()); List<String> format = l.getStringList("meta-formatting.suffix.format", new ArrayList<>());
if (format.isEmpty()) { if (format.isEmpty()) {
format.add("highest"); format.add("highest");
} }
@ -311,37 +313,37 @@ public final class ConfigKeys {
/** /**
* If log notifications are enabled * If log notifications are enabled
*/ */
public static final ConfigKey<Boolean> LOG_NOTIFY = BooleanKey.of("log-notify", true); public static final ConfigKey<Boolean> LOG_NOTIFY = booleanKey("log-notify", true);
/** /**
* If auto op is enabled. Only used by the Bukkit platform. * If auto op is enabled. Only used by the Bukkit platform.
*/ */
public static final ConfigKey<Boolean> AUTO_OP = EnduringKey.wrap(BooleanKey.of("auto-op", false)); public static final ConfigKey<Boolean> AUTO_OP = enduringKey(booleanKey("auto-op", false));
/** /**
* If server operators should be enabled. Only used by the Bukkit platform. * If server operators should be enabled. Only used by the Bukkit platform.
*/ */
public static final ConfigKey<Boolean> OPS_ENABLED = EnduringKey.wrap(CustomKey.of(c -> !AUTO_OP.get(c) && c.getBoolean("enable-ops", true))); public static final ConfigKey<Boolean> OPS_ENABLED = enduringKey(customKey(c -> !AUTO_OP.get(c) && c.getBoolean("enable-ops", true)));
/** /**
* If server operators should be able to use LuckPerms commands by default. Only used by the Bukkit platform. * If server operators should be able to use LuckPerms commands by default. Only used by the Bukkit platform.
*/ */
public static final ConfigKey<Boolean> COMMANDS_ALLOW_OP = EnduringKey.wrap(BooleanKey.of("commands-allow-op", true)); public static final ConfigKey<Boolean> COMMANDS_ALLOW_OP = enduringKey(booleanKey("commands-allow-op", true));
/** /**
* If Vault lookups for offline players on the main server thread should be enabled * If Vault lookups for offline players on the main server thread should be enabled
*/ */
public static final ConfigKey<Boolean> VAULT_UNSAFE_LOOKUPS = BooleanKey.of("vault-unsafe-lookups", false); public static final ConfigKey<Boolean> VAULT_UNSAFE_LOOKUPS = booleanKey("vault-unsafe-lookups", false);
/** /**
* If the vault server option should be used * If the vault server option should be used
*/ */
public static final ConfigKey<Boolean> USE_VAULT_SERVER = BooleanKey.of("use-vault-server", true); public static final ConfigKey<Boolean> USE_VAULT_SERVER = booleanKey("use-vault-server", true);
/** /**
* The name of the server to use for Vault. * The name of the server to use for Vault.
*/ */
public static final ConfigKey<String> VAULT_SERVER = CustomKey.of(c -> { public static final ConfigKey<String> VAULT_SERVER = customKey(c -> {
// default to true for backwards compatibility // default to true for backwards compatibility
if (USE_VAULT_SERVER.get(c)) { if (USE_VAULT_SERVER.get(c)) {
return c.getString("vault-server", "global").toLowerCase(); return c.getString("vault-server", "global").toLowerCase();
@ -353,23 +355,23 @@ public final class ConfigKeys {
/** /**
* If Vault should apply global permissions * If Vault should apply global permissions
*/ */
public static final ConfigKey<Boolean> VAULT_INCLUDING_GLOBAL = BooleanKey.of("vault-include-global", true); public static final ConfigKey<Boolean> VAULT_INCLUDING_GLOBAL = booleanKey("vault-include-global", true);
/** /**
* If any worlds provided with Vault lookups should be ignored * If any worlds provided with Vault lookups should be ignored
*/ */
public static final ConfigKey<Boolean> VAULT_IGNORE_WORLD = BooleanKey.of("vault-ignore-world", false); public static final ConfigKey<Boolean> VAULT_IGNORE_WORLD = booleanKey("vault-ignore-world", false);
/** /**
* If Vault debug mode is enabled * If Vault debug mode is enabled
*/ */
public static final ConfigKey<Boolean> VAULT_DEBUG = BooleanKey.of("vault-debug", false); public static final ConfigKey<Boolean> VAULT_DEBUG = booleanKey("vault-debug", false);
/** /**
* The world rewrites map * The world rewrites map
*/ */
public static final ConfigKey<Map<String, String>> WORLD_REWRITES = CustomKey.of(c -> { public static final ConfigKey<Map<String, String>> WORLD_REWRITES = customKey(c -> {
return c.getMap("world-rewrite", ImmutableMap.of()).entrySet().stream() return c.getStringMap("world-rewrite", ImmutableMap.of()).entrySet().stream()
.collect(ImmutableCollectors.toMap( .collect(ImmutableCollectors.toMap(
e -> e.getKey().toLowerCase(), e -> e.getKey().toLowerCase(),
e -> e.getValue().toLowerCase() e -> e.getValue().toLowerCase()
@ -379,18 +381,18 @@ public final class ConfigKeys {
/** /**
* The group name rewrites map * The group name rewrites map
*/ */
public static final ConfigKey<Map<String, String>> GROUP_NAME_REWRITES = MapKey.of("group-name-rewrite"); public static final ConfigKey<Map<String, String>> GROUP_NAME_REWRITES = mapKey("group-name-rewrite");
/** /**
* The default assignments being applied by the plugin * The default assignments being applied by the plugin
*/ */
public static final ConfigKey<List<AssignmentRule>> DEFAULT_ASSIGNMENTS = CustomKey.of(c -> { public static final ConfigKey<List<AssignmentRule>> DEFAULT_ASSIGNMENTS = customKey(c -> {
return c.getKeys("default-assignments", ImmutableList.of()).stream().map(name -> { return c.getKeys("default-assignments", ImmutableList.of()).stream().map(name -> {
String hasTrue = c.getString("default-assignments." + name + ".if.has-true", null); String hasTrue = c.getString("default-assignments." + name + ".if.has-true", null);
String hasFalse = c.getString("default-assignments." + name + ".if.has-false", null); String hasFalse = c.getString("default-assignments." + name + ".if.has-false", null);
String lacks = c.getString("default-assignments." + name + ".if.lacks", 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> give = ImmutableList.copyOf(c.getStringList("default-assignments." + name + ".give", ImmutableList.of()));
List<String> take = ImmutableList.copyOf(c.getList("default-assignments." + name + ".take", ImmutableList.of())); List<String> take = ImmutableList.copyOf(c.getStringList("default-assignments." + name + ".take", ImmutableList.of()));
String pg = c.getString("default-assignments." + name + ".set-primary-group", null); String pg = c.getString("default-assignments." + name + ".set-primary-group", null);
return new AssignmentRule(hasTrue, hasFalse, lacks, give, take, pg); return new AssignmentRule(hasTrue, hasFalse, lacks, give, take, pg);
}).collect(ImmutableCollectors.toList()); }).collect(ImmutableCollectors.toList());
@ -399,12 +401,12 @@ public final class ConfigKeys {
/** /**
* The database settings, username, password, etc for use by any database * The database settings, username, password, etc for use by any database
*/ */
public static final ConfigKey<StorageCredentials> DATABASE_VALUES = EnduringKey.wrap(CustomKey.of(c -> { public static final ConfigKey<StorageCredentials> DATABASE_VALUES = enduringKey(customKey(c -> {
int maxPoolSize = c.getInt("data.pool-settings.maximum-pool-size", c.getInt("data.pool-size", 10)); int maxPoolSize = c.getInteger("data.pool-settings.maximum-pool-size", c.getInteger("data.pool-size", 10));
int minIdle = c.getInt("data.pool-settings.minimum-idle", maxPoolSize); int minIdle = c.getInteger("data.pool-settings.minimum-idle", maxPoolSize);
int maxLifetime = c.getInt("data.pool-settings.maximum-lifetime", 1800000); int maxLifetime = c.getInteger("data.pool-settings.maximum-lifetime", 1800000);
int connectionTimeout = c.getInt("data.pool-settings.connection-timeout", 5000); int connectionTimeout = c.getInteger("data.pool-settings.connection-timeout", 5000);
Map<String, String> props = ImmutableMap.copyOf(c.getMap("data.pool-settings.properties", ImmutableMap.of())); Map<String, String> props = ImmutableMap.copyOf(c.getStringMap("data.pool-settings.properties", ImmutableMap.of()));
return new StorageCredentials( return new StorageCredentials(
c.getString("data.address", null), c.getString("data.address", null),
@ -418,37 +420,37 @@ public final class ConfigKeys {
/** /**
* The prefix for any SQL tables * The prefix for any SQL tables
*/ */
public static final ConfigKey<String> SQL_TABLE_PREFIX = EnduringKey.wrap(StringKey.of("data.table_prefix", "luckperms_")); public static final ConfigKey<String> SQL_TABLE_PREFIX = enduringKey(stringKey("data.table_prefix", "luckperms_"));
/** /**
* The prefix for any MongoDB collections * The prefix for any MongoDB collections
*/ */
public static final ConfigKey<String> MONGODB_COLLECTION_PREFIX = EnduringKey.wrap(StringKey.of("data.mongodb_collection_prefix", "")); public static final ConfigKey<String> MONGODB_COLLECTION_PREFIX = enduringKey(stringKey("data.mongodb_collection_prefix", ""));
/** /**
* MongoDB ClientConnectionURI to override default connection options * MongoDB ClientConnectionURI to override default connection options
*/ */
public static final ConfigKey<String> MONGODB_CONNECTION_URI = EnduringKey.wrap(StringKey.of("data.mongodb_connection_URI", "")); public static final ConfigKey<String> MONGODB_CONNECTION_URI = enduringKey(stringKey("data.mongodb_connection_URI", ""));
/** /**
* The name of the storage method being used * The name of the storage method being used
*/ */
public static final ConfigKey<String> STORAGE_METHOD = EnduringKey.wrap(LowercaseStringKey.of("storage-method", "h2")); public static final ConfigKey<String> STORAGE_METHOD = enduringKey(lowercaseStringKey("storage-method", "h2"));
/** /**
* If storage files should be monitored for changes * If storage files should be monitored for changes
*/ */
public static final ConfigKey<Boolean> WATCH_FILES = BooleanKey.of("watch-files", true); public static final ConfigKey<Boolean> WATCH_FILES = booleanKey("watch-files", true);
/** /**
* If split storage is being used * If split storage is being used
*/ */
public static final ConfigKey<Boolean> SPLIT_STORAGE = EnduringKey.wrap(BooleanKey.of("split-storage.enabled", false)); public static final ConfigKey<Boolean> SPLIT_STORAGE = enduringKey(booleanKey("split-storage.enabled", false));
/** /**
* The options for split storage * The options for split storage
*/ */
public static final ConfigKey<Map<SplitStorageType, String>> SPLIT_STORAGE_OPTIONS = EnduringKey.wrap(CustomKey.of(c -> { public static final ConfigKey<Map<SplitStorageType, String>> SPLIT_STORAGE_OPTIONS = enduringKey(customKey(c -> {
EnumMap<SplitStorageType, String> map = new EnumMap<>(SplitStorageType.class); EnumMap<SplitStorageType, String> map = new EnumMap<>(SplitStorageType.class);
map.put(SplitStorageType.USER, c.getString("split-storage.methods.user", "h2").toLowerCase()); map.put(SplitStorageType.USER, c.getString("split-storage.methods.user", "h2").toLowerCase());
map.put(SplitStorageType.GROUP, c.getString("split-storage.methods.group", "h2").toLowerCase()); map.put(SplitStorageType.GROUP, c.getString("split-storage.methods.group", "h2").toLowerCase());
@ -461,96 +463,105 @@ public final class ConfigKeys {
/** /**
* The name of the messaging service in use, or "none" if not enabled * The name of the messaging service in use, or "none" if not enabled
*/ */
public static final ConfigKey<String> MESSAGING_SERVICE = EnduringKey.wrap(LowercaseStringKey.of("messaging-service", "none")); public static final ConfigKey<String> MESSAGING_SERVICE = enduringKey(lowercaseStringKey("messaging-service", "none"));
/** /**
* If updates should be automatically pushed by the messaging service * If updates should be automatically pushed by the messaging service
*/ */
public static final ConfigKey<Boolean> AUTO_PUSH_UPDATES = EnduringKey.wrap(BooleanKey.of("auto-push-updates", true)); public static final ConfigKey<Boolean> AUTO_PUSH_UPDATES = enduringKey(booleanKey("auto-push-updates", true));
/** /**
* If LuckPerms should push logging entries to connected servers via the messaging service * If LuckPerms should push logging entries to connected servers via the messaging service
*/ */
public static final ConfigKey<Boolean> PUSH_LOG_ENTRIES = EnduringKey.wrap(BooleanKey.of("push-log-entries", true)); public static final ConfigKey<Boolean> PUSH_LOG_ENTRIES = enduringKey(booleanKey("push-log-entries", true));
/** /**
* If LuckPerms should broadcast received logging entries to players on this platform * If LuckPerms should broadcast received logging entries to players on this platform
*/ */
public static final ConfigKey<Boolean> BROADCAST_RECEIVED_LOG_ENTRIES = EnduringKey.wrap(BooleanKey.of("broadcast-received-log-entries", false)); public static final ConfigKey<Boolean> BROADCAST_RECEIVED_LOG_ENTRIES = enduringKey(booleanKey("broadcast-received-log-entries", false));
/** /**
* If redis messaging is enabled * If redis messaging is enabled
*/ */
public static final ConfigKey<Boolean> REDIS_ENABLED = EnduringKey.wrap(BooleanKey.of("redis.enabled", false)); public static final ConfigKey<Boolean> REDIS_ENABLED = enduringKey(booleanKey("redis.enabled", false));
/** /**
* The address of the redis server * The address of the redis server
*/ */
public static final ConfigKey<String> REDIS_ADDRESS = EnduringKey.wrap(StringKey.of("redis.address", null)); public static final ConfigKey<String> REDIS_ADDRESS = enduringKey(stringKey("redis.address", null));
/** /**
* The password in use by the redis server, or an empty string if there is no passworld * The password in use by the redis server, or an empty string if there is no passworld
*/ */
public static final ConfigKey<String> REDIS_PASSWORD = EnduringKey.wrap(StringKey.of("redis.password", "")); public static final ConfigKey<String> REDIS_PASSWORD = enduringKey(stringKey("redis.password", ""));
/** /**
* The URL of the web editor * The URL of the web editor
*/ */
public static final ConfigKey<String> WEB_EDITOR_URL_PATTERN = StringKey.of("web-editor-url", "https://luckperms.github.io/editor/"); public static final ConfigKey<String> WEB_EDITOR_URL_PATTERN = stringKey("web-editor-url", "https://luckperms.github.io/editor/");
/** /**
* The URL of the verbose viewer * The URL of the verbose viewer
*/ */
public static final ConfigKey<String> VERBOSE_VIEWER_URL_PATTERN = StringKey.of("verbose-viewer-url", "https://luckperms.github.io/verbose/"); public static final ConfigKey<String> VERBOSE_VIEWER_URL_PATTERN = stringKey("verbose-viewer-url", "https://luckperms.github.io/verbose/");
/** /**
* The URL of the tree viewer * The URL of the tree viewer
*/ */
public static final ConfigKey<String> TREE_VIEWER_URL_PATTERN = StringKey.of("tree-viewer-url", "https://luckperms.github.io/treeview/"); public static final ConfigKey<String> TREE_VIEWER_URL_PATTERN = stringKey("tree-viewer-url", "https://luckperms.github.io/treeview/");
private static Map<String, ConfigKey<?>> KEYS = null; private static final AtomicInteger ORDINAL_COUNTER = new AtomicInteger(0);
private static final Map<String, ConfigKey<?>> KEYS;
/** static {
* Gets all of the possible config keys defined in this class Map<String, ConfigKey<?>> keys = new LinkedHashMap<>();
* Field[] values = ConfigKeys.class.getFields();
* @return all of the possible config keys defined in this class for (Field f : values) {
*/ // ignore non-static fields
public static synchronized Map<String, ConfigKey<?>> getAllKeys() { if (!Modifier.isStatic(f.getModifiers())) {
if (KEYS == null) { continue;
Map<String, ConfigKey<?>> keys = new LinkedHashMap<>();
try {
Field[] values = ConfigKeys.class.getFields();
int counter = 0;
for (Field f : values) {
// ignore non-static fields
if (!Modifier.isStatic(f.getModifiers())) {
continue;
}
// ignore fields that aren't configkeys
if (!ConfigKey.class.equals(f.getType())) {
continue;
}
// get the key instance
BaseConfigKey<?> key = (BaseConfigKey<?>) f.get(null);
// set the ordinal value of the key.
key.ordinal = counter++;
// add the key to the return map
keys.put(f.getName(), key);
}
} catch (Exception e) {
e.printStackTrace();
} }
KEYS = ImmutableMap.copyOf(keys); // ignore fields that aren't configkeys
} if (!ConfigKey.class.equals(f.getType())) {
continue;
}
try {
// get the key instance
ConfigKeyTypes.BaseConfigKey<?> key = (ConfigKeyTypes.BaseConfigKey<?>) f.get(null);
// set the ordinal value of the key.
key.ordinal = ORDINAL_COUNTER.getAndIncrement();
// add the key to the return map
keys.put(f.getName(), key);
} catch (IllegalAccessException e) {
throw new RuntimeException("Exception processing field: " + f, e);
}
}
KEYS = ImmutableMap.copyOf(keys);
}
/**
* Gets a map of the keys defined in this class.
*
* <p>The string key in the map is the {@link Field#getName() field name}
* corresponding to each key.</p>
*
* @return the defined keys
*/
public static Map<String, ConfigKey<?>> getKeys() {
return KEYS; return KEYS;
} }
/**
* Gets the number of defined keys.
*
* @return how many keys are defined in this class
*/
public static int size() {
return ORDINAL_COUNTER.get();
}
private ConfigKeys() {} private ConfigKeys() {}
} }

View File

@ -1,41 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.adapter;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
public abstract class AbstractConfigurationAdapter implements ConfigurationAdapter {
private final LuckPermsPlugin plugin;
public AbstractConfigurationAdapter(LuckPermsPlugin plugin) {
this.plugin = plugin;
}
@Override
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
}

View File

@ -39,13 +39,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public abstract class ConfigurateConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter { public abstract class ConfigurateConfigAdapter implements ConfigurationAdapter {
private final LuckPermsPlugin plugin;
private final Path path; private final Path path;
private ConfigurationNode root; private ConfigurationNode root;
public ConfigurateConfigAdapter(LuckPermsPlugin plugin, Path path) { public ConfigurateConfigAdapter(LuckPermsPlugin plugin, Path path) {
super(plugin); this.plugin = plugin;
this.path = path; this.path = path;
reload(); reload();
} }
@ -76,7 +76,7 @@ public abstract class ConfigurateConfigAdapter extends AbstractConfigurationAdap
} }
@Override @Override
public int getInt(String path, int def) { public int getInteger(String path, int def) {
return resolvePath(path).getInt(def); return resolvePath(path).getInt(def);
} }
@ -86,7 +86,7 @@ public abstract class ConfigurateConfigAdapter extends AbstractConfigurationAdap
} }
@Override @Override
public List<String> getList(String path, List<String> def) { public List<String> getStringList(String path, List<String> def) {
ConfigurationNode node = resolvePath(path); ConfigurationNode node = resolvePath(path);
if (node.isVirtual()) { if (node.isVirtual()) {
return def; return def;
@ -107,7 +107,7 @@ public abstract class ConfigurateConfigAdapter extends AbstractConfigurationAdap
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Map<String, String> getMap(String path, Map<String, String> def) { public Map<String, String> getStringMap(String path, Map<String, String> def) {
ConfigurationNode node = resolvePath(path); ConfigurationNode node = resolvePath(path);
if (node.isVirtual()) { if (node.isVirtual()) {
return def; return def;
@ -116,4 +116,9 @@ public abstract class ConfigurateConfigAdapter extends AbstractConfigurationAdap
Map<String, Object> m = (Map<String, Object>) node.getValue(Collections.emptyMap()); Map<String, Object> m = (Map<String, Object>) node.getValue(Collections.emptyMap());
return m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().toString())); return m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().toString()));
} }
@Override
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
} }

View File

@ -38,14 +38,14 @@ public interface ConfigurationAdapter {
String getString(String path, String def); String getString(String path, String def);
int getInt(String path, int def); int getInteger(String path, int def);
boolean getBoolean(String path, boolean def); boolean getBoolean(String path, boolean def);
List<String> getList(String path, List<String> def); List<String> getStringList(String path, List<String> def);
List<String> getKeys(String path, List<String> def); List<String> getKeys(String path, List<String> def);
Map<String, String> getMap(String path, Map<String, String> def); Map<String, String> getStringMap(String path, Map<String, String> def);
} }

View File

@ -1,48 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
public class BooleanKey extends BaseConfigKey<Boolean> {
public static BooleanKey of(String path, boolean def) {
return new BooleanKey(path, def);
}
private final String path;
private final boolean def;
private BooleanKey(String path, boolean def) {
this.path = path;
this.def = def;
}
@Override
public Boolean get(ConfigurationAdapter adapter) {
return adapter.getBoolean(this.path, this.def);
}
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import java.util.function.Function;
public class CustomKey<T> extends BaseConfigKey<T> {
public static <T> CustomKey<T> of(Function<ConfigurationAdapter, T> function) {
return new CustomKey<>(function);
}
private final Function<ConfigurationAdapter, T> function;
private CustomKey(Function<ConfigurationAdapter, T> function) {
this.function = function;
}
@Override
public T get(ConfigurationAdapter adapter) {
return this.function.apply(adapter);
}
}

View File

@ -1,52 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.ConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
/**
* Wrapper class to mark a config key as enduring (doesn't change in the event of a reload)
* @param <T>
*/
public class EnduringKey<T> extends BaseConfigKey<T> {
public static <T> EnduringKey<T> wrap(ConfigKey<T> delegate) {
return new EnduringKey<>(delegate);
}
private final ConfigKey<T> delegate;
private EnduringKey(ConfigKey<T> delegate) {
this.delegate = delegate;
}
@Override
public T get(ConfigurationAdapter adapter) {
return this.delegate.get(adapter);
}
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
public class IntegerKey extends BaseConfigKey<Integer> {
public static IntegerKey of(String path, int def) {
return new IntegerKey(path, def);
}
private final String path;
private final int def;
private IntegerKey(String path, int def) {
this.path = path;
this.def = def;
}
@Override
public Integer get(ConfigurationAdapter adapter) {
return adapter.getInt(this.path, this.def);
}
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
public class LowercaseStringKey extends BaseConfigKey<String> {
public static LowercaseStringKey of(String path, String def) {
return new LowercaseStringKey(path, def);
}
private final String path;
private final String def;
private LowercaseStringKey(String path, String def) {
this.path = path;
this.def = def;
}
@Override
public String get(ConfigurationAdapter adapter) {
return adapter.getString(this.path, this.def).toLowerCase();
}
}

View File

@ -1,50 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import com.google.common.collect.ImmutableMap;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import java.util.Map;
public class MapKey extends BaseConfigKey<Map<String, String>> {
public static MapKey of(String path) {
return new MapKey(path);
}
private final String path;
private MapKey(String path) {
this.path = path;
}
@Override
public Map<String, String> get(ConfigurationAdapter adapter) {
return ImmutableMap.copyOf(adapter.getMap(this.path, ImmutableMap.of()));
}
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.config.keys;
import me.lucko.luckperms.common.config.BaseConfigKey;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
public class StringKey extends BaseConfigKey<String> {
public static StringKey of(String path, String def) {
return new StringKey(path, def);
}
private final String path;
private final String def;
private StringKey(String path, String def) {
this.path = path;
this.def = def;
}
@Override
public String get(ConfigurationAdapter adapter) {
return adapter.getString(this.path, this.def);
}
}

View File

@ -25,7 +25,6 @@
package me.lucko.luckperms.nukkit; package me.lucko.luckperms.nukkit;
import me.lucko.luckperms.common.config.adapter.AbstractConfigurationAdapter;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -39,13 +38,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class NukkitConfigAdapter extends AbstractConfigurationAdapter implements ConfigurationAdapter { public class NukkitConfigAdapter implements ConfigurationAdapter {
private final LuckPermsPlugin plugin;
private final File file; private final File file;
private Config configuration; private Config configuration;
public NukkitConfigAdapter(LuckPermsPlugin plugin, File file) { public NukkitConfigAdapter(LuckPermsPlugin plugin, File file) {
super(plugin); this.plugin = plugin;
this.file = file; this.file = file;
reload(); reload();
} }
@ -61,7 +60,7 @@ public class NukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public int getInt(String path, int def) { public int getInteger(String path, int def) {
return this.configuration.getInt(path, def); return this.configuration.getInt(path, def);
} }
@ -71,7 +70,7 @@ public class NukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public List<String> getList(String path, List<String> def) { public List<String> getStringList(String path, List<String> def) {
List<String> ret = this.configuration.getStringList(path); List<String> ret = this.configuration.getStringList(path);
return ret == null ? def : ret; return ret == null ? def : ret;
} }
@ -88,7 +87,7 @@ public class NukkitConfigAdapter extends AbstractConfigurationAdapter implements
} }
@Override @Override
public Map<String, String> getMap(String path, Map<String, String> def) { public Map<String, String> getStringMap(String path, Map<String, String> def) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
ConfigSection section = this.configuration.getSection(path); ConfigSection section = this.configuration.getSection(path);
if (section == null) { if (section == null) {
@ -101,4 +100,9 @@ public class NukkitConfigAdapter extends AbstractConfigurationAdapter implements
return map; return map;
} }
@Override
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
} }

View File

@ -1,3 +1,28 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.velocity; package me.lucko.luckperms.velocity;
import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader; import me.lucko.luckperms.common.dependencies.classloader.PluginClassLoader;

View File

@ -1,3 +1,28 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.velocity.service; package me.lucko.luckperms.velocity.service;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;