mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 21:58:16 +08:00
build(deps): Update with EasyConfiguration
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+28
-11
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.UnmodifiableView;
|
import org.jetbrains.annotations.UnmodifiableView;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -13,12 +14,14 @@ public class BukkitSection implements ConfigureSection {
|
|||||||
|
|
||||||
protected final @NotNull BukkitSource source;
|
protected final @NotNull BukkitSource source;
|
||||||
protected final @Nullable BukkitSection parent;
|
protected final @Nullable BukkitSection parent;
|
||||||
|
protected final @NotNull String path;
|
||||||
protected final @NotNull ConfigurationSection data;
|
protected final @NotNull ConfigurationSection data;
|
||||||
|
|
||||||
public BukkitSection(@NotNull BukkitSource source, @Nullable BukkitSection parent,
|
public BukkitSection(@NotNull BukkitSource source, @Nullable BukkitSection parent,
|
||||||
@NotNull ConfigurationSection data) {
|
@NotNull String path, @NotNull ConfigurationSection data) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.path = path;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +34,11 @@ public class BukkitSection implements ConfigureSection {
|
|||||||
return this.parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String path() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull ConfigurationSection data() {
|
public @NotNull ConfigurationSection data() {
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
@@ -42,11 +50,23 @@ public class BukkitSection implements ConfigureSection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull @UnmodifiableView Map<String, Object> getValues(boolean deep) {
|
public @NotNull @UnmodifiableView Map<String, Object> getValues(boolean deep) {
|
||||||
return data().getValues(deep);
|
|
||||||
|
Map<String, Object> original = data().getValues(deep);
|
||||||
|
// wrap all ConfigurationSection
|
||||||
|
for (Map.Entry<String, Object> entry : original.entrySet()) {
|
||||||
|
if (entry.getValue() instanceof ConfigurationSection) {
|
||||||
|
original.put(entry.getKey(), createSection(entry.getKey(), (ConfigurationSection) entry.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.unmodifiableMap(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(@NotNull String path, @Nullable Object value) {
|
public void set(@NotNull String path, @Nullable Object value) {
|
||||||
|
if (value instanceof BukkitSection) { // unwrap
|
||||||
|
value = ((BukkitSection) value).data();
|
||||||
|
}
|
||||||
data().set(path, value);
|
data().set(path, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,27 +80,24 @@ public class BukkitSection implements ConfigureSection {
|
|||||||
Object value = get(path);
|
Object value = get(path);
|
||||||
if (value instanceof ConfigureSection) {
|
if (value instanceof ConfigureSection) {
|
||||||
return (ConfigureSection) value;
|
return (ConfigureSection) value;
|
||||||
} else if (value instanceof ConfigurationSection) {
|
|
||||||
return new BukkitSection(source(), this, (ConfigurationSection) value);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull BukkitSection createSection(@NotNull String path, @NotNull ConfigurationSection section) {
|
||||||
public @NotNull ConfigureSection createSection(@NotNull Map<?, ?> data) {
|
return new BukkitSection(source(), this, path, section);
|
||||||
throw new UnsupportedOperationException("BukkitSection does not support this operation");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ConfigureSection computeSection(@NotNull String path) {
|
public @NotNull BukkitSection createSection(@NotNull String path, @NotNull Map<?, ?> data) {
|
||||||
return new BukkitSection(source(), this, data.createSection(path));
|
return createSection(path, data().createSection(path, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Object get(@NotNull String path) {
|
public @Nullable Object get(@NotNull String path) {
|
||||||
Object value = data().get(path);
|
Object value = data().get(path);
|
||||||
if (value instanceof ConfigurationSection) {
|
if (value instanceof ConfigurationSection) { // wrap
|
||||||
return new BukkitSection(source(), this, (ConfigurationSection) value);
|
return createSection(path, (ConfigurationSection) value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -38,7 +38,7 @@ public class BukkitSource extends FileConfigSource<BukkitSection, YamlConfigurat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BukkitSource self() {
|
protected @NotNull BukkitSource self() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class BukkitSource extends FileConfigSource<BukkitSection, YamlConfigurat
|
|||||||
@Override
|
@Override
|
||||||
protected void onReload() throws Exception {
|
protected void onReload() throws Exception {
|
||||||
YamlConfiguration configuration = fileReader(YamlConfiguration::loadConfiguration);
|
YamlConfiguration configuration = fileReader(YamlConfiguration::loadConfiguration);
|
||||||
this.rootSection = new BukkitSection(this, null, configuration);
|
this.rootSection = new BukkitSection(this, null, "", configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -10,14 +10,14 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
|
|
||||||
<deps.easyconfifuration.version>4.0.6</deps.easyconfifuration.version>
|
<deps.easyconfifuration.version>4.0.7</deps.easyconfifuration.version>
|
||||||
<deps.yamlcommentwriter.version>1.2.0</deps.yamlcommentwriter.version>
|
<deps.yamlcommentwriter.version>1.2.0</deps.yamlcommentwriter.version>
|
||||||
<deps.easyplugin.version>1.5.12</deps.easyplugin.version>
|
<deps.easyplugin.version>1.5.12</deps.easyplugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user