Compare commits

...
3 Commits
Author SHA1 Message Date
Chaoscaot 12e085600e Move arena runtime configuration into GameCore
Pull Request Build / Build (pull_request) Successful in 1m42s
- Replace FightSystem runtime properties with shared GameConfig
- Update dependent modules, commands, states, and tests
2026-07-24 12:51:03 +02:00
Chaoscaot f8cda32119 Remove File
Pull Request Build / Build (pull_request) Successful in 1m40s
2026-07-24 12:19:35 +02:00
Chaoscaot 867ca6f5dc Migrate FightSystem modes and countdowns to GameCore
- Move shared arena-mode abstractions into GameCore
- Adapt fight countdowns and APIs to the shared model
- Add SteamWar issue audit workflow and SQL language settings
2026-07-24 12:18:49 +02:00
136 changed files with 1993 additions and 1154 deletions
+151
View File
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="LanguageInjectionConfiguration">
<injection language="SQL" injector-id="java">
<display-name>AsyncQueryRunner (org.apache.commons.dbutils)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("batch").withParameterCount(2).definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("insertBatch").withParameterCount(3).definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "insert").withParameters("java.lang.String", "org.apache.commons.dbutils.ResultSetHandler").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "insert").withParameters("java.lang.String", "org.apache.commons.dbutils.ResultSetHandler", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update").withParameters("java.lang.String").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update").withParameters("java.lang.String", "java.lang.Object").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update").withParameters("java.lang.String", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("batch").withParameterCount(3).definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("insertBatch").withParameterCount(4).definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("query", "insert").withParameters("java.sql.Connection", "java.lang.String", "org.apache.commons.dbutils.ResultSetHandler").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("query", "insert").withParameters("java.sql.Connection", "java.lang.String", "org.apache.commons.dbutils.ResultSetHandler", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update").withParameters("java.sql.Connection", "java.lang.String").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update").withParameters("java.sql.Connection", "java.lang.String", "java.lang.Object").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update").withParameters("java.sql.Connection", "java.lang.String", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.AsyncQueryRunner"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>Jodd (jodd.db)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query").withParameterCount(1).definedInClass("jodd.db.DbQuery"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("DbQuery").withParameterCount(2).definedInClass("jodd.db.DbQuery"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("query").withParameterCount(2).definedInClass("jodd.db.DbQuery"))]]></place>
<place><![CDATA[psiParameter().ofMethod(2, psiMethod().withName("DbQuery").withParameterCount(3).definedInClass("jodd.db.DbQuery"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>MyBatis @Select/@Delete/@Insert/@Update</display-name>
<single-file value="true" />
<place><![CDATA[psiMethod().withName("value").withParameters().definedInClass("org.apache.ibatis.annotations.Delete")]]></place>
<place><![CDATA[psiMethod().withName("value").withParameters().definedInClass("org.apache.ibatis.annotations.Insert")]]></place>
<place><![CDATA[psiMethod().withName("value").withParameters().definedInClass("org.apache.ibatis.annotations.Select")]]></place>
<place><![CDATA[psiMethod().withName("value").withParameters().definedInClass("org.apache.ibatis.annotations.Update")]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>QueryRunner (org.apache.commons.dbutils)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("batch").withParameterCount(2).definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("insertBatch").withParameterCount(3).definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "insert").withParameters("java.lang.String", "org.apache.commons.dbutils.ResultSetHandler").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "insert", "execute").withParameters("java.lang.String", "org.apache.commons.dbutils.ResultSetHandler", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update").withParameters("java.lang.String").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update").withParameters("java.lang.String", "java.lang.Object").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("update", "execute").withParameters("java.lang.String", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("batch").withParameterCount(3).definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("insertBatch").withParameterCount(4).definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("query", "insert").withParameters("java.sql.Connection", "java.lang.String", "org.apache.commons.dbutils.ResultSetHandler", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("query", "insert", "execute").withParameters("java.sql.Connection", "java.lang.String", "org.apache.commons.dbutils.ResultSetHandler").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update").withParameters("java.sql.Connection", "java.lang.String").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update").withParameters("java.sql.Connection", "java.lang.String", "java.lang.Object").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
<place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("update", "execute").withParameters("java.sql.Connection", "java.lang.String", "java.lang.Object...").definedInClass("org.apache.commons.dbutils.QueryRunner"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>R2DBC (io.r2dbc)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("add").definedInClass("io.r2dbc.spi.Batch"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("createStatement").definedInClass("io.r2dbc.spi.Connection"))]]></place>
</injection>
<injection language="PostgreSQL" injector-id="java">
<display-name>Reactiverse Postgres Client (io.reactiverse)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.reactiverse.pgclient.PgConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.reactiverse.pgclient.PgTransaction"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.reactiverse.reactivex.pgclient.PgClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.reactiverse.reactivex.pgclient.PgConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.reactiverse.reactivex.pgclient.PgPool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.reactiverse.reactivex.pgclient.PgTransaction"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.reactiverse.axle.pgclient.PgClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.reactiverse.pgclient.PgClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.reactiverse.pgclient.PgPool"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>SmallRye Axle SqlClient (io.vertx.axle.sqlclient)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.vertx.axle.sqlclient.Pool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.vertx.axle.sqlclient.SqlClient"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>SmallRye Mutiny SqlClient (io.vertx.mutiny.sqlclient)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.vertx.mutiny.sqlclient.Pool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "preparedQuery", "preparedBatch").definedInClass("io.vertx.mutiny.sqlclient.SqlClient"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>SmallRye Mutiny SqlConnection (io.vertx.mutiny.sqlclient)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("prepare", "prepareAndAwait").definedInClass("io.vertx.mutiny.db2client.DB2Connection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("prepare", "prepareAndAwait").definedInClass("io.vertx.mutiny.mssqlclient.MSSQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("prepare", "prepareAndAwait").definedInClass("io.vertx.mutiny.mysqlclient.MySQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("prepare", "prepareAndAwait").definedInClass("io.vertx.mutiny.pgclient.PgConnection"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>Vert.x SQL Extensions (io.vertx.ext.sql)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams").definedInClass("io.vertx.ext.sql.SQLClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams").definedInClass("io.vertx.ext.sql.SQLOperations"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams", "execute", "batchWithParams", "batchCallableWithParams").definedInClass("io.vertx.ext.sql.SQLConnection"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>Vert.x SQL Reactive Extensions (io.vertx.reactivex.ext.sql)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams").definedInClass("io.vertx.reactivex.ext.sql.SQLOperations"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams", "execute", "batchWithParams", "batchCallableWithParams", "rxQuerySingle", "rxQuerySingleWithParams", "rxQuery", "rxQueryWithParams", "rxQueryStream", "rxQueryStreamWithParams", "rxUpdate", "rxUpdateWithParams", "rxCall", "rxCallWithParams", "rxExecute", "rxBatchWithParams", "rxBatchCallableWithParams").definedInClass("io.vertx.reactivex.ext.sql.SQLClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "queryWithParams", "queryStream", "queryStreamWithParams", "querySingle", "querySingleWithParams", "update", "updateWithParams", "call", "callWithParams", "execute", "batchWithParams", "batchCallableWithParams", "rxQuerySingle", "rxQuerySingleWithParams", "rxQuery", "rxQueryWithParams", "rxQueryStream", "rxQueryStreamWithParams", "rxUpdate", "rxUpdateWithParams", "rxCall", "rxCallWithParams", "rxExecute", "rxBatchWithParams", "rxBatchCallableWithParams").definedInClass("io.vertx.reactivex.ext.sql.SQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("querySingle", "rxQuerySingle", "querySingleWithParams", "rxQuerySingleWithParams").definedInClass("io.vertx.reactivex.ext.asyncsql.AsyncSQLClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("querySingle", "rxQuerySingle", "querySingleWithParams", "rxQuerySingleWithParams").definedInClass("io.vertx.reactivex.ext.asyncsql.MySQLClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("querySingle", "rxQuerySingle", "querySingleWithParams", "rxQuerySingleWithParams").definedInClass("io.vertx.reactivex.ext.asyncsql.PostgreSQLClient"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>Vert.x SqlClient (io.vertx.sqlclient)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.mssqlclient.MSSQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.mysqlclient.MySQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.pgclient.PgConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.sqlclient.Pool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.sqlclient.SqlClient"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.sqlclient.SqlConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch").definedInClass("io.vertx.sqlclient.Transaction"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>Vert.x SqlClient RxJava2 (io.vertx.reactivex.sqlclient)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.mysqlclient.MySQLConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.pgclient.PgConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.sqlclient.SqlConnection"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPrepare", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.sqlclient.Transaction"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.mysqlclient.MySQLPool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.pgclient.PgPool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.sqlclient.Pool"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "prepare", "preparedQuery", "preparedBatch", "rxQuery", "rxPreparedQuery", "rxPreparedBatch").definedInClass("io.vertx.reactivex.sqlclient.SqlClient"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>jOOQ (org.jooq.DSLContext)</display-name>
<single-file value="true" />
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("batch").withParameters("java.lang.String", "java.lang.Object[]...").definedInClass("org.jooq.DSLContext"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "fetch", "fetchLazy", "fetchAsync", "fetchStream", "fetchMany", "fetchOne", "fetchSingle", "fetchOptional", "fetchValue", "fetchOptionalValue", "fetchValues", "execute", "resultQuery").withParameters("java.lang.String", "java.lang.Object...").definedInClass("org.jooq.DSLContext"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("query", "fetch", "fetchLazy", "fetchAsync", "fetchStream", "fetchMany", "fetchOne", "fetchSingle", "fetchOptional", "fetchValue", "fetchOptionalValue", "fetchValues", "execute", "resultQuery", "batch").withParameters("java.lang.String").definedInClass("org.jooq.DSLContext"))]]></place>
<place><![CDATA[psiParameter().ofMethod(psiMethod().withName("batch").withParameters("java.lang.String...").definedInClass("org.jooq.DSLContext"))]]></place>
</injection>
<injection language="SQL" injector-id="java">
<display-name>rxjava2-jdbc (org.davidmoten.rx.jdbc)</display-name>
<single-file value="true" />
<place><![CDATA[psiMethod().withName("value").definedInClass("org.davidmoten.rx.jdbc.annotations.Query")]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("call", "select", "update").definedInClass("org.davidmoten.rx.jdbc.Database"))]]></place>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("call", "select", "update").definedInClass("org.davidmoten.rx.jdbc.TransactedBuilder"))]]></place>
</injection>
</component>
</project>
@@ -29,6 +29,7 @@ java {
dependencies {
compileOnly(libs.classindex)
annotationProcessor(libs.classindex)
compileOnly(project(":GameCore", "default"))
compileOnly(project(":SpigotCore", "default"))
compileOnly(libs.netty)
@@ -1,56 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
public enum ArenaMode {
NORMAL,
EVENT,
TEST,
CHECK,
PREPARE,
REPLAY;
public static final Set<ArenaMode> All = Collections.unmodifiableSet(EnumSet.allOf(ArenaMode.class));
public static final Set<ArenaMode> Normal = Collections.unmodifiableSet(EnumSet.of(NORMAL));
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
public static final Set<ArenaMode> AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY, CHECK)));
public static final Set<ArenaMode> ManualTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST));
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
public static final Set<ArenaMode> SeriousFight = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY)));
}
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem;
import de.steamwar.data.GameModeConfigUtils;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.sql.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -35,7 +36,6 @@ import org.bukkit.util.Vector;
import java.io.File;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
public class Config {
@@ -75,8 +75,6 @@ public class Config {
public static final String TeamBlueName;
public static final String TeamRedColor;
public static final String TeamBlueColor;
public static final UUID BlueLeader;
public static final UUID RedLeader;
//event parameter
public static final EventFight EventKampf;
@@ -87,23 +85,12 @@ public class Config {
public static final int MaximumTeamMembers;
public static final boolean LiveReplay;
//check parameter
public static final int CheckSchemID;
public static final int PrepareSchemID;
public static final ArenaMode mode;
//replay system parameter
public static final String spectateIP = "127.0.0.1";
public static final int SpectatePort;
public static final int ReplayID;
static {
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
String configFile = System.getProperty("config", "config.yml");
String configFile = GameConfig.ConfigFile;
if (!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
FightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
@@ -209,7 +196,7 @@ public class Config {
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMinY() + GameModeConfig.Schematic.Inset.bottom, BluePasteRegion.getMinZ() + GameModeConfig.Schematic.Inset.z, BluePasteRegion.getMaxX() - GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMaxY() - GameModeConfig.Schematic.Inset.top, BluePasteRegion.getMaxZ() - GameModeConfig.Schematic.Inset.z);
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
int eventKampfID = GameConfig.EventKampfID;
if (eventKampfID >= 1) {
EventKampf = EventFight.byId(eventKampfID);
if (EventKampf == null) {
@@ -261,43 +248,8 @@ public class Config {
Referees = Collections.emptySet();
MaximumTeamMembers = Integer.MAX_VALUE;
LiveReplay = false;
SpectatePort = -ReplayID;
SpectatePort = -GameConfig.ReplayID;
}
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;
}
if (CheckSchemID != 0) {
mode = ArenaMode.CHECK;
} else if (PrepareSchemID != 0) {
mode = ArenaMode.PREPARE;
} else if (eventKampfID >= 1) {
mode = ArenaMode.EVENT;
} else if (eventKampfID == -1) {
mode = ArenaMode.TEST;
} else if (ReplayID != 0) {
mode = ArenaMode.REPLAY;
} else {
mode = ArenaMode.NORMAL;
}
}
public static boolean test() {
return ArenaMode.Test.contains(mode);
}
public static boolean replayserver() {
return ReplayID < 0;
}
public static boolean blueNegZ() {
@@ -36,6 +36,8 @@ import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.HullHider;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.utils.TechHiderWrapper;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.linkage.AbstractLinker;
import de.steamwar.linkage.SpigotLinker;
import de.steamwar.message.Message;
@@ -75,7 +77,7 @@ public class FightSystem extends JavaPlugin {
}
if (Config.SpectatePort != 0) {
Core.setServerName("Spectate");
} else if (Config.ReplayID != 0) {
} else if (GameConfig.ReplayID != 0) {
Core.setServerName("Replay");
}
@@ -109,7 +111,7 @@ public class FightSystem extends JavaPlugin {
});
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(GameConfig.mode));
hullHider = new HullHider();
techHider = new TechHiderWrapper(hullHider);
@@ -118,10 +120,10 @@ public class FightSystem extends JavaPlugin {
FileSource.startReplay();
if (Config.mode == ArenaMode.EVENT) {
if (GameConfig.mode == ArenaMode.EVENT) {
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
} else if (Config.mode == ArenaMode.CHECK) {
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
} else if (GameConfig.mode == ArenaMode.CHECK) {
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(GameConfig.CheckSchemID);
Fight.getBlueTeam().setSchem(checkSchematicNode);
if (checkSchematicNode.isPrepared()) {
@@ -129,8 +131,8 @@ public class FightSystem extends JavaPlugin {
}
new TechareaCommand();
} else if (Config.mode == ArenaMode.PREPARE) {
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
} else if (GameConfig.mode == ArenaMode.PREPARE) {
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(GameConfig.PrepareSchemID));
}
Config.world.setGameRule(GameRule.LOCATOR_BAR, false);
@@ -20,7 +20,7 @@
package de.steamwar.fightsystem.ai;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.ai;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.fight.FightTeam;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class AIManager {
private static final List<AIManager> AIs = Arrays.asList(
new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(Config.mode))
new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(GameConfig.mode))
);
public static List<AIManager> availableAIs() {
@@ -20,7 +20,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,8 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.ai.AIManager;
@@ -56,7 +57,7 @@ public class GUI {
inv.setItem(pos, ColorConverter.chat2dye(team.getColor()), msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
p.closeInventory();
if (ArenaMode.ManualTeams.contains(Config.mode) && team.canbeLeader(p)) {
if (ArenaMode.ManualTeams.contains(GameConfig.mode) && team.canbeLeader(p)) {
team.addMember(p);
} else {
JoinRequest.forPlayer(p, team);
@@ -198,7 +199,7 @@ public class GUI {
}
public static void preSchemDialog(Player p) {
if (!Config.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP) {
if (!GameConfig.test() && FightState.getFightState() != FightState.PRE_SCHEM_SETUP) {
msg.sendPrefixless("SCHEM_NO_ENEMY", p, ChatMessageType.ACTION_BAR);
return;
}
@@ -209,7 +210,7 @@ public class GUI {
for (int i = 0; i < Config.GameModeConfig.Schematic.SubTypes.size(); i++) {
setupSchemTypeRow(p, inv, Config.GameModeConfig.Schematic.SubTypes.get(i), i + 1);
}
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
if (!GameConfig.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameModeConfig.GameName, (Integer) null);
if (node != null) {
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
@@ -233,14 +234,14 @@ public class GUI {
return;
}
if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(Config.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(GameConfig.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, true);
});
}
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) {
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !GameConfig.test()) {
inv.setItem(row * 9, Material.GRAY_DYE, (byte) 8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click) -> {
});
return;
@@ -253,7 +254,7 @@ public class GUI {
}
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked) {
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
SchematicSelector selector = new SchematicSelector(p, GameConfig.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
schemSelect(p, node);
});
selector.setPublicMode(publicSchems ? SchematicSelector.PublicMode.PUBLIC_ONLY : SchematicSelector.PublicMode.PRIVATE_ONLY);
@@ -263,7 +264,7 @@ public class GUI {
private static void schemSelect(Player p, SchematicNode node) {
FightTeam fightTeam = Fight.getPlayerTeam(p);
if (fightTeam == null) return;
if (Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) {
if (GameConfig.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) {
fightTeam.pasteSchem(node);
}
p.closeInventory();
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands;
import com.google.common.collect.ImmutableList;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.linkage.Linked;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
@@ -65,7 +66,7 @@ public class GamemodeCommand extends BukkitCommand {
Player p = (Player) sender;
if (!(Config.test() || Config.isReferee(p))) {
if (!(GameConfig.test() || Config.isReferee(p))) {
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
return false;
}
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.linkage.Linked;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.linkage.Linked;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.linkage.Linked;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.record.PacketProcessor;
import de.steamwar.fightsystem.states.FightState;
@@ -35,7 +35,7 @@ import org.bukkit.entity.Player;
public class SkipCommand implements CommandExecutor {
public SkipCommand() {
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this);
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(GameConfig.mode) ? FightState.All : FightState.TeamFix, "skip", this);
}
@Override
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.linkage.Linked;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
@@ -17,7 +17,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
@@ -20,7 +20,8 @@
package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -49,7 +50,7 @@ public class TechhiderbugCommand implements CommandExecutor {
StringWriter writer = new StringWriter();
try {
writer.append("ArenaMode: ").append(Config.mode.name()).append('\n');
writer.append("ArenaMode: ").append(GameConfig.mode.name()).append('\n');
writer.append("FightState: ").append(FightState.getFightState().name()).append('\n');
writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n');
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -1,151 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
public abstract class Countdown {
private static final List<Countdown> currentCountdowns = new ArrayList<>();
protected final Message appendix;
private final int totalTime;
protected final Sound sound;
private final boolean level;
protected int time;
private BukkitTask task = null;
public abstract void countdownFinished();
protected Countdown(int time, Message appendix, SWSound sound, boolean level) {
this.totalTime = time;
this.time = time;
this.appendix = appendix;
this.sound = sound != null ? sound.getSound() : null;
this.level = level;
}
public void enable() {
time = totalTime;
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20);
currentCountdowns.add(this);
show();
}
public void disable() {
if (task != null) {
task.cancel();
currentCountdowns.remove(this);
task = null;
}
}
public static void skip() {
if (currentCountdowns.isEmpty()) return;
int smallestTime = currentCountdowns.get(0).time;
for (Countdown countdown : currentCountdowns) {
if (countdown.time < smallestTime) smallestTime = countdown.time;
}
for (Countdown countdown : new ArrayList<>(currentCountdowns)) {
countdown.time -= smallestTime;
countdown.show();
}
FightUI.addSubtitle("UI_SKIP");
}
public static void sendCountdownMessage(Player p, String message, int displaytime, Message appendix) {
FightSystem.getMessage().sendPrefixless(message, p, ChatMessageType.ACTION_BAR, displaytime, FightSystem.getMessage().parse(appendix.getMsg(), p, appendix.getParams()));
}
protected void broadcast(String message, int divisor) {
if (this.sound != null && divisor == 1) {
Fight.playSound(this.sound, 100.0F, 1.0F);
}
GlobalRecorder.getInstance().countdown(message, time / divisor, appendix);
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
}
public int getTimeLeft() {
return time;
}
private void count() {
time--;
show();
}
private void show() {
switch (time) {
case 900:
case 600:
case 300:
case 180:
case 120:
broadcast("COUNTDOWN_MINUTES", 60);
break;
case 60:
case 30:
case 20:
case 15:
case 10:
case 5:
case 4:
case 3:
case 2:
broadcast("COUNTDOWN_SECONDS", 1);
break;
case 1:
broadcast("COUNTDOWN_SECOND", 1);
break;
case 0:
if (this.sound != null) {
Fight.playSound(this.sound, 100.0F, 2.0F);
}
disable();
countdownFinished();
break;
default:
}
if (this.level) {
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(time));
}
}
}
@@ -27,10 +27,12 @@ import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.gamecore.countdown.StandardCountdown;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
public class EnternCountdown extends Countdown {
public class EnternCountdown extends StandardCountdown {
private static int calcTime(FightPlayer fp, Countdown countdown) {
int time = Config.GameModeConfig.EnterStages.get(fp.getKit().getEnterStage());
@@ -46,13 +48,17 @@ public class EnternCountdown extends Countdown {
private final FightPlayer fightPlayer;
public EnternCountdown(FightPlayer fp, Countdown countdown) {
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
super(
FightSystem.getPlugin(),
calcTime(fp, countdown),
FightCountdownAdapter.playerPresentation(fp, new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING)
);
fightPlayer = fp;
enable();
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
fightPlayer.ifPlayer(player -> {
@@ -61,11 +67,4 @@ public class EnternCountdown extends Countdown {
});
}
@Override
protected void broadcast(String message, int divisor) {
fightPlayer.ifPlayer(player -> {
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
sendCountdownMessage(player, message, time / divisor, appendix);
});
}
}
@@ -19,25 +19,27 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.linkage.Linked;
@Linked
public class EventSpectateCountdown extends Countdown {
public class EventSpectateCountdown extends StandardCountdown {
public EventSpectateCountdown() {
super(Config.GameModeConfig.Times.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
new StateDependentCountdown(ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.NotRestartable.contains(GameConfig.mode) && !GameConfig.replayserver(), FightState.Spectate, this);
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
FightSystem.shutdown();
}
}
@@ -0,0 +1,91 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.CountdownMessageSink;
import de.steamwar.gamecore.countdown.CountdownPresentation;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Binds FightSystem's transports to GameCore's presentation engine.
*/
public final class FightCountdownAdapter {
private FightCountdownAdapter() {
}
public static CountdownPresentation presentation(Message appendix, SWSound sound, boolean level) {
return presentation(
appendix,
sound,
level,
(message, displayTime) -> {
GlobalRecorder.getInstance().countdown(message.getKey(), displayTime, appendix);
Bukkit.getOnlinePlayers().forEach(player ->
sendCountdownMessage(player, message.getKey(), displayTime, appendix)
);
}
);
}
public static CountdownPresentation presentation(
Message appendix,
SWSound sound,
boolean level,
CountdownMessageSink messageSink
) {
return new CountdownPresentation(
messageSink,
sound != null
? pitch -> Fight.playSound(sound.getSound(), 100.0F, pitch)
: null,
level
? timeLeft -> Bukkit.getOnlinePlayers().forEach(player -> player.setLevel(timeLeft))
: null
);
}
public static CountdownPresentation playerPresentation(
FightPlayer fightPlayer,
Message appendix,
SWSound sound
) {
return new CountdownPresentation(
(message, displayTime) -> fightPlayer.ifPlayer(player ->
sendCountdownMessage(player, message.getKey(), displayTime, appendix)
),
pitch -> fightPlayer.ifPlayer(player ->
player.playSound(player.getLocation(), sound.getSound(), 100.0F, pitch)
),
pitch -> Fight.playSound(sound.getSound(), 100.0F, pitch),
null,
true
);
}
public static void sendCountdownMessage(Player player, String message, int displayTime, Message appendix) {
FightSystem.getMessage().sendPrefixless(
message,
player,
ChatMessageType.ACTION_BAR,
displayTime,
FightSystem.getMessage().parse(appendix.getMsg(), player, appendix.getParams())
);
}
}
@@ -19,27 +19,30 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
@Linked
public class NoPlayersOnlineCountdown extends Countdown {
public class NoPlayersOnlineCountdown extends StandardCountdown {
public NoPlayersOnlineCountdown() {
super(Config.GameModeConfig.Times.NoPlayersOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.NoPlayersOnlineDuration, FightCountdownAdapter.presentation(new Message("SHUTDOWN_COUNTDOWN"), null, false));
if (!Config.GameModeConfig.Arena.Leaveable) {
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreLeaderSetup, this);
}
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
Bukkit.getServer().shutdown();
}
}
@@ -19,27 +19,30 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
@Linked
public class PostSchemCountdown extends Countdown {
public class PostSchemCountdown extends StandardCountdown {
public PostSchemCountdown() {
super(Config.GameModeConfig.Times.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
if (Config.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare) {
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.SetupDuration, FightCountdownAdapter.presentation(new Message("POST_SCHEM_COUNTDOWN"), null, false));
if (GameConfig.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare) {
return;
}
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.SeriousFight.contains(GameConfig.mode), FightState.PostSchemSetup, this);
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
FightState.setFightState(FightState.PRE_RUNNING);
}
}
@@ -19,24 +19,27 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
@Linked
public class PreRunningCountdown extends Countdown {
public class PreRunningCountdown extends StandardCountdown {
public PreRunningCountdown() {
super(Config.GameModeConfig.Times.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true);
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreFightDuration, FightCountdownAdapter.presentation(new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true));
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreRunning, this);
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
FightState.setFightState(FightState.RUNNING);
}
}
@@ -19,24 +19,27 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
@Linked
public class PreSchemCountdown extends Countdown {
public class PreSchemCountdown extends StandardCountdown {
public PreSchemCountdown() {
super(Config.GameModeConfig.Times.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
super(FightSystem.getPlugin(), Config.GameModeConfig.Times.PreSchemPasteDuration, FightCountdownAdapter.presentation(new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.AntiReplay.contains(GameConfig.mode), FightState.PreSchemSetup, this);
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
FightState.setFightState(FightState.POST_SCHEM_SETUP);
}
}
@@ -19,24 +19,27 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
@Linked
public class SpectateOverCountdown extends Countdown {
public class SpectateOverCountdown extends StandardCountdown {
public SpectateOverCountdown() {
super(Config.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
new StateDependentCountdown(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
super(FightSystem.getPlugin(), GameConfig.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, FightCountdownAdapter.presentation(new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false));
new StateDependentCountdown<>(FightState.lifecycle, ArenaMode.Restartable.contains(GameConfig.mode) || GameConfig.replayserver(), FightState.Spectate, this);
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
FightState.setFightState(FightState.PRE_LEADER_SETUP);
}
}
@@ -20,20 +20,22 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.gamecore.countdown.StandardCountdown;
public class TimeOverCountdown extends Countdown {
public class TimeOverCountdown extends StandardCountdown {
private final Runnable timeOver;
public TimeOverCountdown(Runnable timeOver) {
super(Config.GameModeConfig.WinConditionParams.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false);
super(FightSystem.getPlugin(), Config.GameModeConfig.WinConditionParams.TimeoutTime, FightCountdownAdapter.presentation(new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false));
this.timeOver = timeOver;
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
timeOver.run();
}
}
@@ -21,13 +21,14 @@ package de.steamwar.fightsystem.event;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
@@ -139,14 +140,14 @@ public class HellsBells {
}.register();
}
private class HellsBellsCountdown extends Countdown {
private class HellsBellsCountdown extends StandardCountdown {
public HellsBellsCountdown(int time) {
super(time, new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
super(FightSystem.getPlugin(), time, FightCountdownAdapter.presentation(new Message("HELLS_BELLS_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true));
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
drop();
startCountdown();
}
@@ -240,4 +241,4 @@ public class HellsBells {
return this == NORTH || this == WEST;
}
}
}
}
@@ -21,7 +21,7 @@ package de.steamwar.fightsystem.event;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
@@ -29,6 +29,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.Fireball;
@@ -154,14 +155,14 @@ public class Meteor implements Listener {
}.register();
}
private class MeteorCountdown extends Countdown {
private class MeteorCountdown extends StandardCountdown {
public MeteorCountdown(int time) {
super(time, new Message("METEOR_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true);
super(FightSystem.getPlugin(), time, FightCountdownAdapter.presentation(new Message("METEOR_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, true));
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
drop();
startCountdown();
}
@@ -212,4 +213,4 @@ public class Meteor implements Listener {
}
}
}
}
}
@@ -20,8 +20,8 @@
package de.steamwar.fightsystem.event;
import com.sk89q.worldedit.WorldEditException;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
@@ -37,7 +37,7 @@ import java.util.logging.Level;
public class PersistentDamage {
public PersistentDamage() {
if (!ArenaMode.SeriousFight.contains(Config.mode)) return;
if (!ArenaMode.SeriousFight.contains(GameConfig.mode)) return;
new OneShotStateDependent(Winconditions.PERSISTENT_DAMAGE, FightState.Spectate, () -> Fight.teams().forEach(team -> {
try {
@@ -19,9 +19,11 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.gamecore.team.TeamRegistry;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Registry;
@@ -29,41 +31,24 @@ import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
public class Fight {
private Fight() {
}
@Getter
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, GameConfig.RedLeader);
@Getter
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
private static final Collection<FightTeam> teams = new HashSet<>();
static {
teams.add(redTeam);
teams.add(blueTeam);
}
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, GameConfig.BlueLeader);
private static final TeamRegistry<FightTeam, LivingEntity> teamRegistry = new TeamRegistry<>(List.of(redTeam, blueTeam));
public static FightTeam getPlayerTeam(LivingEntity player) {
if (redTeam.isPlayerInTeam(player)) {
return redTeam;
}
if (blueTeam.isPlayerInTeam(player)) {
return blueTeam;
}
return null;
return teamRegistry.findTeam(player);
}
public static FightTeam getOpposite(FightTeam fightTeam) {
if (fightTeam == redTeam) {
return blueTeam;
} else if (fightTeam == blueTeam) {
return redTeam;
}
throw new IllegalArgumentException();
return teamRegistry.opposite(fightTeam);
}
public static FightPlayer getFightPlayer(LivingEntity player) {
@@ -81,7 +66,11 @@ public class Fight {
}
public static Collection<FightTeam> teams() {
return teams;
return teamRegistry.getTeams();
}
public static boolean allTeamsReady() {
return teamRegistry.allReady();
}
public static FightTeam getUnrotated() {
@@ -95,20 +84,14 @@ public class Fight {
}
public static FightTeam getTeamByName(String name) {
if (redTeam.getName().equalsIgnoreCase(name)) {
return redTeam;
}
if (blueTeam.getName().equalsIgnoreCase(name)) {
return blueTeam;
}
return null;
return teamRegistry.findById(name);
}
public static boolean publicOnly() {
if (Config.OnlyPublicSchematics) {
return true;
}
if (Config.GameModeConfig.Schematic.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
if (Config.GameModeConfig.Schematic.IgnorePublicOnly || ArenaMode.RankedEvent.contains(GameConfig.mode)) {
return false;
}
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
@@ -21,7 +21,7 @@ package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.ai.AI;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.sql.PersonalKit;
@@ -22,7 +22,8 @@ package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.AffineTransform;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.GlobalRecorder;
@@ -130,7 +131,7 @@ public class FightSchematic extends StateDependent {
setSchematic(publics.get(new Random().nextInt(publics.size())));
}
if (ArenaMode.AntiReplay.contains(Config.mode)) {
if (ArenaMode.AntiReplay.contains(GameConfig.mode)) {
boolean changeRotation = false;
if (Config.GameModeConfig.WinConditions.contains(Winconditions.RANDOM_ROTATE)) {
changeRotation = new Random().nextBoolean();
@@ -148,7 +149,7 @@ public class FightSchematic extends StateDependent {
private void replaceTeamColor(Clipboard clipboard) {
try {
WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dyeColor(team.getColor()) : DyeColor.PINK);
WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(GameConfig.mode) ? ColorConverter.chat2dyeColor(team.getColor()) : DyeColor.PINK);
} catch (WorldEditException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not recolor schematic", e);
}
@@ -173,7 +174,7 @@ public class FightSchematic extends StateDependent {
);
FightSystem.getHullHider().initialize(team);
team.getPlayers().forEach(fightPlayer -> fightPlayer.ifAI(ai -> ai.schematic(clipboard)));
if (ArenaMode.Check.contains(Config.mode) && !team.isBlue()) {
if (ArenaMode.Check.contains(GameConfig.mode) && !team.isBlue()) {
replaceSync(Material.TNT, Material.RED_WOOL);
}
@@ -182,7 +183,7 @@ public class FightSchematic extends StateDependent {
@Override
public void disable() {
if (Config.mode == ArenaMode.PREPARE) {
if (GameConfig.mode == ArenaMode.PREPARE) {
return;
}
@@ -20,12 +20,13 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.ai.AIManager;
import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.listener.FightScoreboard;
@@ -57,7 +58,7 @@ import java.util.*;
import java.util.function.Consumer;
public class FightTeam {
public class FightTeam implements de.steamwar.gamecore.team.GameTeam<LivingEntity> {
private static void setKitButton(HotbarKit kit, boolean leader) {
if (Kit.getAvailableKits(leader).size() > 1 || Config.GameModeConfig.Kits.PersonalKits) {
@@ -79,14 +80,14 @@ public class FightTeam {
static {
setKitButton(notReadyKit, true);
if (ArenaMode.VariableTeams.contains(Config.mode)) {
if (ArenaMode.VariableTeams.contains(GameConfig.mode)) {
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
if (!AIManager.availableAIs().isEmpty()) {
notReadyKit.setItem(6, "ADD_AI", new ItemBuilder(Material.REDSTONE).build(), GUI::addAI);
}
}
if (Config.test()) {
if (GameConfig.test()) {
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(Material.CAULDRON).enchant().build(), GUI::preSchemDialog);
}
@@ -163,7 +164,7 @@ public class FightTeam {
}
new OneShotStateDependent(ArenaMode.Restartable, FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
new OneShotStateDependent(GameConfig.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
if (leader != null) leader.ifPlayer(notReadyKit::loadToPlayer);
});
@@ -236,7 +237,7 @@ public class FightTeam {
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true));
if (ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()) {
if (ArenaMode.VariableTeams.contains(GameConfig.mode) && isLeaderless()) {
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
Collections.shuffle(onlinePlayers);
for (Player player : onlinePlayers) {
@@ -338,7 +339,7 @@ public class FightTeam {
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, Fight.getOpposite(this).getExtendRegion());
if (ArenaMode.VariableTeams.contains(Config.mode)) {
if (ArenaMode.VariableTeams.contains(GameConfig.mode)) {
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
}
@@ -356,7 +357,7 @@ public class FightTeam {
this.leader = null;
if (!players.isEmpty()) {
setLeader(players.values().iterator().next(), false);
} else if (FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)) {
} else if (FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(GameConfig.mode)) {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> FightState.setFightState(FightState.PRE_LEADER_SETUP), 1);
}
}
@@ -404,6 +405,31 @@ public class FightTeam {
return players.values();
}
@Override
public String teamId() {
return name;
}
@Override
public Collection<LivingEntity> members() {
return players.values().stream().map(FightPlayer::getEntity).toList();
}
@Override
public LivingEntity leader() {
return leader == null ? null : leader.getEntity();
}
@Override
public boolean ready() {
return ready;
}
@Override
public boolean contains(LivingEntity member) {
return isPlayerInTeam(member);
}
public void pasteSchem() {
testPasteAction();
}
@@ -423,7 +449,7 @@ public class FightTeam {
}
private void testPasteAction() {
if (Config.test()) {
if (GameConfig.test()) {
this.schematic.enable();
} else if (Fight.getOpposite(this).schematic.hasSchematic()) {
FightState.setFightState(FightState.POST_SCHEM_SETUP);
@@ -455,7 +481,7 @@ public class FightTeam {
if (ready) {
broadcast("TEAM_READY");
leader.ifPlayer(readyKit::loadToPlayer);
if (Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode)) {
if (Fight.allTeamsReady() || ArenaMode.SoloLeader.contains(GameConfig.mode)) {
FightState.setFightState(FightState.PRE_RUNNING);
}
} else {
@@ -468,10 +494,12 @@ public class FightTeam {
this.skip = !skip;
if (skip) {
broadcast("SKIP_READY");
if (Fight.getOpposite(this).skip || Config.test()) {
if (Fight.getOpposite(this).skip || GameConfig.test()) {
skip = false;
Fight.getOpposite(this).skip = false;
Countdown.skip();
if (Countdown.skipActive()) {
FightUI.addSubtitle("UI_SKIP");
}
}
} else {
broadcast("SKIP_NOT_READY");
@@ -19,7 +19,8 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.listener.Recording;
@@ -46,7 +47,7 @@ public class FightWorld extends StateDependent {
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
public FightWorld() {
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);
super(ArenaMode.Restartable.contains(GameConfig.mode) || GameConfig.replayserver(), FightState.Schem);
register();
}
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.linkage.Linked;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -51,7 +51,7 @@ public class Check implements Listener {
if (user.hasPerm(UserPerm.CHECK)) return;
SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID);
SchematicNode schem = SchematicNode.getSchematicNode(GameConfig.CheckSchemID);
if (user.getId() == schem.getOwner()) return;
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.scoreboard.SWScoreboard;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -85,7 +86,7 @@ public class Permanent implements Listener {
@EventHandler
public void onTpGM3(PlayerTeleportEvent e) {
if (ArenaMode.AntiTest.contains(Config.mode) && e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
if (ArenaMode.AntiTest.contains(GameConfig.mode) && e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
e.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_TELEPORT", e.getPlayer(), ChatMessageType.ACTION_BAR);
e.getPlayer().kickPlayer(null);
@@ -19,10 +19,11 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
@@ -41,7 +42,7 @@ public class PistonListener implements Listener {
public PistonListener(Set<ArenaMode> condition, Consumer<BlockPistonEvent> leftAreaHandler) {
this.leftAreaHandler = leftAreaHandler;
if (!condition.contains(Config.mode)) return;
if (!condition.contains(GameConfig.mode)) return;
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
new StateDependentListener(!Config.GameModeConfig.Arena.AllowMissiles, FightState.All, this);
@@ -20,7 +20,8 @@
package de.steamwar.fightsystem.listener;
import com.sk89q.worldedit.WorldEditException;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -67,7 +68,7 @@ public class PrepareSchem implements Listener {
SchematicNode schem;
try {
schem = SchematicNode.getSchematicNode(Config.PrepareSchemID);
schem = SchematicNode.getSchematicNode(GameConfig.PrepareSchemID);
} catch (SecurityException e) {
FightSystem.getMessage().broadcast("PREPARE_SCHEM_DELETED");
Bukkit.shutdown();
@@ -20,7 +20,7 @@
package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.TeamDeathEvent;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -19,7 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -33,12 +34,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class Shutdown implements Listener {
public Shutdown() {
new StateDependentListener(ArenaMode.AntiEvent.contains(Config.mode) && !Config.replayserver(), FightState.All, this);
new StateDependentListener(ArenaMode.AntiEvent.contains(GameConfig.mode) && !GameConfig.replayserver(), FightState.All, this);
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
if (Config.replayserver() || Config.GameModeConfig.Arena.Leaveable) return;
if (GameConfig.replayserver() || Config.GameModeConfig.Arena.Leaveable) return;
//Shutdown server if nobody online
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) {
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.events.TeamDeathEvent;
@@ -19,8 +19,8 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@@ -43,7 +43,7 @@ public class TestJoin implements Listener {
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
if (GameConfig.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);
player.kickPlayer("");
return;
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.linkage.Linked;
import lombok.Getter;
@@ -36,7 +37,7 @@ public class FileRecorder extends StateDependent implements Recorder {
private DataOutputStream outputStream;
public FileRecorder() {
super(Config.ReplayID == 0, FightState.Recording);
super(GameConfig.ReplayID == 0, FightState.Recording);
register();
}
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import de.steamwar.gamecore.GameConfig;
import java.io.File;
import java.io.IOException;
@@ -33,7 +33,7 @@ public class FileSource extends PacketSource {
}
public static void startReplay() {
if (Config.replayserver()) {
if (GameConfig.replayserver()) {
try {
new LiveServer();
} catch (IOException e) {
@@ -42,9 +42,9 @@ public class FileSource extends PacketSource {
return;
}
if (Config.ReplayID > 0) {
if (GameConfig.ReplayID > 0) {
try {
new FileSource(replayFile(Config.ReplayID));
new FileSource(replayFile(GameConfig.ReplayID));
} catch (IOException e) {
throw new SecurityException("Could not start replay", e);
}
@@ -24,10 +24,11 @@ import de.steamwar.core.WorldEditWrapper;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RPlayer;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld;
@@ -255,7 +256,7 @@ public class PacketProcessor implements Listener {
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
team.addEntry(user.getUserName());
if (ArenaMode.Test.contains(Config.mode)) {
if (ArenaMode.Test.contains(GameConfig.mode)) {
entities.get(entityId).setGlowing(true);
}
});
@@ -393,7 +394,7 @@ public class PacketProcessor implements Listener {
int displaytime = source.readInt();
Message appendix = readMessage();
Bukkit.getOnlinePlayers().forEach(p -> Countdown.sendCountdownMessage(p, message, displaytime, appendix));
Bukkit.getOnlinePlayers().forEach(p -> FightCountdownAdapter.sendCountdownMessage(p, message, displaytime, appendix));
}
private void oldArenaInfo() throws IOException {
@@ -633,7 +634,7 @@ public class PacketProcessor implements Listener {
entities.clear();
freezer.disable();
if (!Config.replayserver()) {
if (!GameConfig.replayserver()) {
FightSystem.getMessage().broadcast("REPLAY_ENDS");
}
if (FightSystem.getLastWinner() != null) {
@@ -19,7 +19,8 @@
package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
@@ -51,7 +52,7 @@ public interface Recorder {
default void enable() {
GlobalRecorder.getInstance().add(this);
if (ArenaMode.Event.contains(Config.mode)) {
if (ArenaMode.Event.contains(GameConfig.mode)) {
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
}
@@ -1,27 +1,12 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import lombok.Getter;
import de.steamwar.gamecore.state.GameStateMachine;
import de.steamwar.gamecore.state.IStateDependent;
import java.util.*;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
public enum FightState {
PRE_LEADER_SETUP,
@@ -31,63 +16,58 @@ public enum FightState {
RUNNING,
SPECTATE;
public static final Set<FightState> All = Collections.unmodifiableSet(EnumSet.allOf(FightState.class));
public static final Set<FightState> All = immutable(EnumSet.allOf(FightState.class));
public static final Set<FightState> PreLeaderSetup = immutable(EnumSet.of(PRE_LEADER_SETUP));
public static final Set<FightState> PreSchemSetup = immutable(EnumSet.of(PRE_SCHEM_SETUP));
public static final Set<FightState> PostSchemSetup = immutable(EnumSet.of(POST_SCHEM_SETUP));
public static final Set<FightState> PreRunning = immutable(EnumSet.of(PRE_RUNNING));
public static final Set<FightState> Running = immutable(EnumSet.of(RUNNING));
public static final Set<FightState> Spectate = immutable(EnumSet.of(SPECTATE));
public static final Set<FightState> Setup = immutable(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP));
public static final Set<FightState> Ingame = immutable(EnumSet.of(PRE_RUNNING, RUNNING));
public static final Set<FightState> TeamFix = immutable(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
public static final Set<FightState> Schem = complement(PRE_LEADER_SETUP, PRE_SCHEM_SETUP);
public static final Set<FightState> Recording = complement(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE);
public static final Set<FightState> AntiRunning = complement(RUNNING);
public static final Set<FightState> AntiIngame = complement(PRE_RUNNING, RUNNING);
public static final Set<FightState> AntiSpectate = complement(SPECTATE);
public static final Set<FightState> PreLeaderSetup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP));
public static final Set<FightState> PreSchemSetup = Collections.unmodifiableSet(EnumSet.of(PRE_SCHEM_SETUP));
public static final Set<FightState> PostSchemSetup = Collections.unmodifiableSet(EnumSet.of(POST_SCHEM_SETUP));
public static final Set<FightState> PreRunning = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING));
public static final Set<FightState> Running = Collections.unmodifiableSet(EnumSet.of(RUNNING));
public static final Set<FightState> Spectate = Collections.unmodifiableSet(EnumSet.of(SPECTATE));
public static final GameStateMachine<FightState> lifecycle = new GameStateMachine<>(PRE_LEADER_SETUP);
public static final Set<FightState> Setup = Collections.unmodifiableSet(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP));
public static final Set<FightState> Ingame = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING));
public static final Set<FightState> TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
public static final Set<FightState> Recording = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE)));
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
public static final Set<FightState> AntiIngame = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_RUNNING, RUNNING)));
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
@Getter
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter
private static FightState fightState = PRE_LEADER_SETUP;
public static void registerStateDependent(IStateDependent stateDependent) {
if (stateDependent.enabled().isEmpty()) return;
boolean enabled = stateDependent.enabled().contains(fightState);
stateDependentFeatures.put(stateDependent, enabled);
if (enabled) stateDependent.enable();
public static void registerStateDependent(IStateDependent<FightState> stateDependent) {
lifecycle.registerStateDependent(stateDependent);
}
public static void setFightState(FightState state) {
fightState = state;
lifecycle.transitionTo(state);
}
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
//Enable feature if should be enabled and currently disabled
if (feature.getKey().enabled().contains(fightState) && !feature.getValue()) {
feature.getKey().enable();
feature.setValue(true);
}
public static FightState getFightState() {
return lifecycle.getCurrentState();
}
//Disable feature if should be disabled and currently enabled
if (!feature.getKey().enabled().contains(fightState) && feature.getValue()) {
feature.getKey().disable();
feature.setValue(false);
}
}
public static Map<IStateDependent<FightState>, Boolean> getStateDependentFeatures() {
return lifecycle.getStateDependentFeatures();
}
public static boolean setup() {
return Setup.contains(fightState);
return Setup.contains(getFightState());
}
public static boolean ingame() {
return Ingame.contains(fightState);
return Ingame.contains(getFightState());
}
public static boolean infight() {
return fightState == RUNNING;
return getFightState() == RUNNING;
}
private static Set<FightState> complement(FightState first, FightState... remaining) {
EnumSet<FightState> excluded = EnumSet.of(first, remaining);
return immutable(EnumSet.complementOf(excluded));
}
private static Set<FightState> immutable(EnumSet<FightState> states) {
return Collections.unmodifiableSet(states);
}
}
@@ -1,40 +1,5 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import java.util.Set;
public interface IStateDependent {
/**
* @return returns a set containing
*/
Set<FightState> enabled();
/**
* Enables the state dependent object
*/
void enable();
/**
* Disables the state dependent object
*/
void disable();
@Deprecated
public interface IStateDependent extends de.steamwar.gamecore.state.IStateDependent<FightState> {
}
@@ -1,59 +1,22 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.gamecore.GameConfig;
import java.util.Set;
public class OneShotStateDependent extends StateDependent {
private final Runnable runnable;
public OneShotStateDependent(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable) {
super(mode, states);
this.runnable = runnable;
register();
@Deprecated
public class OneShotStateDependent extends de.steamwar.gamecore.state.OneShotStateDependent<FightState> implements IStateDependent {
public OneShotStateDependent(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Runnable runnable) {
super(FightState.lifecycle, modes, GameConfig.mode, states, runnable);
}
public OneShotStateDependent(Winconditions wincondition, Set<FightState> states, Runnable runnable) {
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
this.runnable = runnable;
register();
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, runnable);
}
public OneShotStateDependent(boolean active, Set<FightState> states, Runnable runnable) {
super(active, states);
this.runnable = runnable;
register();
}
@Override
public void enable() {
runnable.run();
}
@Override
public void disable() {
//Do nothing, oneshot
super(FightState.lifecycle, active, states, runnable);
}
}
@@ -1,54 +1,22 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.gamecore.GameConfig;
import java.util.Set;
public abstract class StateDependent implements IStateDependent {
private final Set<FightState> enabled;
private final boolean register;
@Deprecated
public abstract class StateDependent extends de.steamwar.gamecore.state.StateDependent<FightState> implements IStateDependent {
protected StateDependent(Winconditions wincondition, Set<FightState> states) {
this(Config.GameModeConfig.WinConditions.contains(wincondition), states);
}
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states) {
this(mode.contains(Config.mode), states);
protected StateDependent(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states) {
super(FightState.lifecycle, modes, GameConfig.mode, states);
}
protected StateDependent(boolean enabled, Set<FightState> states) {
this.enabled = states;
this.register = enabled;
}
public void register() {
if (register) FightState.registerStateDependent(this);
}
@Override
public Set<FightState> enabled() {
return enabled;
super(FightState.lifecycle, enabled, states);
}
}
@@ -1,58 +1,20 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.gamecore.GameConfig;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import java.util.Set;
public class StateDependentCommand extends StateDependent {
private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> {
@Deprecated
public class StateDependentCommand extends de.steamwar.gamecore.state.StateDependentCommand<FightState> implements IStateDependent {
private static final CommandExecutor unavailable = (sender, cmd, label, args) -> {
FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
return false;
};
private final PluginCommand command;
private final CommandExecutor executor;
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
super(mode, states);
this.executor = executor;
this.command = FightSystem.getPlugin().getCommand(name);
assert command != null;
disable();
register();
}
@Override
public void enable() {
command.setExecutor(executor);
}
@Override
public void disable() {
command.setExecutor(unavailable);
public StateDependentCommand(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, String name, CommandExecutor executor) {
super(FightState.lifecycle, modes.contains(GameConfig.mode), states, FightSystem.getPlugin(), name, executor, unavailable);
}
}
@@ -1,70 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.winconditions.Winconditions;
import java.util.Set;
public class StateDependentCountdown extends StateDependent {
private static Countdown mainCountdown = null;
public static Countdown getMainCountdown() {
return mainCountdown;
}
private final Countdown countdown;
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
super(mode, states);
this.countdown = countdown;
register();
}
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, countdown);
}
public StateDependentCountdown(boolean active, Set<FightState> states, Countdown countdown) {
super(active, states);
this.countdown = countdown;
register();
}
public Countdown getCountdown() {
return countdown;
}
@Override
public void enable() {
mainCountdown = countdown;
countdown.enable();
}
@Override
public void disable() {
countdown.disable();
if (mainCountdown == countdown) mainCountdown = null;
}
}
@@ -1,63 +1,24 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.winconditions.Winconditions;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import de.steamwar.gamecore.GameConfig;
import org.bukkit.event.Listener;
import java.util.Set;
public class StateDependentListener extends StateDependent {
private final Listener listener;
@Deprecated
public class StateDependentListener extends de.steamwar.gamecore.state.StateDependentListener<FightState> implements IStateDependent {
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener) {
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
this.listener = listener;
register();
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, listener);
}
public StateDependentListener(boolean enabled, Set<FightState> states, Listener listener) {
super(enabled, states);
this.listener = listener;
register();
public StateDependentListener(boolean active, Set<FightState> states, Listener listener) {
super(FightState.lifecycle, active, states, FightSystem.getPlugin(), listener);
}
public StateDependentListener(Set<ArenaMode> mode, Set<FightState> states, Listener listener) {
super(mode, states);
this.listener = listener;
register();
}
@Override
public void enable() {
Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin());
}
@Override
public void disable() {
HandlerList.unregisterAll(listener);
public StateDependentListener(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Listener listener) {
super(FightState.lifecycle, modes, GameConfig.mode, states, FightSystem.getPlugin(), listener);
}
}
@@ -1,69 +1,23 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 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.fightsystem.states;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.winconditions.Winconditions;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import de.steamwar.gamecore.GameConfig;
import java.util.Set;
public class StateDependentTask extends StateDependent {
private final Runnable runnable;
private final long delay;
private final long period;
private BukkitTask task = null;
@Deprecated
public class StateDependentTask extends de.steamwar.gamecore.state.StateDependentTask<FightState> implements IStateDependent {
public StateDependentTask(Winconditions wincondition, Set<FightState> states, Runnable runnable, long delay, long period) {
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, runnable, delay, period);
}
public StateDependentTask(boolean enabled, Set<FightState> states, Runnable runnable, long delay, long period) {
super(enabled, states);
this.runnable = runnable;
this.delay = delay;
this.period = period;
register();
public StateDependentTask(boolean active, Set<FightState> states, Runnable runnable, long delay, long period) {
super(FightState.lifecycle, active, states, FightSystem.getPlugin(), runnable, delay, period);
}
public StateDependentTask(Set<ArenaMode> mode, Set<FightState> states, Runnable runnable, long delay, long period) {
super(mode, states);
this.runnable = runnable;
this.delay = delay;
this.period = period;
register();
public StateDependentTask(Set<de.steamwar.gamecore.ArenaMode> modes, Set<FightState> states, Runnable runnable, long delay, long period) {
super(FightState.lifecycle, modes, GameConfig.mode, states, FightSystem.getPlugin(), runnable, delay, period);
}
@Override
public void enable() {
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), runnable, delay, period);
}
@Override
public void disable() {
task.cancel();
}
}
@@ -19,11 +19,12 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.linkage.Linked;
import de.steamwar.network.NetworkSender;
@@ -41,6 +42,7 @@ public class BungeeFightInfo {
}
private void send() {
Countdown mainCountdown = StateDependentCountdown.getMainCountdown(FightState.lifecycle);
NetworkSender.send(new FightInfoPacket(
Config.world.getName(),
Config.GameModeConfig.Schematic.Type.toDB(),
@@ -48,7 +50,7 @@ public class BungeeFightInfo {
Fight.getBlueTeam().getColoredName(),
Fight.getRedTeam().getColoredName(),
FightState.getFightState().name(),
StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0,
mainCountdown != null ? mainCountdown.getTimeLeft() : 0,
Fight.getBlueTeam().getLeader() != null ? Fight.getBlueTeam().getLeader().getUser().getId() : 0,
Fight.getRedTeam().getLeader() != null ? Fight.getRedTeam().getLeader().getUser().getId() : 0,
Fight.getBlueTeam().getSchematic(),
@@ -19,10 +19,11 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
@@ -125,7 +126,7 @@ public class FightStatistics {
savePlayerStats(fp, fightId);
}
if (ArenaMode.Event.contains(Config.mode)) {
if (ArenaMode.Event.contains(GameConfig.mode)) {
Config.EventKampf.setFight(fightId);
}
@@ -20,7 +20,8 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.TPSWatcher;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@@ -28,7 +29,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.linkage.Linked;
@@ -71,7 +72,8 @@ public class FightUI {
totalHearts = 1.0;
}
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
Countdown mainCountdown = StateDependentCountdown.getMainCountdown(FightState.lifecycle);
int timeLeft = mainCountdown != null ? mainCountdown.getTimeLeft() : 0;
String time = "§7" + (timeLeft / 60) + "§8:§7" + (timeLeft % 60 < 10 ? "0" : "") + (timeLeft % 60);
String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount();
String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount();
@@ -29,6 +29,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.gamecore.GameConfig;
import de.steamwar.techhider.AccessPrivilegeProvider;
import de.steamwar.techhider.TechHider;
import lombok.Getter;
@@ -58,7 +59,7 @@ import java.util.stream.Stream;
public class TechHiderWrapper extends StateDependent implements Listener {
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.GameModeConfig.Techhider.Active;
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !GameConfig.test() && Config.GameModeConfig.Techhider.Active;
@Getter
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
@@ -19,7 +19,7 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.gamecore.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -20,10 +20,12 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.gamecore.wincondition.GameResult;
import lombok.Getter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@@ -31,13 +33,12 @@ import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
import java.util.function.ToDoubleFunction;
import java.util.stream.Collectors;
public abstract class Wincondition {
public abstract class Wincondition implements de.steamwar.gamecore.wincondition.WinCondition<FightTeam> {
@Getter
protected static WinconditionBasePercent percentWincondition = null;
protected static StateDependentCountdown timeOverCountdown = null;
protected static StateDependentCountdown<FightState> timeOverCountdown = null;
@Getter
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
@@ -47,6 +48,11 @@ public abstract class Wincondition {
this.windescription = windescription;
}
@Override
public String id() {
return windescription;
}
public static Countdown getTimeOverCountdown() {
if (timeOverCountdown == null) return null;
return timeOverCountdown.getCountdown();
@@ -63,12 +69,12 @@ public abstract class Wincondition {
}
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());
if (teams.size() > 1) {
win(null, tieMessage);
GameResult<FightTeam> result = de.steamwar.gamecore.wincondition.WinConditions.winnerByScore(Fight.teams(), evaluate);
if (result instanceof GameResult.Winner<FightTeam> winner) {
FightTeam team = winner.getWinner();
win(team, winMessage, team.getColoredName());
} else {
win(teams.get(0), winMessage, teams.get(0).getColoredName());
win(null, tieMessage);
}
}
}
@@ -23,7 +23,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import java.util.function.ToDoubleFunction;
@@ -32,7 +32,12 @@ public abstract class WinconditionComparisonTimeout extends Wincondition {
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
super(windescription);
if (Config.GameModeConfig.WinConditions.contains(wincondition)) {
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER")));
timeOverCountdown = new StateDependentCountdown<>(
FightState.lifecycle,
true,
FightState.Running,
new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER"))
);
}
}
}
@@ -24,7 +24,7 @@ import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.linkage.Linked;
@@ -54,7 +54,12 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
if (Config.GameModeConfig.WinConditions.contains(Winconditions.POINTS)) {
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
timeOverCountdown = new StateDependentCountdown<>(
FightState.lifecycle,
true,
FightState.Running,
new TimeOverCountdown(this::timeOver)
);
}
}
@@ -20,7 +20,10 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -109,17 +112,17 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
});
}
private class TechKOCountdown extends Countdown {
private class TechKOCountdown extends StandardCountdown {
private final FightTeam team;
public TechKOCountdown(FightTeam team, int countdownTime) {
super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false);
super(FightSystem.getPlugin(), countdownTime, FightCountdownAdapter.presentation(new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false));
this.team = team;
super.enable();
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
}
}
@@ -20,7 +20,10 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.FightCountdownAdapter;
import de.steamwar.gamecore.countdown.Countdown;
import de.steamwar.gamecore.countdown.StandardCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@@ -100,16 +103,16 @@ public class WinconditionTimedDamageTechKO extends Wincondition implements Print
});
}
private class TechKOCountdown extends Countdown {
private class TechKOCountdown extends StandardCountdown {
private final FightTeam team;
public TechKOCountdown(FightTeam team, int countdownTime) {
super(countdownTime, new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false);
super(FightSystem.getPlugin(), countdownTime, FightCountdownAdapter.presentation(new Message("TECHKO_COUNTDOWN", team.getColoredName()), SWSound.BLOCK_NOTE_PLING, false));
this.team = team;
}
@Override
public void countdownFinished() {
protected void countdownFinished() {
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
}
}
@@ -22,7 +22,7 @@ package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.gamecore.state.StateDependentCountdown;
import de.steamwar.linkage.Linked;
@Linked
@@ -31,7 +31,12 @@ public class WinconditionTimeout extends Wincondition {
public WinconditionTimeout() {
super("Timeout");
if (Config.GameModeConfig.WinConditions.contains(Winconditions.TIMEOUT)) {
timeOverCountdown = new StateDependentCountdown(Winconditions.TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
timeOverCountdown = new StateDependentCountdown<>(
FightState.lifecycle,
true,
FightState.Running,
new TimeOverCountdown(this::timeOver)
);
}
}
+2 -1
View File
@@ -7,6 +7,7 @@ main: de.steamwar.fightsystem.FightSystem
softdepend:
- SpigotCore
depend:
- GameCore
- WorldEdit
api-version: "1.13"
@@ -28,4 +29,4 @@ commands:
tpslimit:
tpswarp:
techhiderbug:
unrank:
unrank:
+5
View File
@@ -30,6 +30,11 @@ dependencies {
implementation(project(":FightSystem:FightSystem_Core"))
}
tasks.withType<FightServer>().configureEach {
dependsOn(":KotlinCore:shadowJar")
dependsOn(":GameCore:jar")
}
tasks.register<FightServer>("HalloweenWS") {
group = "run"
description = "Run a Halloween 1.21 Fight Replay Server"
+35
View File
@@ -0,0 +1,35 @@
# GameCore
GameCore is the Kotlin runtime library shared by SteamWar game-mode plugins.
Its implementation is based on FightSystem, the most exhaustive game mode, and
contains the mechanics that do not depend on a specific arena:
- restartable Bukkit countdown scheduling, FightSystem milestone behavior,
message/sound/level presentation policy, and shared skip behavior;
- generic team contracts, team lookup, readiness, and opposite-team handling;
- reusable winner/draw results and score/last-remaining evaluation;
- the complete state-dependent lifecycle (one-shots, tasks, listeners, commands,
and countdowns);
- the FightSystem arena modes and shared JVM runtime configuration;
- observable, generic game-state transitions.
GameCore intentionally does not define a game-state enum. Each consumer supplies
its own enum to `GameStateMachine<S>` and the generic state-dependent classes, so
each game mode controls its valid states while sharing the lifecycle behavior.
```kotlin
enum class State { WAITING, RUNNING, END }
val lifecycle = GameStateMachine(State.WAITING)
StateDependentListener(
lifecycle,
true,
setOf(State.RUNNING),
plugin,
ingameListener,
)
```
FightSystem, MissileWars, TNTLeague, and TowerRun retain their own messages,
inventories, listeners, schematics, and concrete win rules. They depend on the
GameCore plugin at runtime; GameCore itself depends on KotlinCore.
+22
View File
@@ -0,0 +1,22 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
plugins {
steamwar.kotlin
}
dependencies {
compileOnly(libs.paperapi)
compileOnly(project(":KotlinCore", "default"))
testImplementation(libs.junit)
testImplementation(libs.hamcrest)
}
@@ -0,0 +1,58 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.gamecore
import java.util.Collections
import java.util.EnumSet
/**
* Canonical arena mode model, ported from FightSystem.
*/
enum class ArenaMode {
NORMAL,
EVENT,
TEST,
CHECK,
PREPARE,
REPLAY;
companion object {
@JvmField val All: Set<ArenaMode> = immutable(EnumSet.allOf(ArenaMode::class.java))
@JvmField val Normal: Set<ArenaMode> = immutable(EnumSet.of(NORMAL))
@JvmField val Check: Set<ArenaMode> = immutable(EnumSet.of(CHECK))
@JvmField val Event: Set<ArenaMode> = immutable(EnumSet.of(EVENT))
@JvmField val Test: Set<ArenaMode> = immutable(EnumSet.of(TEST, CHECK))
@JvmField val Prepare: Set<ArenaMode> = immutable(EnumSet.of(PREPARE))
@JvmField val Replay: Set<ArenaMode> = immutable(EnumSet.of(REPLAY, TEST))
@JvmField val AntiReplay: Set<ArenaMode> = complement(REPLAY)
@JvmField val AntiTest: Set<ArenaMode> = complement(TEST, CHECK)
@JvmField val AntiEvent: Set<ArenaMode> = complement(EVENT)
@JvmField val AntiTestCheckPrepare: Set<ArenaMode> = complement(TEST, CHECK, PREPARE)
@JvmField val AntiPrepare: Set<ArenaMode> = complement(PREPARE)
@JvmField val VariableTeams: Set<ArenaMode> = complement(EVENT, REPLAY, CHECK)
@JvmField val ManualTeams: Set<ArenaMode> = complement(EVENT, REPLAY)
@JvmField val RankedEvent: Set<ArenaMode> = immutable(EnumSet.of(EVENT, REPLAY))
@JvmField val Restartable: Set<ArenaMode> = immutable(EnumSet.of(NORMAL, TEST))
@JvmField val NotRestartable: Set<ArenaMode> = immutable(EnumSet.of(EVENT, REPLAY))
@JvmField val SoloLeader: Set<ArenaMode> = immutable(EnumSet.of(TEST, CHECK, PREPARE))
@JvmField val NotOnBau: Set<ArenaMode> = complement(TEST, CHECK, PREPARE, REPLAY)
@JvmField val SeriousFight: Set<ArenaMode> = complement(TEST, CHECK, REPLAY)
private fun complement(vararg modes: ArenaMode): Set<ArenaMode> =
immutable(EnumSet.complementOf(EnumSet.copyOf(modes.toSet())))
private fun immutable(modes: EnumSet<ArenaMode>): Set<ArenaMode> =
Collections.unmodifiableSet(modes)
}
}
@@ -0,0 +1,65 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.gamecore
import java.util.UUID
/**
* Runtime configuration shared by all GameCore game modes.
*
* The values are supplied as JVM system properties by the game server launcher.
*/
object GameConfig {
@JvmField
val CheckSchemID: Int = System.getProperty("checkSchemID", "0").toInt()
@JvmField
val PrepareSchemID: Int = System.getProperty("prepareSchemID", "0").toInt()
@JvmField
val ReplayID: Int = System.getProperty("replay", "0").toInt()
@JvmField
val ConfigFile: String = System.getProperty("config", "config.yml")
@JvmField
val EventKampfID: Int = System.getProperty("fightID", "0").toInt()
@JvmField
val BlueLeader: UUID? = System.getProperty("blueLeader")?.let(UUID::fromString)
@JvmField
val RedLeader: UUID? = System.getProperty("redLeader")?.let(UUID::fromString)
@JvmField
val mode: ArenaMode = resolveArenaMode(CheckSchemID, PrepareSchemID, EventKampfID, ReplayID)
@JvmStatic
fun test(): Boolean = ArenaMode.Test.contains(mode)
@JvmStatic
fun replayserver(): Boolean = ReplayID < 0
internal fun resolveArenaMode(
checkSchemID: Int,
prepareSchemID: Int,
eventKampfID: Int,
replayID: Int,
): ArenaMode = when {
checkSchemID != 0 -> ArenaMode.CHECK
prepareSchemID != 0 -> ArenaMode.PREPARE
eventKampfID >= 1 -> ArenaMode.EVENT
eventKampfID == -1 -> ArenaMode.TEST
replayID != 0 -> ArenaMode.REPLAY
else -> ArenaMode.NORMAL
}
}
@@ -0,0 +1,22 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.gamecore
import org.bukkit.plugin.java.JavaPlugin
/**
* Runtime boundary for code shared by the SteamWar game modes.
*
* GameCore intentionally has no game lifecycle of its own. Depending plugins
* provide the concrete teams, states, messages and win effects.
*/
class GameCore : JavaPlugin()
@@ -0,0 +1,242 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.gamecore.countdown
import org.bukkit.plugin.Plugin
import org.bukkit.scheduler.BukkitTask
import java.util.concurrent.CopyOnWriteArraySet
import java.util.function.IntConsumer
/**
* Common, restartable countdown implementation.
*
* The engine owns scheduling and cancellation. Game modes only implement
* presentation in [onTick] and their transition in [onFinished].
*/
abstract class Countdown @JvmOverloads constructor(
private val plugin: Plugin,
val totalTime: Int,
private val initialDelayTicks: Long = 20,
private val periodTicks: Long = 20,
private val showInitialValue: Boolean = true,
) {
init {
require(totalTime >= 0) { "totalTime must not be negative" }
require(initialDelayTicks >= 0) { "initialDelayTicks must not be negative" }
require(periodTicks > 0) { "periodTicks must be positive" }
}
@Volatile
var timeLeft: Int = totalTime
private set
@Volatile
private var enabled = false
private var task: BukkitTask? = null
val isRunning: Boolean
get() = enabled
fun enable() {
disable()
timeLeft = totalTime
enabled = true
activeCountdowns.add(this)
onStarted()
if (!enabled) return
if (showInitialValue) {
onTick(timeLeft)
}
if (!enabled) return
if (totalTime == 0) {
finish()
return
}
task = plugin.server.scheduler.runTaskTimer(
plugin,
Runnable { advance() },
initialDelayTicks,
periodTicks,
)
}
fun disable() {
val wasEnabled = enabled
enabled = false
val currentTask = task
task = null
currentTask?.cancel()
activeCountdowns.remove(this)
if (wasEnabled) {
onStopped()
}
}
fun reset() {
timeLeft = totalTime
}
fun setRemainingTime(time: Int) {
timeLeft = time.coerceIn(0, totalTime)
}
fun decreaseBy(time: Int) {
require(time >= 0) { "time must not be negative" }
if (!enabled) return
timeLeft = (timeLeft - time).coerceAtLeast(0)
onTick(timeLeft)
if (timeLeft == 0 && isRunning) {
finish()
}
}
private fun advance() {
if (!enabled) return
timeLeft = (timeLeft - 1).coerceAtLeast(0)
onTick(timeLeft)
if (timeLeft == 0) {
finish()
}
}
private fun finish() {
if (!enabled) return
disable()
onFinished()
}
protected open fun onStarted() = Unit
protected open fun onStopped() = Unit
protected open fun onTick(timeLeft: Int) = Unit
protected abstract fun onFinished()
companion object {
private val activeCountdowns = CopyOnWriteArraySet<Countdown>()
/**
* Advances every running countdown to the next countdown that finishes.
*/
@JvmStatic
fun skipActive(): Boolean {
val advanceBy = activeCountdowns.minOfOrNull { it.timeLeft } ?: return false
activeCountdowns.toList().forEach { it.decreaseBy(advanceBy) }
return true
}
}
}
enum class CountdownMessage(val key: String) {
MINUTES("COUNTDOWN_MINUTES"),
SECONDS("COUNTDOWN_SECONDS"),
SECOND("COUNTDOWN_SECOND"),
}
data class CountdownMilestone(
val message: CountdownMessage,
val displayTime: Int,
)
object CountdownMilestones {
@JvmStatic
fun at(timeLeft: Int): CountdownMilestone? = when (timeLeft) {
900, 600, 300, 180, 120 ->
CountdownMilestone(CountdownMessage.MINUTES, timeLeft / 60)
60, 30, 20, 15, 10, 5, 4, 3, 2 ->
CountdownMilestone(CountdownMessage.SECONDS, timeLeft)
1 ->
CountdownMilestone(CountdownMessage.SECOND, timeLeft)
else -> null
}
}
/**
* FightSystem's complete countdown behavior. Consumers bind their game-specific
* transports while GameCore owns lifecycle, milestones, and presentation.
*/
abstract class StandardCountdown @JvmOverloads constructor(
plugin: Plugin,
totalTime: Int,
private val presentation: CountdownPresentation,
initialDelayTicks: Long = 20,
periodTicks: Long = 20,
showInitialValue: Boolean = true,
) : Countdown(
plugin,
totalTime,
initialDelayTicks,
periodTicks,
showInitialValue,
) {
final override fun onTick(timeLeft: Int) {
presentation.update(timeLeft)
}
final override fun onFinished() {
presentation.finished()
countdownFinished()
}
protected abstract fun countdownFinished()
}
fun interface CountdownMessageSink {
fun display(message: CountdownMessage, displayTime: Int)
}
fun interface CountdownSoundSink {
fun play(pitch: Float)
}
/**
* Complete standard presentation policy. Game modes only bind their actual
* message, sound, and level transports.
*/
class CountdownPresentation constructor(
private val messageSink: CountdownMessageSink,
private val tickSoundSink: CountdownSoundSink?,
private val finishedSoundSink: CountdownSoundSink?,
private val levelSink: IntConsumer?,
private val tickSoundOnMinutes: Boolean,
) {
@JvmOverloads
constructor(
messageSink: CountdownMessageSink,
soundSink: CountdownSoundSink? = null,
levelSink: IntConsumer? = null,
) : this(messageSink, soundSink, soundSink, levelSink, false)
fun update(timeLeft: Int) {
CountdownMilestones.at(timeLeft)?.let {
if (tickSoundOnMinutes || it.message != CountdownMessage.MINUTES) {
tickSoundSink?.play(1.0f)
}
messageSink.display(it.message, it.displayTime)
}
levelSink?.accept(timeLeft)
}
fun finished() {
finishedSoundSink?.play(2.0f)
}
}
@@ -0,0 +1,74 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 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.
*/
package de.steamwar.gamecore.state
import java.util.Collections
import java.util.LinkedHashMap
import java.util.concurrent.CopyOnWriteArrayList
fun interface GameStateListener<S : Enum<S>> {
fun onStateChange(oldState: S, newState: S)
}
/**
* Small state holder used by game modes instead of duplicating listener lists
* and transition notification code.
*/
class GameStateMachine<S : Enum<S>>(initialState: S) {
private val listeners = CopyOnWriteArrayList<GameStateListener<S>>()
private val stateDependents = LinkedHashMap<IStateDependent<S>, Boolean>()
@Volatile
var currentState: S = initialState
private set
val stateDependentFeatures: Map<IStateDependent<S>, Boolean>
get() = Collections.unmodifiableMap(LinkedHashMap(stateDependents))
fun registerStateDependent(stateDependent: IStateDependent<S>) {
if (stateDependent.enabled().isEmpty()) return
val enabled = currentState in stateDependent.enabled()
stateDependents[stateDependent] = enabled
if (enabled) stateDependent.enable()
}
fun transitionTo(newState: S) {
val oldState = currentState
if (oldState == newState) return
currentState = newState
stateDependents.entries.toList().forEach { (feature, wasEnabled) ->
val shouldBeEnabled = newState in feature.enabled()
if (shouldBeEnabled && !wasEnabled) {
feature.enable()
stateDependents[feature] = true
} else if (!shouldBeEnabled && wasEnabled) {
feature.disable()
stateDependents[feature] = false
}
}
listeners.forEach { it.onStateChange(oldState, newState) }
}
fun reset(initialState: S) {
transitionTo(initialState)
}
fun addListener(listener: GameStateListener<S>) {
listeners.add(listener)
}
fun removeListener(listener: GameStateListener<S>) {
listeners.remove(listener)
}
}

Some files were not shown because too many files have changed in this diff Show More