/*
* Copyright (C) 2014-2023 Daniel Saukel
*
* This library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see .
*/
package de.erethon.dungeonsxl.api.dungeon;
import de.erethon.caliburn.item.ExItem;
import de.erethon.caliburn.mob.ExMob;
import de.erethon.bedrock.chat.MessageUtil;
import de.erethon.bedrock.misc.EnumUtil;
import de.erethon.bedrock.misc.NumberUtil;
import de.erethon.dungeonsxl.api.DungeonsAPI;
import de.erethon.dungeonsxl.api.Requirement;
import de.erethon.dungeonsxl.api.Reward;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection;
/**
* Represents a game rule for a {@link Game}.
*
* @param the type of the game rule value
* @author Daniel Saukel
*/
public class GameRule {
/**
* Shall players play the dungeon with their own items or do you want to use classes?
*/
public static final GameRule KEEP_INVENTORY_ON_ENTER = new GameRule<>(Boolean.class, "keepInventoryOnEnter", false);
/**
* Shall players keep their inventory when they leave the dungeon without succeeding?
*/
public static final GameRule KEEP_INVENTORY_ON_ESCAPE = new GameRule<>(Boolean.class, "keepInventoryOnEscape", false);
/**
* Shall players keep their inventory when they finish the dungeon?
*/
public static final GameRule KEEP_INVENTORY_ON_FINISH = new GameRule<>(Boolean.class, "keepInventoryOnFinish", false);
/**
* Shall players lose their items when they die (do not mix up this with "onEscape"!)?
*/
public static final GameRule KEEP_INVENTORY_ON_DEATH = new GameRule<>(Boolean.class, "keepInventoryOnDeath", true);
/**
* Shall players reset their inventory to their chosen class when respawning?
*/
public static final GameRule RESET_CLASS_INVENTORY_ON_RESPAWN = new GameRule<>(Boolean.class, "resetClassInventoryOnRespawn", false);
/**
* The location where the players spawn when they leave the dungeon without succeeding.
*/
public static final GameRule ESCAPE_LOCATION = new GameRule<>(String.class, "escapeLocation", null);
/**
* The location where the players spawn when they finish the dungeon.
*/
public static final GameRule FINISH_LOCATION = new GameRule<>(String.class, "finishLocation", null);
/**
* The goal of the game that defines what makes it end.
*/
public static final GameRule GAME_GOAL = new GameRule<>(GameGoal.class, "gameGoal", GameGoal.DEFAULT, GameGoal.READER);
/**
* The Vanilla game mode.
*/
public static final GameRule GAME_MODE = new GameRule<>(GameMode.class, "gameMode", GameMode.SURVIVAL);
/**
* The Vanilla difficulty.
*/
public static final GameRule DIFFICULTY = new GameRule<>(Difficulty.class, "difficulty", Difficulty.NORMAL);
/**
* If the food levels of the players change.
*/
public static final GameRule FOOD_LEVEL = new GameRule<>(Boolean.class, "foodLevel", true);
/**
* Sets if death screens are enabled. If false, players that would have died are healed and teleported to the respawn location;
* their inventory and experience are dropped if {@link #KEEP_INVENTORY_ON_DEATH} is set to false.
*/
public static final GameRule DEATH_SCREEN = new GameRule<>(Boolean.class, "deathScreen", false);
/**
* If players may fly.
*/
public static final GameRule FLY = new GameRule<>(Boolean.class, "fly", false);
/**
* If players can build and destroy blocks in this world.
*/
public static final GameRule BREAK_BLOCKS = new GameRule<>(BuildMode.class, "breakBlocks", BuildMode.FALSE, ConfigReader.BUILD_MODE_READER);
/**
* A blacklist of block types players cannot interact with.
*/
public static final GameRule