Add Config
Dieser Commit ist enthalten in:
Ursprung
81ffdf0cbc
Commit
bfb996c9bc
88
src/de/steamwar/towerrun/Config.java
Normale Datei
88
src/de/steamwar/towerrun/Config.java
Normale Datei
@ -0,0 +1,88 @@
|
|||||||
|
package de.steamwar.towerrun;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
private Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
public static final int TOWER_MIN_X;
|
||||||
|
public static final int TOWER_FLOOR_Y;
|
||||||
|
public static final int TOWER_MIN_Z;
|
||||||
|
|
||||||
|
public static final int TOWER_MIN_HEIGHT;
|
||||||
|
public static final int TOWER_MAX_HEIGHT;
|
||||||
|
|
||||||
|
public static final List<Generator> TOWER_GENERATORS = new ArrayList<>();
|
||||||
|
|
||||||
|
public static final List<Door> TOWER_DOORS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
File worldConfigFile = new File(world.getWorldFolder(), "config.yml");
|
||||||
|
if (!worldConfigFile.exists()) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
|
||||||
|
Bukkit.shutdown();
|
||||||
|
}
|
||||||
|
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
||||||
|
|
||||||
|
ConfigurationSection tower = worldconfig.getConfigurationSection("tower");
|
||||||
|
TOWER_MIN_X = tower.getInt("minX");
|
||||||
|
TOWER_FLOOR_Y = tower.getInt("floorY");
|
||||||
|
TOWER_MIN_Z = tower.getInt("minZ");
|
||||||
|
|
||||||
|
TOWER_MIN_HEIGHT = tower.getInt("minHeight");
|
||||||
|
TOWER_MAX_HEIGHT = tower.getInt("maxHeight");
|
||||||
|
|
||||||
|
for (String key : tower.getConfigurationSection("generators").getKeys(false)) {
|
||||||
|
TOWER_GENERATORS.add(new Generator(tower.getConfigurationSection("generators." + key)));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : tower.getConfigurationSection("doors").getKeys(false)) {
|
||||||
|
TOWER_DOORS.add(new Door(tower.getConfigurationSection("doors." + key)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static final class Generator {
|
||||||
|
public final int minX;
|
||||||
|
public final int maxX;
|
||||||
|
public final int minZ;
|
||||||
|
public final int maxZ;
|
||||||
|
public final Material type;
|
||||||
|
|
||||||
|
private Generator(ConfigurationSection generator) {
|
||||||
|
minX = generator.getInt("minX");
|
||||||
|
maxX = generator.getInt("maxX");
|
||||||
|
minZ = generator.getInt("minZ");
|
||||||
|
maxZ = generator.getInt("maxZ");
|
||||||
|
type = Material.valueOf(generator.getString("type"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static final class Door {
|
||||||
|
public final int x;
|
||||||
|
public final int offsetY;
|
||||||
|
public final int z;
|
||||||
|
|
||||||
|
private Door(ConfigurationSection door) {
|
||||||
|
x = door.getInt("x");
|
||||||
|
offsetY = door.getInt("offsetY");
|
||||||
|
z = door.getInt("z");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren