Make TowerRun Event System Capable

This commit is contained in:
2025-02-01 22:58:49 +01:00
parent 90666e2d20
commit 414bd20eb9
5 changed files with 65 additions and 7 deletions
@@ -19,6 +19,8 @@
package de.steamwar.towerrun.config;
import de.steamwar.sql.Event;
import de.steamwar.sql.EventFight;
import de.steamwar.towerrun.TowerRun;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
@@ -41,6 +43,12 @@ public class Config {
private static final int EVENT_KAMPF_ID;
// Event
public static final EventFight EVENT_FIGHT;
public static final int EVENT_TEAM_BLUE_ID;
public static final int EVENT_TEAM_RED_ID;
public static final int EVENT_MAXIMUM_TEAM_MEMBERS;
static {
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
if (!configFile.exists()) {
@@ -57,9 +65,34 @@ public class Config {
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
EVENT_KAMPF_ID = Integer.parseInt(System.getProperty("fightID", "0"));
if (event()) {
EVENT_FIGHT = EventFight.get(EVENT_KAMPF_ID);
if (EVENT_FIGHT == null) {
Bukkit.shutdown();
throw new IllegalStateException("Event not found");
}
Event event = Event.get(EVENT_FIGHT.getEventID());
EVENT_TEAM_BLUE_ID = EVENT_FIGHT.getTeamBlue();
EVENT_TEAM_RED_ID = EVENT_FIGHT.getTeamRed();
EVENT_MAXIMUM_TEAM_MEMBERS = event.getMaximumTeamMembers();
} else {
EVENT_FIGHT = null;
EVENT_TEAM_BLUE_ID = 0;
EVENT_TEAM_RED_ID = 0;
EVENT_MAXIMUM_TEAM_MEMBERS = Integer.MAX_VALUE;
}
}
public static boolean test() {
return EVENT_KAMPF_ID == -1;
}
public static boolean event() {
return EVENT_KAMPF_ID > 0;
}
}