Compare commits

..

2 Commits

Author SHA1 Message Date
Chaoscaot 59de3e81ae Merge branch 'main' into modular-fight-system
SteamWarCI Build failed
2026-05-09 20:16:30 +02:00
Chaoscaot a37321d3b8 Add modular fight system components and configurations
Signed-off-by: Chaoscaot <max@maxsp.de>
2026-03-17 18:30:53 +01:00
75 changed files with 722 additions and 1201 deletions
-60
View File
@@ -1,60 +0,0 @@
name: Bug Report
about: Du hast einen Fehler gefunden? Melde ihn hier!
labels: [ "typ/bug" ]
body:
- type: markdown
attributes:
value: |
ACHTUNG: Sollte es bei dem Bug ein Sicherheitsrisiko geben, melde es bitte auf unserem Discord Server
- type: textarea
id: description
attributes:
label: Description
description: |
Beschreibe deinen Bug in kurzer Form.
- type: input
id: mc-ver
attributes:
label: Minecraft Version
description: Minecraft Version des Clients
validations:
required: true
- type: input
id: mc-ver-ser
attributes:
label: Minecraft Version Server
description: Minecraft Version des Servers, nur bei Bau oder Arenen Servern
- type: dropdown
id: can-reproduce
attributes:
label: Kannst du den Fehler wiederholen?
description: |
Wenn du den Fehler wiederholen kannst, können wir dieses Problem schneller beheben.
Solltest du den Fehler nicht wiederholen können, melde dich bitte auf unserem Discord Server.
options:
- "Yes"
- "No"
validations:
required: true
- type: textarea
id: reproduce-steps
attributes:
label: Wie kannst du den Fehler wiederholen?
description: Welche Schritte musst du ausführen, um den Fehler wiederholen zu können?
validations:
required: true
- type: textarea
id: expected-result
attributes:
label: Was sollte passieren?
description: Was sollte hier deiner Erwartung nach passieren?
- type: input
id: logs
attributes:
label: Auf welchem Server ist der Fehler aufgetreten?
description: Gebe bitte den Namen des Servers an, auf dem der Fehler aufgetreten ist. z.B. "Lobby", "Lixfels Bauserver" etc.
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: Sollte es ein Visuelles Problem geben, kannst du hier Screenshots hinzufügen.
-1
View File
@@ -1 +0,0 @@
blank_issues_enabled: true
@@ -1,17 +0,0 @@
name: Feature Idee
about: Du hast eine Idee für ein neues Feature, welches SteamWar nicht hat? Stelle sie hier vor.
labels: ["typ/idee"]
body:
- type: textarea
id: description
attributes:
label: Feature Beschreibung
placeholder: |
Ich glaube, dass ...
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: Wenn es sich um etwas grafisches handelt, kannst du hier Screenshots hinzufügen.
-193
View File
@@ -1,193 +0,0 @@
name: Backport CommonCore
on:
pull_request:
types:
- closed
branches:
- main
permissions:
contents: write
pull-requests: write
env:
BACKPORT_PATH: CommonCore
BACKPORT_BRANCH_PREFIX: backport/commoncore
DISABLE_BACKPORT_LABEL: no-backport
jobs:
backport:
name: Create CommonCore backport PRs
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check backport eligibility
id: eligibility
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
run: |
set -euo pipefail
api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}"
echo "Backport debug: event=${GITHUB_EVENT_NAME:-unknown}"
echo "Backport debug: server=${GITHUB_SERVER_URL}"
echo "Backport debug: api=${api_url}"
echo "Backport debug: repository=${GITHUB_REPOSITORY}"
echo "Backport debug: action=$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")"
merged="$(jq -r '.pull_request.merged // (.pull_request.merged_at != null)' "$GITHUB_EVENT_PATH")"
base_branch="$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")"
has_disable_label="$(jq -r --arg disable_backport_label "$DISABLE_BACKPORT_LABEL" 'any(.pull_request.labels[]?; .name == $disable_backport_label)' "$GITHUB_EVENT_PATH")"
echo "Backport debug: pr=$(jq -r '.pull_request.number // ""' "$GITHUB_EVENT_PATH") base=${base_branch} merged=${merged}"
echo "Backport debug: disable label present=${has_disable_label}"
{
echo "should_backport=$([[ "$merged" == "true" && "$base_branch" == "main" && "$has_disable_label" != "true" ]] && echo true || echo false)"
echo "pr_number=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
echo "pr_title<<EOF"
jq -r '.pull_request.title' "$GITHUB_EVENT_PATH"
echo "EOF"
} >> "$GITHUB_OUTPUT"
labels="$(curl -fsS \
-H "Accept: application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${api_url}/repos/${GITHUB_REPOSITORY}/labels")"
if ! jq -e --arg disable_backport_label "$DISABLE_BACKPORT_LABEL" 'any(.[]; .name == $disable_backport_label)' <<< "$labels" >/dev/null; then
curl -fsS -X POST \
-H "Accept: application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg name "$DISABLE_BACKPORT_LABEL" --arg color "ededed" --arg description "Disable automatic CommonCore backporting for this pull request." '{name: $name, color: $color, description: $description}')" \
"${api_url}/repos/${GITHUB_REPOSITORY}/labels"
fi
- name: Create backport pull requests
if: steps.eligibility.outputs.should_backport == 'true'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
PR_NUMBER: ${{ steps.eligibility.outputs.pr_number }}
PR_TITLE: ${{ steps.eligibility.outputs.pr_title }}
run: |
set -euo pipefail
api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}"
repo_api_path="/repos/${GITHUB_REPOSITORY}"
api_request() {
local method="$1"
local path="$2"
local output="$3"
local data_file="${4:-}"
local status
local args=(-sS -X "$method" -H "Accept: application/json" -H "Authorization: token ${GITHUB_TOKEN}" -w "%{http_code}" -o "$output")
if [[ -n "$data_file" ]]; then
args+=(-H "Content-Type: application/json" --data-binary "@${data_file}")
fi
echo "Backport debug: ${method} ${path}"
if ! status="$(curl "${args[@]}" "${api_url}${path}")"; then
echo "Backport debug: ${method} ${path} failed before HTTP status was captured."
if [[ -s "$output" ]]; then
echo "Backport debug: response body:"
cat "$output"
fi
return 1
fi
echo "Backport debug: ${method} ${path} -> HTTP ${status}"
if [[ ! "$status" =~ ^2 ]]; then
echo "Backport debug: response body:"
cat "$output"
return 1
fi
}
echo "Backport debug: event=${GITHUB_EVENT_NAME:-unknown}"
echo "Backport debug: server=${GITHUB_SERVER_URL}"
echo "Backport debug: api=${api_url}"
echo "Backport debug: repository=${GITHUB_REPOSITORY}"
echo "Backport debug: pr=${PR_NUMBER}"
echo "Backport debug: actor=${GITHUB_ACTOR:-unknown}"
git config user.name "SteamWar Backport Bot"
git config user.email "actions@steamwar.de"
if [[ "${GITHUB_SERVER_URL}" == https://* ]]; then
auth_host="${GITHUB_SERVER_URL#https://}"
git remote set-url origin "https://oauth2:${GITHUB_TOKEN}@${auth_host}/${GITHUB_REPOSITORY}.git"
fi
git fetch --prune origin '+refs/heads/version/*:refs/remotes/origin/version/*'
api_request GET "${repo_api_path}" repo-debug.json
jq -r '"Backport debug: repo permissions admin=\(.permissions.admin // "unknown") push=\(.permissions.push // "unknown") pull=\(.permissions.pull // "unknown")"' repo-debug.json || true
echo "Backport debug: GET ${repo_api_path}/pulls/${PR_NUMBER}.diff"
curl -fsSL -w "Backport debug: GET ${repo_api_path}/pulls/${PR_NUMBER}.diff -> HTTP %{http_code}\n" \
-H "Accept: text/plain" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${api_url}${repo_api_path}/pulls/${PR_NUMBER}.diff" \
-o pull-request.diff
if ! grep -Eq "^diff --git a/${BACKPORT_PATH}/" pull-request.diff; then
echo "Pull request #${PR_NUMBER} has no ${BACKPORT_PATH} changes to backport."
exit 0
fi
mapfile -t target_branches < <(git for-each-ref --format='%(refname:strip=3)' refs/remotes/origin/version)
if [[ "${#target_branches[@]}" -eq 0 ]]; then
echo "No version/* branches found."
exit 0
fi
for target_branch in "${target_branches[@]}"; do
safe_target="${target_branch//\//-}"
backport_branch="${BACKPORT_BRANCH_PREFIX}/pr-${PR_NUMBER}-to-${safe_target}"
git checkout -B "${backport_branch}" "origin/${target_branch}"
git reset --hard "origin/${target_branch}"
if ! git apply --3way --index --include="${BACKPORT_PATH}/**" pull-request.diff; then
echo "Failed to apply CommonCore backport for ${target_branch}."
exit 1
fi
if git diff --cached --quiet; then
echo "CommonCore changes from #${PR_NUMBER} are already present in ${target_branch}."
continue
fi
git commit -m "Backport CommonCore changes from #${PR_NUMBER}" -m "${PR_TITLE}"
git push --force-with-lease origin "${backport_branch}"
api_request GET "${repo_api_path}/pulls?state=open" open-pulls.json
open_pr_number="$(jq -r --arg base "$target_branch" --arg head "$backport_branch" '[.[] | select(.base.ref == $base and .head.ref == $head) | (.number // .index)][0] // empty' open-pulls.json)"
if [[ -n "$open_pr_number" ]]; then
echo "Backport PR #${open_pr_number} already exists for ${target_branch}."
continue
fi
pr_body="$(printf 'Automatic CommonCore backport of #%s.\n\nOriginal PR title: %s\n\nOnly files below `CommonCore/` are included.' "$PR_NUMBER" "$PR_TITLE")"
jq -n \
--arg base "$target_branch" \
--arg head "$backport_branch" \
--arg title "Backport CommonCore changes from #${PR_NUMBER} to ${target_branch}" \
--arg body "$pr_body" \
'{base: $base, head: $head, title: $title, body: $body}' > create-pull.json
echo "Backport debug: create PR base=${target_branch} head=${backport_branch}"
api_request POST "${repo_api_path}/pulls" create-pull-response.json create-pull.json
done
-145
View File
@@ -1,145 +0,0 @@
name: Deploy
on:
push:
branches:
- main
- version/*
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Setup Java 8
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 8
- name: Setup Java 11
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 11
- name: Setup Java 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Setup Maven Repository
env:
SW_MAVEN_CREDENTIALS: ${{ secrets.SW_MAVEN_CREDENTIALS }}
run: |
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
- name: Build with Gradle
run: ./gradlew build --no-daemon
- name: Stage deploy artifacts
shell: bash
run: |
set -euo pipefail
rm -rf deploy
mkdir -p deploy
cp "BauSystem/build/libs/BauSystem-all.jar" "deploy/BauSystem.jar"
cp "LegacyBauSystem/build/libs/LegacyBauSystem.jar" "deploy/BauSystem-1.12.jar"
cp "FightSystem/build/libs/FightSystem-all.jar" "deploy/FightSystem.jar"
cp "KotlinCore/build/libs/KotlinCore-all.jar" "deploy/KotlinCore.jar"
cp "TNTLeague/build/libs/TNTLeague.jar" "deploy/TNTLeague.jar"
cp "LobbySystem/build/libs/LobbySystem.jar" "deploy/LobbySystem.jar"
cp "MissileWars/build/libs/MissileWars.jar" "deploy/MissileWars.jar"
cp "Realtime/build/libs/Realtime.jar" "deploy/RealTime.jar"
cp "SchematicSystem/build/libs/SchematicSystem-all.jar" "deploy/SchematicSystem.jar"
cp "SpigotCore/build/libs/SpigotCore-all.jar" "deploy/SpigotCore.jar"
cp "Teamserver/build/libs/Teamserver.jar" "deploy/Builder.jar"
cp "TowerRun/build/libs/TowerRun.jar" "deploy/TowerRun.jar"
cp "VelocityCore/Persistent/build/libs/Persistent.jar" "deploy/PersistentVelocityCore.jar"
cp "VelocityCore/Dependencies/build/libs/Dependencies-all.jar" "deploy/DependenciesVelocityCore.jar"
cp "VelocityCore/build/libs/VelocityCore-all.jar" "deploy/VelocityCore.jar"
cp "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "deploy/website-api.jar"
cp "CLI/build/distributions/sw.zip" "deploy/sw.zip"
- name: Upload deploy artifacts
uses: actions/upload-artifact@v3
with:
name: steamwar-jars
path: deploy/
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
steps:
- name: Download deploy artifacts
uses: actions/download-artifact@v3
with:
name: steamwar-jars
path: deploy
- name: Resolve deploy target
id: target
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
echo "path=/jars/current" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF_NAME}" == version/* ]]; then
version="${GITHUB_REF_NAME#version/}"
if [[ ! "$version" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "Unsupported version branch name: ${GITHUB_REF_NAME}" >&2
exit 1
fi
echo "path=/jars/${version}" >> "$GITHUB_OUTPUT"
else
echo "Unsupported deployment branch: ${GITHUB_REF_NAME}" >&2
exit 1
fi
- name: Upload jars with scp
shell: bash
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_PATH: ${{ steps.target.outputs.path }}
run: |
set -euo pipefail
: "${DEPLOY_HOST:?Missing DEPLOY_HOST secret}"
: "${DEPLOY_USER:?Missing DEPLOY_USER secret}"
: "${DEPLOY_SSH_KEY:?Missing DEPLOY_SSH_KEY secret}"
port="${DEPLOY_PORT:-22}"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p "$port" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH'"
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
- name: Restart Services
shell: bash
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
set -euo pipefail
ssh -i ~/.ssh/deploy_key -p "$DEPLOY_PORT" "${DEPLOY_USER}@${DEPLOY_HOST}" "sudo systemctl restart api.service"
ssh -i ~/.ssh/deploy_key -p "$DEPLOY_PORT" "${DEPLOY_USER}@${DEPLOY_HOST}" "unzip -o /jars/current/sw.zip -d /jars"
-76
View File
@@ -1,76 +0,0 @@
name: Pull Request Build
on:
pull_request:
permissions:
contents: write
pull-requests: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Setup Java 8
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 8
- name: Setup Java 11
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 11
- name: Setup Java 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Setup Maven Repository
env:
SW_MAVEN_CREDENTIALS: ${{ secrets.SW_MAVEN_CREDENTIALS }}
run: |
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
- name: Build with Gradle
run: ./gradlew build --no-daemon
- name: Merge successful backport PR
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
BACKPORT_BRANCH_PREFIX: backport/commoncore
run: |
set -euo pipefail
head_branch="$(jq -r '.pull_request.head.ref // ""' "$GITHUB_EVENT_PATH")"
base_branch="$(jq -r '.pull_request.base.ref // ""' "$GITHUB_EVENT_PATH")"
pr_number="$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
if [[ "${head_branch}" != "${BACKPORT_BRANCH_PREFIX}/"* ]]; then
echo "Not a CommonCore backport PR."
exit 0
fi
if [[ "${base_branch}" != version/* ]]; then
echo "Backport PR target is not a version/* branch."
exit 0
fi
api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}"
curl -fsS -X POST \
-H "Accept: application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"Do":"merge","delete_branch_after_merge":true}' \
"${api_url}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/merge"
+1 -1
View File
@@ -21,4 +21,4 @@ lib
/WebsiteBackend/logs /WebsiteBackend/logs
/WebsiteBackend/skins /WebsiteBackend/skins
/WebsiteBackend/config.json /WebsiteBackend/config.json
/WebsiteBackend/sessions /WebsiteBackend/sessions
@@ -67,7 +67,11 @@ public class TNTListener implements Listener, ScoreboardElement {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent event) { public void onExplode(EntityExplodeEvent event) {
explode(event.blockList(), event.getEntity() instanceof TNTPrimed); if (!(event.getEntity() instanceof TNTPrimed)) {
event.blockList().clear();
return;
}
explode(event.blockList(), true);
} }
@Override @Override
-32
View File
@@ -1,32 +0,0 @@
plugins {
steamwar.kotlin
application
}
kotlin {
jvmToolchain(21)
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
application {
mainClass.set("de.steamwar.MainKt")
applicationName = "sw"
}
dependencies {
implementation(project(":CommonCore:SQL"))
implementation("com.github.ajalt.clikt:clikt:5.0.3")
implementation("com.github.ajalt.mordant:mordant:3.0.2")
implementation(libs.logback)
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.1")
implementation(libs.exposedCore)
implementation(libs.exposedDao)
implementation(libs.exposedJdbc)
implementation(libs.exposedTime)
}
-22
View File
@@ -1,22 +0,0 @@
package de.steamwar
import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.subcommands
import de.steamwar.commands.SteamWar
import de.steamwar.commands.database.DatabaseCommand
import de.steamwar.commands.database.InfoCommand
import de.steamwar.commands.database.ResetCommand
import de.steamwar.commands.dev.DevCommand
import de.steamwar.commands.profiler.ProfilerCommand
import de.steamwar.commands.user.UserCommand
import de.steamwar.commands.user.UserInfoCommand
import de.steamwar.commands.user.UserSearchCommand
fun main(args: Array<String>) = SteamWar()
.subcommands(
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
DevCommand(),
ProfilerCommand()
)
.main(args)
-10
View File
@@ -1,10 +0,0 @@
package de.steamwar.commands
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.mordant.rendering.TextStyles
class SteamWar: CliktCommand(name = "sw") {
override fun run() {
echo(TextStyles.bold("SteamWar-CLI"))
}
}
@@ -1,22 +0,0 @@
package de.steamwar.commands.database
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.findOrSetObject
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import de.steamwar.db.Database
class DatabaseCommand: CliktCommand(name = "db") {
val useProduction by option().flag()
val db by findOrSetObject { Database }
override fun help(context: Context): String = "Run database commands"
override fun run() {
if (!useProduction && db.database == "production") {
throw CliktError("You should not use the production database!")
}
}
}
-25
View File
@@ -1,25 +0,0 @@
package de.steamwar.commands.database
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.mordant.table.table
import de.steamwar.db.Database
import de.steamwar.db.execute
import de.steamwar.db.useDb
class InfoCommand: CliktCommand() {
val db by requireObject<Database>()
override fun run() = useDb {
val tables = execute("SHOW TABLES") { it.getString(1) }
echo(
table {
header { row("Name") }
body {
tables.map { row(it) }
}
}
)
}
}
-33
View File
@@ -1,33 +0,0 @@
package de.steamwar.commands.database
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.mordant.rendering.TextColors
import com.github.ajalt.mordant.rendering.TextStyles
import de.steamwar.db.Database
import de.steamwar.db.execute
import de.steamwar.db.useDb
import java.io.File
class ResetCommand: CliktCommand() {
val db by requireObject<Database>()
override fun run() = useDb {
val schemaFile = File("/var/Schema.sql")
if (!schemaFile.exists()) {
throw CliktError("Schema file not found!")
}
val schema = schemaFile.readText()
val tables = execute("SHOW TABLES;") { it.getString(1) }
for (table in tables) {
execute("DROP TABLE IF EXISTS $table;") { }
}
execute(schema) { }
echo(TextColors.brightGreen(TextStyles.bold("Database reset!")))
}
}
-179
View File
@@ -1,179 +0,0 @@
package de.steamwar.commands.dev
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.help
import com.github.ajalt.clikt.parameters.arguments.multiple
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.defaultLazy
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.help
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file
import com.github.ajalt.clikt.parameters.types.long
import com.github.ajalt.clikt.parameters.types.path
import com.sun.security.auth.module.UnixSystem
import java.io.File
import kotlin.io.path.absolute
import kotlin.io.path.absolutePathString
const val LOG4J_CONFIG = """<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
<Appenders>
<Console name="WINDOWS_COMPAT" target="SYSTEM_OUT"></Console>
<Queue name="TerminalConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="$\{'sys:logPath'}/latest.log" filePattern="$\{'sys:logPath'}/%d{yyyy.MM.dd}.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="7"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="WINDOWS_COMPAT" level="info"/>
<AppenderRef ref="File"/>
<AppenderRef ref="TerminalConsole" level="info"/>
</Root>
</Loggers>
</Configuration>"""
class DevCommand : CliktCommand("dev") {
override fun help(context: Context): String = "Start a dev Server"
override val treatUnknownOptionsAsArgs = true
val server by argument().help("Server Template")
val port by option("--port").long().defaultLazy { UnixSystem().uid + 1010 }.help("Port for Server")
val world by option("--world", "-w").path(canBeFile = false).help("User World")
val plugins by option("--plugins", "-p").path(true, canBeFile = false).help("Plugin Dir")
val profile by option().flag().help("Add Profiling Arguments")
val forceUpgrade by option().flag().help("Force Upgrade")
val jar by option().file(true, canBeDir = false).help("Jar File")
val jvm by option().file(true, canBeDir = false).help("Java Executable")
val jvmArgs by argument().multiple()
override val printHelpOnEmptyArgs = true
val workingDir = File("").absoluteFile
val log4jConfig = File(workingDir, "log4j2.xml")
override fun run() {
val args = mutableListOf<String>()
val serverDirectory = File(workingDir, server)
val serverDir =
if (serverDirectory.exists() && serverDirectory.isDirectory) serverDirectory else File(workingDir, server)
if (isVelocity(server)) {
runServer(args, jvmArgs, listOf(jar?.absolutePath ?: File("/jar/Velocity.jar").absolutePath), serverDir)
} else {
setLogConfig(args)
val version = findVersion(server) ?: throw CliktError("Unknown Server Version")
val worldFile = world?.absolute()?.toFile() ?: File(serverDir, "devtempworld")
val jarFile = jar?.absolutePath ?: additionalVersions[server]?.let { supportedVersionJars[it] } ?: supportedVersionJars[version]
?: throw CliktError("Unknown Server Version")
if (!worldFile.exists()) {
val templateFile = File(serverDir, "Bauwelt")
if (!templateFile.exists()) {
throw CliktError("World Template not found!")
}
templateFile.copyRecursively(worldFile)
}
val devFile = File("/configs/DevServer/${System.getProperty("user.name")}.$port.$version")
if (System.getProperty("user.name") != "minecraft") {
devFile.createNewFile()
}
runServer(
args, jvmArgs, listOf(
jarFile,
*(if (forceUpgrade) arrayOf("-forceUpgrade") else arrayOf()),
"--port", port.toString(),
"--level-name", worldFile.name,
"--world-dir", workingDir.absolutePath,
"--nogui",
*(if (plugins != null) arrayOf("--plugins", plugins!!.absolutePathString()) else arrayOf())
), serverDir
)
try {
devFile.delete()
} catch (_: Exception) { /* ignored */ }
}
}
val jvmDefaultParams = arrayOf(
"-Xmx1G",
"-Xgc:excessiveGCratio=80",
"-Xsyslog:none",
"-Xtrace:none",
"-Xnoclassgc",
"-Xdisableexplicitgc",
"-XX:+AlwaysPreTouch",
"-XX:+CompactStrings",
"-XX:-HeapDumpOnOutOfMemory",
"-XX:+ExitOnOutOfMemoryError"
)
val jvmArgOverrides = arrayOf("--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED")
val supportedVersionJars = mapOf(
8 to "/jars/paper-1.8.8.jar",
9 to "/jars/spigot-1.9.4.jar",
10 to "/jars/paper-1.10.2.jar",
12 to "/jars/spigot-1.12.2.jar",
14 to "/jars/spigot-1.14.4.jar",
15 to "/jars/spigot-1.15.2.jar",
18 to "/jars/paper-1.18.2.jar",
19 to "/jars/paper-1.19.3.jar",
20 to "/jars/paper-1.20.1.jar",
21 to "/jars/paper-1.21.6.jar"
)
val additionalVersions = mapOf(
"Tutorial" to 15,
"Lobby" to 20
)
fun findVersion(server: String): Int? = server.dropWhile { !it.isDigit() }.toIntOrNull()
fun isJava8(server: String): Boolean = findVersion(server)?.let { it <= 10 } ?: false
fun isVelocity(server: String): Boolean = server.endsWith("Velocity")
fun setLogConfig(args: MutableList<String>) {
args += "-DlogPath=${workingDir.absolutePath}/logs"
args += "-Dlog4j.configurationFile=${log4jConfig.absolutePath}"
if (!log4jConfig.exists()) {
log4jConfig.writeText(LOG4J_CONFIG)
}
}
fun runServer(args: List<String>, jvmArgs: List<String>, cmd: List<String>, serverDir: File) {
val process = ProcessBuilder(
jvm?.absolutePath ?: if (isJava8(server)) "/usr/lib/jvm/openj9-8/bin/java" else "java",
*jvmArgs.toTypedArray(),
*args.toTypedArray(),
*jvmDefaultParams,
*(if (isJava8(server)) arrayOf() else jvmArgOverrides),
*(if (profile) arrayOf("-javaagent:/jars/LixfelsProfiler.jar=start") else arrayOf()),
"-Xshareclasses:nonfatal,name=$server",
"-jar",
*cmd.toTypedArray()
).directory(serverDir).inheritIO().start()
Runtime.getRuntime().addShutdownHook(Thread { if (process.isAlive) process.destroyForcibly() })
process.waitFor()
}
}
@@ -1,42 +0,0 @@
package de.steamwar.commands.profiler
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.help
import com.github.ajalt.clikt.parameters.arguments.optional
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.int
const val SPARK = "/jars/spark.jar"
class ProfilerCommand: CliktCommand("profiler") {
val pid by argument().help("Process id").int().optional()
val port by option("--port", "-p").int().default(8543)
override fun run() {
if (pid != null) {
ProcessBuilder()
.command("java", "-jar", SPARK, pid.toString(), "port=$port")
.start()
.waitFor()
Thread.sleep(1000)
ProcessBuilder()
.command("ssh", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-p", port.toString(), "spark@localhost")
.inheritIO()
.start()
.waitFor()
} else {
ProcessBuilder()
.command("java", "-jar", SPARK)
.inheritIO()
.start()
.waitFor()
}
}
override fun help(context: Context): String = "Start a profiler"
}
-9
View File
@@ -1,9 +0,0 @@
package de.steamwar.commands.user
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
class UserCommand: CliktCommand("user") {
override fun run() = Unit
override fun help(context: Context): String = "User related commands"
}
-65
View File
@@ -1,65 +0,0 @@
package de.steamwar.commands.user
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.help
import com.github.ajalt.mordant.table.table
import de.steamwar.db.findUser
import de.steamwar.db.useDb
import de.steamwar.sql.Punishment
import de.steamwar.sql.SessionTable
import de.steamwar.sql.SteamwarUser
import de.steamwar.sql.Team
import org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.jdbc.selectAll
import java.time.Duration
class UserInfoCommand : CliktCommand("info") {
val userId by argument().help("Id, Name, UUID or DiscordId")
val user by lazy { findUser(userId) ?: throw CliktError("User not found") }
override val printHelpOnEmptyArgs = true
override fun run() = useDb {
val sessions =
SessionTable.selectAll().where { SessionTable.userId eq user.id.value }
.map { it[SessionTable.startTime] to it[SessionTable.endTime] }
val totalPlayed = sessions.sumOf { Duration.between(it.first, it.second).toMinutes() } / 60.0
val firstJoin = sessions.minByOrNull { it.first }?.first
val lastJoin = sessions.maxByOrNull { it.second }?.second
val punishments = Punishment.getAllPunishmentsOfPlayer(user.id.value)
echo(
table {
body {
row("Name", user.userName)
row("UUID", user.uuid)
row("Team", Team.byId(user.team).teamName)
row("Leader", user.leader)
row("Locale", user.locale)
row("Beigetreten am", firstJoin)
row("Zuletzt gesehen am", lastJoin)
row("Spielzeit", totalPlayed.toString() + "h")
row("Punishments", if (punishments.isEmpty()) "Keine" else table {
header { row("Typ", "Ersteller", "Von", "Bis", "Grund") }
body {
punishments.map {
row(
it.type,
SteamwarUser.byId(it.punisher)?.userName ?: it.punisher,
it.startTime.toString(),
if (it.perma) "Perma" else it.endTime.toString(),
it.reason
)
}
}
})
}
}
)
}
}
@@ -1,42 +0,0 @@
package de.steamwar.commands.user
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.help
import com.github.ajalt.mordant.table.table
import de.steamwar.db.joinedOr
import de.steamwar.db.useDb
import de.steamwar.sql.SteamwarUser
import de.steamwar.sql.SteamwarUserTable
import de.steamwar.sql.Team
import org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.core.like
class UserSearchCommand : CliktCommand("search") {
val query by argument().help("Name, Id, UUID or DiscordId")
override val printHelpOnEmptyArgs = true
override fun help(context: Context): String = "Search for users"
override fun run() = useDb {
val users = SteamwarUser.find {
joinedOr(
SteamwarUserTable.username like "%$query%",
SteamwarUserTable.uuid like "%$query%",
query.toLongOrNull()?.let { SteamwarUserTable.discordId eq it },
query.toIntOrNull()?.let { SteamwarUserTable.id eq it }
)
}
val teams = mutableMapOf<Int, Team>()
echo(table {
header { row("Id", "Username", "UUID", "Team", "DiscordId") }
body {
users.map { row(it.id.value, it.userName, it.uuid, teams.computeIfAbsent(it.team) { teamId -> Team.byId(teamId) }.teamName, it.discordId) }
}
})
}
}
-84
View File
@@ -1,84 +0,0 @@
package de.steamwar.db
import com.github.ajalt.clikt.core.BaseCliktCommand
import com.github.ajalt.clikt.core.CliktError
import de.steamwar.sql.SteamwarUser
import de.steamwar.sql.SteamwarUserTable
import org.jetbrains.exposed.v1.core.Expression
import org.jetbrains.exposed.v1.core.Op
import org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.core.or
import org.jetbrains.exposed.v1.jdbc.Database
import org.jetbrains.exposed.v1.jdbc.JdbcTransaction
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import java.io.File
import java.sql.ResultSet
import java.util.Properties
object Database {
lateinit var host: String
lateinit var port: String
lateinit var database: String
lateinit var db: Database
fun ensureConnected() {
if (::db.isInitialized) {
return
}
val config = File(System.getProperty("user.home"), "mysql.properties")
if (!config.exists()) {
throw CliktError("Config file not found!")
}
val props = Properties();
props.load(config.inputStream())
host = props.getProperty("host")
port = props.getProperty("port")
database = props.getProperty("database")
val username = props.getProperty("user")
val password = props.getProperty("password")
val url = "jdbc:mariadb://$host:$port/$database"
db = Database.connect(url, driver = "org.mariadb.jdbc.Driver", user = username, password = password)
return
}
}
fun <T: BaseCliktCommand<T>> BaseCliktCommand<T>.findUser(query: String): SteamwarUser? = transaction {
SteamwarUser.find { joinedOr(query.toIntOrNull()?.let { SteamwarUserTable.id eq it }, (SteamwarUserTable.username eq query), SteamwarUserTable.uuid eq query, query.toLongOrNull()?.let { SteamwarUserTable.discordId eq it }) }
.firstOrNull()
?.let { return@transaction it }
}
fun joinedOr(vararg expressions: Expression<Boolean>?): Op<Boolean> =
expressions.filterNotNull().reduce { acc, expression -> acc or expression } as Op<Boolean>
fun <T> JdbcTransaction.execute(sql: String, transform: (ResultSet) -> T): List<T> {
val result = mutableListOf<T>()
exec(sql) { rs ->
while (rs.next()) {
result += transform(rs)
}
}
return result
}
fun <T> JdbcTransaction.executeSingle(sql: String, transform: (ResultSet) -> T): T? {
return execute(sql) { rs ->
if (!rs.next()) {
return@execute null
}
transform(rs)
}.single()
}
fun useDb(statement: JdbcTransaction.() -> Unit) {
de.steamwar.db.Database.ensureConnected()
transaction(de.steamwar.db.Database.db, statement)
}
-11
View File
@@ -1,11 +0,0 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -28,11 +28,11 @@ import org.jetbrains.exposed.v1.javatime.timestamp
import java.time.Instant import java.time.Instant
object AuditLogTable: IntIdTable("AuditLog", "AuditLogId") { object AuditLogTable: IntIdTable("AuditLog", "AuditLogId") {
val time = timestamp("Time").index() val time = timestamp("Time")
val server = varchar("ServerName", 255).index() val server = varchar("ServerName", 255)
val serverOwner = reference("ServerOwner", SteamwarUserTable).nullable().index() val serverOwner = reference("ServerOwner", SteamwarUserTable).nullable()
val actor = reference("Actor", SteamwarUserTable).index() val actor = reference("Actor", SteamwarUserTable)
val action = enumerationByName("ActionType", 255, AuditLog.Type::class).index() val action = enumerationByName("ActionType", 255, AuditLog.Type::class)
val actionText = text("ActionText") val actionText = text("ActionText")
} }
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -33,8 +33,8 @@ import java.sql.Timestamp
import java.time.Instant import java.time.Instant
object BannedUserIPsTable: CompositeIdTable("BannedUserIPs") { object BannedUserIPsTable: CompositeIdTable("BannedUserIPs") {
val userId = reference("UserID", SteamwarUserTable).index() val userId = reference("UserID", SteamwarUserTable)
val timestamp = timestamp("Timestamp").index() val timestamp = timestamp("Timestamp")
val ip = varchar("IP", 45).entityId() val ip = varchar("IP", 45).entityId()
init { init {
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -32,8 +32,8 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore
import java.util.* import java.util.*
object BauweltMemberTable: CompositeIdTable("BauweltMember") { object BauweltMemberTable: CompositeIdTable("BauweltMember") {
val bauweltId = reference("BauweltID", SteamwarUserTable).index() val bauweltId = reference("BauweltID", SteamwarUserTable)
val memberId = reference("MemberID", SteamwarUserTable).index() val memberId = reference("MemberID", SteamwarUserTable)
val build = bool("Build") val build = bool("Build")
val worldEdit = bool("WorldEdit") val worldEdit = bool("WorldEdit")
val world = bool("World") val world = bool("World")
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -20,7 +20,6 @@
package de.steamwar.sql package de.steamwar.sql
import de.steamwar.sql.internal.useDb import de.steamwar.sql.internal.useDb
import org.jetbrains.exposed.v1.core.ReferenceOption
import org.jetbrains.exposed.v1.core.SortOrder import org.jetbrains.exposed.v1.core.SortOrder
import org.jetbrains.exposed.v1.core.and import org.jetbrains.exposed.v1.core.and
import org.jetbrains.exposed.v1.core.dao.id.CompositeID import org.jetbrains.exposed.v1.core.dao.id.CompositeID
@@ -35,23 +34,19 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore
import java.sql.Timestamp import java.sql.Timestamp
object CheckedSchematicTable: CompositeIdTable("CheckedSchematic") { object CheckedSchematicTable: CompositeIdTable("CheckedSchematic") {
val nodeId = optReference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL, onUpdate = ReferenceOption.SET_NULL).index() val nodeId = optReference("NodeId", SchematicNodeTable)
val nodeOwner = reference("NodeOwner", SteamwarUserTable).index() val nodeOwner = reference("NodeOwner", SteamwarUserTable)
val nodeName = varchar("NodeName", 64).entityId().index() val nodeName = varchar("NodeName", 64).entityId()
val validator = reference("Validator", SteamwarUserTable).index() val validator = reference("Validator", SteamwarUserTable)
val startTime = timestamp("StartTime").entityId().index() val startTime = timestamp("StartTime").entityId()
val endTime = timestamp("EndTime") val endTime = timestamp("EndTime")
val declineReason = text("DeclineReason") val declineReason = text("DeclineReason")
val seen = bool("Seen").index() val seen = bool("Seen")
val nodeType = varchar("NodeType", 16) val nodeType = varchar("NodeType", 16)
init { init {
addIdColumn(nodeOwner) addIdColumn(nodeOwner)
addIdColumn(nodeName) addIdColumn(nodeName)
index(false, nodeOwner, endTime)
index(false, startTime, endTime, nodeName)
index(false, seen, nodeOwner, startTime)
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -36,8 +36,8 @@ import java.time.Instant
object EventTable : IntIdTable("Event", "EventId") { object EventTable : IntIdTable("Event", "EventId") {
val name = varchar("EventName", 100).uniqueIndex() val name = varchar("EventName", 100).uniqueIndex()
val deadline = timestamp("Deadline") val deadline = timestamp("Deadline")
val start = timestamp("Start").index() val start = timestamp("Start")
val end = timestamp("End").index() val end = timestamp("End")
val maxPlayers = integer("MaximumTeamMembers") val maxPlayers = integer("MaximumTeamMembers")
val schemType = varchar("SchemType", 16).nullable() val schemType = varchar("SchemType", 16).nullable()
val publicsOnly = bool("PublicSchemsOnly") val publicsOnly = bool("PublicSchemsOnly")
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -33,17 +33,17 @@ import java.time.Instant
import java.util.* import java.util.*
object EventFightTable : IntIdTable("EventFight", "FightID") { object EventFightTable : IntIdTable("EventFight", "FightID") {
val eventId = reference("EventID", EventTable).index() val eventId = reference("EventID", EventTable)
val startTime = timestamp("StartTime").index() val startTime = timestamp("StartTime")
val gamemode = text("Spielmodus") val gamemode = text("Spielmodus")
val map = text("Map") val map = text("Map")
val groupId = optReference("GroupId", EventGroupTable).index() val groupId = optReference("GroupId", EventGroupTable)
val teamBlue = reference("TeamBlue", TeamTable).index() val teamBlue = reference("TeamBlue", TeamTable)
val teamRed = reference("TeamRed", TeamTable).index() val teamRed = reference("TeamRed", TeamTable)
val spectatePort = integer("SpectatePort").nullable() val spectatePort = integer("SpectatePort").nullable()
val bestOf = integer("BestOf") val bestOf = integer("BestOf")
val ergebnis = integer("Ergebnis") val ergebnis = integer("Ergebnis")
val fight = optReference("Fight", FightTable).index() val fight = optReference("Fight", FightTable)
} }
class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> { class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
@@ -34,10 +34,6 @@ object EventGroupTable : IntIdTable("EventGroup", "Id") {
val pointsPerWin = integer("PointsPerWin").default(3) val pointsPerWin = integer("PointsPerWin").default(3)
val pointsPerLoss = integer("PointsPerLoss").default(0) val pointsPerLoss = integer("PointsPerLoss").default(0)
val pointsPerDraw = integer("PointsPerDraw").default(1) val pointsPerDraw = integer("PointsPerDraw").default(1)
init {
uniqueIndex(event, name)
}
} }
class EventGroup(id: EntityID<Int>) : IntEntity(id) { class EventGroup(id: EntityID<Int>) : IntEntity(id) {
@@ -29,7 +29,7 @@ import org.jetbrains.exposed.v1.dao.IntEntityClass
import org.jetbrains.exposed.v1.jdbc.select import org.jetbrains.exposed.v1.jdbc.select
object EventRelationTable : IntIdTable("EventRelation") { object EventRelationTable : IntIdTable("EventRelation") {
val fightId = reference("FightId", EventFightTable).index() val fightId = reference("FightId", EventFightTable)
val fightTeam = enumeration("FightTeam", EventRelation.FightTeam::class) val fightTeam = enumeration("FightTeam", EventRelation.FightTeam::class)
val fromType = enumeration("FromType", EventRelation.FromType::class) val fromType = enumeration("FromType", EventRelation.FromType::class)
val fromId = integer("FromId") val fromId = integer("FromId")
+5 -5
View File
@@ -34,14 +34,14 @@ import org.jetbrains.exposed.v1.jdbc.update
import java.sql.Timestamp import java.sql.Timestamp
object FightTable : IntIdTable("Fight", "FightId") { object FightTable : IntIdTable("Fight", "FightId") {
val gamemode = varchar("Gamemode", 30).index() val gamemode = varchar("Gamemode", 30)
val server = text("Server") val server = text("Server")
val startTime = timestamp("StartTime") val startTime = timestamp("StartTime")
val duration = integer("Duration") val duration = integer("Duration")
val blueLeader = reference("BlueLeader", SteamwarUserTable).index() val blueLeader = reference("BlueLeader", SteamwarUserTable)
val redLeader = reference("RedLeader", SteamwarUserTable).index() val redLeader = reference("RedLeader", SteamwarUserTable)
val blueSchem = optReference("BlueSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL).index() val blueSchem = optReference("BlueSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL)
val redSchem = optReference("RedSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL).index() val redSchem = optReference("RedSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL)
val win = enumeration("Win", Fight.WinningTeam::class) val win = enumeration("Win", Fight.WinningTeam::class)
val winCondition = varchar("WinCondition", 100) val winCondition = varchar("WinCondition", 100)
val replayAvailable = bool("ReplayAvailable") val replayAvailable = bool("ReplayAvailable")
@@ -30,7 +30,7 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore
object FightPlayerTable : CompositeIdTable("FightPlayer") { object FightPlayerTable : CompositeIdTable("FightPlayer") {
val fightId = reference("FightId", FightTable) val fightId = reference("FightId", FightTable)
val userId = reference("UserId", SteamwarUserTable).index() val userId = reference("UserId", SteamwarUserTable)
val team = integer("Team") val team = integer("Team")
val kit = varchar("Kit", 64) val kit = varchar("Kit", 64)
val kills = integer("Kills") val kills = integer("Kills")
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -30,8 +30,8 @@ import org.jetbrains.exposed.v1.dao.CompositeEntityClass
import java.util.* import java.util.*
object IgnoreSystemTable: CompositeIdTable("IgnoredPlayers") { object IgnoreSystemTable: CompositeIdTable("IgnoredPlayers") {
val ignorer = reference("Ignorer", SteamwarUserTable).index() val ignorer = reference("Ignorer", SteamwarUserTable)
val ignored = reference("Ignored", SteamwarUserTable).index() val ignored = reference("Ignored", SteamwarUserTable)
override val primaryKey = PrimaryKey(ignorer, ignored) override val primaryKey = PrimaryKey(ignorer, ignored)
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
+1 -1
View File
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -35,7 +35,7 @@ import java.io.InputStream
import java.util.zip.GZIPInputStream import java.util.zip.GZIPInputStream
object NodeDataTable: CompositeIdTable("NodeData") { object NodeDataTable: CompositeIdTable("NodeData") {
val nodeId = reference("NodeId", SchematicNodeTable).index() val nodeId = reference("NodeId", SchematicNodeTable)
val createdAt = timestamp("CreatedAt").defaultExpression(CurrentTimestamp).entityId() val createdAt = timestamp("CreatedAt").defaultExpression(CurrentTimestamp).entityId()
val nodeFormat = enumeration("NodeFormat", NodeData.SchematicFormat::class) val nodeFormat = enumeration("NodeFormat", NodeData.SchematicFormat::class)
val schemData = blob("SchemData") val schemData = blob("SchemData")
@@ -20,7 +20,6 @@
package de.steamwar.sql package de.steamwar.sql
import de.steamwar.sql.internal.useDb import de.steamwar.sql.internal.useDb
import org.jetbrains.exposed.v1.core.ReferenceOption
import org.jetbrains.exposed.v1.core.dao.id.EntityID import org.jetbrains.exposed.v1.core.dao.id.EntityID
import org.jetbrains.exposed.v1.core.dao.id.IdTable import org.jetbrains.exposed.v1.core.dao.id.IdTable
import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.core.eq
@@ -33,8 +32,8 @@ import java.sql.Timestamp
import java.time.Instant import java.time.Instant
object NodeDownloadTable: IdTable<Int>("NodeDownload") { object NodeDownloadTable: IdTable<Int>("NodeDownload") {
override val id = reference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.CASCADE).uniqueIndex() override val id = reference("NodeId", SchematicNodeTable).uniqueIndex()
val link = varchar("Link", 255).uniqueIndex() val link = varchar("Link", 255)
val timestamp = timestamp("Timestamp").defaultExpression(CurrentTimestamp) val timestamp = timestamp("Timestamp").defaultExpression(CurrentTimestamp)
} }
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -20,7 +20,6 @@
package de.steamwar.sql package de.steamwar.sql
import de.steamwar.sql.internal.useDb import de.steamwar.sql.internal.useDb
import org.jetbrains.exposed.v1.core.ReferenceOption
import org.jetbrains.exposed.v1.core.and import org.jetbrains.exposed.v1.core.and
import org.jetbrains.exposed.v1.core.dao.id.CompositeID import org.jetbrains.exposed.v1.core.dao.id.CompositeID
import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
@@ -33,9 +32,9 @@ import java.util.*
import kotlin.jvm.optionals.getOrNull import kotlin.jvm.optionals.getOrNull
object NodeMemberTable : CompositeIdTable("NodeMember") { object NodeMemberTable : CompositeIdTable("NodeMember") {
val node = reference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.CASCADE, onUpdate = ReferenceOption.CASCADE).index() val node = reference("NodeId", SchematicNodeTable)
val userId = reference("UserId", SteamwarUserTable).index() val userId = reference("UserId", SteamwarUserTable)
val parentNode = optReference("ParentId", SchematicNodeTable).index() val parentNode = optReference("ParentId", SchematicNodeTable)
override val primaryKey = PrimaryKey(node, userId) override val primaryKey = PrimaryKey(node, userId)
@@ -41,7 +41,6 @@ object PersonalKitTable: CompositeIdTable("PersonalKit") {
init { init {
addIdColumn(userId) addIdColumn(userId)
index(false, userId, gamemode)
} }
} }
@@ -34,16 +34,12 @@ import java.util.function.Consumer
object PunishmentTable : IntIdTable("Punishments", "PunishmentId") { object PunishmentTable : IntIdTable("Punishments", "PunishmentId") {
val userId = reference("UserId", SteamwarUserTable) val userId = reference("UserId", SteamwarUserTable)
val punisher = reference("Punisher", SteamwarUserTable).index() val punisher = reference("Punisher", SteamwarUserTable)
val type = enumerationByName("Type", 32, Punishment.PunishmentType::class) val type = enumerationByName("Type", 32, Punishment.PunishmentType::class)
val startTime = timestamp("StartTime") val startTime = timestamp("StartTime")
val endTime = timestamp("EndTime") val endTime = timestamp("EndTime")
val perma = bool("Perma") val perma = bool("Perma")
val reason = text("Reason") val reason = text("Reason")
init {
index(false, userId, type)
}
} }
class Punishment(id: EntityID<Int>) : IntEntity(id) { class Punishment(id: EntityID<Int>) : IntEntity(id) {
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -30,7 +30,7 @@ import org.jetbrains.exposed.v1.dao.CompositeEntityClass
object RefereeTable: CompositeIdTable("Referee") { object RefereeTable: CompositeIdTable("Referee") {
val eventId = reference("EventId", EventTable) val eventId = reference("EventId", EventTable)
val userId = reference("UserId", SteamwarUserTable).index() val userId = reference("UserId", SteamwarUserTable)
override val primaryKey = PrimaryKey(eventId, userId) override val primaryKey = PrimaryKey(eventId, userId)
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -34,17 +34,13 @@ import java.util.*
import java.util.function.Consumer import java.util.function.Consumer
object SchematicNodeTable : IntIdTable("SchematicNode", "NodeId") { object SchematicNodeTable : IntIdTable("SchematicNode", "NodeId") {
val owner = reference("NodeOwner", SteamwarUserTable).index() val owner = reference("NodeOwner", SteamwarUserTable)
val name = varchar("NodeName", 64) val name = varchar("NodeName", 64)
val parent = optReference("ParentNode", SchematicNodeTable).index() val parent = optReference("ParentNode", SchematicNodeTable)
val lastUpdate = timestamp("LastUpdate").defaultExpression(CurrentTimestamp) val lastUpdate = timestamp("LastUpdate").defaultExpression(CurrentTimestamp)
val item = text("NodeItem") val item = text("NodeItem")
val type = varchar("NodeType", 16).nullable().index() val type = varchar("NodeType", 16).nullable()
val config = integer("Config") val config = integer("Config")
init {
uniqueIndex(parent, owner, name)
}
} }
class SchematicNode(id: EntityID<Int>) : IntEntity(id) { class SchematicNode(id: EntityID<Int>) : IntEntity(id) {
+2 -6
View File
@@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2026 SteamWar.de-Serverteam * Copyright (C) 2025 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@@ -28,13 +28,9 @@ import org.jetbrains.exposed.v1.dao.IntEntity
import org.jetbrains.exposed.v1.dao.IntEntityClass import org.jetbrains.exposed.v1.dao.IntEntityClass
object ScriptTable: IntIdTable("Script") { object ScriptTable: IntIdTable("Script") {
val userId = reference("UserId", SteamwarUserTable).index() val userId = reference("UserId", SteamwarUserTable)
val name = varchar("Name", 64) val name = varchar("Name", 64)
val code = text("Code") val code = text("Code")
init {
uniqueIndex(userId, name)
}
} }
class Script(id: EntityID<Int>) : IntEntity(id) { class Script(id: EntityID<Int>) : IntEntity(id) {
@@ -28,7 +28,7 @@ import org.jetbrains.exposed.v1.jdbc.insert
import java.sql.Timestamp import java.sql.Timestamp
object SessionTable: Table("Session") { object SessionTable: Table("Session") {
val userId = reference("UserId", SteamwarUserTable).index() val userId = reference("UserId", SteamwarUserTable)
val startTime = timestamp("StartTime") val startTime = timestamp("StartTime")
val endTime = timestamp("EndTime").defaultExpression(CurrentTimestamp) val endTime = timestamp("EndTime").defaultExpression(CurrentTimestamp)
} }
@@ -37,15 +37,15 @@ import javax.crypto.SecretKeyFactory
import javax.crypto.spec.PBEKeySpec import javax.crypto.spec.PBEKeySpec
object SteamwarUserTable : IntIdTable("UserData", "id") { object SteamwarUserTable : IntIdTable("UserData", "id") {
val uuid = varchar("UUID", 36).uniqueIndex() val uuid = varchar("UUID", 36)
val username = varchar("UserName", 32).index() val username = varchar("UserName", 32)
val team = reference("Team", TeamTable).index() val team = reference("Team", TeamTable)
val leader = bool("Leader") val leader = bool("Leader")
val locale = varchar("Locale", 16).nullable() val locale = varchar("Locale", 16).nullable()
val manualLocale = bool("ManualLocale") val manualLocale = bool("ManualLocale")
val bedrock = bool("Bedrock") val bedrock = bool("Bedrock")
val password = text("Password").nullable() val password = text("Password").nullable()
val discordId = long("DiscordId").nullable().uniqueIndex() val discordId = long("DiscordId").nullable()
} }
class SteamwarUser(id: EntityID<Int>): IntEntity(id) { class SteamwarUser(id: EntityID<Int>): IntEntity(id) {
+2 -2
View File
@@ -28,9 +28,9 @@ import org.jetbrains.exposed.v1.dao.IntEntityClass
import org.jetbrains.exposed.v1.jdbc.select import org.jetbrains.exposed.v1.jdbc.select
object TeamTable : IntIdTable("Team", "TeamID") { object TeamTable : IntIdTable("Team", "TeamID") {
val kuerzel = varchar("TeamKuerzel", 10).index() val kuerzel = varchar("TeamKuerzel", 10)
val color = char("TeamColor", 1).default("8") val color = char("TeamColor", 1).default("8")
val name = varchar("TeamName", 16).index() val name = varchar("TeamName", 16)
val deleted = bool("TeamDeleted").default(false) val deleted = bool("TeamDeleted").default(false)
} }
@@ -32,8 +32,8 @@ import org.jetbrains.exposed.v1.jdbc.deleteWhere
import org.jetbrains.exposed.v1.jdbc.insertIgnore import org.jetbrains.exposed.v1.jdbc.insertIgnore
object TeamTeilnahmeTable : CompositeIdTable("TeamTeilnahme") { object TeamTeilnahmeTable : CompositeIdTable("TeamTeilnahme") {
val teamId = reference("teamId", TeamTable).index() val teamId = reference("teamId", TeamTable)
val eventId = reference("eventId", EventTable).index() val eventId = reference("eventId", EventTable)
val placement = integer("Placement").nullable() val placement = integer("Placement").nullable()
override val primaryKey = PrimaryKey(teamId, eventId) override val primaryKey = PrimaryKey(teamId, eventId)
+3 -3
View File
@@ -33,10 +33,10 @@ import java.sql.Timestamp
import java.util.* import java.util.*
object TokenTable: IntIdTable("Token") { object TokenTable: IntIdTable("Token") {
val name = varchar("Name", 64).uniqueIndex() val name = varchar("Name", 64)
val owner = reference("Owner", SteamwarUserTable).index() val owner = reference("Owner", SteamwarUserTable)
val created = timestamp("Created").defaultExpression(CurrentTimestamp) val created = timestamp("Created").defaultExpression(CurrentTimestamp)
val hash = varchar("Hash", 88).uniqueIndex() val hash = varchar("Hash", 88)
} }
class Token(id: EntityID<Int>): IntEntity(id) { class Token(id: EntityID<Int>): IntEntity(id) {
@@ -28,7 +28,7 @@ import org.jetbrains.exposed.v1.jdbc.insert
import org.jetbrains.exposed.v1.jdbc.selectAll import org.jetbrains.exposed.v1.jdbc.selectAll
object UserPermTable: Table("UserPerm") { object UserPermTable: Table("UserPerm") {
val user = reference("User", SteamwarUserTable.id).index() val user = reference("User", SteamwarUserTable.id)
val perm = enumerationByName("Perm", 32, UserPerm::class) val perm = enumerationByName("Perm", 32, UserPerm::class)
override val primaryKey = PrimaryKey(user, perm) override val primaryKey = PrimaryKey(user, perm)
@@ -67,7 +67,7 @@ object KotlinDatabase {
} }
} }
fun <T> useDb(statement: JdbcTransaction.() -> T): T { fun <T: Any?> useDb(statement: JdbcTransaction.() -> T): T {
KotlinDatabase.ensureConnected() KotlinDatabase.ensureConnected()
return TransactionManager.currentOrNull()?.statement() ?: transaction(KotlinDatabase.db) { return TransactionManager.currentOrNull()?.statement() ?: transaction(KotlinDatabase.db) {
statement() statement()
@@ -181,12 +181,7 @@ public class Permanent implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onExplosion(EntityExplodeEvent e) { public void onExplosion(EntityExplodeEvent e) {
if (!(e.getEntity() instanceof TNTPrimed)) { if (!(e.getEntity() instanceof TNTPrimed)) return;
if (Config.GameModeConfig.Schematic.Type.toDB().equals("wargearseason26")) {
e.blockList().clear();
}
return;
}
if (!Config.GameModeConfig.Arena.WaterDamage) return; if (!Config.GameModeConfig.Arena.WaterDamage) return;
e.blockList().removeIf(block -> { e.blockList().removeIf(block -> {
if(block.getType() == Material.TNT) { if(block.getType() == Material.TNT) {
+3 -2
View File
@@ -67,9 +67,10 @@ tasks.register<FightServer>("WarGear21") {
description = "Run a WarGear 1.21 Fight Server" description = "Run a WarGear 1.21 Fight Server"
dependsOn(":SpigotCore:shadowJar") dependsOn(":SpigotCore:shadowJar")
dependsOn(":FightSystem:shadowJar") dependsOn(":FightSystem:shadowJar")
dependsOn(":KotlinCore:shadowJar")
template = "WarGear21" template = "WarGear21"
worldName = "arenas/Pentraki" worldName = "arenas/Colosso"
config = "WarGear20.yml" config = "WarGear21.yml"
jar = "/jars/paper-1.21.6.jar" jar = "/jars/paper-1.21.6.jar"
} }
@@ -0,0 +1,32 @@
/*
* 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.
*
* 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/>.
*/
plugins {
steamwar.kotlin
alias(libs.plugins.shadow)
}
java {
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
}
dependencies {
implementation(project(":ModularFightSystem:GameCore"))
}
@@ -0,0 +1,29 @@
/*
* 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.
*
* 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 de.steamwar.fightsystem.state.FightState
class FightSystem {
}
fun test() {
FightState.register()
}
@@ -0,0 +1,54 @@
/*
* 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.
*
* 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.state
import de.steamwar.modularfightsystem.complement
import de.steamwar.modularfightsystem.enumSetAll
import de.steamwar.modularfightsystem.enumSetOf
import de.steamwar.modularfightsystem.state.FightStateMachine
enum class FightState {
PRE_LEADER_SETUP,
PRE_SCHEM_SETUP,
POST_SCHEM_SETUP,
PRE_RUNNING,
RUNNING,
SPECTATE;
companion object : FightStateMachine<FightState>(PRE_LEADER_SETUP) {
val All = enumSetAll<FightState>()
val PreLeaderSetup = enumSetOf(PRE_LEADER_SETUP)
val PreSchemSetup = enumSetOf(PRE_SCHEM_SETUP)
val PostSchemSetup = enumSetOf(POST_SCHEM_SETUP)
val PreRunning = enumSetOf(PRE_RUNNING)
val Running = enumSetOf(RUNNING)
val Spectate = enumSetOf(SPECTATE)
val Setup = enumSetOf(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, POST_SCHEM_SETUP)
val Ingame = enumSetOf(PRE_RUNNING, RUNNING)
val TeamFix = enumSetOf(PRE_RUNNING, RUNNING, SPECTATE)
val Schem = enumSetOf(PRE_LEADER_SETUP, PRE_SCHEM_SETUP).complement()
val Recording = enumSetOf(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE).complement()
val AntiRunning = enumSetOf(RUNNING).complement()
val AntiIngame = enumSetOf(PRE_RUNNING, RUNNING).complement()
val AntiSpectate = enumSetOf(SPECTATE).complement()
}
}
@@ -0,0 +1,33 @@
/*
* 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.
*
* 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/>.
*/
plugins {
steamwar.kotlin
}
java {
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
}
dependencies {
compileOnly(libs.paperapi21)
compileOnly(libs.nms21)
compileOnly(project(":SpigotCore", "default"))
}
@@ -0,0 +1,54 @@
/*
* 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.
*
* 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.modularfightsystem
enum class ArenaMode {
NORMAL,
EVENT,
TEST,
CHECK,
PREPARE,
REPLAY;
companion object {
val All = enumSetAll<ArenaMode>()
val Normal = enumSetOf(NORMAL)
val Event = enumSetOf(EVENT)
val Test = enumSetOf(TEST)
val Check = enumSetOf(CHECK)
val Prepare = enumSetOf(PREPARE)
val Replay = enumSetOf(REPLAY)
val AntiReplay = Replay.complement()
val AntiTest = Test.complement()
val AntiEvent = Event.complement()
val AntiTestCheckPrepare = enumSetOf(TEST, CHECK, PREPARE).complement()
val AntiPrepare = Prepare.complement()
val VariableTeams = enumSetOf(EVENT, REPLAY, CHECK).complement()
val ManualTeams = enumSetOf(EVENT, REPLAY).complement()
val RankedEvent = enumSetOf(EVENT, REPLAY)
val Restartable = enumSetOf(NORMAL, TEST)
val NotRestartable = enumSetOf(EVENT, REPLAY)
val SoloLeader = enumSetOf(TEST, CHECK, PREPARE)
val NotOnBau = enumSetOf(TEST, CHECK, PREPARE, REPLAY).complement()
val SeriousFight = enumSetOf(TEST, CHECK, REPLAY).complement()
}
}
+29
View File
@@ -0,0 +1,29 @@
/*
* 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.
*
* 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.modularfightsystem
import de.steamwar.message.Message
import org.bukkit.plugin.Plugin
object Config {
lateinit var plugin: Plugin
val mode = ArenaMode.TEST
}
+33
View File
@@ -0,0 +1,33 @@
/*
* 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.
*
* 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.modularfightsystem
import java.util.Collections
import java.util.EnumSet
typealias KEnumSet<T> = Set<T>
inline fun <reified T> enumSetOf(): KEnumSet<T> where T : Enum<T> = Collections.unmodifiableSet(EnumSet.noneOf(T::class.java))
inline fun <reified T> enumSetAll(): KEnumSet<T> where T : Enum<T> = Collections.unmodifiableSet(EnumSet.allOf(T::class.java))
inline fun <reified T> enumSetOf(vararg elements: T): KEnumSet<T> where T : Enum<T> = Collections.unmodifiableSet(EnumSet.copyOf(elements.toSet()))
fun <T> KEnumSet<T>.complement(): KEnumSet<T> where T: Enum<T> = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.copyOf(this)))
@@ -0,0 +1,96 @@
/*
* 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.
*
* 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.modularfightsystem.countdown
import de.steamwar.modularfightsystem.Config
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.ComponentLike
import org.bukkit.Bukkit
import org.bukkit.Sound
import org.bukkit.entity.Player
import org.bukkit.scheduler.BukkitTask
abstract class Countdown(val totalTime: Int, val appendix: ComponentLike, val sound: Sound?, val level: Boolean) {
var time = totalTime
private var task: BukkitTask? = null
abstract fun countdownFinished()
fun enable() {
time = totalTime
task = Bukkit.getScheduler().runTaskTimer(Config.plugin, this::count, 0, 20)
countdowns.add(this)
show()
}
fun disable() {
if (task != null) {
task!!.cancel()
countdowns.remove(this)
task = null
}
}
private fun show() {
when(time) {
900, 600, 300, 180, 120 -> broadcast("COUNTDOWN_MINUTES", 60)
60, 30, 20, 15, 10, 5, 4, 3, 2 -> broadcast("COUNTDOWN_SECONDS", 1)
1 -> broadcast("COUNTDOWN_SECOND", 1)
0 -> {
playSound()
disable()
countdownFinished()
}
}
if (level) {
Bukkit.getOnlinePlayers().forEach { it.level = time }
}
}
private fun count() {
time--
show()
}
protected fun broadcast(message: String, divisor: Int) {
playSound()
Bukkit.getOnlinePlayers().forEach { sendCountdownMessage(it, message, totalTime / divisor, appendix) }
}
fun playSound() = sound?.let { Bukkit.getOnlinePlayers().forEach { it.playSound(it.location, sound, 100f, 1f) } }
fun sendCountdownMessage(p: Player, message: String, displayTime: Int, appendix: ComponentLike) =
p.sendMessage(Component.translatable(message, Component.text(displayTime), appendix))
companion object {
private val countdowns = mutableListOf<Countdown>()
fun skip() {
if (countdowns.isEmpty()) return
val smallestTime = countdowns.minOf { it.time }
countdowns.forEach { it.also { it.time -= smallestTime }.show() }
}
}
}
@@ -0,0 +1,23 @@
/*
* 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.
*
* 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.modularfightsystem.fight
class FightPlayer {
}
@@ -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.
*
* 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.modularfightsystem.fight
class FightTeam()
@@ -0,0 +1,46 @@
/*
* 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.
*
* 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.modularfightsystem.state
abstract class FightStateMachine<T: Enum<*>>(initialState: T) {
init {
instance = this
}
var state: T = initialState
set(value) {
field = value
stateDependents.forEach { dependent -> dependent.enabled = value in dependent.states }
}
private val stateDependents = mutableListOf<StateDependent>()
fun register(stateDependent: StateDependent) {
if (stateDependent.states.isEmpty() or !stateDependent.active) return
stateDependents.add(stateDependent)
stateDependent.enabled = state in stateDependent.states
}
companion object {
lateinit var instance: FightStateMachine<*>
private set
}
}
@@ -0,0 +1,35 @@
/*
* 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.
*
* 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.modularfightsystem.state
import de.steamwar.modularfightsystem.ArenaMode
import de.steamwar.modularfightsystem.Config
import de.steamwar.modularfightsystem.KEnumSet
class OneShotStateDependent(active: Boolean, states: KEnumSet<*>, val runnable: () -> Unit): StateDependent(active, states) {
constructor(modes: KEnumSet<ArenaMode>, states: KEnumSet<*>, runnable: () -> Unit) : this(Config.mode in modes, states, runnable)
init {
register()
}
override fun enable() = runnable()
override fun disable() = Unit
}
@@ -0,0 +1,41 @@
/*
* 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.
*
* 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.modularfightsystem.state
import de.steamwar.modularfightsystem.ArenaMode
import de.steamwar.modularfightsystem.Config
import de.steamwar.modularfightsystem.KEnumSet
abstract class StateDependent(val active: Boolean, val states: KEnumSet<*>) {
constructor(modes: KEnumSet<ArenaMode>, states: KEnumSet<*>) : this(Config.mode in modes, states)
var enabled = false
set(value) {
if (value != field) if (value) enable() else disable()
field = value
}
fun register() {
FightStateMachine.instance.register(this)
}
abstract fun enable()
abstract fun disable()
}
@@ -0,0 +1,33 @@
/*
* 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.
*
* 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.modularfightsystem.state
import de.steamwar.command.SWCommand
import de.steamwar.modularfightsystem.ArenaMode
import de.steamwar.modularfightsystem.KEnumSet
class StateDependentCommand(mode: KEnumSet<ArenaMode>, states: KEnumSet<*>, val command: SWCommand): StateDependent(mode, states) {
init {
register()
}
override fun enable() = command.register()
override fun disable() = command.unregister()
}
@@ -0,0 +1,45 @@
/*
* 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.
*
* 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.modularfightsystem.state
import de.steamwar.modularfightsystem.ArenaMode
import de.steamwar.modularfightsystem.Config
import de.steamwar.modularfightsystem.KEnumSet
import org.bukkit.Bukkit
import org.bukkit.scheduler.BukkitTask
class StateDependentTask(active: Boolean, states: KEnumSet<*>, val runnable: () -> Unit, val delay: Long, val period: Long): StateDependent(active, states) {
constructor(modes: KEnumSet<ArenaMode>, states: KEnumSet<*>, runnable: () -> Unit, delay: Long, period: Long) : this(
Config.mode in modes, states, runnable, delay, period)
init {
register()
}
var task: BukkitTask? = null
override fun enable() {
task = Bukkit.getScheduler().runTaskTimer(Config.plugin, runnable, delay, period)
}
override fun disable() {
task?.cancel()
}
}
+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.
*
* 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/>.
*/
plugins {
`java-library`
}
+2 -1
View File
@@ -18,7 +18,7 @@
*/ */
plugins { plugins {
steamwar.java steamwar.kotlin
} }
dependencies { dependencies {
@@ -29,4 +29,5 @@ dependencies {
compileOnly(libs.nms14) compileOnly(libs.nms14)
compileOnly(libs.worldedit15) compileOnly(libs.worldedit15)
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.2.21")
} }
@@ -316,18 +316,8 @@ public class CheckCommand extends SWCommand {
SchematicNode node = SchematicNode.createSchematic(-1, name, teamFolder.getNodeId()); SchematicNode node = SchematicNode.createSchematic(-1, name, teamFolder.getNodeId());
NodeData.saveFromStream(node, data.schemData(false), data.getNodeFormat()); NodeData.saveFromStream(node, data.schemData(false), data.getNodeFormat());
// Accept the team folder schematic and set other to Normal as well as adding the original owner on the schematic // Accept the team folder schematic and set other to Normal
node.setSchemtype(GameModeConfig.getBySchematicType(schematic.getSchemtype()).Schematic.Type); node.setSchemtype(GameModeConfig.getBySchematicType(schematic.getSchemtype()).Schematic.Type);
NodeMember.createNodeMember(node.getNodeId(), schematic.getOwner());
// Remove any added players from the schematic in the folder
for (SchematicNode schematicNode : SchematicNode.getSchematicNodeInNode(teamFolder.getNodeId())) {
if (schematicNode.getNodeId() == node.getNodeId()) continue;
for (NodeMember nodeMember : NodeMember.getNodeMembers(schematicNode.getNodeId())) {
NodeMember.createNodeMember(node.getNodeId(), nodeMember.getMember());
nodeMember.delete();
}
}
// Conclude by setting send in schematic to normal and broadcast // Conclude by setting send in schematic to normal and broadcast
concludeCheckSession("freigegeben", SchematicType.Normal, () -> { concludeCheckSession("freigegeben", SchematicType.Normal, () -> {
@@ -50,7 +50,7 @@ public class WhoisCommand extends SWCommand {
@Register(description = "WHOIS_USAGE") @Register(description = "WHOIS_USAGE")
public void whois(Chatter sender, long id, WhoisParameterTypes... parameters) { public void whois(Chatter sender, long id, WhoisParameterTypes... parameters) {
if(!sender.user().hasPerm(UserPerm.ADMINISTRATION) && !sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) { if(!sender.user().hasPerm(UserPerm.ADMINISTRATION)) {
sender.system("UNKNOWN_PLAYER"); sender.system("UNKNOWN_PLAYER");
return; return;
} }
@@ -26,7 +26,6 @@ import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.listeners.ChannelListener; import de.steamwar.velocitycore.discord.listeners.ChannelListener;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.Webhook; import net.dv8tion.jda.api.entities.Webhook;
import net.dv8tion.jda.api.entities.WebhookClient; import net.dv8tion.jda.api.entities.WebhookClient;
@@ -105,16 +104,10 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
return; return;
} }
String avatarUrl = null; String avatarUrl;
if (user.getDiscordId() != null) { if (user.getDiscordId() != null) {
Member member = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()) avatarUrl = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()).complete().getEffectiveAvatarUrl();
.onErrorMap(throwable -> null) } else {
.complete();
if (member != null) {
avatarUrl = member.getEffectiveAvatarUrl();
}
}
if (avatarUrl == null) {
avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatarUrl(); avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatarUrl();
} }
+6 -2
View File
@@ -183,8 +183,6 @@ include(
include("CommandFramework") include("CommandFramework")
include("CLI")
include( include(
"CommonCore", "CommonCore",
"CommonCore:Data", "CommonCore:Data",
@@ -259,3 +257,9 @@ include(
include("TNTLeague") include("TNTLeague")
include("WebsiteBackend") include("WebsiteBackend")
include(
"ModularFightSystem",
"ModularFightSystem:GameCore",
"ModularFightSystem:FightSystem"
)
-2
View File
@@ -33,6 +33,4 @@ artifacts:
"/jars/website-api.jar": "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "/jars/website-api.jar": "WebsiteBackend/build/libs/WebsiteBackend-all.jar"
release: release:
- "rm -rf /jars/sw"
- "unzip -o CLI/build/distributions/sw.zip -d /jars"
- "sudo systemctl restart api.service" - "sudo systemctl restart api.service"