package net.knarcraft.minigames.arena.parkour; import net.knarcraft.minigames.arena.ArenaGameMode; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; /** * A representation of possible arena game-modes */ public enum ParkourArenaGameMode implements ConfigurationSerializable, ArenaGameMode { /** * The default game-mode. Failing once throws the player out. */ DEFAULT, /** * A hardcore game mode where no checkpoints are allowed */ HARDCORE, ; /** * Tries to match the correct game-mode according to the given string * * @param gameMode

The game-mode string to match

* @return

The specified arena game-mode

*/ @NotNull public static ParkourArenaGameMode matchGameMode(@NotNull String gameMode) { try { return ParkourArenaGameMode.valueOf(gameMode.toUpperCase()); } catch (IllegalArgumentException exception) { return ParkourArenaGameMode.DEFAULT; } } @NotNull @Override public Map serialize() { Map data = new HashMap<>(); data.put("name", this.name()); return data; } /** * Deserializes the arena game-mode specified by the given data * * @param data

The data to deserialize

* @return

The deserialized arena game-mode

*/ @SuppressWarnings("unused") @NotNull public static ParkourArenaGameMode deserialize(@NotNull Map data) { return ParkourArenaGameMode.valueOf((String) data.get("name")); } @Override @NotNull public ParkourArenaGameMode[] getValues() { return ParkourArenaGameMode.values(); } }