16.7_dev-3 repo release

ConfigWriter
- add List & "" to String
- fix forceSet
This commit is contained in:
2024-07-03 00:01:02 +02:00
parent 2f168197fe
commit e9a43889cb
6 changed files with 91 additions and 78 deletions

View File

@@ -34,10 +34,10 @@ public class T2CconfigWriter {
config = YamlConfiguration.loadConfiguration(configFile);
Map<String, List<String>> comments = new LinkedHashMap<>();
for (T2CconfigItem value : values) {
if ((value.getForceSet() && exist) || (!exist && !value.getForceSet())) {
config.addDefault(value.getPath(), value.getValue());
comments.put(value.getPath(), value.getComments());
for (T2CconfigItem item : values) {
if (item.getForceSet() || !exist) {
config.addDefault(item.getPath(), item.getValue());
comments.put(item.getPath(), item.getComments());
}
}
@@ -93,7 +93,19 @@ public class T2CconfigWriter {
addSection((ConfigurationSection) value, comments, builder, fullKey, indentLevel + 1);
} else {
// Add value with proper indentation
builder.append(indent).append(key).append(": ").append(value).append("\n");
if (value instanceof List) {
builder.append(indent).append(key).append(": ").append("\n");
List<Object> zw = (List<Object>) value;
for (Object s : zw) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
}
} else {
if (value instanceof String) {
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
}
}
}
}

View File

@@ -5,6 +5,8 @@ import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.t2codelib.Util;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
@@ -44,14 +46,6 @@ public class T2CLibConfig {
space_command("command", null, true,""),
test("opWhitelist.whitelist", null, true,"Test"),
testp1n("opWhitelist.whitelist.player1.name", "PlayerName", false,"Test"),
testp1u("opWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false,"Test"),
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]",
true,"This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'."),
;

View File

@@ -1,24 +0,0 @@
// This class was created by JaTiTV.
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.ConfigurationSection;
import java.util.List;
public class test {
/**
public void test(){
ConfigurationSection test = (ConfigurationSection) T2CLibConfig.VALUES.test.getValue();
for (String key : test.getConfigurationSection("").getKeys(false)) {
String name = test.getString(key + ".Playername");//value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject(
name,
test.getString(key + ".UUID")//value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCache.getOpHashMap().put(name, playerObject);
}
}
*/
}