SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/FightSystem_API/src/de/steamwar/fightsystem/Config.java

323 Zeilen
14 KiB
Java

2019-11-16 08:37:33 +01:00
package de.steamwar.fightsystem;
import de.steamwar.sql.Event;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.Team;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class Config {
private Config(){}
//Fight sequence durations
public static final int NoPlayerOnlineDuration;
public static final int SetupDuration;
public static final int PreFightDuration;
public static final int SpectatorDuration;
//arena parameter
public static final int SchemsizeX;
public static final int SchemsizeY;
public static final int SchemsizeZ;
public static final int TeamBlueCornerX;
public static final int TeamBlueCornerY;
public static final int TeamBlueCornerZ;
private static final int TeamBluePasteX;
private static final int TeamBluePasteZ;
2019-11-16 08:37:33 +01:00
public static final Location TeamBlueSpawn;
public static final int TeamRedCornerX;
public static final int TeamRedCornerY;
public static final int TeamRedCornerZ;
private static final int TeamRedPasteX;
private static final int TeamRedPasteZ;
2019-11-16 08:37:33 +01:00
public static final Location TeamRedSpawn;
private static final int TeamBluetoReddistanceX;
private static final int TeamBluetoReddistanceY;
public static final int TeamBluetoReddistanceZ;
public static final Location SpecSpawn;
public static final int underArenaBorder;
public static final int BorderFromSchematic;
public static final int upperArenaBorder;
public static final boolean AlignWater;
public static final int WaterDepth;
private static final int Schem2BorderX;
private static final int Schem2BorderZ;
public static final int ArenaMinX;
public static final int ArenaMinZ;
public static final int ArenaMaxX;
public static final int ArenaMaxZ;
//schematic parameter
public static final boolean OnlyPublicSchematics;
public static final de.steamwar.sql.SchematicType SchematicType;
public static final boolean TeamRedRotate;
public static final boolean TeamBlueRotate;
2019-12-06 22:51:26 +01:00
public static final boolean ReplaceObsidian;
public static final boolean ReplaceBedrock;
2019-11-16 08:37:33 +01:00
//team parameter
public static final String TeamRedName;
public static final String TeamBlueName;
public static final String TeamRedPrefix;
public static final String TeamBluePrefix;
public static final String GameName;
public static final String TeamChatDetection;
public static final UUID BlueLeader;
public static final UUID RedLeader;
//Active win conditions
public static final boolean Timeout;
public static final boolean HeartRatioTimeout;
2019-11-16 08:37:33 +01:00
public static final boolean AllDead;
public static final boolean CaptainDead;
public static final boolean PercentSystem;
public static final boolean RelativePercent;
public static final boolean Points;
2019-11-16 08:37:33 +01:00
public static final boolean Entern;
public static final boolean TechKO;
public static final boolean WaterTechKO;
public static final boolean PumpkinTechKO;
2019-11-16 08:37:33 +01:00
//win condition parameters
public static final int TimeoutTime;
public static final int EnterPhaseBegin;
public static final double PercentWin;
public static final List<String> IgnoredBlocks;
2019-11-16 08:37:33 +01:00
//default kits
public static final String MemberDefault;
public static final String LeaderDefault;
//tech hider parameter
public static final List<Integer> HiddenBlocks;
2019-11-16 08:37:33 +01:00
public static final List<String> HiddenBlockEntities;
public static final int ObfuscateWith;
public static final String ObfuscateWithTag;
2019-11-16 08:37:33 +01:00
//event parameter
private static final int EventKampfID;
public static final int EventTeamBlueID;
public static final int EventTeamRedID;
public static final boolean BothTeamsPublic;
public static final int MaximumTeamMembers;
static{
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if(!worldConfigFile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
IFightSystem.shutdown(null);
}
if(!new File(IFightSystem.getPlugin().getDataFolder(), "config.yml").exists()) {
IFightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
IFightSystem.shutdown(null);
}
FileConfiguration config = IFightSystem.getPlugin().getConfig();
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration");
SetupDuration = config.getInt("Times.SetupDuration");
PreFightDuration = config.getInt("Times.PreFightDuration");
SpectatorDuration = config.getInt("Times.SpectatorDuration");
int schemsizeX = worldconfig.getInt("Arena.Schemsize.x");
int schemsizeY = worldconfig.getInt("Arena.Schemsize.y");
int schemsizeZ = worldconfig.getInt("Arena.Schemsize.z");
int teamBlueCornerX = worldconfig.getInt("Arena.TeamBlueCorner.x");
int teamBlueCornerY = worldconfig.getInt("Arena.TeamBlueCorner.y");
int teamBlueCornerZ = worldconfig.getInt("Arena.TeamBlueCorner.z");
TeamBluetoReddistanceX = worldconfig.getInt("Arena.TeamBluetoReddistance.x");
TeamBluetoReddistanceY = worldconfig.getInt("Arena.TeamBluetoReddistance.y");
TeamBluetoReddistanceZ = worldconfig.getInt("Arena.TeamBluetoReddistance.z");
Schem2BorderX = worldconfig.getInt("Arena.Schem2Border.x");
Schem2BorderZ = worldconfig.getInt("Arena.Schem2Border.z");
underArenaBorder = worldconfig.getInt("Arena.underArenaBorder");
BorderFromSchematic = worldconfig.getInt("Arena.BorderFromSchematic");
AlignWater = worldconfig.getBoolean("Arena.AlignWater");
WaterDepth = worldconfig.getInt("Arena.WaterDepth");
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
boolean rotate = config.getBoolean("Schematic.Rotate");
2019-12-06 22:51:26 +01:00
ReplaceObsidian = config.getBoolean("Schematic.ReplaceObsidian");
ReplaceBedrock = config.getBoolean("Schematic.ReplaceBedrock");
2019-11-16 08:37:33 +01:00
TeamRedPrefix = config.getString("Output.TeamRedPrefix");
TeamBluePrefix = config.getString("Output.TeamBluePrefix");
GameName = config.getString("Output.GameName");
TeamChatDetection = config.getString("Output.TeamChatDetection");
Timeout = config.getBoolean("WinConditions.Timeout");
HeartRatioTimeout = config.getBoolean("WinConditions.HeartRatioTimeout");
2019-11-16 08:37:33 +01:00
AllDead = config.getBoolean("WinConditions.AllDead");
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
RelativePercent = config.getBoolean("WinConditions.RelativePercent");
Points = config.getBoolean("WinConditions.Points");
2019-11-16 08:37:33 +01:00
Entern = config.getBoolean("WinConditions.Entern");
TechKO = config.getBoolean("WinConditions.TechKO");
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
PumpkinTechKO = config.getBoolean("WinConditions.PumpkinTechKO");
2019-11-16 08:37:33 +01:00
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
PercentWin = config.getDouble("WinConditionParams.PercentWin");
IgnoredBlocks = Collections.unmodifiableList(config.getStringList("WinConditionParams.IgnoredBlocks"));
2019-11-16 08:37:33 +01:00
MemberDefault = config.getString("Kits.MemberDefault");
LeaderDefault = config.getString("Kits.LeaderDefault");
HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks"));
2019-11-16 08:37:33 +01:00
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
2019-11-16 08:37:33 +01:00
if(schemsizeX < 0){
SchemsizeX = -schemsizeX;
TeamBlueCornerX = teamBlueCornerX - SchemsizeX;
}else{
SchemsizeX = schemsizeX;
TeamBlueCornerX = teamBlueCornerX;
}
if(schemsizeY < 0){
SchemsizeY = -schemsizeY;
TeamBlueCornerY = teamBlueCornerY - SchemsizeY;
}else{
SchemsizeY = schemsizeY;
TeamBlueCornerY = teamBlueCornerY;
}
if(schemsizeZ < 0){
SchemsizeZ = -schemsizeZ;
TeamBlueCornerZ = teamBlueCornerZ - SchemsizeZ;
}else{
SchemsizeZ = schemsizeZ;
TeamBlueCornerZ = teamBlueCornerZ;
}
upperArenaBorder = TeamBlueCornerY + SchemsizeY + BorderFromSchematic;
TeamRedCornerX = TeamBluetoReddistanceX + TeamBlueCornerX;
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
2019-11-16 08:37:33 +01:00
World world = Bukkit.getWorlds().get(0);
2019-12-13 15:51:52 +01:00
TeamBlueSpawn = new Location(world, TeamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY + 0.5, TeamBluePasteZ + 0.5);
TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY + 0.5, TeamRedPasteZ + 0.5);
2019-11-16 08:37:33 +01:00
SpecSpawn = new Location(world,
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
2019-11-16 08:37:33 +01:00
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
TeamBluePasteZ + TeamBluetoReddistanceZ/2.0);
2019-11-16 08:37:33 +01:00
boolean teamRedRotate;
boolean teamBlueRotate;
if(TeamBluetoReddistanceX > 0){
ArenaMinX = TeamBlueCornerX - Schem2BorderX;
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
teamRedRotate = true;
teamBlueRotate = false;
}else{
ArenaMinX = TeamRedCornerX - Schem2BorderX;
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
teamRedRotate = false;
teamBlueRotate = true;
}
if(TeamBluetoReddistanceZ > 0){
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
teamRedRotate = true;
teamBlueRotate = false;
}else{
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
if(TeamBluetoReddistanceZ != 0){
teamRedRotate = false;
teamBlueRotate = true;
}
}
if(!rotate){
teamRedRotate = false;
teamBlueRotate = false;
}
TeamRedRotate = teamRedRotate;
TeamBlueRotate = teamBlueRotate;
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(event()){
EventFight eventFight = EventFight.get(EventKampfID);
if(eventFight == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
IFightSystem.shutdown(null);
}
assert eventFight != null;
Team team1 = Team.get(eventFight.getTeamBlue());
Team team2 = Team.get(eventFight.getTeamRed());
if(team1 == null || team2 == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
IFightSystem.shutdown(null);
}
assert team1 != null;
assert team2 != null;
TeamBlueName = team1.getTeamKuerzel();
TeamRedName = team2.getTeamKuerzel();
EventTeamBlueID = team1.getTeamId();
EventTeamRedID = team2.getTeamId();
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
IFightSystem.setEventFight(eventFight);
Event event = Event.get(eventFight.getEventID());
2019-11-18 18:52:12 +01:00
if(BothTeamsPublic) {
2019-11-16 08:37:33 +01:00
OnlyPublicSchematics = true;
2019-11-18 18:52:12 +01:00
MaximumTeamMembers = Integer.MAX_VALUE;
}else{
2019-11-16 08:37:33 +01:00
OnlyPublicSchematics = event.publicSchemsOnly();
2019-11-18 18:52:12 +01:00
MaximumTeamMembers = event.getMaximumTeamMembers();
}
2019-11-16 08:37:33 +01:00
}else{
//No event
TeamRedName = config.getString("Output.TeamRedName");
TeamBlueName = config.getString("Output.TeamBlueName");
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics");
EventTeamBlueID = 0;
EventTeamRedID = 0;
BothTeamsPublic = true;
MaximumTeamMembers = Integer.MAX_VALUE;
}
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;
}
public static boolean event(){
return EventKampfID >= 1;
}
public static boolean test(){
return EventKampfID == -1;
}
}