mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 21:58:16 +08:00
[1.3.0] 版本更新
1. 更新 EasyConfiguration 到 3.0.0 (破坏性更新)。 2. 添加 ConfiguredTitle 用于快捷向玩家发送title消息。 3. 为 ConfiguredItem 添加name和lore的原生params变量支持。 4. 添加 ProtocolLibHelper 用于支持多版本情况下的部分功能。(如需使用请安装 ProtocolLib 插件)
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.carm.lib.configuration;
|
||||
|
||||
import cc.carm.lib.configuration.spigot.source.SpigotConfigProvider;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -30,4 +31,12 @@ public class MineConfiguration {
|
||||
return from(new File(fileName), source);
|
||||
}
|
||||
|
||||
public static SpigotConfigProvider from(Plugin plugin, String fileName) {
|
||||
return from(plugin, fileName, fileName);
|
||||
}
|
||||
|
||||
public static SpigotConfigProvider from(Plugin plugin, String fileName, String source) {
|
||||
return from(new File(plugin.getDataFolder(), fileName), source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-24
@@ -1,15 +1,14 @@
|
||||
package cc.carm.lib.configuration.spigot.source;
|
||||
|
||||
import cc.carm.lib.configuration.core.ConfigInitializer;
|
||||
import cc.carm.lib.configuration.core.source.ConfigCommentInfo;
|
||||
import cc.carm.lib.configuration.craft.source.CraftConfigProvider;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SpigotConfigProvider extends CraftConfigProvider {
|
||||
@@ -25,33 +24,31 @@ public class SpigotConfigProvider extends CraftConfigProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComment(@Nullable String path, @Nullable ConfigCommentInfo commentInfo) {
|
||||
public void setHeaderComment(@Nullable String path, @Nullable List<String> comments) {
|
||||
if (path == null) {
|
||||
if (commentInfo == null) this.configuration.options().setFooter(null);
|
||||
else if (!String.join("", commentInfo.getComments()).isEmpty()) {
|
||||
this.configuration.options().setFooter(Arrays.asList(commentInfo.getComments()));
|
||||
}
|
||||
this.configuration.options().setHeader(comments);
|
||||
} else {
|
||||
if (commentInfo == null) this.configuration.setComments(path, null);
|
||||
else {
|
||||
List<String> comments = new ArrayList<>();
|
||||
|
||||
if (!String.join("", commentInfo.getComments()).isEmpty()) {
|
||||
if (commentInfo.startWrap()) comments.add("");
|
||||
comments.addAll(Arrays.asList(commentInfo.getComments()));
|
||||
if (commentInfo.endWrap()) comments.add("");
|
||||
} else if (commentInfo.startWrap() || commentInfo.endWrap()) {
|
||||
comments.add("");
|
||||
}
|
||||
|
||||
this.configuration.setComments(path, comments);
|
||||
}
|
||||
this.configuration.setComments(path, comments);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ConfigCommentInfo getComment(@Nullable String path) {
|
||||
return null;
|
||||
public void setInlineComment(@NotNull String path, @Nullable String comment) {
|
||||
if (comment == null) {
|
||||
this.configuration.setInlineComments(path, null);
|
||||
} else {
|
||||
this.configuration.setComments(path, Collections.singletonList(comment));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable @Unmodifiable List<String> getHeaderComment(@Nullable String path) {
|
||||
if (path == null) return Collections.unmodifiableList(this.configuration.options().getHeader());
|
||||
else return this.configuration.getComments(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getInlineComment(@NotNull String path) {
|
||||
return String.join(" ", this.configuration.getInlineComments(path));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user