SteamWar/MissileWars
Archiviert
13
0
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
MissileWars/src/de/steamwar/misslewars/Config.java
yoyosource b8da1a3d24
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Add SpaceListener
2022-12-28 18:40:10 +01:00

122 Zeilen
4.0 KiB
Java

/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.misslewars;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.UUID;
import java.util.logging.Level;
public class Config {
private Config(){}
public static final int ArenaMinX;
public static final int ArenaMaxX;
public static final int ArenaMinY;
public static final int ArenaMinZ;
public static final int ArenaMaxZ;
public static final Location RedSpawn;
public static final int RedPortalZ;
public static final Location BlueSpawn;
public static final int BluePortalZ;
public static final int WaitingTime;
public static final int PlatformTime;
public static final int ItemTime;
public static final int ShieldFlyTime;
public static final int EndTime;
public static final double MissileChance;
public static UUID BlueLeader;
public static UUID RedLeader;
private static final int EventKampfID;
public static final boolean Barrier;
public static final boolean Space;
static {
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if (!configfile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
Bukkit.shutdown();
}
FileConfiguration config = YamlConfiguration.loadConfiguration(configfile);
WaitingTime = config.getInt("WaitingTime");
PlatformTime = config.getInt("PlatformTime");
ItemTime = config.getInt("ItemTime");
ShieldFlyTime = config.getInt("ShieldFlyTime");
EndTime = config.getInt("EndTime");
MissileChance = config.getDouble("MissileChance");
ConfigurationSection arena = config.getConfigurationSection("Arena");
assert arena != null;
ArenaMinX = arena.getInt("MinX");
ArenaMaxX = arena.getInt("MaxX");
ArenaMinY = arena.getInt("MinY");
ArenaMinZ = arena.getInt("MinZ");
ArenaMaxZ = arena.getInt("MaxZ");
ConfigurationSection red = config.getConfigurationSection("Red");
assert red != null;
RedPortalZ = red.getInt("PortalZ");
RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ"), (float)red.getDouble("SpawnYaw"), (float)red.getDouble("SpawnPitch"));
ConfigurationSection blue = config.getConfigurationSection("Blue");
assert blue != null;
BluePortalZ = blue.getInt("PortalZ");
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float)blue.getDouble("SpawnYaw"), (float)blue.getDouble("SpawnPitch"));
String blueLeader = System.getProperty("blueLeader", null);
String redLeader = System.getProperty("redLeader", null);
if(blueLeader != null)
BlueLeader = UUID.fromString(blueLeader);
else
BlueLeader = null;
if(redLeader != null)
RedLeader = UUID.fromString(redLeader);
else
RedLeader = null;
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
Barrier = config.getBoolean("Barrier", false);
Space = config.getBoolean("Space", false);
}
public static boolean isChallenge() {
return BlueLeader != null && RedLeader != null;
}
public static boolean test(){
return EventKampfID == -1;
}
}