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;
|
2019-11-23 18:15:45 +01:00
|
|
|
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;
|
2019-11-23 18:15:45 +01:00
|
|
|
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 String SchematicDirectory;
|
|
|
|
public static final de.steamwar.sql.SchematicType SchematicType;
|
|
|
|
public static final boolean TeamRedRotate;
|
|
|
|
public static final boolean TeamBlueRotate;
|
|
|
|
|
|
|
|
//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 AllDead;
|
|
|
|
public static final boolean CaptainDead;
|
|
|
|
public static final boolean PercentSystem;
|
|
|
|
public static final boolean Entern;
|
|
|
|
public static final boolean TechKO;
|
|
|
|
public static final boolean WaterTechKO;
|
|
|
|
|
|
|
|
//win condition parameters
|
|
|
|
public static final int TimeoutTime;
|
|
|
|
public static final int EnterPhaseBegin;
|
|
|
|
public static final double PercentWin;
|
|
|
|
|
|
|
|
//default kits
|
|
|
|
public static final String MemberDefault;
|
|
|
|
public static final String LeaderDefault;
|
|
|
|
|
|
|
|
//tech hider parameter
|
2019-11-23 18:15:45 +01:00
|
|
|
public static final List<String> HiddenBlocks;
|
2019-11-16 08:37:33 +01:00
|
|
|
public static final List<String> HiddenBlockEntities;
|
2019-11-23 18:15:45 +01:00
|
|
|
public static final String ObfuscateWith;
|
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");
|
|
|
|
|
|
|
|
SchematicDirectory = config.getString("Schematic.Directory");
|
|
|
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
|
|
|
boolean rotate = config.getBoolean("Schematic.Rotate");
|
|
|
|
|
|
|
|
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");
|
|
|
|
AllDead = config.getBoolean("WinConditions.AllDead");
|
|
|
|
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
|
|
|
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
|
|
|
Entern = config.getBoolean("WinConditions.Entern");
|
|
|
|
TechKO = config.getBoolean("WinConditions.TechKO");
|
|
|
|
WaterTechKO = config.getBoolean("WinConditions.WaterTechKO");
|
|
|
|
|
|
|
|
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime");
|
|
|
|
EnterPhaseBegin = config.getInt("WinConditionParams.EnterPhaseBegin");
|
|
|
|
PercentWin = config.getDouble("WinConditionParams.PercentWin");
|
|
|
|
|
|
|
|
MemberDefault = config.getString("Kits.MemberDefault");
|
|
|
|
LeaderDefault = config.getString("Kits.LeaderDefault");
|
|
|
|
|
2019-11-23 18:15:45 +01:00
|
|
|
HiddenBlocks = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlocks"));
|
2019-11-16 08:37:33 +01:00
|
|
|
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
|
2019-11-23 18:15:45 +01:00
|
|
|
ObfuscateWith = config.getString("Techhider.ObfuscateWith");
|
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;
|
|
|
|
|
2019-11-23 18:15:45 +01:00
|
|
|
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-11-23 18:15:45 +01:00
|
|
|
TeamBlueSpawn = new Location(world, TeamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, TeamBluePasteZ + 0.5);
|
|
|
|
TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, TeamRedPasteZ + 0.5);
|
2019-11-16 08:37:33 +01:00
|
|
|
SpecSpawn = new Location(world,
|
2019-11-23 18:15:45 +01:00
|
|
|
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
2019-11-16 08:37:33 +01:00
|
|
|
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
2019-11-23 18:15:45 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|