package net.knarcraft.minigames.container; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; /** * A material container able to be serialized */ public class SerializableMaterial extends SerializableContainer { /** * Instantiates a new serializable material * * @param material

The material to contain

*/ public SerializableMaterial(Material material) { super(material); } @Override public SerializableContainer getSerializable(Material value) { return new SerializableMaterial(value); } @NotNull @Override public Map serialize() { Map data = new HashMap<>(); data.put("name", getRawValue().name()); return data; } /** * Deserializes a serialized material * * @param data

The serialized data

* @return

The deserialized material

*/ @SuppressWarnings("unused") public static SerializableMaterial deserialize(Map data) { Material material = Material.matchMaterial((String) data.get("name")); if (material == null) { return null; } else { return new SerializableMaterial(material); } } }