Class ScenarioUtils
java.lang.Object
uk.radialbog9.spigot.manhunt.scenario.ScenarioUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ScenarioConfigurationfromConfig(String config, Class<? extends ScenarioConfiguration> clazz) static ObjectgetScenarioInstance(String scenarioName, Class<?> scenarioClass) Creates the instance of the scenario and sets the config if it exists.static booleanisScenarioEnabled(Object instance) Check if a scenario is enabled and the game is startedstatic voidLoad the configuration for all scenariosstatic voidloadConfigFromScenario(String scenarioName, Class<?> scenarioClass) Loads the configuration for the scenario, the intent being to add it to the configuration file if it doesn't exist.static StringtoConfig(ScenarioConfiguration config)
-
Constructor Details
-
ScenarioUtils
public ScenarioUtils()
-
-
Method Details
-
isScenarioEnabled
Check if a scenario is enabled and the game is started- Parameters:
instance- The instance of the scenario- Returns:
- True if the scenario is enabled and the game is started
-
toConfig
-
fromConfig
public static ScenarioConfiguration fromConfig(String config, Class<? extends ScenarioConfiguration> clazz) -
loadConfigFromScenario
public static void loadConfigFromScenario(String scenarioName, Class<?> scenarioClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Loads the configuration for the scenario, the intent being to add it to the configuration file if it doesn't exist.- Parameters:
scenarioName- The name of the scenarioscenarioClass- The class of the scenario- Throws:
NoSuchMethodException- If the method doesn't existInvocationTargetException- If the method can't be invokedInstantiationException- If the class can't be instantiatedIllegalAccessException- If the class can't be accessed
-
getScenarioInstance
public static Object getScenarioInstance(String scenarioName, Class<?> scenarioClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Creates the instance of the scenario and sets the config if it exists.- Parameters:
scenarioName- The name of the scenarioscenarioClass- The class of the scenario- Returns:
- The instance of the scenario
- Throws:
NoSuchMethodException- If the method doesn't existInvocationTargetException- If the method can't be invokedInstantiationException- If the class can't be instantiatedIllegalAccessException- If the class can't be accessed
-
loadConfigAllScenarios
public static void loadConfigAllScenarios()Load the configuration for all scenarios
-