mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	Add PlayerNotificationSerializer
This commit is contained in:
		| @@ -16,6 +16,7 @@ import com.gmail.nossr50.config.hocon.metrics.ConfigMetrics; | ||||
| import com.gmail.nossr50.config.hocon.mobs.ConfigMobs; | ||||
| import com.gmail.nossr50.config.hocon.motd.ConfigMOTD; | ||||
| import com.gmail.nossr50.config.hocon.notifications.ConfigNotifications; | ||||
| import com.gmail.nossr50.config.hocon.notifications.PlayerNotification; | ||||
| import com.gmail.nossr50.config.hocon.particles.ConfigParticles; | ||||
| import com.gmail.nossr50.config.hocon.party.ConfigParty; | ||||
| import com.gmail.nossr50.config.hocon.party.data.ConfigPartyData; | ||||
| @@ -272,6 +273,7 @@ public final class ConfigManager { | ||||
|         customSerializers.registerType(TypeToken.of(SkillCeiling.class), new SkillCeilingSerializer()); | ||||
|         customSerializers.registerType(TypeToken.of(SkillRankProperty.class), new SkillRankPropertySerializer()); | ||||
|         customSerializers.registerType(TypeToken.of(MaxBonusLevel.class), new MaxBonusLevelSerializer()); | ||||
|         customSerializers.registerType(TypeToken.of(PlayerNotification.class), new PlayerNotificationSerializer()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -20,7 +20,6 @@ public class MinecraftMaterialWrapperSerializer implements TypeSerializer<Minecr | ||||
|  | ||||
|     @Override | ||||
|     public void serialize(TypeToken<?> type, MinecraftMaterialWrapper obj, ConfigurationNode value) { | ||||
|  | ||||
|         value.setValue(obj.getName()); //Name | ||||
|         value.getNode(FULLY_QUALIFIED_NAME).setValue(obj.getFullyQualifiedName()); | ||||
|         value.getNode(BUKKIT_MATERIAL_NAME).setValue(obj.getBukkitMaterialName()); | ||||
|   | ||||
| @@ -0,0 +1,34 @@ | ||||
| package com.gmail.nossr50.config.hocon.serializers; | ||||
|  | ||||
| import com.gmail.nossr50.config.hocon.notifications.PlayerNotification; | ||||
| 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 PlayerNotificationSerializer implements TypeSerializer<PlayerNotification> { | ||||
|     private static final String ENABLED_NODE = "Enabled"; | ||||
|     private static final String SEND_TO_CHAT_NODE = "Send-To-Chat"; | ||||
|     private static final String SEND_TO_ACTION_BAR_NODE = "Send-To-Action-Bar"; | ||||
|  | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public PlayerNotification deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { | ||||
|         Boolean enabled = value.getNode(ENABLED_NODE).getValue(TypeToken.of(Boolean.class)); | ||||
|         Boolean sendTochat = value.getNode(SEND_TO_CHAT_NODE).getValue(TypeToken.of(Boolean.class)); | ||||
|         Boolean sendToActionBar = value.getNode(SEND_TO_ACTION_BAR_NODE).getValue(TypeToken.of(Boolean.class)); | ||||
|  | ||||
|         PlayerNotification playerNotification = new PlayerNotification(enabled, sendTochat, sendToActionBar); | ||||
|         return playerNotification; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void serialize(@NonNull TypeToken<?> type, @Nullable PlayerNotification obj, @NonNull ConfigurationNode value) throws ObjectMappingException { | ||||
|         value.getNode(ENABLED_NODE).setValue(obj.isEnabled()); | ||||
|         value.getNode(SEND_TO_CHAT_NODE).setValue(obj.isSendToChat()); | ||||
|         value.getNode(SEND_TO_ACTION_BAR_NODE).setValue(obj.isSendToActionBar()); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 nossr50
					nossr50