Files
SteamWar/TowerRun/src/de/steamwar/towerrun/config/Config.java
T
2024-08-05 09:02:07 +02:00

59 lines
2.1 KiB
Java

/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.towerrun.config;
import de.steamwar.towerrun.TowerRun;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.EnumSet;
import java.util.Set;
import java.util.stream.Collectors;
@UtilityClass
public class Config {
public static final int MIN_PLAYERS;
public static final int LOBBY_TIMER;
public static final Set<Material> DESTROYABLE_BLOCKS;
public static final int GAME_TIMER;
public static final int GAME_ESCAPE_TIMER;
static {
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
if (!configFile.exists()) {
TowerRun.getInstance().getLogger().severe("Config not found!");
Bukkit.shutdown();
}
ConfigurationSection config = YamlConfiguration.loadConfiguration(configFile);
MIN_PLAYERS = config.getInt("minPlayers");
LOBBY_TIMER = config.getInt("lobbyTimer");
GAME_TIMER = config.getInt("gameTimer", 20 * 60);
GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60);
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
}
}