mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Custom Serializer for DamageProperty
This commit is contained in:
parent
7a0ef0d4ed
commit
8c1c17fa17
@ -3,7 +3,7 @@ Version 2.2.0
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
This changelog is not complete, I'll be going over it and cleaning it up once 2.2 is close to release
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!mvn clea
|
||||
mcMMO's config system has been rewritten
|
||||
Nearly every config setting has been renamed and most have brand new comments
|
||||
You can now add an unlimited number of custom XP perks with custom defined XP boosts
|
||||
|
@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -48,6 +48,7 @@ import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.properties.DamageProperty;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
@ -260,6 +261,7 @@ public final class ConfigManager {
|
||||
customSerializers.registerType(TypeToken.of(Salvageable.class), new SalvageableSerializer());
|
||||
customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer());
|
||||
customSerializers.registerType(TypeToken.of(CustomXPPerk.class), new CustomXPPerkSerializer());
|
||||
customSerializers.registerType(TypeToken.of(DamageProperty.class), new DamagePropertySerializer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.gmail.nossr50.config.hocon;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.properties.AbstractDamageProperty;
|
||||
import com.gmail.nossr50.datatypes.skills.properties.DamageProperty;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class DamagePropertySerializer implements TypeSerializer<DamageProperty> {
|
||||
|
||||
public static final String PVP_NODE = "PVP";
|
||||
public static final String PVE_NODE = "PVE";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DamageProperty deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||
Float pvp = value.getNode(PVP_NODE).getValue(TypeToken.of(Float.class));
|
||||
Float pve = value.getNode(PVE_NODE).getValue(TypeToken.of(Float.class));
|
||||
DamageProperty damageProperty = new AbstractDamageProperty(pve, pvp);
|
||||
return damageProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NonNull TypeToken<?> type, @Nullable DamageProperty obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||
value.getNode(PVP_NODE).setValue(obj.getPVPModifier());
|
||||
value.getNode(PVE_NODE).setValue(obj.getPVEModifier());
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.config.hocon.skills.axes;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.properties.AbstractDamageProperty;
|
||||
import com.gmail.nossr50.datatypes.skills.properties.AbstractMaximumProgressionLevel;
|
||||
import com.gmail.nossr50.datatypes.skills.properties.DamageProperty;
|
||||
|
Loading…
Reference in New Issue
Block a user