I'll probably end up rewriting these serializers

This commit is contained in:
nossr50 2019-09-28 17:58:02 -07:00
parent 7385679ec5
commit 90897c9ae1
2 changed files with 5 additions and 4 deletions

View File

@ -261,6 +261,8 @@ public final class ConfigManager {
customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer()); customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer());
customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer()); customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer());
customSerializers.registerType(new TypeToken<ItemMatch<?>>() {}, new CustomItemTargetSerializer());
customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer()); customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer());
customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer()); customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer());
@ -274,7 +276,6 @@ public final class ConfigManager {
customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer()); customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer());
customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer()); customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer());
customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer()); customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer());
customSerializers.registerType(TypeToken.of(ItemMatch.class), new CustomItemTargetSerializer());
customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer()); customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer());
customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer()); customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer());
} }

View File

@ -13,9 +13,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashSet; import java.util.HashSet;
public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch> { public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch<?>> {
private static final String ITEM_CONSUMED_FOR_REPAIR = "Item-Consumed-For-Repair"; private static final String ITEM_CONSUMED_FOR_REPAIR = "Target-Item";
private static final String NBT_REQUIREMENTS = "NBT-Requirements"; private static final String NBT_REQUIREMENTS = "NBT-Requirements";
@Nullable @Nullable
@ -32,7 +32,7 @@ public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch> {
} }
@Override @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch obj, @NonNull ConfigurationNode value) throws ObjectMappingException { public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem()); value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem());
if(obj.getItemMatchProperties().size() > 0) { if(obj.getItemMatchProperties().size() > 0) {