diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 39a1f5d9..f6e5afd3 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -92,22 +92,10 @@ redis.clients.jedis me.lucko.luckperms.lib.jedis - - redis.clients.util - me.lucko.luckperms.lib.jedisutil - - - org.apache.commons.pool2 - me.lucko.luckperms.lib.commonspool2 - ninja.leaping.configurate me.lucko.luckperms.lib.configurate - - com.typesafe.config - me.lucko.luckperms.lib.hocon - diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index 416cba9f..bc12a743 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -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 getGlobalDependencies() { + return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + } + @Override protected ConfigurationAdapter provideConfigurationAdapter() { return new BukkitConfigAdapter(this, resolveConfig()); diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 3a25fc1a..be490e07 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -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. diff --git a/bungee/pom.xml b/bungee/pom.xml index 2ceac3df..53fdc253 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -92,22 +92,10 @@ redis.clients.jedis me.lucko.luckperms.lib.jedis - - redis.clients.util - me.lucko.luckperms.lib.jedisutil - - - org.apache.commons.pool2 - me.lucko.luckperms.lib.commonspool2 - ninja.leaping.configurate me.lucko.luckperms.lib.configurate - - com.typesafe.config - me.lucko.luckperms.lib.hocon - diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index 0061d6b6..f1d42c74 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -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 getGlobalDependencies() { + return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + } + @Override protected ConfigurationAdapter provideConfigurationAdapter() { return new BungeeConfigAdapter(this, resolveConfig()); diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index d907fc09..c270c049 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -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. diff --git a/common/pom.xml b/common/pom.xml index f47b53c9..cf4aacb6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -83,7 +83,7 @@ com.google.guava guava 19.0 - provided + compile @@ -109,9 +109,9 @@ - ninja.leaping.configurate + me.lucko.configurate configurate-core - 3.3 + 3.4 provided @@ -122,9 +122,9 @@ - ninja.leaping.configurate + me.lucko.configurate configurate-yaml - 3.3 + 3.4 provided @@ -135,9 +135,9 @@ - ninja.leaping.configurate + me.lucko.configurate configurate-gson - 3.3 + 3.4 provided @@ -148,11 +148,24 @@ - ninja.leaping.configurate + me.lucko.configurate configurate-hocon - 3.3 + 3.4 provided + + + me.lucko.configurate + configurate-toml + 3.4 + provided + + + com.moandjiezana.toml + toml4j + + + com.zaxxer diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index f8027b73..22c47970 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -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; diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRegistry.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRegistry.java index ec8d45f1..312764de 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRegistry.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRegistry.java @@ -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 GLOBAL_DEPENDENCIES = ImmutableSet.copyOf(EnumSet.of( - Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP - )); - private static final Map> STORAGE_DEPENDENCIES = ImmutableMap.>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; } diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index a931b185..7e2d1d99 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -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 getGlobalDependencies(); protected abstract ConfigurationAdapter provideConfigurationAdapter(); protected abstract void registerPlatformListeners(); protected abstract MessagingFactory provideMessagingFactory(); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java index a1ae76aa..6a6302ae 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java @@ -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); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java b/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java index 47582323..2d794b4e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java @@ -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"), diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/AbstractConfigurateDao.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/AbstractConfigurateDao.java index b25f70e7..63cd743f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/AbstractConfigurateDao.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/AbstractConfigurateDao.java @@ -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 parseEntry(ConfigurationNode appended) { + private static Map.Entry parseEntry(ConfigurationNode appended, String keyFieldName) { if (!appended.hasMapChildren()) { return null; } - Map.Entry entry = Iterables.getFirst(appended.getChildrenMap().entrySet(), null); - if (entry == null || !entry.getValue().hasMapChildren()) { + + Map 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 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 readNodes(ConfigurationNode data) { @@ -504,7 +526,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao { continue; } - Map.Entry entry = parseEntry(appended); + Map.Entry entry = parseEntry(appended, "permission"); if (entry == null) { continue; } @@ -521,7 +543,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao { continue; } - Map.Entry entry = parseEntry(appended); + Map.Entry entry = parseEntry(appended, "group"); if (entry == null) { continue; } @@ -534,7 +556,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao { if (data.getNode(keyName).hasListChildren()) { List children = data.getNode(keyName).getChildrenList(); for (ConfigurationNode appended : children) { - Map.Entry entry = parseEntry(appended); + Map.Entry 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 children = data.getNode("meta").getChildrenList(); for (ConfigurationNode appended : children) { - Map.Entry entry = parseEntry(appended); + Map.Entry 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 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 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"); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/loader/TomlLoader.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/loader/TomlLoader.java new file mode 100644 index 00000000..c38d6f46 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/loader/TomlLoader.java @@ -0,0 +1,47 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * 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 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(); + } +} diff --git a/nukkit/pom.xml b/nukkit/pom.xml index e49ed5d8..cbcd58aa 100644 --- a/nukkit/pom.xml +++ b/nukkit/pom.xml @@ -92,22 +92,10 @@ redis.clients.jedis me.lucko.luckperms.lib.jedis - - redis.clients.util - me.lucko.luckperms.lib.jedisutil - - - org.apache.commons.pool2 - me.lucko.luckperms.lib.commonspool2 - ninja.leaping.configurate me.lucko.luckperms.lib.configurate - - com.typesafe.config - me.lucko.luckperms.lib.hocon - diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java index 9742deb0..2b27b2c4 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java @@ -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 getGlobalDependencies() { + return EnumSet.of(Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + } + @Override protected ConfigurationAdapter provideConfigurationAdapter() { return new NukkitConfigAdapter(this, resolveConfig()); diff --git a/nukkit/src/main/resources/config.yml b/nukkit/src/main/resources/config.yml index ff4da5ef..fade4e29 100644 --- a/nukkit/src/main/resources/config.yml +++ b/nukkit/src/main/resources/config.yml @@ -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. diff --git a/sponge/pom.xml b/sponge/pom.xml index 571cda05..3e390f48 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -93,12 +93,8 @@ me.lucko.luckperms.lib.jedis - redis.clients.util - me.lucko.luckperms.lib.jedisutil - - - org.apache.commons.pool2 - me.lucko.luckperms.lib.commonspool2 + ninja.leaping.configurate + me.lucko.luckperms.lib.configurate @@ -158,6 +154,32 @@ spongeapi 8.0.0-SNAPSHOT provided + + + ninja.leaping.configurate + configurate-core + + + ninja.leaping.configurate + configurate-hocon + + + ninja.leaping.configurate + configurate-gson + + + ninja.leaping.configurate + configurate-yaml + + + + + + + me.lucko.configurate + configurate-hocon + 3.4 + provided diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 25c41599..b4487956 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -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 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()); diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 37625b73..0cff25f8 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -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.