mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
优化默认配置格式
This commit is contained in:
@@ -5,8 +5,11 @@ import java.util.List;
|
||||
public interface EntityData<T> {
|
||||
|
||||
Object serializer();
|
||||
|
||||
int id();
|
||||
|
||||
T defaultValue();
|
||||
|
||||
Object entityDataAccessor();
|
||||
|
||||
default Object createEntityDataIfNotDefaultValue(T value) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import net.momirealms.craftengine.core.util.FileUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -29,7 +31,13 @@ public class DebugMigrateTemplatesCommand extends BukkitCommandFeature<CommandSe
|
||||
for (Pack pack : BukkitCraftEngine.instance().packManager().loadedPacks()) {
|
||||
for (Path file : FileUtils.getYmlConfigsDeeply(pack.configurationFolder())) {
|
||||
try {
|
||||
Files.writeString(file, replacePlaceholders(Files.readString(file)));
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
options.setPrettyFlow(true);
|
||||
Yaml yaml = new Yaml(options);
|
||||
Object data = yaml.load(Files.newBufferedReader(file));
|
||||
String fileStr = yaml.dump(data);
|
||||
Files.writeString(file, fileStr);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -3336,26 +3336,15 @@ public final class CoreReflections {
|
||||
);
|
||||
|
||||
// 1.20.5+
|
||||
public static final Field field$ItemStack$CODEC = ReflectionUtils.getDeclaredField(
|
||||
clazz$ItemStack, "CODEC", "b"
|
||||
);
|
||||
public static final Field field$ItemStack$CODEC = ReflectionUtils.getDeclaredField(clazz$ItemStack, "CODEC", "b");
|
||||
|
||||
public static final Codec<Object> instance$ItemStack$CODEC;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Codec<Object> getInstance$ItemStack$CODEC() throws IllegalAccessException {
|
||||
return (Codec<Object>) field$ItemStack$CODEC.get(null);
|
||||
}
|
||||
public static final Codec<?> instance$ItemStack$CODEC;
|
||||
|
||||
static {
|
||||
try {
|
||||
if (VersionHelper.isOrAbove1_20_5()) {
|
||||
instance$ItemStack$CODEC = getInstance$ItemStack$CODEC();
|
||||
} else {
|
||||
instance$ItemStack$CODEC = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
instance$ItemStack$CODEC = VersionHelper.isOrAbove1_20_5() ? (Codec<?>) field$ItemStack$CODEC.get(null) : null;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new ReflectionInitException("Failed to init ItemStack$CODEC", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user