Refactor configurate deo serialization of permission data, add support for the TOML format

This commit is contained in:
Luck 2018-04-28 21:26:59 +01:00
parent 3784d904fb
commit 7d089cb5f0
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
20 changed files with 245 additions and 109 deletions

View File

@ -92,22 +92,10 @@
<pattern>redis.clients.jedis</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedis</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedisutil</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool2</pattern>
<shadedPattern>me.lucko.luckperms.lib.commonspool2</shadedPattern>
</relocation>
<relocation>
<pattern>ninja.leaping.configurate</pattern>
<shadedPattern>me.lucko.luckperms.lib.configurate</shadedPattern>
</relocation>
<relocation>
<pattern>com.typesafe.config</pattern>
<shadedPattern>me.lucko.luckperms.lib.hocon</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>

View File

@ -49,6 +49,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.listener.ConnectionListener;
import me.lucko.luckperms.common.managers.group.StandardGroupManager;
@ -70,8 +71,10 @@ import org.bukkit.plugin.ServicePriority;
import java.io.File;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
/**
@ -106,6 +109,11 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
this.senderFactory = new BukkitSenderFactory(this);
}
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override
protected ConfigurationAdapter provideConfigurationAdapter() {
return new BukkitConfigAdapter(this, resolveConfig());

View File

@ -74,6 +74,11 @@ use-server-uuid-cache: false
# |=> YAML (.yml files)
# |=> JSON (.json files)
# |=> HOCON (.conf files)
# |=> TOML (.toml files)
# |
# | By default, user, group and track data is separated into different files. Data can be combined
# | and all stored in the same file by switching to a combined storage variant.
# | Just add '-combined' to the end of the storage-method, e.g. 'yaml-combined'
#
# - A H2 database is the default option.
# - If you want to edit data manually in "traditional" storage files, we suggest using YAML.

View File

@ -92,22 +92,10 @@
<pattern>redis.clients.jedis</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedis</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedisutil</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool2</pattern>
<shadedPattern>me.lucko.luckperms.lib.commonspool2</shadedPattern>
</relocation>
<relocation>
<pattern>ninja.leaping.configurate</pattern>
<shadedPattern>me.lucko.luckperms.lib.configurate</shadedPattern>
</relocation>
<relocation>
<pattern>com.typesafe.config</pattern>
<shadedPattern>me.lucko.luckperms.lib.hocon</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>

View File

@ -39,6 +39,7 @@ import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.listener.ConnectionListener;
import me.lucko.luckperms.common.managers.group.StandardGroupManager;
@ -57,7 +58,9 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
/**
@ -88,6 +91,11 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
this.senderFactory = new BungeeSenderFactory(this);
}
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override
protected ConfigurationAdapter provideConfigurationAdapter() {
return new BungeeConfigAdapter(this, resolveConfig());

View File

@ -71,6 +71,11 @@ use-server-uuid-cache: false
# |=> YAML (.yml files)
# |=> JSON (.json files)
# |=> HOCON (.conf files)
# |=> TOML (.toml files)
# |
# | By default, user, group and track data is separated into different files. Data can be combined
# | and all stored in the same file by switching to a combined storage variant.
# | Just add '-combined' to the end of the storage-method, e.g. 'yaml-combined'
#
# - A H2 database is the default option.
# - If you want to edit data manually in "traditional" storage files, we suggest using YAML.

View File

@ -83,7 +83,7 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<!-- caffeine -->
<dependency>
@ -109,9 +109,9 @@
<!-- configurate -->
<dependency>
<groupId>ninja.leaping.configurate</groupId>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-core</artifactId>
<version>3.3</version>
<version>3.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -122,9 +122,9 @@
</dependency>
<!-- configurate yaml -->
<dependency>
<groupId>ninja.leaping.configurate</groupId>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-yaml</artifactId>
<version>3.3</version>
<version>3.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -135,9 +135,9 @@
</dependency>
<!-- configurate gson -->
<dependency>
<groupId>ninja.leaping.configurate</groupId>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-gson</artifactId>
<version>3.3</version>
<version>3.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -148,11 +148,24 @@
</dependency>
<!-- configurate hocon -->
<dependency>
<groupId>ninja.leaping.configurate</groupId>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
<version>3.3</version>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<!-- configurate toml -->
<dependency>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-toml</artifactId>
<version>3.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- HikariCP -->
<dependency>
<groupId>com.zaxxer</groupId>

View File

@ -168,31 +168,31 @@ public enum Dependency {
Relocation.of("commonspool2", "org{}apache{}commons{}pool2")
),
CONFIGURATE_CORE(
"ninja{}leaping{}configurate",
"me{}lucko{}configurate",
"configurate-core",
"3.3",
"4leBJEqj1kVszaifZeKNl4hgHxG5M+Nk5TJKkPW2s4Y=",
"3.4",
"XetsTkFaqO7NS7wpGyTK68P29AUl+NsbLZIldvvXUAg=",
Relocation.of("configurate", "ninja{}leaping{}configurate")
),
CONFIGURATE_GSON(
"ninja{}leaping{}configurate",
"me{}lucko{}configurate",
"configurate-gson",
"3.3",
"4HxrW3/ZKdn095x/W4gylQMNskdmteXYVxVv0UKGJA4=",
"3.4",
"1Glt4ijo6xQ8MatviUO+36AbZH5qR+f3tWx466iYZug=",
Relocation.of("configurate", "ninja{}leaping{}configurate")
),
CONFIGURATE_YAML(
"ninja{}leaping{}configurate",
"me{}lucko{}configurate",
"configurate-yaml",
"3.3",
"hgADp3g+xHHPD34bAuxMWtB+OQ718Tlw69jVp2KPJNk=",
"3.4",
"icv/JayTYDOSCpbm60qU7EccSxUYVVXQOU7CFZqUK2Y=",
Relocation.of("configurate", "ninja{}leaping{}configurate")
),
CONFIGURATE_HOCON(
"ninja{}leaping{}configurate",
"me{}lucko{}configurate",
"configurate-hocon",
"3.3",
"UIy5FVmsBUG6+Z1mpIEE2EXgtOI1ZL0p/eEW+BbtGLU=",
"3.4",
"A27PLuPnh/rlpcHIABCwjo4QPvjUXaKRUh7sMvbp+Y0=",
Relocation.allOf(
Relocation.of("configurate", "ninja{}leaping{}configurate"),
Relocation.of("hocon", "com{}typesafe{}config")
@ -204,6 +204,23 @@ public enum Dependency {
"1.3.1",
"5vrfxhCCINOmuGqn5OFsnnu4V7pYlViGMIuxOXImSvA=",
Relocation.of("hocon", "com{}typesafe{}config")
),
CONFIGURATE_TOML(
"me{}lucko{}configurate",
"configurate-toml",
"3.4",
"skbgSFsBg6wVeudWyCYIzJpz+Ia3CSTVLCGlnF4XD+A=",
Relocation.allOf(
Relocation.of("configurate", "ninja{}leaping{}configurate"),
Relocation.of("toml4j", "com{}moandjiezana{}toml")
)
),
TOML4J(
"com{}moandjiezana{}toml",
"toml4j",
"0.7.2",
"9UdeY+fonl22IiNImux6Vr0wNUN3IHehfCy1TBnKOiA=",
Relocation.of("toml4j", "com{}moandjiezana{}toml")
);
private final String url;

View File

@ -27,14 +27,11 @@ package me.lucko.luckperms.common.dependencies;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.storage.StorageType;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@ -42,17 +39,15 @@ import java.util.Set;
public class DependencyRegistry {
public static final Set<Dependency> GLOBAL_DEPENDENCIES = ImmutableSet.copyOf(EnumSet.of(
Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP
));
private static final Map<StorageType, List<Dependency>> STORAGE_DEPENDENCIES = ImmutableMap.<StorageType, List<Dependency>>builder()
.put(StorageType.YAML, ImmutableList.of(Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_YAML))
.put(StorageType.JSON, ImmutableList.of(Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_GSON))
.put(StorageType.HOCON, ImmutableList.of(Dependency.HOCON_CONFIG, Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON))
.put(StorageType.TOML, ImmutableList.of(Dependency.TOML4J, Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_TOML))
.put(StorageType.YAML_COMBINED, ImmutableList.of(Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_YAML))
.put(StorageType.JSON_COMBINED, ImmutableList.of(Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_GSON))
.put(StorageType.HOCON_COMBINED, ImmutableList.of(Dependency.HOCON_CONFIG, Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON))
.put(StorageType.TOML_COMBINED, ImmutableList.of(Dependency.TOML4J, Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_TOML))
.put(StorageType.MONGODB, ImmutableList.of(Dependency.MONGODB_DRIVER))
.put(StorageType.MARIADB, ImmutableList.of(Dependency.MARIADB_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MYSQL, ImmutableList.of(Dependency.MYSQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
@ -85,15 +80,6 @@ public class DependencyRegistry {
dependencies.remove(Dependency.SLF4J_SIMPLE);
}
// don't load configurate dependencies on sponge
if (this.plugin.getBootstrap().getType() == PlatformType.SPONGE) {
dependencies.remove(Dependency.CONFIGURATE_CORE);
dependencies.remove(Dependency.CONFIGURATE_GSON);
dependencies.remove(Dependency.CONFIGURATE_YAML);
dependencies.remove(Dependency.CONFIGURATE_HOCON);
dependencies.remove(Dependency.HOCON_CONFIG);
}
return dependencies;
}

View File

@ -39,8 +39,8 @@ import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.contexts.LuckPermsCalculator;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.dependencies.DependencyManager;
import me.lucko.luckperms.common.dependencies.DependencyRegistry;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.event.EventFactory;
import me.lucko.luckperms.common.inheritance.InheritanceHandler;
@ -95,7 +95,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
// load dependencies
this.dependencyManager = new DependencyManager(this);
this.dependencyManager.loadDependencies(DependencyRegistry.GLOBAL_DEPENDENCIES);
this.dependencyManager.loadDependencies(getGlobalDependencies());
}
public final void enable() {
@ -230,6 +230,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
}
protected abstract void setupSenderFactory();
protected abstract Set<Dependency> getGlobalDependencies();
protected abstract ConfigurationAdapter provideConfigurationAdapter();
protected abstract void registerPlatformListeners();
protected abstract MessagingFactory<?> provideMessagingFactory();

View File

@ -36,6 +36,7 @@ import me.lucko.luckperms.common.storage.dao.file.CombinedConfigurateDao;
import me.lucko.luckperms.common.storage.dao.file.SeparatedConfigurateDao;
import me.lucko.luckperms.common.storage.dao.file.loader.HoconLoader;
import me.lucko.luckperms.common.storage.dao.file.loader.JsonLoader;
import me.lucko.luckperms.common.storage.dao.file.loader.TomlLoader;
import me.lucko.luckperms.common.storage.dao.file.loader.YamlLoader;
import me.lucko.luckperms.common.storage.dao.mongodb.MongoDao;
import me.lucko.luckperms.common.storage.dao.sql.SqlDao;
@ -168,12 +169,16 @@ public class StorageFactory {
return new SeparatedConfigurateDao(this.plugin, new JsonLoader(), "JSON", ".json", "json-storage");
case HOCON:
return new SeparatedConfigurateDao(this.plugin, new HoconLoader(), "HOCON", ".conf", "hocon-storage");
case TOML:
return new SeparatedConfigurateDao(this.plugin, new TomlLoader(), "TOML", ".toml", "toml-storage");
case YAML_COMBINED:
return new CombinedConfigurateDao(this.plugin, new YamlLoader(), "YAML Combined", ".yml", "yaml-storage");
case JSON_COMBINED:
return new CombinedConfigurateDao(this.plugin, new JsonLoader(), "JSON Combined", ".json", "json-storage");
case HOCON_COMBINED:
return new CombinedConfigurateDao(this.plugin, new HoconLoader(), "HOCON Combined", ".conf", "hocon-storage");
case TOML_COMBINED:
return new CombinedConfigurateDao(this.plugin, new TomlLoader(), "TOML Combined", ".toml", "toml-storage");
default:
throw new RuntimeException("Unknown method: " + method);
}

View File

@ -35,9 +35,11 @@ public enum StorageType {
YAML("YAML", "yaml", "yml"),
JSON("JSON", "json", "flatfile"),
HOCON("HOCON", "hocon"),
TOML("TOML", "toml"),
YAML_COMBINED("YAML Combined", "yaml-combined"),
JSON_COMBINED("JSON Combined", "json-combined"),
HOCON_COMBINED("HOCON Combined", "hocon-combined"),
TOML_COMBINED("TOML Combined", "toml-combined"),
// Remote databases
MONGODB("MongoDB", "mongodb"),

View File

@ -48,6 +48,7 @@ import me.lucko.luckperms.common.storage.PlayerSaveResult;
import me.lucko.luckperms.common.storage.dao.AbstractDao;
import me.lucko.luckperms.common.storage.dao.file.loader.ConfigurateLoader;
import me.lucko.luckperms.common.storage.dao.file.loader.JsonLoader;
import me.lucko.luckperms.common.storage.dao.file.loader.YamlLoader;
import me.lucko.luckperms.common.utils.ImmutableCollectors;
import me.lucko.luckperms.common.utils.MoreFiles;
@ -480,16 +481,37 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
}
}
private static Map.Entry<String, ConfigurationNode> parseEntry(ConfigurationNode appended) {
private static Map.Entry<String, ConfigurationNode> parseEntry(ConfigurationNode appended, String keyFieldName) {
if (!appended.hasMapChildren()) {
return null;
}
Map.Entry<Object, ? extends ConfigurationNode> entry = Iterables.getFirst(appended.getChildrenMap().entrySet(), null);
if (entry == null || !entry.getValue().hasMapChildren()) {
Map<Object, ? extends ConfigurationNode> children = appended.getChildrenMap();
if (children.isEmpty()) {
return null;
}
return Maps.immutableEntry(entry.getKey().toString(), entry.getValue());
// if children.size == 1 and the only entry doesn't have a key called "permission" - assume
// the key refers to the name of the permission
if (children.size() == 1) {
Map.Entry<Object, ? extends ConfigurationNode> entry = Iterables.getFirst(children.entrySet(), null);
if (entry != null) {
String permission = entry.getKey().toString();
ConfigurationNode attributes = entry.getValue();
if (!permission.equals(keyFieldName)) {
return Maps.immutableEntry(permission, attributes);
}
}
}
// assume 'appended' is the actual entry.
String permission = children.get(keyFieldName).getString(null);
if (permission == null) {
return null;
}
return Maps.immutableEntry(permission, appended);
}
protected static Set<NodeModel> readNodes(ConfigurationNode data) {
@ -504,7 +526,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
continue;
}
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended, "permission");
if (entry == null) {
continue;
}
@ -521,7 +543,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
continue;
}
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended, "group");
if (entry == null) {
continue;
}
@ -534,7 +556,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
if (data.getNode(keyName).hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode(keyName).getChildrenList();
for (ConfigurationNode appended : children) {
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended, chatMetaType.toString());
if (entry == null) {
continue;
}
@ -546,7 +568,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
if (data.getNode("meta").hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode("meta").getChildrenList();
for (ConfigurationNode appended : children) {
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended, "key");
if (entry == null) {
continue;
}
@ -587,7 +609,24 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
node.getContexts().isEmpty();
}
private static void writeNodes(ConfigurationNode to, Set<NodeModel> nodes) {
private void appendNode(ConfigurationNode base, String key, ConfigurationNode attributes, String keyFieldName) {
if (this.loader instanceof YamlLoader) {
// create a map node with a single entry of key --> attributes
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(key).setValue(attributes);
base.getAppendedNode().setValue(appended);
} else {
// include the attributes and key in the same map
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(keyFieldName).setValue(key);
appended.mergeValuesFrom(appended);
base.getAppendedNode().setValue(appended);
}
}
private void writeNodes(ConfigurationNode to, Set<NodeModel> nodes) {
ConfigurationNode permissionsSection = SimpleConfigurationNode.root();
ConfigurationNode parentsSection = SimpleConfigurationNode.root();
ConfigurationNode prefixesSection = SimpleConfigurationNode.root();
@ -598,7 +637,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
Node n = node.toNode();
// just add a string to the list.
if (isPlain(node)) {
if (this.loader instanceof YamlLoader && isPlain(node)) {
if (n.isGroupNode()) {
parentsSection.getAppendedNode().setValue(n.getGroupName());
continue;
@ -618,15 +657,12 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
attributes.getNode("priority").setValue(entry.getKey());
writeAttributesTo(attributes, node, false);
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(entry.getValue()).setValue(attributes);
switch (chatMetaType) {
case PREFIX:
prefixesSection.getAppendedNode().setValue(appended);
appendNode(prefixesSection, entry.getValue(), attributes, "prefix");
break;
case SUFFIX:
suffixesSection.getAppendedNode().setValue(appended);
appendNode(suffixesSection, entry.getValue(), attributes, "suffix");
break;
default:
throw new AssertionError();
@ -639,28 +675,19 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
attributes.getNode("value").setValue(meta.getValue());
writeAttributesTo(attributes, node, false);
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(meta.getKey()).setValue(attributes);
metaSection.getAppendedNode().setValue(appended);
appendNode(metaSection, meta.getKey(), attributes, "key");
} else if (n.isGroupNode() && n.getValuePrimitive()) {
// handle group nodes
ConfigurationNode attributes = SimpleConfigurationNode.root();
writeAttributesTo(attributes, node, false);
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(n.getGroupName()).setValue(attributes);
parentsSection.getAppendedNode().setValue(appended);
appendNode(parentsSection, n.getGroupName(), attributes, "group");
} else {
// handle regular permissions and negated meta+prefixes+suffixes
ConfigurationNode attributes = SimpleConfigurationNode.root();
writeAttributesTo(attributes, node, true);
ConfigurationNode appended = SimpleConfigurationNode.root();
appended.getNode(n.getPermission()).setValue(attributes);
permissionsSection.getAppendedNode().setValue(appended);
appendNode(permissionsSection, n.getPermission(), attributes, "permission");
}
}

View File

@ -0,0 +1,47 @@
/*
* 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.storage.dao.file.loader;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.toml.TOMLConfigurationLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class TomlLoader implements ConfigurateLoader {
@Override
public ConfigurationLoader<? extends ConfigurationNode> loader(Path path) {
return TOMLConfigurationLoader.builder()
.setKeyIndent(2)
.setTableIndent(2)
.setSource(() -> Files.newBufferedReader(path, StandardCharsets.UTF_8))
.setSink(() -> Files.newBufferedWriter(path, StandardCharsets.UTF_8))
.build();
}
}

View File

@ -92,22 +92,10 @@
<pattern>redis.clients.jedis</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedis</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedisutil</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool2</pattern>
<shadedPattern>me.lucko.luckperms.lib.commonspool2</shadedPattern>
</relocation>
<relocation>
<pattern>ninja.leaping.configurate</pattern>
<shadedPattern>me.lucko.luckperms.lib.configurate</shadedPattern>
</relocation>
<relocation>
<pattern>com.typesafe.config</pattern>
<shadedPattern>me.lucko.luckperms.lib.hocon</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.listener.ConnectionListener;
import me.lucko.luckperms.common.managers.group.StandardGroupManager;
@ -68,8 +69,10 @@ import cn.nukkit.plugin.service.ServicePriority;
import cn.nukkit.utils.Config;
import java.io.File;
import java.util.EnumSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
/**
@ -103,6 +106,11 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
this.senderFactory = new NukkitSenderFactory(this);
}
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
}
@Override
protected ConfigurationAdapter provideConfigurationAdapter() {
return new NukkitConfigAdapter(this, resolveConfig());

View File

@ -74,6 +74,11 @@ use-server-uuid-cache: false
# |=> YAML (.yml files)
# |=> JSON (.json files)
# |=> HOCON (.conf files)
# |=> TOML (.toml files)
# |
# | By default, user, group and track data is separated into different files. Data can be combined
# | and all stored in the same file by switching to a combined storage variant.
# | Just add '-combined' to the end of the storage-method, e.g. 'yaml-combined'
#
# - A H2 database is the default option.
# - If you want to edit data manually in "traditional" storage files, we suggest using YAML.

View File

@ -93,12 +93,8 @@
<shadedPattern>me.lucko.luckperms.lib.jedis</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>me.lucko.luckperms.lib.jedisutil</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool2</pattern>
<shadedPattern>me.lucko.luckperms.lib.commonspool2</shadedPattern>
<pattern>ninja.leaping.configurate</pattern>
<shadedPattern>me.lucko.luckperms.lib.configurate</shadedPattern>
</relocation>
</relocations>
</configuration>
@ -158,6 +154,32 @@
<artifactId>spongeapi</artifactId>
<version>8.0.0-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-core</artifactId>
</exclusion>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
</exclusion>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-gson</artifactId>
</exclusion>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-yaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- configurate -->
<dependency>
<groupId>me.lucko.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -34,6 +34,7 @@ import me.lucko.luckperms.common.command.abstraction.Command;
import me.lucko.luckperms.common.command.access.CommandPermission;
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.dependencies.Dependency;
import me.lucko.luckperms.common.event.AbstractEventBus;
import me.lucko.luckperms.common.managers.track.StandardTrackManager;
import me.lucko.luckperms.common.messaging.MessagingFactory;
@ -60,7 +61,6 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
import me.lucko.luckperms.sponge.service.persisted.PersistedCollection;
import me.lucko.luckperms.sponge.tasks.ServiceCacheHousekeepingTask;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.service.permission.PermissionDescription;
import org.spongepowered.api.service.permission.PermissionService;
import org.spongepowered.api.service.permission.Subject;
@ -70,8 +70,10 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
/**
@ -106,6 +108,12 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
this.senderFactory = new SpongeSenderFactory(this);
}
@Override
protected Set<Dependency> getGlobalDependencies() {
return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP,
Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON, Dependency.HOCON_CONFIG);
}
@Override
protected ConfigurationAdapter provideConfigurationAdapter() {
return new SpongeConfigAdapter(this, resolveConfig());

View File

@ -74,6 +74,11 @@ use-server-uuid-cache = false
# |=> YAML (.yml files)
# |=> JSON (.json files)
# |=> HOCON (.conf files)
# |=> TOML (.toml files)
# |
# | By default, user, group and track data is separated into different files. Data can be combined
# | and all stored in the same file by switching to a combined storage variant.
# | Just add '-combined' to the end of the storage-method, e.g. 'yaml-combined'
#
# - A H2 database is the default option.
# - If you want to edit data manually in "traditional" storage files, we suggest using YAML.