fix some startup issues
This commit is contained in:
parent
04801b7982
commit
66a288b4f4
3 changed files with 60 additions and 15 deletions
|
@ -934,7 +934,7 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9db94ec0cd508a13e86c56e991b9c853a103520d
|
||||
index 0000000000000000000000000000000000000000..0b6d68350f608bb64a701d0e390283d50f12094e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
||||
@@ -0,0 +1,435 @@
|
||||
|
@ -1143,7 +1143,7 @@ index 0000000000000000000000000000000000000000..9db94ec0cd508a13e86c56e991b9c853
|
|||
+ .register(new TypeToken<Reference2IntMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2IntMap<?>>(Reference2IntOpenHashMap::new, Integer.TYPE))
|
||||
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
|
||||
+ .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer())
|
||||
+ .register(new StringRepresentableSerializer())
|
||||
+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer())
|
||||
+ .register(IntOr.Default.SERIALIZER)
|
||||
+ .register(IntOr.Disabled.SERIALIZER)
|
||||
+ .register(DoubleOrDefault.SERIALIZER)
|
||||
|
@ -2468,14 +2468,15 @@ index 0000000000000000000000000000000000000000..bc065d5cc8975dd189954272116a6bc5
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/StringRepresentableSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/StringRepresentableSerializer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..add9d16bac9e4570fbdcf8368d7ba03116e97ddf
|
||||
index 0000000000000000000000000000000000000000..7fc0905fc6b8f5df762b4cea573f935dc00b8bc1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/serializer/StringRepresentableSerializer.java
|
||||
@@ -0,0 +1,43 @@
|
||||
@@ -0,0 +1,52 @@
|
||||
+package io.papermc.paper.configuration.serializer;
|
||||
+
|
||||
+import net.minecraft.util.StringRepresentable;
|
||||
+import net.minecraft.world.entity.MobCategory;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.spongepowered.configurate.serialize.ScalarSerializer;
|
||||
+import org.spongepowered.configurate.serialize.SerializationException;
|
||||
+
|
||||
|
@ -2487,18 +2488,26 @@ index 0000000000000000000000000000000000000000..add9d16bac9e4570fbdcf8368d7ba031
|
|||
+
|
||||
+public final class StringRepresentableSerializer extends ScalarSerializer<StringRepresentable> {
|
||||
+ private static final Map<Type, Function<String, StringRepresentable>> TYPES = Collections.synchronizedMap(Map.ofEntries(
|
||||
+ Map.entry(MobCategory.class, s -> {
|
||||
+ for (MobCategory value : MobCategory.values()) {
|
||||
+ createEntry(MobCategory.class)
|
||||
+ ));
|
||||
+
|
||||
+ public StringRepresentableSerializer() {
|
||||
+ super(StringRepresentable.class);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isValidFor(final Type type) {
|
||||
+ return TYPES.containsKey(type);
|
||||
+ }
|
||||
+
|
||||
+ private static <E extends Enum<E> & StringRepresentable> Map.Entry<Type, Function<String, @Nullable StringRepresentable>> createEntry(Class<E> type) {
|
||||
+ return Map.entry(type, s -> {
|
||||
+ for (E value : type.getEnumConstants()) {
|
||||
+ if (value.getSerializedName().equals(s)) {
|
||||
+ return value;
|
||||
+ }
|
||||
+ }
|
||||
+ return null;
|
||||
+ })
|
||||
+ ));
|
||||
+
|
||||
+ public StringRepresentableSerializer() {
|
||||
+ super(StringRepresentable.class);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue