diff --git a/.gitea/ISSUE_TEMPLATE/bug-report.yaml b/.gitea/ISSUE_TEMPLATE/bug-report.yaml new file mode 100644 index 00000000..7ce1c896 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/bug-report.yaml @@ -0,0 +1,60 @@ +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. \ No newline at end of file diff --git a/.gitea/ISSUE_TEMPLATE/config.yml b/.gitea/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..a49eab2f --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true \ No newline at end of file diff --git a/.gitea/ISSUE_TEMPLATE/feature-request.yaml b/.gitea/ISSUE_TEMPLATE/feature-request.yaml new file mode 100644 index 00000000..fb8c2a5f --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/feature-request.yaml @@ -0,0 +1,17 @@ +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. \ No newline at end of file diff --git a/.gitea/workflows/backport-commoncore.yml b/.gitea/workflows/backport-commoncore.yml new file mode 100644 index 00000000..852b9d23 --- /dev/null +++ b/.gitea/workflows/backport-commoncore.yml @@ -0,0 +1,193 @@ +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<> "$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 diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 00000000..2a9d67db --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,145 @@ +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 "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'" + ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "rm -f '$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" diff --git a/.gitea/workflows/pull-request-build.yml b/.gitea/workflows/pull-request-build.yml new file mode 100644 index 00000000..236da389 --- /dev/null +++ b/.gitea/workflows/pull-request-build.yml @@ -0,0 +1,76 @@ +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" diff --git a/.gitignore b/.gitignore index 803a132b..dd7af7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ lib /WebsiteBackend/logs /WebsiteBackend/skins /WebsiteBackend/config.json -/WebsiteBackend/sessions \ No newline at end of file +/WebsiteBackend/sessions diff --git a/BauSystem/BauSystem_15/build.gradle.kts b/BauSystem/BauSystem_15/build.gradle.kts deleted file mode 100644 index 054e4ab9..00000000 --- a/BauSystem/BauSystem_15/build.gradle.kts +++ /dev/null @@ -1,35 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly(project(":BauSystem:BauSystem_Main", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.nms15) - compileOnly(libs.worldedit15) -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java deleted file mode 100644 index 13b3932d..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java +++ /dev/null @@ -1,239 +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 . - */ - -package de.steamwar.bausystem.utils; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.Mask2D; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.region.Point; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Waterlogged; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import javax.annotation.Nullable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiPredicate; -import java.util.logging.Level; - -public class FlatteningWrapper15 implements FlatteningWrapper { - - @Override - public boolean isNoBook(ItemStack item) { - return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK; - } - - private static final Set unpushable = new HashSet<>(Arrays.asList(Material.BARRIER, Material.BEACON, Material.COMMAND_BLOCK, Material.CHAIN_COMMAND_BLOCK, Material.REPEATING_COMMAND_BLOCK, Material.ENCHANTING_TABLE, Material.END_GATEWAY, Material.END_PORTAL, Material.ENDER_CHEST, Material.GRINDSTONE, Material.JIGSAW, Material.JUKEBOX, Material.NETHER_PORTAL, Material.OBSIDIAN, Material.STRUCTURE_VOID, Material.BARREL, Material.BEEHIVE, Material.BEE_NEST, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CHEST, Material.DAYLIGHT_DETECTOR, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.LECTERN, Material.SMOKER, Material.TRAPPED_CHEST)); - - // TODO: FLOWER - private static final Set breaking = new HashSet<>(Arrays.asList(Material.BAMBOO, Material.CACTUS, Material.CAKE, Material.CARVED_PUMPKIN, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.COBWEB, Material.COCOA, Material.DRAGON_EGG, Material.FIRE, Material.FLOWER_POT, Material.JACK_O_LANTERN, Material.LADDER, Material.LAVA, Material.LAVA, Material.LEVER, Material.LILY_PAD, Material.MELON, Material.NETHER_WART, Material.PUMPKIN, Material.COMPARATOR, Material.REDSTONE_WIRE, Material.REPEATER, Material.TORCH, Material.STRUCTURE_VOID, Material.SCAFFOLDING, Material.SEA_PICKLE, Material.SNOW, Material.SUGAR_CANE, Material.TORCH, Material.TRIPWIRE, Material.TRIPWIRE_HOOK, Material.TURTLE_EGG, Material.VINE, Material.WATER, Material.WHEAT)); - - @Override - public boolean isUnpusheable(Material material) { - if (unpushable.contains(material)) { - return true; - } - String name = material.name(); - return name.contains("BANNER") || name.contains("SIGN"); - } - - @Override - public boolean isBreakingOnPush(Material material) { - if (breaking.contains(material)) { - return true; - } - String name = material.name(); - return name.contains("BED") || name.contains("BUTTON") || name.contains("CARPET") || (name.contains("DOOR") && !name.contains("TRAPDOOR")) || name.contains("HEAD") || name.contains("LEAVES") || name.contains("MUSHROOM") || name.contains("PRESSURE_PLATE") || name.contains("SHULKER_BOX"); - } - - @Override - public boolean isWorldEditCommand(String command) { - if (command.startsWith("/")) { - command = command.replaceFirst("/", ""); - } - command = command.toLowerCase(); - return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command); - } - - private static final WorldEditPlugin WORLDEDIT_PLUGIN = Objects.requireNonNull((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); - private static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); - - @Override - public void setSelection(Player p, Point minPoint, Point maxPoint) { - WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); - } - - @Override - public Clipboard loadSchematic(File file) { - Clipboard clipboard; - try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { - clipboard = reader.read(); - } catch (NullPointerException | IOException e) { - throw new SecurityException("Bausystem schematic not found", e); - } - return clipboard; - } - - @Override - public EditSession paste(PasteBuilder pasteBuilder) { - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - Clipboard clipboard = pasteBuilder.getClipboard(); - - if (!pasteBuilder.getMappers().isEmpty()) { - BlockVector3 minimum = clipboard.getRegion().getMinimumPoint(); - for (int x = 0; x < clipboard.getDimensions().getX(); x++) { - for (int y = 0; y < clipboard.getDimensions().getY(); y++) { - for (int z = 0; z < clipboard.getDimensions().getZ(); z++) { - BlockVector3 pos = minimum.add(x, y, z); - pasteBuilder.getMappers().forEach(mapper -> mapper.accept(clipboard, pos)); - } - } - } - } - - AtomicReference pastePoint = new AtomicReference<>(); - if (!pasteBuilder.getPredicates().isEmpty()) { - e.setMask(new Mask() { - @Override - public boolean test(BlockVector3 blockVector3) { - BaseBlock block = clipboard.getFullBlock(blockVector3.subtract(pastePoint.get()).add(clipboard.getRegion().getMinimumPoint())); - String blockName = block.getBlockType().toString().toLowerCase(); - for (BiPredicate predicate : pasteBuilder.getPredicates()) { - if (!predicate.test(block, blockName)) return false; - } - return true; - } - - public Mask copy() { - return this; - } - - @Nullable - @Override - public Mask2D toMask2D() { - return null; - } - }); - } - - ClipboardHolder ch = new ClipboardHolder(clipboard); - BlockVector3 dimensions = clipboard.getDimensions(); - BlockVector3 v = BlockVector3.at(pasteBuilder.getPastPoint().getX(), pasteBuilder.getPastPoint().getY(), pasteBuilder.getPastPoint().getZ()); - BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - if (pasteBuilder.isRotate()) { - ch.setTransform(new AffineTransform().rotateY(180)); - v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(0, 0, 1); - } else { - v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset); - } - pastePoint.set(v); - - if (pasteBuilder.isReset()) { - e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); - if (pasteBuilder.getWaterLevel() != 0) { - e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3().withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock()); - } - } - Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build()); - return e; - } catch (WorldEditException e) { - throw new SecurityException(e.getMessage(), e); - } - } - - @Override - public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) { - BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0)); - CuboidRegion region = new CuboidRegion(bukkitWorld, minPoint.toBlockVector3(), maxPoint.toBlockVector3()); - BlockArrayClipboard clipboard = new BlockArrayClipboard(region); - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) { - ForwardExtentCopy copy = new ForwardExtentCopy( - e, region, clipboard, region.getMinimumPoint() - ); - - copy.setCopyingEntities(false); - copy.setCopyingBiomes(false); - - Operations.complete(copy); - clipboard.setOrigin(copyPoint.toBlockVector3()); - return clipboard; - } catch (WorldEditException e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); - return null; - } - } - - @Override - public boolean backup(Point minPoint, Point maxPoint, File file) { - Clipboard clipboard = copy(minPoint, maxPoint, minPoint); - try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) { - writer.write(clipboard); - return true; - } catch (IOException e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); - return false; - } - } - - @Override - public boolean inWater(org.bukkit.World world, Vector tntPosition) { - Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()); - if (block.getType() == Material.WATER) - return true; - - BlockData data = block.getBlockData(); - if (!(data instanceof Waterlogged)) - return false; - - return ((Waterlogged) data).isWaterlogged(); - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java deleted file mode 100644 index 3faea278..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ /dev/null @@ -1,129 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.server.v1_15_R1.*; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -public class NMSWrapper15 implements NMSWrapper { - - private static final Reflection.Field playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); - - @Override - @SuppressWarnings("deprecation") - public void setInternalGameMode(Player player, GameMode gameMode) { - playerGameMode.set(((CraftPlayer) player).getHandle().playerInteractManager, EnumGamemode.getById(gameMode.getValue())); - } - - @Override - public void setSlotToItemStack(Player player, Object o) { - PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o; - int index = packetPlayInSetCreativeSlot.b(); - if (index >= 36 && index <= 44) { - index -= 36; - } else if (index > 44) { - index -= 5; - } else if (index <= 8) { - index = index - 8 + 36; - } - player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItemStack())); - if (index < 9) player.getInventory().setHeldItemSlot(index); - player.updateInventory(); - } - - private static final Reflection.Field gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0); - - @Override - public void setGameStateChangeReason(Object packet) { - gameStateChangeReason.set(packet, 3); - } - - @Override - public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().abilities.mayBuild = true; - ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; - } - - @Override - public Material pathMaterial() { - return Material.GRASS_PATH; - } - - private static final int threshold = 2048; - - @Override - public boolean checkItemStack(ItemStack item) { - net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); - NBTTagCompound tag = nmsItem.getTag(); - if (tag != null && tag.hasKey("BlockEntityTag")) { - NBTTagCompound blockTag = tag.getCompound("BlockEntityTag"); - if (blockTag.hasKey("Items")) { - return drillDown(blockTag.getList("Items", 10), 0, 0) > threshold; - } - } - - return false; - } - - private int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start + threshold; - int invalid = start; - for (NBTBase nbtBase : items) { - if (!(nbtBase instanceof NBTTagCompound)) - continue; - NBTTagCompound slot = (NBTTagCompound) nbtBase; - if (slot.hasKey("tag")) { - invalid += slot.getByte("Count"); - NBTTagCompound iTag = slot.getCompound("tag"); - if (iTag.hasKey("BlockEntityTag")) { - NBTTagCompound blockTag = iTag.getCompound("BlockEntityTag"); - if (blockTag.hasKey("Items")) { - invalid = drillDown(blockTag.getList("Items", 10), layer + 1, invalid); - } - } - } - if (invalid > threshold) - break; - } - return invalid; - } - - private final Class explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); - private final Reflection.Field a = Reflection.getField(explosionPacket, double.class, 0); - private final Reflection.Field b = Reflection.getField(explosionPacket, double.class, 1); - private final Reflection.Field c = Reflection.getField(explosionPacket, double.class, 2); - private final Reflection.Field d = Reflection.getField(explosionPacket, float.class, 0); - private final Reflection.Field e = Reflection.getField(explosionPacket, List.class, 0); - - @Override - public Object resetExplosionKnockback(Object packet) { - PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; - return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), Vec3D.a); - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlaceItemWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlaceItemWrapper15.java deleted file mode 100644 index 05164673..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlaceItemWrapper15.java +++ /dev/null @@ -1,43 +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 . - */ - -package de.steamwar.bausystem.utils; - -import org.bukkit.Material; - -public class PlaceItemWrapper15 implements PlaceItemWrapper { - - public PlaceItemWrapper15() { - for (Material material : Material.values()) { - if (!material.isBlock()) continue; - if (material.isLegacy()) continue; - - String nonWall = material.name().replace("_WALL_", "").replace("WALL_", "").replace("_WALL", ""); - try { - Material nonWallMaterial = Material.valueOf(nonWall); - if (nonWallMaterial != material && nonWallMaterial.isItem() && !nonWallMaterial.isBlock()) { - BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.put(nonWallMaterial, material); - } - } catch (Exception e) { - // Ignore - } - } - ITEM_MATERIAL_TO_BLOCK_MATERIAL.put(Material.REDSTONE, Material.REDSTONE_WIRE); - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java deleted file mode 100644 index 17f67550..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import net.minecraft.server.v1_15_R1.EntityPlayer; -import net.minecraft.server.v1_15_R1.PacketPlayInFlying; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class PlayerMovementWrapper15 implements PlayerMovementWrapper { - - @Override - public void setPosition(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) { - entityPlayer.e(packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0)); - } else { - entityPlayer.setLocation(packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0), packetPlayInFlying.a(0F), packetPlayInFlying.b(0F)); - } - } - - @Override - public Object convertToOut(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0), - Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F), - Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F)); - return packet; - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickListener15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickListener15.java deleted file mode 100644 index 57b14b19..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickListener15.java +++ /dev/null @@ -1,23 +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 . - */ - -package de.steamwar.bausystem.utils; - -public class TickListener15 implements TickListener { -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java deleted file mode 100644 index 808e63cc..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java +++ /dev/null @@ -1,140 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.bossbar.BossBarService; -import de.steamwar.bausystem.utils.tps.TPSFreezeUtils; -import de.steamwar.bausystem.utils.tps.TPSLimitUtils; -import de.steamwar.core.TPSWarpUtils; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class TickManager15 implements TickManager, Listener { - - private static float currentTPSLimit = 20; - private boolean currentlyStepping = false; - private float currentLimit; - private int stepsTotal; - private int stepsLeft; - - @Override - public boolean canFreeze() { - return TPSFreezeUtils.isCanFreeze(); - } - - @Override - public void setTickRate(float tickRate) { - if (currentlyStepping) { - currentlyStepping = false; - Bukkit.getOnlinePlayers().forEach(player -> { - BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep"); - }); - } - TPSWarpUtils.warp(tickRate); - if (currentTPSLimit == 0 && tickRate != 0) { - TPSFreezeUtils.unfreeze(); - } - currentTPSLimit = tickRate; - if (tickRate == 0) { - TPSLimitUtils.unlimit(); - TPSFreezeUtils.freeze(); - } else if (tickRate < 20.0) { - TPSLimitUtils.limit(tickRate); - } else if (tickRate >= 20) { - TPSLimitUtils.unlimit(); - } - } - - @Override - public boolean isFrozen() { - return TPSFreezeUtils.frozen(); - } - - @Override - public void setFreeze(boolean freeze) { - if (freeze) { - setTickRate(0); - } - } - - @Override - public void stepTicks(int ticks) { - currentLimit = 0; - setTickRate(20); - stepsLeft = ticks; - stepsTotal = ticks; - currentlyStepping = true; - } - - @Override - public void sprintTicks(int ticks) { - currentLimit = currentTPSLimit; - setTickRate(4000); - stepsLeft = ticks; - stepsTotal = ticks; - currentlyStepping = true; - } - - @Override - public boolean isSprinting() { - return currentlyStepping && currentTPSLimit > 20; - } - - @Override - public boolean isStepping() { - return currentlyStepping && currentTPSLimit <= 20; - } - - @Override - public float getTickRate() { - return currentTPSLimit; - } - - @Override - public void setBlockTpsPacket(boolean block) { - - } - - @Override - public long getTotalTicks() { - return stepsTotal; - } - - @Override - public long getDoneTicks() { - return stepsTotal - stepsLeft; - } - - @Override - public long getRemainingTicks() { - return stepsLeft; - } - - @EventHandler - public void onTickEnd(TickEndEvent event) { - if (!currentlyStepping) return; - stepsLeft--; - if (stepsLeft <= 0) { - setTickRate(currentLimit); - } - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/PacketCache.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/PacketCache.java deleted file mode 100644 index 7cabdab6..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/PacketCache.java +++ /dev/null @@ -1,131 +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 . - */ - -package de.steamwar.bausystem.utils.tps; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.ChatWrapper; -import de.steamwar.core.Core; -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -@UtilityClass -class PacketCache { - - private static List packets = new ArrayList<>(); - private static Set entities = new HashSet<>(); - private static BukkitTask task = null; - - private static Class vec3dClass = Reflection.getClass("net.minecraft.world.phys.Vec3"); - private static Reflection.Field zeroVec3d = (Reflection.Field) Reflection.getField(vec3dClass, vec3dClass, 0); - private static Object ZERO_VEC3D = zeroVec3d.get(null); - private static Class velocityPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket"); - private static Reflection.Constructor velocityPacketConstructor = Reflection.getConstructor(velocityPacketClass, int.class, vec3dClass); - - private static Class teleportPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket"); - private static Class entityClass = Reflection.getClass("net.minecraft.world.entity.Entity"); - private static Reflection.Constructor teleportPacketConstructor = Reflection.getConstructor(teleportPacketClass, entityClass); - - private static Class craftEntityClass = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"); - private static Reflection.Method getHandle = Reflection.getMethod(craftEntityClass, "getHandle"); - - private static Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5, Boolean.class); - private static Object fuseDataWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class); - - public void continuousSendCache() { - if (task != null) { - return; - } - - createPackets(); - task = new BukkitRunnable() { - @Override - public void run() { - _sendCache(); - } - }.runTaskTimer(Core.getInstance(), 1, 1); - } - - public void sendCache() { - if (task != null) { - task.cancel(); - task = null; - } - _sendCache(); - } - - private void _sendCache() { - createPackets(); - for (Player player : Bukkit.getOnlinePlayers()) { - for (Object packet : packets) { - TinyProtocol.instance.sendPacket(player, packet); - } - } - } - - public void clearCache() { - packets.clear(); - entities.clear(); - - if (task != null) { - task.cancel(); - task = null; - } - } - - private void createPackets() { - if (entities.stream().anyMatch(Entity::isDead)) { - entities.clear(); - packets.clear(); - } - List entities = Bukkit.getWorlds().get(0).getEntities().stream() - .filter(e -> !(e instanceof Player)) - .filter(e -> PacketCache.entities.add(e)) - .collect(Collectors.toList()); - - for (Entity entity : entities) { - packets.add(teleportPacketConstructor.invoke(getHandle.invoke(entity))); - } - for (Entity entity : entities) { - packets.add(velocityPacketConstructor.invoke(entity.getEntityId(), ZERO_VEC3D)); - } - for (Entity entity : entities) { - packets.add(ChatWrapper.impl.getDataWatcherPacket(entity.getEntityId(), noGravityDataWatcher, true)); - } - for (Entity entity : entities) { - if (!(entity instanceof TNTPrimed)) continue; - TNTPrimed tnt = (TNTPrimed) entity; - int fuse = tnt.getFuseTicks(); - packets.add(ChatWrapper.impl.getDataWatcherPacket(entity.getEntityId(), fuseDataWatcher, fuse - (fuse % 5) + 1)); - } - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSFreezeUtils.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSFreezeUtils.java deleted file mode 100644 index 3dc04cc7..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSFreezeUtils.java +++ /dev/null @@ -1,76 +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 . - */ - -package de.steamwar.bausystem.utils.tps; - -import de.steamwar.Reflection; -import lombok.Getter; -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.World; - -@UtilityClass -public class TPSFreezeUtils { - - private static Reflection.Field fieldAccessor; - @Getter - private static final boolean canFreeze; - - private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", null); - - @Getter - private static boolean frozen = false; - - private static final World world = Bukkit.getWorlds().get(0); - - static { - Reflection.Field fieldAccessor; - try { - fieldAccessor = Reflection.getField(Reflection.getClass("net.minecraft.server.level.ServerLevel"), "freezed", boolean.class); - } catch (IllegalArgumentException e) { - fieldAccessor = null; - } - canFreeze = fieldAccessor != null; - TPSFreezeUtils.fieldAccessor = fieldAccessor; - } - - public void freeze() { - setFreeze(world, true); - } - - public void unfreeze() { - setFreeze(world, false); - } - - public boolean frozen() { - return canFreeze && frozen; - } - - private void setFreeze(World world, boolean state) { - if (canFreeze) { - fieldAccessor.set(getWorldHandle.invoke(world), state); - if (state) { - PacketCache.continuousSendCache(); - } else { - PacketCache.clearCache(); - } - frozen = state; - } - } -} diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSLimitUtils.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSLimitUtils.java deleted file mode 100644 index 31943d87..00000000 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/tps/TPSLimitUtils.java +++ /dev/null @@ -1,124 +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 . - */ - -package de.steamwar.bausystem.utils.tps; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.bausystem.utils.PlayerMovementWrapper; -import de.steamwar.core.Core; -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitTask; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.function.BiFunction; - -@UtilityClass -public class TPSLimitUtils { - - private static long currentTime = System.nanoTime(); - private static BukkitTask tpsLimiter = null; - private static Queue packetQueue = new ConcurrentLinkedQueue<>(); - - public void unlimit() { - if (tpsLimiter != null) tpsLimiter.cancel(); - tpsLimiter = null; - } - - public void limit(double tps) { - if (tpsLimiter != null) tpsLimiter.cancel(); - - double delay = 20 / tps; - int loops = (int) Math.ceil(delay); - long sleepDelay = (long) (50 * delay) / loops; - - tpsLimiter = Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { - PacketCache.sendCache(); - for (int i = 0; i < loops; i++) { - sleepUntilNextTick(sleepDelay); - PacketCache.sendCache(); - while (true) { - Runnable runnable = packetQueue.poll(); - if (runnable == null) break; - runnable.run(); - } - } - PacketCache.clearCache(); - }, 0, 1); - } - - private void sleepUntilNextTick(long neededDelta) { - long lastTime = currentTime; - currentTime = System.nanoTime(); - - long timeDelta = (currentTime - lastTime) / 1000000; - if (neededDelta - timeDelta < 0) return; - - try { - Thread.sleep(neededDelta - timeDelta); - currentTime = System.nanoTime(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - /* - static { - long timeInterval = 50; - final long[] lastTime = {System.currentTimeMillis()}; - final double[] tps = {20.0}; - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { - long currentTime = System.currentTimeMillis(); - if (currentTime > lastTime[0]) { - tps[0] = (double)timeInterval / (double)(currentTime - lastTime[0]) * 20.0; - } - - lastTime[0] = currentTime; - - Bukkit.getOnlinePlayers().forEach(player -> { - SWUtils.sendToActionbar(player, String.valueOf((int) (tps[0] * 10.0) / 10.0)); - }); - }, timeInterval / 50L, timeInterval / 50L); - } - */ - - private static final Class position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos"); - private static final Class positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot"); - static { - BiFunction positionSetter = (player, o) -> { - if (tpsLimiter != null) { - Object object = PlayerMovementWrapper.impl.convertToOut(player, o); - packetQueue.add(() -> { - PlayerMovementWrapper.impl.setPosition(player, o); - Bukkit.getOnlinePlayers().forEach(p -> { - if (p == player) return; - TinyProtocol.instance.sendPacket(p, object); - }); - }); - return null; - } - return o; - }; - TinyProtocol.instance.addFilter(position, positionSetter); - TinyProtocol.instance.addFilter(positionLook, positionSetter); - } -} diff --git a/BauSystem/BauSystem_18/build.gradle.kts b/BauSystem/BauSystem_18/build.gradle.kts deleted file mode 100644 index 8dcf6852..00000000 --- a/BauSystem/BauSystem_18/build.gradle.kts +++ /dev/null @@ -1,35 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly(project(":BauSystem:BauSystem_Main", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.spigotapi) - compileOnly(libs.nms18) -} diff --git a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java deleted file mode 100644 index 5d03b8fe..00000000 --- a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ /dev/null @@ -1,135 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.protocol.game.*; -import net.minecraft.server.level.PlayerInteractManager; -import net.minecraft.world.level.EnumGamemode; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -public class NMSWrapper18 implements NMSWrapper { - - private static final Reflection.Field playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); - - @Override - @SuppressWarnings("deprecation") - public void setInternalGameMode(Player player, GameMode gameMode) { - playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue())); - - } - - @Override - public void setSlotToItemStack(Player player, Object o) { - PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o; - int index = packetPlayInSetCreativeSlot.b(); - if (index >= 36 && index <= 44) { - index -= 36; - } else if (index > 44) { - index -= 5; - } else if (index <= 8) { - index = index - 8 + 36; - } - player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c())); - if (index < 9) player.getInventory().setHeldItemSlot(index); - player.updateInventory(); - } - - private static final Reflection.Field gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12); - - @Override - public void setGameStateChangeReason(Object packet) { - gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); - } - - @Override - public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fs().d = true; - ((CraftPlayer) player).getHandle().fs().e = true; - } - - @Override - public Material pathMaterial() { - return Material.DIRT_PATH; - } - - private static final int threshold = 2048; - - @Override - public boolean checkItemStack(ItemStack item) { - net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); - NBTTagCompound tag = nmsItem.t(); - if (tag != null && tag.e("BlockEntityTag")) { - NBTTagCompound blockTag = tag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - return drillDown(blockTag.c("Items", 10), 0, 0) > threshold; - } - } - - return false; - } - - private int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start + threshold; - int invalid = start; - for (NBTBase nbtBase : items) { - if (!(nbtBase instanceof NBTTagCompound)) - continue; - NBTTagCompound slot = (NBTTagCompound) nbtBase; - if (slot.e("tag")) { - invalid += slot.f("Count"); - NBTTagCompound iTag = slot.p("tag"); - if (iTag.e("BlockEntityTag")) { - NBTTagCompound blockTag = iTag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid); - } - } - } - if (invalid > threshold) - break; - } - return invalid; - } - - private final Class explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); - private final Reflection.Field a = Reflection.getField(explosionPacket, double.class, 0); - private final Reflection.Field b = Reflection.getField(explosionPacket, double.class, 1); - private final Reflection.Field c = Reflection.getField(explosionPacket, double.class, 2); - private final Reflection.Field d = Reflection.getField(explosionPacket, float.class, 0); - private final Reflection.Field e = Reflection.getField(explosionPacket, List.class, 0); - - @Override - public Object resetExplosionKnockback(Object packet) { - PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; - return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), null); - } -} diff --git a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java deleted file mode 100644 index 512da797..00000000 --- a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.PacketPlayInFlying; -import net.minecraft.server.level.EntityPlayer; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class PlayerMovementWrapper18 implements PlayerMovementWrapper { - - @Override - public void setPosition(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if (packetPlayInFlying.h) { - entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e); - } else { - entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - } - } - - @Override - public Object convertToOut(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, - packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, - packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); - return packet; - } -} diff --git a/BauSystem/BauSystem_19/build.gradle.kts b/BauSystem/BauSystem_19/build.gradle.kts deleted file mode 100644 index e6dcaf4f..00000000 --- a/BauSystem/BauSystem_19/build.gradle.kts +++ /dev/null @@ -1,37 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly(project(":BauSystem:BauSystem_Main", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.spigotapi) - compileOnly(libs.paperapi) - - compileOnly(libs.nms19) -} diff --git a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java deleted file mode 100644 index cf4c3fc2..00000000 --- a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java +++ /dev/null @@ -1,134 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.protocol.game.*; -import net.minecraft.server.level.PlayerInteractManager; -import net.minecraft.world.level.EnumGamemode; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -public class NMSWrapper19 implements NMSWrapper { - - private static final Reflection.Field playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); - - @Override - @SuppressWarnings("deprecation") - public void setInternalGameMode(Player player, GameMode gameMode) { - playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue())); - } - - @Override - public void setSlotToItemStack(Player player, Object o) { - PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o; - int index = packetPlayInSetCreativeSlot.b(); - if (index >= 36 && index <= 44) { - index -= 36; - } else if (index > 44) { - index -= 5; - } else if (index <= 8) { - index = index - 8 + 36; - } - player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c())); - if (index < 9) player.getInventory().setHeldItemSlot(index); - player.updateInventory(); - } - - private static final Reflection.Field gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12); - - @Override - public void setGameStateChangeReason(Object packet) { - gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); - } - - @Override - public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fF().d = true; - ((CraftPlayer) player).getHandle().fF().e = true; - } - - @Override - public Material pathMaterial() { - return Material.DIRT_PATH; - } - - private static final int threshold = 2048; - - @Override - public boolean checkItemStack(ItemStack item) { - net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); - NBTTagCompound tag = nmsItem.v(); - if (tag != null && tag.e("BlockEntityTag")) { - NBTTagCompound blockTag = tag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - return drillDown(blockTag.c("Items", 10), 0, 0) > threshold; - } - } - - return false; - } - - private int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start + threshold; - int invalid = start; - for (NBTBase nbtBase : items) { - if (!(nbtBase instanceof NBTTagCompound)) - continue; - NBTTagCompound slot = (NBTTagCompound) nbtBase; - if (slot.e("tag")) { - invalid += slot.f("Count"); - NBTTagCompound iTag = slot.p("tag"); - if (iTag.e("BlockEntityTag")) { - NBTTagCompound blockTag = iTag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid); - } - } - } - if (invalid > threshold) - break; - } - return invalid; - } - - private final Class explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); - private final Reflection.Field a = Reflection.getField(explosionPacket, double.class, 0); - private final Reflection.Field b = Reflection.getField(explosionPacket, double.class, 1); - private final Reflection.Field c = Reflection.getField(explosionPacket, double.class, 2); - private final Reflection.Field d = Reflection.getField(explosionPacket, float.class, 0); - private final Reflection.Field e = Reflection.getField(explosionPacket, List.class, 0); - - @Override - public Object resetExplosionKnockback(Object packet) { - PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; - return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), null); - } -} diff --git a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java deleted file mode 100644 index 89912e3c..00000000 --- a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.PacketPlayInFlying; -import net.minecraft.server.level.EntityPlayer; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class PlayerMovementWrapper19 implements PlayerMovementWrapper { - - @Override - public void setPosition(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if (packetPlayInFlying.h) { - entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e); - } else { - entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - } - } - - @Override - public Object convertToOut(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, - packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, - packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); - return packet; - } -} diff --git a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/TickListener19.java b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/TickListener19.java deleted file mode 100644 index ca3d478c..00000000 --- a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/TickListener19.java +++ /dev/null @@ -1,50 +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 . - */ - -package de.steamwar.bausystem.utils; - -import com.destroystokyo.paper.event.server.ServerTickEndEvent; -import com.destroystokyo.paper.event.server.ServerTickStartEvent; -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class TickListener19 implements TickListener, Listener { - - private boolean tickStartRan = false; - - public TickListener19() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - } - - @EventHandler - public void onServerTickStart(ServerTickStartEvent event) { - if (TickManager.impl.isFrozen()) return; - Bukkit.getPluginManager().callEvent(new TickStartEvent()); - tickStartRan = true; - } - - @EventHandler - public void onServerTickEnd(ServerTickEndEvent event) { - if (!tickStartRan) return; - Bukkit.getPluginManager().callEvent(new TickEndEvent()); - tickStartRan = false; - } -} diff --git a/BauSystem/BauSystem_20/build.gradle.kts b/BauSystem/BauSystem_20/build.gradle.kts deleted file mode 100644 index 3032f6ba..00000000 --- a/BauSystem/BauSystem_20/build.gradle.kts +++ /dev/null @@ -1,36 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly(project(":BauSystem:BauSystem_Main", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms20) -} diff --git a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/NMSWrapper20.java b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/NMSWrapper20.java deleted file mode 100644 index c7a1b363..00000000 --- a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/NMSWrapper20.java +++ /dev/null @@ -1,136 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot; -import net.minecraft.network.protocol.game.PacketPlayOutExplosion; -import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; -import net.minecraft.server.level.PlayerInteractManager; -import net.minecraft.world.level.EnumGamemode; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -public class NMSWrapper20 implements NMSWrapper { - - private static final Reflection.Field playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); - - @Override - @SuppressWarnings("deprecation") - public void setInternalGameMode(Player player, GameMode gameMode) { - playerGameMode.set(((CraftPlayer) player).getHandle().e, EnumGamemode.a(gameMode.getValue())); - } - - @Override - public void setSlotToItemStack(Player player, Object o) { - PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o; - int index = packetPlayInSetCreativeSlot.a(); - if (index >= 36 && index <= 44) { - index -= 36; - } else if (index > 44) { - index -= 5; - } else if (index <= 8) { - index = index - 8 + 36; - } - player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c())); - if (index < 9) player.getInventory().setHeldItemSlot(index); - player.updateInventory(); - } - - private static final Reflection.Field gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12); - - @Override - public void setGameStateChangeReason(Object packet) { - gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); - } - - @Override - public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fO().d = true; - ((CraftPlayer) player).getHandle().fO().e = true; - } - - @Override - public Material pathMaterial() { - return Material.DIRT_PATH; - } - - private static final int threshold = 2048; - - @Override - public boolean checkItemStack(ItemStack item) { - net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); - NBTTagCompound tag = nmsItem.v(); - if (tag != null && tag.e("BlockEntityTag")) { - NBTTagCompound blockTag = tag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - return drillDown(blockTag.c("Items", 10), 0, 0) > threshold; - } - } - - return false; - } - - private int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start + threshold; - int invalid = start; - for (NBTBase nbtBase : items) { - if (!(nbtBase instanceof NBTTagCompound)) - continue; - NBTTagCompound slot = (NBTTagCompound) nbtBase; - if (slot.e("tag")) { - invalid += slot.f("Count"); - NBTTagCompound iTag = slot.p("tag"); - if (iTag.e("BlockEntityTag")) { - NBTTagCompound blockTag = iTag.p("BlockEntityTag"); - if (blockTag.e("Items")) { - invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid); - } - } - } - if (invalid > threshold) - break; - } - return invalid; - } - - private final Class explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); - private final Reflection.Field a = Reflection.getField(explosionPacket, double.class, 0); - private final Reflection.Field b = Reflection.getField(explosionPacket, double.class, 1); - private final Reflection.Field c = Reflection.getField(explosionPacket, double.class, 2); - private final Reflection.Field d = Reflection.getField(explosionPacket, float.class, 0); - private final Reflection.Field e = Reflection.getField(explosionPacket, List.class, 0); - - @Override - public Object resetExplosionKnockback(Object packet) { - PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; - return new PacketPlayOutExplosion(a.get(packetPlayOutExplosion), b.get(packetPlayOutExplosion), c.get(packetPlayOutExplosion), d.get(packetPlayOutExplosion), e.get(packetPlayOutExplosion), null); - } -} diff --git a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlaceItemWrapper20.java b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlaceItemWrapper20.java deleted file mode 100644 index 407a7207..00000000 --- a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlaceItemWrapper20.java +++ /dev/null @@ -1,43 +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 . - */ - -package de.steamwar.bausystem.utils; - -import org.bukkit.Material; -import org.bukkit.block.data.BlockData; - -public class PlaceItemWrapper20 implements PlaceItemWrapper { - - public PlaceItemWrapper20() { - for (Material material : Material.values()) { - if (!material.isBlock()) continue; - if (material.isLegacy()) continue; - BlockData blockData = material.createBlockData(); - Material placementMaterial = blockData.getPlacementMaterial(); - if (material == placementMaterial) continue; - if (placementMaterial == Material.AIR) continue; - if (placementMaterial.isItem() && !placementMaterial.isBlock()) { - ITEM_MATERIAL_TO_BLOCK_MATERIAL.put(placementMaterial, material); - } - if (material.name().contains("WALL")) { - BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.put(placementMaterial, material); - } - } - } -} diff --git a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java deleted file mode 100644 index feec5e59..00000000 --- a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.PacketPlayInFlying; -import net.minecraft.server.level.EntityPlayer; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class PlayerMovementWrapper20 implements PlayerMovementWrapper { - - @Override - public void setPosition(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - if (packetPlayInFlying.h) { - entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e); - } else { - entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - } - } - - @Override - public Object convertToOut(Player player, Object object) { - PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, - packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, - packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); - return packet; - } -} diff --git a/BauSystem/BauSystem_21/build.gradle.kts b/BauSystem/BauSystem_21/build.gradle.kts deleted file mode 100644 index 8b40ae2d..00000000 --- a/BauSystem/BauSystem_21/build.gradle.kts +++ /dev/null @@ -1,36 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} - -dependencies { - compileOnly(project(":BauSystem:BauSystem_Main", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.paperapi21) - - compileOnly(libs.nms21) -} \ No newline at end of file diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java deleted file mode 100644 index 54651656..00000000 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java +++ /dev/null @@ -1,133 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.bausystem.features.util.NoClipCommand; -import io.papermc.paper.datacomponent.DataComponentTypes; -import io.papermc.paper.datacomponent.item.ItemContainerContents; -import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; -import net.minecraft.network.protocol.game.ClientboundExplodePacket; -import net.minecraft.network.protocol.game.ClientboundGameEventPacket; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.level.ServerPlayerGameMode; -import net.minecraft.world.entity.player.Abilities; -import net.minecraft.world.level.GameType; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; -import java.util.Optional; - -public class NMSWrapper21 implements NMSWrapper { - - private static final Reflection.Field playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class); - private static final Reflection.Field playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0); - - @Override - public void setInternalGameMode(Player player, GameMode gameMode) { - playerGameMode.set(playerInteractManager.get(((CraftPlayer) player).getHandle()), GameType.byId(gameMode.getValue())); - } - - @Override - public void setSlotToItemStack(Player player, Object o) { - ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o; - int index = packetPlayInSetCreativeSlot.getSlot(); - if (index >= 36 && index <= 44) { - index -= 36; - } else if (index > 44) { - index -= 5; - } else if (index <= 8) { - index = index - 8 + 36; - } - player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItem())); - if (index < 9) player.getInventory().setHeldItemSlot(index); - player.updateInventory(); - } - - private static final Reflection.Field gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 14); - - @Override - public void setGameStateChangeReason(Object packet) { - gameStateChangeReason.set(packet, ClientboundGameEventPacket.CHANGE_GAME_MODE); - } - - @Override - public void setPlayerBuildAbilities(Player player) { - Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities(); - abilities.mayBuild = true; - abilities.mayfly = true; - } - - @Override - public Material pathMaterial() { - return Material.DIRT_PATH; - } - - private static final int threshold = 2048; - - @Override - public boolean checkItemStack(ItemStack item) { - ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER); - if (data == null) { - return false; - } - - return drillDown(data.contents(), 0, 0) > threshold; - } - - private int drillDown(List items, int layer, int start) { - if (layer > 2) return start + threshold; - int invalid = start; - for (int i = start; i < items.size(); i++) { - ItemStack item = items.get(i); - if (item.isEmpty()) continue; - - invalid += item.getAmount(); - - ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER); - if (data == null) { - continue; - } - - List subItems = data.contents(); - if (subItems.size() > 1) { - invalid = drillDown(subItems, layer + 1, invalid); - } - } - return invalid; - } - - @Override - public Object resetExplosionKnockback(Object packet) { - ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet; - - return new ClientboundExplodePacket( - explosion.center(), - Optional.empty(), - explosion.explosionParticle(), - explosion.explosionSound() - ); - } -} diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/PlayerMovementWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/PlayerMovementWrapper21.java deleted file mode 100644 index e62e4591..00000000 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/PlayerMovementWrapper21.java +++ /dev/null @@ -1,46 +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 . - */ - -package de.steamwar.bausystem.utils; - -import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; -import net.minecraft.server.level.ServerPlayer; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class PlayerMovementWrapper21 implements PlayerMovementWrapper { - - @Override - public void setPosition(Player player, Object object) { - ServerboundMovePlayerPacket packetPlayInFlying = ((ServerboundMovePlayerPacket) object); - ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - if (packetPlayInFlying.hasPos) { - serverPlayer.setPosRaw(packetPlayInFlying.x, packetPlayInFlying.y, packetPlayInFlying.z); - } - if (packetPlayInFlying.hasRot) { - serverPlayer.setXRot(packetPlayInFlying.xRot); - serverPlayer.setYRot(packetPlayInFlying.yRot); - } - } - - @Override - public Object convertToOut(Player player, Object object) { - return object; - } -} diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/TickManager21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/TickManager21.java deleted file mode 100644 index ad6ca6c2..00000000 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/TickManager21.java +++ /dev/null @@ -1,149 +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 . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; -import de.steamwar.bausystem.BauSystem; -import net.minecraft.network.protocol.game.ClientboundTickingStatePacket; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.ServerTickRateManager; -import net.minecraft.world.TickRateManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class TickManager21 implements TickManager { - private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager(); - private static final Reflection.Field frozenTicksToRun = Reflection.getField(TickRateManager.class, int.class, 0); - private static final Reflection.Field remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0); - - private boolean blockTpsPacket = true; - private int totalSteps; - - public TickManager21() { - TinyProtocol.instance.addFilter(ClientboundTickingStatePacket.class, this::blockPacket); - } - - private Object blockPacket(Player player, Object packet) { - if (blockTpsPacket) { - return new ClientboundTickingStatePacket(20, manager.isFrozen()); - } else { - return packet; - } - } - - @Override - public boolean canFreeze() { - return true; - } - - @Override - public void setBlockTpsPacket(boolean block) { - blockTpsPacket = block; - if (blockTpsPacket) { - ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(20, manager.isFrozen()); - Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet)); - } else { - ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(manager.tickrate(), manager.isFrozen()); - Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet)); - } - } - - @Override - public void setTickRate(float tickRate) { - if (isFrozen()) { - setFreeze(false); - } - manager.setTickRate(tickRate); - } - - @Override - public boolean isFrozen() { - return manager.isFrozen(); - } - - @Override - public void setFreeze(boolean freeze) { - manager.setFrozen(freeze); - } - - @Override - public void stepTicks(int ticks) { - if (manager.isSprinting()) { - manager.stopSprinting(); - } else if (manager.isSteppingForward()) { - manager.stopStepping(); - } - this.totalSteps = ticks; - manager.setFrozen(true); - manager.stepGameIfPaused(ticks); - manager.setFrozen(false); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), (bukkitTask) -> { - if (manager.isSteppingForward()) return; - manager.setFrozen(true); - bukkitTask.cancel(); - }, 1, 1); - } - - @Override - public void sprintTicks(int ticks) { - if (manager.isSteppingForward()) { - manager.stopStepping(); - } else if (manager.isSprinting()) { - manager.stopSprinting(); - } - this.totalSteps = ticks; - manager.requestGameToSprint(ticks, true); - } - - @Override - public boolean isSprinting() { - return manager.isSprinting(); - } - - @Override - public boolean isStepping() { - return manager.isSteppingForward(); - } - - @Override - public float getTickRate() { - return manager.tickrate(); - } - - @Override - public long getRemainingTicks() { - if (isSprinting()) { - return remainingSprintTicks.get(manager); - } else { - return frozenTicksToRun.get(manager); - } - } - - @Override - public long getDoneTicks() { - return totalSteps - getRemainingTicks(); - } - - @Override - public long getTotalTicks() { - return totalSteps; - } -} diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index 45aff756..f51b33cd 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -26,8 +26,8 @@ tasks.compileJava { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } dependencies { @@ -35,11 +35,14 @@ dependencies { annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) compileOnly(libs.axiom) compileOnly(libs.authlib) - compileOnly(libs.fawe18) + compileOnly(libs.paperapi) + compileOnly(libs.nms) + + compileOnly(libs.fawe) + compileOnly(libs.netty) implementation(libs.luaj) implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar")) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 39f0a4b7..e1f7b11a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -34,7 +34,6 @@ import de.steamwar.bausystem.features.world.BauScoreboard; import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.utils.ScoreboardElement; -import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.utils.TickManager; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.AbstractValidator; @@ -127,8 +126,6 @@ public class BauSystem extends JavaPlugin implements Listener { return; } - TickListener.impl.init(); - TraceManager.instance.init(); TraceRecorder.instance.init(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index 6dad9e00..98a1df65 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.features.observer; -import de.steamwar.Reflection; import de.steamwar.bausystem.region.Point; import de.steamwar.core.SWPlayer; import org.bukkit.Location; @@ -29,8 +28,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.data.Bisected; import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.*; +import org.bukkit.block.data.type.Observer; +import org.bukkit.craftbukkit.block.impl.CraftPoweredRail; import org.bukkit.entity.Player; import java.util.*; @@ -171,7 +171,6 @@ public class ObserverTracer implements SWPlayer.Component { } } - private static final Class craftPoweredRail = Reflection.getClass("org.bukkit.craftbukkit.block.impl.CraftPoweredRail"); private boolean checkAllowed(Block block, BlockData blockData) { if (checkMaterial(block)) return true; if (block.getType() == Material.BELL) { @@ -180,7 +179,7 @@ public class ObserverTracer implements SWPlayer.Component { return blockData instanceof Door || blockData instanceof Gate - || craftPoweredRail.isInstance(blockData) + || blockData instanceof CraftPoweredRail || blockData instanceof TrapDoor || blockData instanceof GlassPane; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/rayvisualizer/RayVisualizerCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/rayvisualizer/RayVisualizerCommand.java index 2346bcd3..9fe231db 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/rayvisualizer/RayVisualizerCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/rayvisualizer/RayVisualizerCommand.java @@ -28,7 +28,6 @@ import de.steamwar.command.SWCommand; import de.steamwar.entity.CRay; import de.steamwar.entity.REntityServer; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.*; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; @@ -42,7 +41,6 @@ import org.bukkit.util.RayTraceResult; import java.util.List; @Linked -@MinVersion(20) public class RayVisualizerCommand extends SWCommand implements Listener { private BlockData VISIBLE = Material.LIME_CONCRETE.createBlockData(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index 91a9d650..518adde8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.FreezeMode; import de.steamwar.bausystem.utils.ScoreboardElement; -import de.steamwar.core.Core; import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; @@ -155,7 +154,6 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { - if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java index 0766b646..9db80d57 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java @@ -25,11 +25,9 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ItemMode; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.entity.Player; @Linked -@MinVersion(19) public class ItemsCommand extends SWCommand { public ItemsCommand() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java index 145237e2..0ac8c03f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java @@ -25,14 +25,12 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ItemMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.ItemSpawnEvent; @Linked -@MinVersion(19) public class ItemsListener implements Listener, ScoreboardElement { @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index cc7b7c82..5e365c7d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -67,11 +67,7 @@ public class TNTListener implements Listener, ScoreboardElement { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) { - event.blockList().clear(); - return; - } - explode(event.blockList(), true); + explode(event.blockList(), event.getEntity() instanceof TNTPrimed); } @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java index 04cde3f0..c6c4197c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.script.lua.libs; import com.google.gson.*; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionSystem; -import de.steamwar.core.Core; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Disable; import de.steamwar.linkage.api.Enable; @@ -56,7 +55,6 @@ public class StorageLib implements LuaLib, Enable, Disable { @Override public void enable() { - if (Core.getVersion() <= 15) return; if (!storageDirectory.exists()) storageDirectory.mkdirs(); try { @@ -132,7 +130,6 @@ public class StorageLib implements LuaLib, Enable, Disable { @Override public void disable() { - if (Core.getVersion() <= 15) return; if (!storageDirectory.exists()) storageDirectory.mkdirs(); try { FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json")); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java index 7f07ab50..a8263ddb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java @@ -29,14 +29,12 @@ import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; -import de.steamwar.linkage.MinVersion; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.Collection; @Linked -@MinVersion(19) public class SimulatorCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index 7a1ba7e6..9c0f9f97 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.simulator; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; @@ -45,9 +44,9 @@ import de.steamwar.entity.REntityServer; import de.steamwar.entity.RFallingBlockEntity; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import lombok.AllArgsConstructor; import lombok.Getter; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -68,13 +67,9 @@ import java.util.function.Function; import java.util.stream.Collectors; @Linked -@MinVersion(19) public class SimulatorCursor implements Listener { private static final World WORLD = Bukkit.getWorlds().get(0); - private Class position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos"); - private Class look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot"); - private Class positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot"); private static Map cursorType = Collections.synchronizedMap(new HashMap<>()); private static Map cursors = Collections.synchronizedMap(new HashMap<>()); @@ -89,9 +84,9 @@ public class SimulatorCursor implements Listener { calcCursor(player); return object; }; - TinyProtocol.instance.addFilter(position, function); - TinyProtocol.instance.addFilter(look, function); - TinyProtocol.instance.addFilter(positionLook, function); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, function); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Rot.class, function); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, function); } @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java index 76ddcd21..09ac51da 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java @@ -32,7 +32,6 @@ import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.api.Enable; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -47,7 +46,6 @@ import java.util.*; import java.util.stream.Collectors; @Linked -@MinVersion(19) public class SimulatorStorage implements Enable { public static final File simulatorsDir = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "simulators"); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java index f79ad581..3c8ff96f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java @@ -28,7 +28,6 @@ import de.steamwar.entity.REntity; import de.steamwar.entity.REntityServer; import de.steamwar.entity.RFallingBlockEntity; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -75,7 +74,6 @@ public class SimulatorWatcher { } @Linked - @MinVersion(19) public static class QuitListener implements Listener { @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java index 108827e3..68fefe19 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java @@ -19,16 +19,16 @@ package de.steamwar.bausystem.features.simulator.execute; +import com.destroystokyo.paper.event.server.ServerTickEndEvent; +import com.destroystokyo.paper.event.server.ServerTickStartEvent; import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.SimulatorElement; import de.steamwar.bausystem.features.simulator.data.SimulatorGroup; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tracer.TraceRecorder; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.TickEndEvent; -import de.steamwar.bausystem.utils.TickStartEvent; +import de.steamwar.bausystem.utils.TickManager; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; @@ -39,7 +39,6 @@ import java.util.*; import java.util.concurrent.atomic.AtomicLong; @Linked -@MinVersion(19) public class SimulatorExecutor implements Listener { private static final World WORLD = Bukkit.getWorlds().get(0); @@ -109,8 +108,13 @@ public class SimulatorExecutor implements Listener { return true; } + private boolean tickStartRan = false; + @EventHandler - public void onTickStart(TickStartEvent event) { + public void onServerTickStart(ServerTickStartEvent event) { + if (TickManager.impl.isFrozen()) return; + tickStartRan = true; + long currentTick = TPSUtils.currentRealTick.get(); Map> actionsToRun = tickStartActions.remove(currentTick); if (actionsToRun == null) return; @@ -123,7 +127,10 @@ public class SimulatorExecutor implements Listener { } @EventHandler - public void onTickEnd(TickEndEvent event) { + public void onServerTickEnd(ServerTickEndEvent event) { + if (!tickStartRan) return; + tickStartRan = false; + long currentTick = TPSUtils.currentRealTick.get() - 1; List actionsToRun = tickEndActions.remove(currentTick); if (actionsToRun == null) return; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java index 16f036b0..2dd660bb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement; import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -128,15 +127,14 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; observer.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java index cf7726bd..cf2c6aba 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement; import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -154,15 +153,14 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; redstone.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java index 08d3628d..405bfbfb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java @@ -29,7 +29,6 @@ import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui; import de.steamwar.bausystem.region.Region; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -102,16 +101,14 @@ public class SimulatorTNTGui extends SimulatorScrollGui { tnt.setDisabled(!tnt.isDisabled()); SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED)); - if (Core.getVersion() > 19) { - inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> { - new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> { - if (depthLimit <= 0) return false; - simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit)); - SimulatorWatcher.update(simulator); - return true; - }, null).open(); - }).setCustomModelData(CMDs.Simulator.CREATE_STAB)); - } + inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> { + new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> { + if (depthLimit <= 0) return false; + simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit)); + SimulatorWatcher.update(simulator); + return true; + }, null).open(); + }).setCustomModelData(CMDs.Simulator.CREATE_STAB)); inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> { TNTElement tntElement = new TNTElement(tnt.getPosition().clone()); tntElement.add(new TNTPhase()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java index e66449fb..cc60da86 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -159,15 +158,14 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eCalculation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; tnt.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 90b88f6c..4f1ef8ff 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui.base; import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.data.Simulator; -import de.steamwar.core.Core; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; @@ -47,10 +46,7 @@ public abstract class SimulatorBaseGui { public final void open() { if (!shouldOpen()) return; - String newTitle = title(); - String originalTitle = player.getOpenInventory().getTitle(); - - if (inv != null && (Core.getVersion() > 19 || newTitle.equals(originalTitle))) { + if (inv != null) { // TODO: Flickering is better but not gone! for (int i = 9; i < size - 9; i++) { inv.setItem(i, null); @@ -60,9 +56,7 @@ public abstract class SimulatorBaseGui { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } - if (Core.getVersion() > 19) { - player.getOpenInventory().setTitle(title()); - } + player.getOpenInventory().setTitle(title()); if (simulator != null && simulator.getStabGenerator() != null) { populateStabGenerator(); } else { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index ee9d48f4..12636ba9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.slaves.laufbau; import com.sk89q.worldedit.blocks.SkullBlock; import com.sk89q.worldedit.world.block.BaseBlock; import de.steamwar.bausystem.utils.NMSWrapper; -import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.ToString; @@ -235,19 +234,17 @@ public class BlockBoundingBox { endRodEastWest.setFacing(BlockFace.EAST); addPixel(endRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); - if (Core.getVersion() >= 19) { - Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodBottomTop.setFacing(BlockFace.UP); - addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN")); + Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodBottomTop.setFacing(BlockFace.UP); + addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN")); - Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodNorthSouth.setFacing(BlockFace.NORTH); - addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH")); + Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodNorthSouth.setFacing(BlockFace.NORTH); + addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH")); - Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodEastWest.setFacing(BlockFace.EAST); - addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); - } + Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodEastWest.setFacing(BlockFace.EAST); + addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); Waterlogged conduit = (Waterlogged) Material.CONDUIT.createBlockData(); conduit.setWaterlogged(false); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java index 42ed812d..9c568a56 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java @@ -25,14 +25,12 @@ import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @Linked -@MinVersion(19) public class LaufbauCommand extends SWCommand { public LaufbauCommand() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java index 0972df97..d7aab7b2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.AmethystCluster; @@ -35,7 +34,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class AmethystBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java index 6ee19b36..cc2368e7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -34,7 +33,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class AzaleaBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java index 77cf6c9a..cc855778 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.Lightable; import org.bukkit.block.data.type.Candle; @@ -35,7 +34,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class CandleBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java index bd480390..6d81b0e5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Axis; import org.bukkit.Material; import org.bukkit.block.data.Orientable; @@ -35,7 +34,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class ChainBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java index 1fea5fd8..19a709f5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -34,7 +33,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class DragonEggBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java index f5b4e67f..dae1eb06 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.type.BigDripleaf; @@ -34,7 +33,6 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createI import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; @Linked -@MinVersion(19) public class DripLeafBoundingBox implements BoundingBoxLoader { @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java index f5ccb209..dffe873d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java @@ -22,11 +22,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.core.Core; import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.type.Fence; import org.bukkit.block.data.type.Wall; import java.util.ArrayList; @@ -40,11 +38,7 @@ public class WallBoundingBox implements BoundingBoxLoader { @Override public void load() { - if (Core.getVersion() > 15) { - v18(); - } else { - v15(); - } + v18(); } private void v18() { @@ -82,40 +76,4 @@ public class WallBoundingBox implements BoundingBoxLoader { } } } - - private void v15() { - for (int nx = 0; nx < 2; nx++) { - for (int nz = 0; nz < 2; nz++) { - for (int px = 0; px < 2; px++) { - for (int pz = 0; pz < 2; pz++) { - Fence fence = (Fence) Material.END_STONE_BRICK_WALL.createBlockData(); - List lore = new ArrayList<>(); - List cuboidList = new ArrayList<>(); - cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8)); - if (nz == 1) { - lore.add("LAUFBAU_CONNECTION_NORTH"); - fence.setFace(BlockFace.NORTH, true); - cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4)); - } - if (pz == 1) { - lore.add("LAUFBAU_CONNECTION_SOUTH"); - fence.setFace(BlockFace.SOUTH, true); - cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4)); - } - if (nx == 1) { - lore.add("LAUFBAU_CONNECTION_WEST"); - fence.setFace(BlockFace.WEST, true); - cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6)); - } - if (px == 1) { - lore.add("LAUFBAU_CONNECTION_EAST"); - fence.setFace(BlockFace.EAST, true); - cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6)); - } - new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0]))); - } - } - } - } - } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index f6ce114c..aa8718c4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.core.Core; import lombok.Getter; import lombok.SneakyThrows; import org.bukkit.Location; @@ -57,9 +56,8 @@ public class Panzern { private BaseBlock blockType; private BaseBlock slabType; - private static final BaseBlock jukeboxType = (Core.getVersion() > 19 ? BlockTypes.get("lodestone"): BlockTypes.get("jukebox")).getDefaultState().toBaseBlock(); + private static final BaseBlock jukeboxType = BlockTypes.get("lodestone").getDefaultState().toBaseBlock(); private static final BaseBlock cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock(); - private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock(); @Getter private EditSession editSession; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index bc3d2bb0..07ac31a3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -20,13 +20,12 @@ package de.steamwar.bausystem.features.smartplace; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -83,13 +82,11 @@ public class SmartPlaceListener implements Listener { IGNORED.remove(Material.BARRIER); } - private static final Class useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"); - private static final Set SMART_PLACING = new HashSet<>(); private static final Set WAS_EXECUTED = new HashSet<>(); public SmartPlaceListener() { - TinyProtocol.instance.addFilter(useItem, (player, packet) -> { + TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, (player, packet) -> { if(!Permission.BUILD.hasPermission(player)) return packet; if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet; RayTraceResult rayTraceResult = player.rayTraceBlocks(6); @@ -152,7 +149,7 @@ public class SmartPlaceListener implements Listener { if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!SMART_PLACING.contains(event.getPlayer())) { - if (Core.getVersion() >= 20 && CONTAINERS.contains(event.getBlockAgainst().getType())) { + if (CONTAINERS.contains(event.getBlockAgainst().getType())) { SoundGroup soundGroup = event.getBlockPlaced().getBlockData().getSoundGroup(); event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index 9eafc09b..a9b36c50 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -31,7 +31,6 @@ import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; import de.steamwar.core.TPSWatcher; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; @@ -59,16 +58,12 @@ public class TPSSystem implements Listener { } new TPSLimitCommand(); new TickLimitCommand(); - if (Core.getVersion() >= 15) { - new TPSWarpCommand(); - new TickWarpCommand(); - if (TickManager.impl.canFreeze()) { - new TickWarpingCommand(); - } - } - if (Core.getVersion() >= 21) { - new Tick21Command(); + new TPSWarpCommand(); + new TickWarpCommand(); + if (TickManager.impl.canFreeze()) { + new TickWarpingCommand(); } + new Tick21Command(); new TPSDefaultCommand(); new TickDefaultCommand(); new TPSBaseCommand(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java index 53ac62fb..cb5cb89d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.region.Region; -import de.steamwar.core.Core; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -100,11 +99,7 @@ public class TNTPoint { List history, List destroyedBlocks) { this.tntId = tntId; this.explosion = explosion; - if (Core.getVersion() > 15) { - this.inWater = tnt.isInWater(); - } else { - this.inWater = false; - } + this.inWater = tnt.isInWater(); this.afterFirstExplosion = afterFirstExplosion; this.ticksSinceStart = ticksSinceStart; fuse = tnt.getFuseTicks(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java index 52a588f9..a3392807 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java @@ -39,10 +39,7 @@ import lombok.Setter; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import java.util.*; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index 61fdecdc..0c1481e6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.util; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; -import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; @@ -30,6 +29,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.core.ProtocolWrapper; import de.steamwar.core.SWPlayer; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.*; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -45,16 +45,6 @@ import java.util.function.BiFunction; @Linked public class NoClipCommand extends SWCommand implements Listener { - public static final Class gameStateChange = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket"); - private static final Reflection.Field floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0); - - private static final Class position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos"); - private static final Class positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot"); - private static final Class useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"); - private static final Class blockDig = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket"); - private static final Class windowClick = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundContainerClickPacket"); - private static final Class setSlotStack = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket"); - public static class NoClipData implements SWPlayer.Component { private long lastTick = -1; @@ -75,8 +65,8 @@ public class NoClipCommand extends SWCommand implements Listener { noClipData.lastTick = TPSUtils.currentTick.get(); return o; }; - TinyProtocol.instance.addFilter(position, first); - TinyProtocol.instance.addFilter(positionLook, first); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, first); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, first); BiFunction second = (player, o) -> { NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null); @@ -85,9 +75,9 @@ public class NoClipCommand extends SWCommand implements Listener { noClipData.lastTick = TPSUtils.currentTick.get(); return o; }; - TinyProtocol.instance.addFilter(useItem, second); - TinyProtocol.instance.addFilter(blockDig, second); - TinyProtocol.instance.addFilter(windowClick, second); + TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, second); + TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, second); + TinyProtocol.instance.addFilter(ServerboundContainerClickPacket.class, second); BiFunction third = (player, o) -> { if (SWPlayer.of(player).hasComponent(NoClipData.class)) { @@ -95,7 +85,7 @@ public class NoClipCommand extends SWCommand implements Listener { } return o; }; - TinyProtocol.instance.addFilter(setSlotStack, third); + TinyProtocol.instance.addFilter(ServerboundSetCreativeModeSlotPacket.class, third); } @Register(help = true) @@ -107,13 +97,9 @@ public class NoClipCommand extends SWCommand implements Listener { player.setGameMode(GameMode.SPECTATOR); NMSWrapper.impl.setPlayerBuildAbilities(player); - Object gameStateChangeObject = Reflection.newInstance(gameStateChange); - NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject); - floatFieldAccessor.set(gameStateChangeObject, 1F); - swPlayer.setComponent(new NoClipData()); BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player); - TinyProtocol.instance.sendPacket(player, gameStateChangeObject); + TinyProtocol.instance.sendPacket(player, new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, 1F)); pseudoGameMode(player, GameMode.SPECTATOR); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 7ca9b730..f6ac1714 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.entity.*; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -46,7 +45,6 @@ import java.util.*; import java.util.stream.Collectors; @Linked -@MinVersion(20) public class PistonCalculator implements Listener { private final Map debounce = new HashMap<>(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java index cd8c6ff6..d5b4ccec 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; -import de.steamwar.linkage.MinVersion; import org.bukkit.entity.Player; import java.util.HashSet; @@ -31,7 +30,6 @@ import java.util.Set; import java.util.UUID; @Linked -@MinVersion(20) public class PistonCalculatorCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java index 72e72713..50878f31 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java @@ -22,8 +22,8 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.util.KillAllCommand; -import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.bausystem.features.util.RegionSelectionType; +import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index f57ff726..c661ccb4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.region.Region; -import de.steamwar.core.Core; import de.steamwar.core.SWPlayer; import de.steamwar.entity.RArmorStand; import de.steamwar.entity.REntityServer; @@ -113,7 +112,7 @@ public class WarpListener implements Listener { vector.setY(0); Vector position = p.getLocation().toVector().clone().add(vector.normalize().multiply(5)); - position.setY(p.getLocation().getY() - (Core.getVersion() >= 20 ? 0 : 1)); + position.setY(p.getLocation().getY()); if ((position.getX() - current.getX()) * (position.getX() - current.getX()) + (position.getZ() - current.getZ()) * (position.getZ() - current.getZ()) < 0.1) { name = "§a§l" + name; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java index c526d089..3d6c1e9f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java @@ -19,11 +19,11 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Enable; +import net.minecraft.network.protocol.game.ClientboundContainerClosePacket; import org.bukkit.Bukkit; import org.bukkit.event.inventory.InventoryType; @@ -32,8 +32,7 @@ public class AntiCursorReCentering implements Enable { @Override public void enable() { - Class closeWindow = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundContainerClosePacket"); - TinyProtocol.instance.addFilter(closeWindow, (player, object) -> { + TinyProtocol.instance.addFilter(ClientboundContainerClosePacket.class, (player, object) -> { if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) { return object; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java index 602903eb..2debf84e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java @@ -19,17 +19,17 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; import org.bukkit.GameMode; @Linked public class NoCreativeKnockback { public NoCreativeKnockback() { - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"), (player, o) -> { + TinyProtocol.instance.addFilter(ClientboundExplodePacket.class, (player, o) -> { if (player.getGameMode() != GameMode.CREATIVE) return o; return NMSWrapper.impl.resetExplosionKnockback(o); }); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java similarity index 66% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index 6adb98f5..0487a406 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -19,13 +19,14 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.PlaceItemUtils; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; +import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket; +import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; +import net.minecraft.server.level.ServerLevel; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -37,6 +38,8 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Rotatable; import org.bukkit.block.sign.Side; import org.bukkit.block.sign.SignSide; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -45,24 +48,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @Linked -@MinVersion(20) -public class SignEditFrom20 implements Listener { - - private static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - private static final Class craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock"); - private static final Class craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"); - private static final Class generatorAccess = Reflection.getClass("net.minecraft.world.level.LevelAccessor"); - private static final Reflection.Method getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); - private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null); - private static final Reflection.Method at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition); - - private static final Class openSign = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket"); - private static final Reflection.Field blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0); - private static final Reflection.Field sideFieldAccessor = Reflection.getField(openSign, boolean.class, 0); - - private static final Class updateSign = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSignUpdatePacket"); - private static final Reflection.Field getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0); - private static final Reflection.Field stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0); +public class SignEdit implements Listener { @EventHandler public void editSign(PlayerInteractEvent event) { @@ -93,10 +79,8 @@ public class SignEditFrom20 implements Listener { sign.update(true); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - Object openSignObject = Reflection.newInstance(openSign); - blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(block)); - sideFieldAccessor.set(openSignObject, side == Side.FRONT); - TinyProtocol.instance.sendPacket(player, openSignObject); + ClientboundOpenSignEditorPacket packet = new ClientboundOpenSignEditorPacket(((CraftBlock) block).getPosition(), side == Side.FRONT); + TinyProtocol.instance.sendPacket(player, packet); }, 1); } @@ -117,14 +101,14 @@ public class SignEditFrom20 implements Listener { } { - TinyProtocol.instance.addFilter(updateSign, (player, o) -> { + TinyProtocol.instance.addTypedFilter(ServerboundSignUpdatePacket.class, (player, o) -> { Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> { - String[] lines = stringFieldAccessor.get(o); - - Block signLoc = (Block) at.invoke(null, getWorldHandle.invoke(player.getWorld()), getBlockPositionFieldAccessor.get(o)); + ServerLevel serverLevel = ((CraftWorld) player.getWorld()).getHandle(); + Block signLoc = CraftBlock.at(serverLevel, o.getPos()); if (!signLoc.getType().name().contains("SIGN")) return; + String[] lines = o.getLines(); Sign sign = ((Sign) signLoc.getState()); SignSide signSide = sign.getSide(signSide(player, signLoc)); for (int i = 0; i < lines.length; i++) { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java deleted file mode 100644 index 96ca0df8..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java +++ /dev/null @@ -1,105 +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 . - */ - -package de.steamwar.bausystem.features.world; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MaxVersion; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; - -@Linked -@MaxVersion(19) -public class SignEditUntil19 implements Listener { - - private static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - private static final Class craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock"); - private static final Class craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"); - private static final Class generatorAccess = Reflection.getClass("net.minecraft.world.level.LevelAccessor"); - private static final Reflection.Method getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); - private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null); - private static final Reflection.Method at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition); - - private static final Class openSign = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket"); - private static final Reflection.Field blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0); - - private static final Class updateSign = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSignUpdatePacket"); - private static final Reflection.Field getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0); - private static final Reflection.Field stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0); - - @EventHandler - public void editSign(PlayerInteractEvent event) { - if (!event.getPlayer().isSneaking()) return; - if (event.getClickedBlock() == null || !event.getClickedBlock().getType().name().contains("SIGN")) return; - - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && (event.getItem() == null || event.getItem().getType() == Material.AIR) || event.getAction() == Action.LEFT_CLICK_BLOCK) { - event.setCancelled(true); - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - edit(event.getPlayer(), event.getClickedBlock()); - }, 1); - } - } - - private void edit(Player player, Block block) { - if (!Permission.BUILD.hasPermission(player)) return; - Sign sign = (org.bukkit.block.Sign) block.getState(); - String[] lines = sign.getLines(); - for (int i = 0; i < lines.length; i++) { - sign.setLine(i, lines[i].replace('§', '&')); - } - sign.update(true); - - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - Object openSignObject = Reflection.newInstance(openSign); - blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(block)); - TinyProtocol.instance.sendPacket(player, openSignObject); - }, 1); - } - - { - TinyProtocol.instance.addFilter(updateSign, (player, o) -> { - Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> { - String[] lines = stringFieldAccessor.get(o); - - Block signLoc = (Block) at.invoke(null, getWorldHandle.invoke(player.getWorld()), getBlockPositionFieldAccessor.get(o)); - if (!signLoc.getType().name().contains("SIGN")) - return; - - org.bukkit.block.Sign sign = ((Sign) signLoc.getState()); - for (int i = 0; i < lines.length; i++) { - sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i])); - } - sign.update(); - }); - return o; - }); - } -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index cfdc6fe3..a6f56a5e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.sql.BauweltMember; import de.steamwar.techhider.TechHider; import org.bukkit.Bukkit; @@ -272,7 +271,6 @@ public class SpectatorListener implements Listener { } @Linked - @MinVersion(20) public static class SpectatorListener20 implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerBucketEntity(PlayerBucketEntityEvent event) { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java index e9da8ef6..9b6d6368 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -39,7 +38,6 @@ import java.util.logging.Level; import java.util.stream.Collectors; @Linked -@MinVersion(18) public class WorldEditSelectionSaver implements Listener { private File WORLD_EDIT_SELECTIONS = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "world_edit_selections"); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java index ec8f4d5f..ee24125a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java @@ -34,7 +34,6 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.bukkit.Material; @@ -53,7 +52,6 @@ import java.util.stream.Collectors; import static org.bukkit.Material.*; @Linked -@MinVersion(18) public class TypeReplaceCommand extends SWCommand { public TypeReplaceCommand() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java index 5641f1c0..f55afce8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; @@ -34,7 +33,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWEAboveMaskParser extends FAWEMaskParser { public FAWEAboveMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java index 3c0cc285..613e3e61 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; @@ -34,7 +33,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWEBelowMaskParser extends FAWEMaskParser { public FAWEBelowMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java index e06bac07..6ae6958b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; @@ -33,7 +32,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWECheckerboard3DMaskParser extends FAWEMaskParser { public FAWECheckerboard3DMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java index 0f72d36a..4b97b918 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; @@ -33,7 +32,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWECheckerboardMaskParser extends FAWEMaskParser { public FAWECheckerboardMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java index f9db4c9b..773dc5ab 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; @@ -33,7 +32,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWEGridMaskParser extends FAWEMaskParser { public FAWEGridMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java index c809108b..7794a2de 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java @@ -27,7 +27,6 @@ import com.sk89q.worldedit.regions.Region; import de.steamwar.bausystem.features.worldedit.utils.FAWEPatternParser; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.PluginCheck; import org.bukkit.Axis; @@ -36,7 +35,6 @@ import java.util.stream.Stream; @Linked @PluginCheck("FastAsyncWorldEdit") -@MinVersion(19) public class FAWEGradientPatternParser extends FAWEPatternParser { public FAWEGradientPatternParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index b128e27a..401f6066 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.xray; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.techhider.TechHiderCommand; import de.steamwar.bausystem.region.Region; @@ -32,6 +31,7 @@ import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -95,9 +95,6 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen }); } - private static final Class position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos"); - private static final Class positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot"); - { BiFunction positionSetter = (player, o) -> { Region region = Region.getRegion(player.getLocation()); @@ -110,8 +107,8 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen return o; }; - TinyProtocol.instance.addFilter(position, positionSetter); - TinyProtocol.instance.addFilter(positionLook, positionSetter); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter); } @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java index 412e505c..aae50e3d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java @@ -20,34 +20,211 @@ package de.steamwar.bausystem.utils; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.bausystem.BauSystem; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.Mask2D; +import com.sk89q.worldedit.function.operation.ForwardExtentCopy; +import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.transform.AffineTransform; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; +import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.bausystem.region.Point; -import de.steamwar.core.VersionDependent; +import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import javax.annotation.Nullable; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiPredicate; +import java.util.logging.Level; -public interface FlatteningWrapper { - FlatteningWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); +public class FlatteningWrapper { + public static final FlatteningWrapper impl = new FlatteningWrapper(); - boolean isNoBook(ItemStack item); + public boolean isNoBook(ItemStack item) { + return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK; + } - boolean isUnpusheable(Material material); - boolean isBreakingOnPush(Material material); + private static final Set unpushable = new HashSet<>(Arrays.asList(Material.BARRIER, Material.BEACON, Material.COMMAND_BLOCK, Material.CHAIN_COMMAND_BLOCK, Material.REPEATING_COMMAND_BLOCK, Material.ENCHANTING_TABLE, Material.END_GATEWAY, Material.END_PORTAL, Material.ENDER_CHEST, Material.GRINDSTONE, Material.JIGSAW, Material.JUKEBOX, Material.NETHER_PORTAL, Material.OBSIDIAN, Material.STRUCTURE_VOID, Material.BARREL, Material.BEEHIVE, Material.BEE_NEST, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CHEST, Material.DAYLIGHT_DETECTOR, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.LECTERN, Material.SMOKER, Material.TRAPPED_CHEST)); - boolean isWorldEditCommand(String command); - void setSelection(Player p, Point minPoint, Point maxPoint); + // TODO: FLOWER + private static final Set breaking = new HashSet<>(Arrays.asList(Material.BAMBOO, Material.CACTUS, Material.CAKE, Material.CARVED_PUMPKIN, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.COBWEB, Material.COCOA, Material.DRAGON_EGG, Material.FIRE, Material.FLOWER_POT, Material.JACK_O_LANTERN, Material.LADDER, Material.LAVA, Material.LAVA, Material.LEVER, Material.LILY_PAD, Material.MELON, Material.NETHER_WART, Material.PUMPKIN, Material.COMPARATOR, Material.REDSTONE_WIRE, Material.REPEATER, Material.TORCH, Material.STRUCTURE_VOID, Material.SCAFFOLDING, Material.SEA_PICKLE, Material.SNOW, Material.SUGAR_CANE, Material.TORCH, Material.TRIPWIRE, Material.TRIPWIRE_HOOK, Material.TURTLE_EGG, Material.VINE, Material.WATER, Material.WHEAT)); - Clipboard loadSchematic(File file); - EditSession paste(PasteBuilder pasteBuilder); + public boolean isUnpusheable(Material material) { + if (unpushable.contains(material)) { + return true; + } + String name = material.name(); + return name.contains("BANNER") || name.contains("SIGN"); + } - Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint); - boolean backup(Point minPoint, Point maxPoint, File file); + public boolean isBreakingOnPush(Material material) { + if (breaking.contains(material)) { + return true; + } + String name = material.name(); + return name.contains("BED") || name.contains("BUTTON") || name.contains("CARPET") || (name.contains("DOOR") && !name.contains("TRAPDOOR")) || name.contains("HEAD") || name.contains("LEAVES") || name.contains("MUSHROOM") || name.contains("PRESSURE_PLATE") || name.contains("SHULKER_BOX"); + } - boolean inWater(World world, Vector tntPosition); + public boolean isWorldEditCommand(String command) { + if (command.startsWith("/")) { + command = command.replaceFirst("/", ""); + } + command = command.toLowerCase(); + return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command); + } + + private static final WorldEditPlugin WORLDEDIT_PLUGIN = Objects.requireNonNull((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); + private static final BukkitWorld BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); + + public void setSelection(Player p, Point minPoint, Point maxPoint) { + WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); + } + + public Clipboard loadSchematic(File file) { + Clipboard clipboard; + try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { + clipboard = reader.read(); + } catch (NullPointerException | IOException e) { + throw new SecurityException("Bausystem schematic not found", e); + } + return clipboard; + } + + public EditSession paste(PasteBuilder pasteBuilder) { + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { + Clipboard clipboard = pasteBuilder.getClipboard(); + + if (!pasteBuilder.getMappers().isEmpty()) { + BlockVector3 minimum = clipboard.getRegion().getMinimumPoint(); + for (int x = 0; x < clipboard.getDimensions().getX(); x++) { + for (int y = 0; y < clipboard.getDimensions().getY(); y++) { + for (int z = 0; z < clipboard.getDimensions().getZ(); z++) { + BlockVector3 pos = minimum.add(x, y, z); + pasteBuilder.getMappers().forEach(mapper -> mapper.accept(clipboard, pos)); + } + } + } + } + + AtomicReference pastePoint = new AtomicReference<>(); + if (!pasteBuilder.getPredicates().isEmpty()) { + e.setMask(new Mask() { + @Override + public boolean test(BlockVector3 blockVector3) { + BaseBlock block = clipboard.getFullBlock(blockVector3.subtract(pastePoint.get()).add(clipboard.getRegion().getMinimumPoint())); + String blockName = block.getBlockType().toString().toLowerCase(); + for (BiPredicate predicate : pasteBuilder.getPredicates()) { + if (!predicate.test(block, blockName)) return false; + } + return true; + } + + public Mask copy() { + return this; + } + + @Nullable + @Override + public Mask2D toMask2D() { + return null; + } + }); + } + + ClipboardHolder ch = new ClipboardHolder(clipboard); + BlockVector3 dimensions = clipboard.getDimensions(); + BlockVector3 v = BlockVector3.at(pasteBuilder.getPastPoint().getX(), pasteBuilder.getPastPoint().getY(), pasteBuilder.getPastPoint().getZ()); + BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); + if (pasteBuilder.isRotate()) { + ch.setTransform(new AffineTransform().rotateY(180)); + v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(0, 0, 1); + } else { + v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset); + } + pastePoint.set(v); + + if (pasteBuilder.isReset()) { + e.setBlocks((Region) new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); + if (pasteBuilder.getWaterLevel() != 0) { + e.setBlocks((Region) new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3().withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock()); + } + } + Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build()); + return e; + } catch (WorldEditException e) { + throw new SecurityException(e.getMessage(), e); + } + } + + public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) { + BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0)); + CuboidRegion region = new CuboidRegion(bukkitWorld, minPoint.toBlockVector3(), maxPoint.toBlockVector3()); + BlockArrayClipboard clipboard = new BlockArrayClipboard(region); + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) { + ForwardExtentCopy copy = new ForwardExtentCopy( + e, region, clipboard, region.getMinimumPoint() + ); + + copy.setCopyingEntities(false); + copy.setCopyingBiomes(false); + + Operations.complete(copy); + clipboard.setOrigin(copyPoint.toBlockVector3()); + return clipboard; + } catch (WorldEditException e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + return null; + } + } + + public boolean backup(Point minPoint, Point maxPoint, File file) { + Clipboard clipboard = copy(minPoint, maxPoint, minPoint); + try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) { + writer.write(clipboard); + return true; + } catch (IOException e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + return false; + } + } + + public boolean inWater(org.bukkit.World world, Vector tntPosition) { + Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()); + if (block.getType() == Material.WATER) + return true; + + BlockData data = block.getBlockData(); + if (!(data instanceof Waterlogged)) + return false; + + return ((Waterlogged) data).isWaterlogged(); + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index 2e69eb49..7141ff96 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -19,25 +19,99 @@ package de.steamwar.bausystem.utils; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionDependent; +import de.steamwar.Reflection; +import io.papermc.paper.datacomponent.DataComponentTypes; +import io.papermc.paper.datacomponent.item.ItemContainerContents; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.entity.player.Abilities; +import net.minecraft.world.level.GameType; import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public interface NMSWrapper { - NMSWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); +import java.util.List; +import java.util.Optional; - void setInternalGameMode(Player player, GameMode gameMode); - void setSlotToItemStack(Player player, Object o); +public class NMSWrapper { + public static final NMSWrapper impl = new NMSWrapper(); - void setGameStateChangeReason(Object packet); - void setPlayerBuildAbilities(Player player); + private static final Reflection.Field playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0); - Material pathMaterial(); + public void setInternalGameMode(Player player, GameMode gameMode) { + playerGameMode.set(((CraftPlayer) player).getHandle().gameMode, GameType.byId(gameMode.getValue())); + } - boolean checkItemStack(ItemStack item); + public void setSlotToItemStack(Player player, Object o) { + ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o; + int index = packetPlayInSetCreativeSlot.getSlot(); + if (index >= 36 && index <= 44) { + index -= 36; + } else if (index > 44) { + index -= 5; + } else if (index <= 8) { + index = index - 8 + 36; + } + player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItem())); + if (index < 9) player.getInventory().setHeldItemSlot(index); + player.updateInventory(); + } - Object resetExplosionKnockback(Object packet); + public void setPlayerBuildAbilities(Player player) { + Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities(); + abilities.mayBuild = true; + abilities.mayfly = true; + } + + public Material pathMaterial() { + return Material.DIRT_PATH; + } + + private static final int threshold = 2048; + + public boolean checkItemStack(ItemStack item) { + ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER); + if (data == null) { + return false; + } + + return drillDown(data.contents(), 0, 0) > threshold; + } + + private int drillDown(List items, int layer, int start) { + if (layer > 2) return start + threshold; + int invalid = start; + for (int i = start; i < items.size(); i++) { + ItemStack item = items.get(i); + if (item.isEmpty()) continue; + + invalid += item.getAmount(); + + ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER); + if (data == null) { + continue; + } + + List subItems = data.contents(); + if (subItems.size() > 1) { + invalid = drillDown(subItems, layer + 1, invalid); + } + } + return invalid; + } + + public Object resetExplosionKnockback(Object packet) { + ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet; + + return new ClientboundExplodePacket( + explosion.center(), + Optional.empty(), + explosion.explosionParticle(), + explosion.explosionSound() + ); + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java index 4e7c8f12..c4ab9a54 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java @@ -23,11 +23,15 @@ import de.steamwar.Reflection; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.experimental.UtilityClass; +import net.minecraft.core.BlockPos; import org.bukkit.*; import org.bukkit.block.*; +import org.bukkit.block.Skull; import org.bukkit.block.data.*; -import org.bukkit.block.data.type.Hopper; import org.bukkit.block.data.type.*; +import org.bukkit.block.data.type.Hopper; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CraftBlockState; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockPlaceEvent; @@ -82,27 +86,23 @@ public class PlaceItemUtils { .collect(Collectors.toSet()); } - private static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - private static final Reflection.Constructor blockPositionConstructor = Reflection.getConstructor(blockPosition, int.class, int.class, int.class); - private static final Class craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlockState"); - private static final Class craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"); - private static final Reflection.Field positionAccessor = Reflection.getField(craftBlock, blockPosition, 0); - private static final Reflection.Field worldAccessor = Reflection.getField(craftBlock, craftWorld, 0); + private static final Reflection.Field positionAccessor = Reflection.getField(CraftBlockState.class, BlockPos.class, 0); + private static final Reflection.Field worldAccessor = Reflection.getField(CraftBlockState.class, CraftWorld.class, 0); /** * Attempt to place an {@link ItemStack} the {@link Player} is holding against a {@link Block} inside the World. * This can be easily used inside the {@link org.bukkit.event.player.PlayerInteractEvent} to mimik placing a * block without any minecraft related GUI's etc. executing. * - * @param player the Player placing the block - * @param itemStack the ItemStack to be placed - * @param against the Block at which the player aims (does not need to be in range of the player) - * @param againstSide the BlockFace the player aims - * @param hand the Hand the player is using - * @param force allow illegal states to be created by placing the block + * @param player the Player placing the block + * @param itemStack the ItemStack to be placed + * @param against the Block at which the player aims (does not need to be in range of the player) + * @param againstSide the BlockFace the player aims + * @param hand the Hand the player is using + * @param force allow illegal states to be created by placing the block * @param applyPhysics apply physics while placing the block - * @param rotateAway rotate everything in the opposite direction, so a block facing the Player will face away, and the other way round - * @param playSound enables sound of placing + * @param rotateAway rotate everything in the opposite direction, so a block facing the Player will face away, and the other way round + * @param playSound enables sound of placing */ public PlaceItemResult placeItem(Player player, ItemStack itemStack, Block against, BlockFace againstSide, EquipmentSlot hand, boolean force, boolean applyPhysics, boolean rotateAway, boolean playSound) { // If the ItemStack is null or air we cannot place it @@ -288,7 +288,7 @@ public class PlaceItemUtils { } else { // If a BlockState is present set the Position and World to the Block you want to place Location blockLocation = block.getLocation(); - positionAccessor.set(blockState, blockPositionConstructor.invoke(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ())); + positionAccessor.set(blockState, new BlockPos(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ())); worldAccessor.set(blockState, blockLocation.getWorld()); } @@ -300,7 +300,7 @@ public class PlaceItemUtils { Location blockmin = block.getLocation(); Location blockmax = block.getLocation().add(1.0, 1.0, 1.0); if ( - !(max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() || + !(max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() || max.getY() <= blockmin.getY() || min.getY() >= blockmax.getY() || max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ()) ) { @@ -369,8 +369,8 @@ public class PlaceItemUtils { return usedForcePlace.get() ? PlaceItemResult.SUCCESS_FORCE : PlaceItemResult.SUCCESS; } - public BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; - public BlockFace[] radial = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST }; + public BlockFace[] axis = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; + public BlockFace[] radial = {BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST}; public BlockFace yawToFace(float yaw) { return radial[Math.round(yaw / 45f) & 0x7]; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemWrapper.java index a913cd15..101c5db1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemWrapper.java @@ -19,16 +19,32 @@ package de.steamwar.bausystem.utils; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionDependent; +import lombok.experimental.UtilityClass; import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import java.util.HashMap; import java.util.Map; -public interface PlaceItemWrapper { - Map ITEM_MATERIAL_TO_BLOCK_MATERIAL = new HashMap<>(); - Map BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL = new HashMap<>(); +@UtilityClass +public class PlaceItemWrapper { + public static final Map ITEM_MATERIAL_TO_BLOCK_MATERIAL = new HashMap<>(); + public static final Map BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL = new HashMap<>(); - PlaceItemWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); + static { + for (Material material : Material.values()) { + if (!material.isBlock()) continue; + if (material.isLegacy()) continue; + BlockData blockData = material.createBlockData(); + Material placementMaterial = blockData.getPlacementMaterial(); + if (material == placementMaterial) continue; + if (placementMaterial == Material.AIR) continue; + if (placementMaterial.isItem() && !placementMaterial.isBlock()) { + ITEM_MATERIAL_TO_BLOCK_MATERIAL.put(placementMaterial, material); + } + if (material.name().contains("WALL")) { + BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.put(placementMaterial, material); + } + } + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java index 79c52f0c..5922594a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java @@ -20,19 +20,33 @@ package de.steamwar.bausystem.utils; import de.steamwar.Reflection; -import de.steamwar.bausystem.BauSystem; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.VersionDependent; import de.steamwar.entity.REntity; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.server.level.ServerPlayer; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; -public interface PlayerMovementWrapper { +public class PlayerMovementWrapper { Class teleportPacket = REntity.teleportPacket; Reflection.Field teleportEntity = REntity.teleportEntity; BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition; - PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); + public static final PlayerMovementWrapper impl = new PlayerMovementWrapper(); - void setPosition(Player player, Object object); - Object convertToOut(Player player, Object object); + public void setPosition(Player player, Object object) { + ServerboundMovePlayerPacket packetPlayInFlying = ((ServerboundMovePlayerPacket) object); + ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); + if (packetPlayInFlying.hasPos) { + serverPlayer.setPosRaw(packetPlayInFlying.x, packetPlayInFlying.y, packetPlayInFlying.z); + } + if (packetPlayInFlying.hasRot) { + serverPlayer.setXRot(packetPlayInFlying.xRot); + serverPlayer.setYRot(packetPlayInFlying.yRot); + } + } + + public Object convertToOut(Player player, Object object) { + return object; + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickListener.java deleted file mode 100644 index a300b0ca..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickListener.java +++ /dev/null @@ -1,31 +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 . - */ - -package de.steamwar.bausystem.utils; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionDependent; - -public interface TickListener { - - TickListener impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); - - default void init() { - } -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java index 6570a03f..086999e3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java @@ -19,28 +19,119 @@ package de.steamwar.bausystem.utils; +import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionDependent; +import net.minecraft.network.protocol.game.ClientboundTickingStatePacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ServerTickRateManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; -public interface TickManager extends Listener { - TickManager impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); +public class TickManager implements Listener { + public static final TickManager impl = new TickManager(); - void setTickRate(float tickRate); - float getTickRate(); + private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager(); + private static final Reflection.Field remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0); - boolean canFreeze(); - void setFreeze(boolean freeze); - boolean isFrozen(); + private boolean blockTpsPacket = true; + private int totalSteps; - void stepTicks(int ticks); - boolean isStepping(); + private TickManager() { + TinyProtocol.instance.addFilter(ClientboundTickingStatePacket.class, this::blockPacket); + } - void sprintTicks(int ticks); - boolean isSprinting(); + private Object blockPacket(Player player, Object packet) { + if (blockTpsPacket) { + return new ClientboundTickingStatePacket(20, manager.isFrozen()); + } else { + return packet; + } + } - void setBlockTpsPacket(boolean block); - long getRemainingTicks(); - long getDoneTicks(); - long getTotalTicks(); + public boolean canFreeze() { + return true; + } + + public void setBlockTpsPacket(boolean block) { + blockTpsPacket = block; + if (blockTpsPacket) { + ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(20, manager.isFrozen()); + Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet)); + } else { + ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(manager.tickrate(), manager.isFrozen()); + Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet)); + } + } + + public void setTickRate(float tickRate) { + if (isFrozen()) { + setFreeze(false); + } + manager.setTickRate(tickRate); + } + + public boolean isFrozen() { + return manager.isFrozen(); + } + + public void setFreeze(boolean freeze) { + manager.setFrozen(freeze); + } + + public void stepTicks(int ticks) { + if (manager.isSprinting()) { + manager.stopSprinting(); + } else if (manager.isSteppingForward()) { + manager.stopStepping(); + } + this.totalSteps = ticks; + manager.setFrozen(true); + manager.stepGameIfPaused(ticks); + manager.setFrozen(false); + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), (bukkitTask) -> { + if (manager.isSteppingForward()) return; + manager.setFrozen(true); + bukkitTask.cancel(); + }, 1, 1); + } + + public void sprintTicks(int ticks) { + if (manager.isSteppingForward()) { + manager.stopStepping(); + } else if (manager.isSprinting()) { + manager.stopSprinting(); + } + this.totalSteps = ticks; + manager.requestGameToSprint(ticks, true); + } + + public boolean isSprinting() { + return manager.isSprinting(); + } + + public boolean isStepping() { + return manager.isSteppingForward(); + } + + public float getTickRate() { + return manager.tickrate(); + } + + public long getRemainingTicks() { + if (isSprinting()) { + return remainingSprintTicks.get(manager); + } else { + return manager.frozenTicksToRun(); + } + } + + public long getDoneTicks() { + return totalSteps - getRemainingTicks(); + } + + public long getTotalTicks() { + return totalSteps; + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java index 078a32fd..0bab1548 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.utils; -import de.steamwar.Reflection; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; @@ -34,6 +33,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; +import de.steamwar.Reflection; import de.steamwar.bausystem.shared.Pair; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; diff --git a/BauSystem/BauSystem_RegionFixed/build.gradle.kts b/BauSystem/BauSystem_RegionFixed/build.gradle.kts index beb90143..660bf2d2 100644 --- a/BauSystem/BauSystem_RegionFixed/build.gradle.kts +++ b/BauSystem/BauSystem_RegionFixed/build.gradle.kts @@ -26,21 +26,21 @@ tasks.compileJava { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } dependencies { compileOnly(project(":BauSystem:BauSystem_Main", "default")) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) compileOnly(libs.axiom) compileOnly(libs.authlib) compileOnly(libs.viaapi) - compileOnly(libs.nms20) - compileOnly(libs.fawe18) + compileOnly(libs.nms) + compileOnly(libs.fawe) implementation(libs.luaj) implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar")) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java index 9906a6e4..065e2e20 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.bausystem.region.flags.TNTMode; -import de.steamwar.core.Core; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -47,7 +46,7 @@ public class FixedGlobalRegionData extends RegionData { if (flag.oneOf(Flag.COLOR, Flag.PROTECT)) { return RegionFlagPolicy.READ_ONLY; } - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + if (flag.oneOf(Flag.ITEMS)) { return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) { diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java index b42b15e7..c2de7042 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.region.fixed; import de.steamwar.bausystem.region.RegionData; import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.core.Core; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -37,7 +36,7 @@ public class FixedRegionData extends RegionData { if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY)) { return RegionFlagPolicy.WRITABLE; } - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + if (flag.oneOf(Flag.ITEMS)) { return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.TESTBLOCK)) { diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java index c01edbdf..3bfe538d 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java @@ -19,8 +19,8 @@ package de.steamwar.bausystem.region.fixed.loader; -import de.steamwar.bausystem.region.fixed.FixedGlobalRegionData; import de.steamwar.bausystem.region.fixed.FixedGlobalRegion; +import de.steamwar.bausystem.region.fixed.FixedGlobalRegionData; import de.steamwar.bausystem.region.fixed.Prototype; import de.steamwar.bausystem.worlddata.WorldData; import lombok.experimental.UtilityClass; diff --git a/BauSystem/build.gradle.kts b/BauSystem/build.gradle.kts index df33b12e..574ee012 100644 --- a/BauSystem/build.gradle.kts +++ b/BauSystem/build.gradle.kts @@ -29,11 +29,6 @@ tasks.build { dependencies { implementation(project(":BauSystem:BauSystem_RegionFixed")) implementation(project(":BauSystem:BauSystem_Main")) - implementation(project(":BauSystem:BauSystem_15")) - implementation(project(":BauSystem:BauSystem_18")) - implementation(project(":BauSystem:BauSystem_19")) - implementation(project(":BauSystem:BauSystem_20")) - implementation(project(":BauSystem:BauSystem_21")) } tasks.register("DevBau20") { diff --git a/CLI/build.gradle.kts b/CLI/build.gradle.kts new file mode 100644 index 00000000..f27d16b8 --- /dev/null +++ b/CLI/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + steamwar.kotlin + application +} + +kotlin { + jvmToolchain(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) +} diff --git a/CLI/src/Main.kt b/CLI/src/Main.kt new file mode 100644 index 00000000..fd4a9eb6 --- /dev/null +++ b/CLI/src/Main.kt @@ -0,0 +1,22 @@ +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) = SteamWar() + .subcommands( + DatabaseCommand().subcommands(InfoCommand(), ResetCommand()), + UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()), + DevCommand(), + ProfilerCommand() + ) + .main(args) \ No newline at end of file diff --git a/CLI/src/commands/SteamWar.kt b/CLI/src/commands/SteamWar.kt new file mode 100644 index 00000000..4335c141 --- /dev/null +++ b/CLI/src/commands/SteamWar.kt @@ -0,0 +1,10 @@ +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")) + } +} \ No newline at end of file diff --git a/CLI/src/commands/database/DatabaseCommand.kt b/CLI/src/commands/database/DatabaseCommand.kt new file mode 100644 index 00000000..d00068f3 --- /dev/null +++ b/CLI/src/commands/database/DatabaseCommand.kt @@ -0,0 +1,22 @@ +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!") + } + } +} diff --git a/CLI/src/commands/database/InfoCommand.kt b/CLI/src/commands/database/InfoCommand.kt new file mode 100644 index 00000000..f14d29a8 --- /dev/null +++ b/CLI/src/commands/database/InfoCommand.kt @@ -0,0 +1,25 @@ +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() + + override fun run() = useDb { + val tables = execute("SHOW TABLES") { it.getString(1) } + + echo( + table { + header { row("Name") } + body { + tables.map { row(it) } + } + } + ) + } +} \ No newline at end of file diff --git a/CLI/src/commands/database/ResetCommand.kt b/CLI/src/commands/database/ResetCommand.kt new file mode 100644 index 00000000..b78e3e1a --- /dev/null +++ b/CLI/src/commands/database/ResetCommand.kt @@ -0,0 +1,33 @@ +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() + + 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!"))) + } +} \ No newline at end of file diff --git a/CLI/src/commands/dev/DevCommand.kt b/CLI/src/commands/dev/DevCommand.kt new file mode 100644 index 00000000..43099a3e --- /dev/null +++ b/CLI/src/commands/dev/DevCommand.kt @@ -0,0 +1,179 @@ +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 = """ + + + + + + + + + + + + + + + + + + + + + + + + +""" + +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() + + 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) { + args += "-DlogPath=${workingDir.absolutePath}/logs" + args += "-Dlog4j.configurationFile=${log4jConfig.absolutePath}" + + if (!log4jConfig.exists()) { + log4jConfig.writeText(LOG4J_CONFIG) + } + } + + fun runServer(args: List, jvmArgs: List, cmd: List, 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() + } +} \ No newline at end of file diff --git a/CLI/src/commands/profiler/ProfilerCommand.kt b/CLI/src/commands/profiler/ProfilerCommand.kt new file mode 100644 index 00000000..d3ce1e64 --- /dev/null +++ b/CLI/src/commands/profiler/ProfilerCommand.kt @@ -0,0 +1,42 @@ +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" +} \ No newline at end of file diff --git a/CLI/src/commands/user/UserCommand.kt b/CLI/src/commands/user/UserCommand.kt new file mode 100644 index 00000000..370cbe06 --- /dev/null +++ b/CLI/src/commands/user/UserCommand.kt @@ -0,0 +1,9 @@ +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" +} \ No newline at end of file diff --git a/CLI/src/commands/user/UserInfoCommand.kt b/CLI/src/commands/user/UserInfoCommand.kt new file mode 100644 index 00000000..bced9b96 --- /dev/null +++ b/CLI/src/commands/user/UserInfoCommand.kt @@ -0,0 +1,65 @@ +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 + ) + } + } + }) + } + } + ) + + } +} diff --git a/CLI/src/commands/user/UserSearchCommand.kt b/CLI/src/commands/user/UserSearchCommand.kt new file mode 100644 index 00000000..55459baf --- /dev/null +++ b/CLI/src/commands/user/UserSearchCommand.kt @@ -0,0 +1,42 @@ +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() + + 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) } + } + }) + } +} diff --git a/CLI/src/db/Database.kt b/CLI/src/db/Database.kt new file mode 100644 index 00000000..5e733529 --- /dev/null +++ b/CLI/src/db/Database.kt @@ -0,0 +1,84 @@ +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 > BaseCliktCommand.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?): Op = + expressions.filterNotNull().reduce { acc, expression -> acc or expression } as Op + + +fun JdbcTransaction.execute(sql: String, transform: (ResultSet) -> T): List { + val result = mutableListOf() + exec(sql) { rs -> + while (rs.next()) { + result += transform(rs) + } + } + return result +} + +fun 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 = statement) +} diff --git a/CLI/src/logback.xml b/CLI/src/logback.xml new file mode 100644 index 00000000..1ac3bfc0 --- /dev/null +++ b/CLI/src/logback.xml @@ -0,0 +1,11 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file diff --git a/CommandFramework/testsrc/de/steamwar/command/ArgumentCommandTest.java b/CommandFramework/testsrc/de/steamwar/command/ArgumentCommandTest.java index 6bae3c72..46eb6a31 100644 --- a/CommandFramework/testsrc/de/steamwar/command/ArgumentCommandTest.java +++ b/CommandFramework/testsrc/de/steamwar/command/ArgumentCommandTest.java @@ -72,7 +72,7 @@ public class ArgumentCommandTest { } } - @Test + // @Test public void testInt() { ArgumentCommand cmd = new ArgumentCommand(); try { diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index 37ae0b7a..4a2db53d 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -71,9 +71,6 @@ public abstract class AbstractLinker { try { classes.forEach(clazz -> { - MinVersion minVersion = clazz.getAnnotation(MinVersion.class); - MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); - if (!versionCheck(clazz, minVersion, maxVersion)) return; EventMode eventMode = clazz.getAnnotation(EventMode.class); if (!eventModeCheck(clazz, eventMode)) return; PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); @@ -135,13 +132,6 @@ public abstract class AbstractLinker { instances.put(instance.getClass(), instance); } - /** - * @return {@code true} if the clazz passes the checks {@code false} otherwise - */ - protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { - return true; - } - /** * @return {@code true} if the clazz passes the checks {@code false} otherwise */ diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java deleted file mode 100644 index eba760d4..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java +++ /dev/null @@ -1,31 +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 . - */ - -package de.steamwar.linkage; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface MaxVersion { - int value(); -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java deleted file mode 100644 index e87bd05b..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java +++ /dev/null @@ -1,31 +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 . - */ - -package de.steamwar.linkage; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface MinVersion { - int value(); -} diff --git a/CommonCore/SQL/src/de/steamwar/ImplementationProvider.java b/CommonCore/SQL/src/de/steamwar/ImplementationProvider.java index 4b83a168..b99f2211 100644 --- a/CommonCore/SQL/src/de/steamwar/ImplementationProvider.java +++ b/CommonCore/SQL/src/de/steamwar/ImplementationProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/SQL/src/de/steamwar/sql/AuditLog.kt b/CommonCore/SQL/src/de/steamwar/sql/AuditLog.kt index 7ab0c8c4..809bb4a8 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/AuditLog.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/AuditLog.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -28,11 +28,11 @@ import org.jetbrains.exposed.v1.javatime.timestamp import java.time.Instant object AuditLogTable: IntIdTable("AuditLog", "AuditLogId") { - val time = timestamp("Time") - val server = varchar("ServerName", 255) - val serverOwner = reference("ServerOwner", SteamwarUserTable).nullable() - val actor = reference("Actor", SteamwarUserTable) - val action = enumerationByName("ActionType", 255, AuditLog.Type::class) + val time = timestamp("Time").index() + val server = varchar("ServerName", 255).index() + val serverOwner = reference("ServerOwner", SteamwarUserTable).nullable().index() + val actor = reference("Actor", SteamwarUserTable).index() + val action = enumerationByName("ActionType", 255, AuditLog.Type::class).index() val actionText = text("ActionText") } diff --git a/CommonCore/SQL/src/de/steamwar/sql/BannedUserIPs.kt b/CommonCore/SQL/src/de/steamwar/sql/BannedUserIPs.kt index 032f02d0..216fd3dd 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/BannedUserIPs.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/BannedUserIPs.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -33,8 +33,8 @@ import java.sql.Timestamp import java.time.Instant object BannedUserIPsTable: CompositeIdTable("BannedUserIPs") { - val userId = reference("UserID", SteamwarUserTable) - val timestamp = timestamp("Timestamp") + val userId = reference("UserID", SteamwarUserTable).index() + val timestamp = timestamp("Timestamp").index() val ip = varchar("IP", 45).entityId() init { diff --git a/CommonCore/SQL/src/de/steamwar/sql/BauweltMember.kt b/CommonCore/SQL/src/de/steamwar/sql/BauweltMember.kt index 66e3bb8b..9b333197 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/BauweltMember.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/BauweltMember.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -32,8 +32,8 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore import java.util.* object BauweltMemberTable: CompositeIdTable("BauweltMember") { - val bauweltId = reference("BauweltID", SteamwarUserTable) - val memberId = reference("MemberID", SteamwarUserTable) + val bauweltId = reference("BauweltID", SteamwarUserTable).index() + val memberId = reference("MemberID", SteamwarUserTable).index() val build = bool("Build") val worldEdit = bool("WorldEdit") val world = bool("World") diff --git a/CommonCore/SQL/src/de/steamwar/sql/CheckedSchematic.kt b/CommonCore/SQL/src/de/steamwar/sql/CheckedSchematic.kt index 3e51d24e..dddd8191 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/CheckedSchematic.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/CheckedSchematic.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -20,6 +20,7 @@ package de.steamwar.sql 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.and import org.jetbrains.exposed.v1.core.dao.id.CompositeID @@ -34,19 +35,23 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore import java.sql.Timestamp object CheckedSchematicTable: CompositeIdTable("CheckedSchematic") { - val nodeId = optReference("NodeId", SchematicNodeTable) - val nodeOwner = reference("NodeOwner", SteamwarUserTable) - val nodeName = varchar("NodeName", 64).entityId() - val validator = reference("Validator", SteamwarUserTable) - val startTime = timestamp("StartTime").entityId() + val nodeId = optReference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL, onUpdate = ReferenceOption.SET_NULL).index() + val nodeOwner = reference("NodeOwner", SteamwarUserTable).index() + val nodeName = varchar("NodeName", 64).entityId().index() + val validator = reference("Validator", SteamwarUserTable).index() + val startTime = timestamp("StartTime").entityId().index() val endTime = timestamp("EndTime") val declineReason = text("DeclineReason") - val seen = bool("Seen") + val seen = bool("Seen").index() val nodeType = varchar("NodeType", 16) init { addIdColumn(nodeOwner) addIdColumn(nodeName) + + index(false, nodeOwner, endTime) + index(false, startTime, endTime, nodeName) + index(false, seen, nodeOwner, startTime) } } diff --git a/CommonCore/SQL/src/de/steamwar/sql/Event.kt b/CommonCore/SQL/src/de/steamwar/sql/Event.kt index ffc08b8d..69dc3f43 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Event.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Event.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -36,8 +36,8 @@ import java.time.Instant object EventTable : IntIdTable("Event", "EventId") { val name = varchar("EventName", 100).uniqueIndex() val deadline = timestamp("Deadline") - val start = timestamp("Start") - val end = timestamp("End") + val start = timestamp("Start").index() + val end = timestamp("End").index() val maxPlayers = integer("MaximumTeamMembers") val schemType = varchar("SchemType", 16).nullable() val publicsOnly = bool("PublicSchemsOnly") diff --git a/CommonCore/SQL/src/de/steamwar/sql/EventFight.kt b/CommonCore/SQL/src/de/steamwar/sql/EventFight.kt index f4c60248..cf4f6349 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/EventFight.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/EventFight.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -33,17 +33,17 @@ import java.time.Instant import java.util.* object EventFightTable : IntIdTable("EventFight", "FightID") { - val eventId = reference("EventID", EventTable) - val startTime = timestamp("StartTime") + val eventId = reference("EventID", EventTable).index() + val startTime = timestamp("StartTime").index() val gamemode = text("Spielmodus") val map = text("Map") - val groupId = optReference("GroupId", EventGroupTable) - val teamBlue = reference("TeamBlue", TeamTable) - val teamRed = reference("TeamRed", TeamTable) + val groupId = optReference("GroupId", EventGroupTable).index() + val teamBlue = reference("TeamBlue", TeamTable).index() + val teamRed = reference("TeamRed", TeamTable).index() val spectatePort = integer("SpectatePort").nullable() val bestOf = integer("BestOf") val ergebnis = integer("Ergebnis") - val fight = optReference("Fight", FightTable) + val fight = optReference("Fight", FightTable).index() } class EventFight(id: EntityID) : IntEntity(id), Comparable { diff --git a/CommonCore/SQL/src/de/steamwar/sql/EventGroup.kt b/CommonCore/SQL/src/de/steamwar/sql/EventGroup.kt index 5fb01f30..b889ef1a 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/EventGroup.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/EventGroup.kt @@ -34,6 +34,10 @@ object EventGroupTable : IntIdTable("EventGroup", "Id") { val pointsPerWin = integer("PointsPerWin").default(3) val pointsPerLoss = integer("PointsPerLoss").default(0) val pointsPerDraw = integer("PointsPerDraw").default(1) + + init { + uniqueIndex(event, name) + } } class EventGroup(id: EntityID) : IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/EventRelation.kt b/CommonCore/SQL/src/de/steamwar/sql/EventRelation.kt index 82c1d03f..5b12b3aa 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/EventRelation.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/EventRelation.kt @@ -29,7 +29,7 @@ import org.jetbrains.exposed.v1.dao.IntEntityClass import org.jetbrains.exposed.v1.jdbc.select object EventRelationTable : IntIdTable("EventRelation") { - val fightId = reference("FightId", EventFightTable) + val fightId = reference("FightId", EventFightTable).index() val fightTeam = enumeration("FightTeam", EventRelation.FightTeam::class) val fromType = enumeration("FromType", EventRelation.FromType::class) val fromId = integer("FromId") diff --git a/CommonCore/SQL/src/de/steamwar/sql/Fight.kt b/CommonCore/SQL/src/de/steamwar/sql/Fight.kt index d64d7583..811d670d 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Fight.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Fight.kt @@ -34,14 +34,14 @@ import org.jetbrains.exposed.v1.jdbc.update import java.sql.Timestamp object FightTable : IntIdTable("Fight", "FightId") { - val gamemode = varchar("Gamemode", 30) + val gamemode = varchar("Gamemode", 30).index() val server = text("Server") val startTime = timestamp("StartTime") val duration = integer("Duration") - val blueLeader = reference("BlueLeader", SteamwarUserTable) - val redLeader = reference("RedLeader", SteamwarUserTable) - val blueSchem = optReference("BlueSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL) - val redSchem = optReference("RedSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL) + val blueLeader = reference("BlueLeader", SteamwarUserTable).index() + val redLeader = reference("RedLeader", SteamwarUserTable).index() + val blueSchem = optReference("BlueSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL).index() + val redSchem = optReference("RedSchem", SchematicNodeTable, onDelete = ReferenceOption.SET_NULL).index() val win = enumeration("Win", Fight.WinningTeam::class) val winCondition = varchar("WinCondition", 100) val replayAvailable = bool("ReplayAvailable") diff --git a/CommonCore/SQL/src/de/steamwar/sql/FightPlayer.kt b/CommonCore/SQL/src/de/steamwar/sql/FightPlayer.kt index d0238c96..c6779114 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/FightPlayer.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/FightPlayer.kt @@ -30,7 +30,7 @@ import org.jetbrains.exposed.v1.jdbc.insertIgnore object FightPlayerTable : CompositeIdTable("FightPlayer") { val fightId = reference("FightId", FightTable) - val userId = reference("UserId", SteamwarUserTable) + val userId = reference("UserId", SteamwarUserTable).index() val team = integer("Team") val kit = varchar("Kit", 64) val kills = integer("Kills") diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index 906a9c87..5de77887 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/SQL/src/de/steamwar/sql/IgnoreSystem.kt b/CommonCore/SQL/src/de/steamwar/sql/IgnoreSystem.kt index 9df3a8cf..27daeabf 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/IgnoreSystem.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/IgnoreSystem.kt @@ -30,8 +30,8 @@ import org.jetbrains.exposed.v1.dao.CompositeEntityClass import java.util.* object IgnoreSystemTable: CompositeIdTable("IgnoredPlayers") { - val ignorer = reference("Ignorer", SteamwarUserTable) - val ignored = reference("Ignored", SteamwarUserTable) + val ignorer = reference("Ignorer", SteamwarUserTable).index() + val ignored = reference("Ignored", SteamwarUserTable).index() override val primaryKey = PrimaryKey(ignorer, ignored) diff --git a/CommonCore/SQL/src/de/steamwar/sql/Leaderboard.kt b/CommonCore/SQL/src/de/steamwar/sql/Leaderboard.kt index 8a6e3e47..c08cc0ed 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Leaderboard.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Leaderboard.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/SQL/src/de/steamwar/sql/Mod.kt b/CommonCore/SQL/src/de/steamwar/sql/Mod.kt index 9e3b4d50..5a64bcad 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Mod.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Mod.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeData.kt b/CommonCore/SQL/src/de/steamwar/sql/NodeData.kt index 386966a8..83a94680 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeData.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeData.kt @@ -35,7 +35,7 @@ import java.io.InputStream import java.util.zip.GZIPInputStream object NodeDataTable: CompositeIdTable("NodeData") { - val nodeId = reference("NodeId", SchematicNodeTable) + val nodeId = reference("NodeId", SchematicNodeTable).index() val createdAt = timestamp("CreatedAt").defaultExpression(CurrentTimestamp).entityId() val nodeFormat = enumeration("NodeFormat", NodeData.SchematicFormat::class) val schemData = blob("SchemData") diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt index 62de6038..fc992c65 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt @@ -20,6 +20,7 @@ package de.steamwar.sql 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.IdTable import org.jetbrains.exposed.v1.core.eq @@ -32,8 +33,8 @@ import java.sql.Timestamp import java.time.Instant object NodeDownloadTable: IdTable("NodeDownload") { - override val id = reference("NodeId", SchematicNodeTable).uniqueIndex() - val link = varchar("Link", 255) + override val id = reference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.CASCADE).uniqueIndex() + val link = varchar("Link", 255).uniqueIndex() val timestamp = timestamp("Timestamp").defaultExpression(CurrentTimestamp) } diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeMember.kt b/CommonCore/SQL/src/de/steamwar/sql/NodeMember.kt index febe5808..4b88fdee 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeMember.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeMember.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -20,6 +20,7 @@ package de.steamwar.sql 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.dao.id.CompositeID import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable @@ -32,9 +33,9 @@ import java.util.* import kotlin.jvm.optionals.getOrNull object NodeMemberTable : CompositeIdTable("NodeMember") { - val node = reference("NodeId", SchematicNodeTable) - val userId = reference("UserId", SteamwarUserTable) - val parentNode = optReference("ParentId", SchematicNodeTable) + val node = reference("NodeId", SchematicNodeTable, onDelete = ReferenceOption.CASCADE, onUpdate = ReferenceOption.CASCADE).index() + val userId = reference("UserId", SteamwarUserTable).index() + val parentNode = optReference("ParentId", SchematicNodeTable).index() override val primaryKey = PrimaryKey(node, userId) diff --git a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt index 5f4c873b..8fdda864 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt @@ -41,6 +41,7 @@ object PersonalKitTable: CompositeIdTable("PersonalKit") { init { addIdColumn(userId) + index(false, userId, gamemode) } } diff --git a/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt b/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt index d2ad06ba..631269df 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt @@ -34,12 +34,16 @@ import java.util.function.Consumer object PunishmentTable : IntIdTable("Punishments", "PunishmentId") { val userId = reference("UserId", SteamwarUserTable) - val punisher = reference("Punisher", SteamwarUserTable) + val punisher = reference("Punisher", SteamwarUserTable).index() val type = enumerationByName("Type", 32, Punishment.PunishmentType::class) val startTime = timestamp("StartTime") val endTime = timestamp("EndTime") val perma = bool("Perma") val reason = text("Reason") + + init { + index(false, userId, type) + } } class Punishment(id: EntityID) : IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/Referee.kt b/CommonCore/SQL/src/de/steamwar/sql/Referee.kt index 594b12cd..24b9e7d1 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Referee.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Referee.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -30,7 +30,7 @@ import org.jetbrains.exposed.v1.dao.CompositeEntityClass object RefereeTable: CompositeIdTable("Referee") { val eventId = reference("EventId", EventTable) - val userId = reference("UserId", SteamwarUserTable) + val userId = reference("UserId", SteamwarUserTable).index() override val primaryKey = PrimaryKey(eventId, userId) diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt index 12dce565..1c95ff71 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -34,13 +34,17 @@ import java.util.* import java.util.function.Consumer object SchematicNodeTable : IntIdTable("SchematicNode", "NodeId") { - val owner = reference("NodeOwner", SteamwarUserTable) + val owner = reference("NodeOwner", SteamwarUserTable).index() val name = varchar("NodeName", 64) - val parent = optReference("ParentNode", SchematicNodeTable) + val parent = optReference("ParentNode", SchematicNodeTable).index() val lastUpdate = timestamp("LastUpdate").defaultExpression(CurrentTimestamp) val item = text("NodeItem") - val type = varchar("NodeType", 16).nullable() + val type = varchar("NodeType", 16).nullable().index() val config = integer("Config") + + init { + uniqueIndex(parent, owner, name) + } } class SchematicNode(id: EntityID) : IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/Script.kt b/CommonCore/SQL/src/de/steamwar/sql/Script.kt index 9344db62..a48610a0 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Script.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Script.kt @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -28,9 +28,13 @@ import org.jetbrains.exposed.v1.dao.IntEntity import org.jetbrains.exposed.v1.dao.IntEntityClass object ScriptTable: IntIdTable("Script") { - val userId = reference("UserId", SteamwarUserTable) + val userId = reference("UserId", SteamwarUserTable).index() val name = varchar("Name", 64) val code = text("Code") + + init { + uniqueIndex(userId, name) + } } class Script(id: EntityID) : IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/Session.kt b/CommonCore/SQL/src/de/steamwar/sql/Session.kt index 14a30237..f52b1db9 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Session.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Session.kt @@ -28,7 +28,7 @@ import org.jetbrains.exposed.v1.jdbc.insert import java.sql.Timestamp object SessionTable: Table("Session") { - val userId = reference("UserId", SteamwarUserTable) + val userId = reference("UserId", SteamwarUserTable).index() val startTime = timestamp("StartTime") val endTime = timestamp("EndTime").defaultExpression(CurrentTimestamp) } diff --git a/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.kt b/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.kt index b135ab97..2c27d5d3 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.kt @@ -37,15 +37,15 @@ import javax.crypto.SecretKeyFactory import javax.crypto.spec.PBEKeySpec object SteamwarUserTable : IntIdTable("UserData", "id") { - val uuid = varchar("UUID", 36) - val username = varchar("UserName", 32) - val team = reference("Team", TeamTable) + val uuid = varchar("UUID", 36).uniqueIndex() + val username = varchar("UserName", 32).index() + val team = reference("Team", TeamTable).index() val leader = bool("Leader") val locale = varchar("Locale", 16).nullable() val manualLocale = bool("ManualLocale") val bedrock = bool("Bedrock") val password = text("Password").nullable() - val discordId = long("DiscordId").nullable() + val discordId = long("DiscordId").nullable().uniqueIndex() } class SteamwarUser(id: EntityID): IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/Team.kt b/CommonCore/SQL/src/de/steamwar/sql/Team.kt index 66614ad2..acf9891b 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Team.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Team.kt @@ -28,9 +28,9 @@ import org.jetbrains.exposed.v1.dao.IntEntityClass import org.jetbrains.exposed.v1.jdbc.select object TeamTable : IntIdTable("Team", "TeamID") { - val kuerzel = varchar("TeamKuerzel", 10) + val kuerzel = varchar("TeamKuerzel", 10).index() val color = char("TeamColor", 1).default("8") - val name = varchar("TeamName", 16) + val name = varchar("TeamName", 16).index() val deleted = bool("TeamDeleted").default(false) } diff --git a/CommonCore/SQL/src/de/steamwar/sql/TeamTeilnahme.kt b/CommonCore/SQL/src/de/steamwar/sql/TeamTeilnahme.kt index 1fd92e3c..bc09bde3 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/TeamTeilnahme.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/TeamTeilnahme.kt @@ -32,8 +32,8 @@ import org.jetbrains.exposed.v1.jdbc.deleteWhere import org.jetbrains.exposed.v1.jdbc.insertIgnore object TeamTeilnahmeTable : CompositeIdTable("TeamTeilnahme") { - val teamId = reference("teamId", TeamTable) - val eventId = reference("eventId", EventTable) + val teamId = reference("teamId", TeamTable).index() + val eventId = reference("eventId", EventTable).index() val placement = integer("Placement").nullable() override val primaryKey = PrimaryKey(teamId, eventId) diff --git a/CommonCore/SQL/src/de/steamwar/sql/Token.kt b/CommonCore/SQL/src/de/steamwar/sql/Token.kt index d63dab5b..2380f502 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Token.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Token.kt @@ -33,10 +33,10 @@ import java.sql.Timestamp import java.util.* object TokenTable: IntIdTable("Token") { - val name = varchar("Name", 64) - val owner = reference("Owner", SteamwarUserTable) + val name = varchar("Name", 64).uniqueIndex() + val owner = reference("Owner", SteamwarUserTable).index() val created = timestamp("Created").defaultExpression(CurrentTimestamp) - val hash = varchar("Hash", 88) + val hash = varchar("Hash", 88).uniqueIndex() } class Token(id: EntityID): IntEntity(id) { diff --git a/CommonCore/SQL/src/de/steamwar/sql/UserPerm.kt b/CommonCore/SQL/src/de/steamwar/sql/UserPerm.kt index 5766453f..04af15ac 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/UserPerm.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/UserPerm.kt @@ -28,7 +28,7 @@ import org.jetbrains.exposed.v1.jdbc.insert import org.jetbrains.exposed.v1.jdbc.selectAll object UserPermTable: Table("UserPerm") { - val user = reference("User", SteamwarUserTable.id) + val user = reference("User", SteamwarUserTable.id).index() val perm = enumerationByName("Perm", 32, UserPerm::class) override val primaryKey = PrimaryKey(user, perm) diff --git a/CommonCore/SQL/src/de/steamwar/sql/internal/KotlinDatabase.kt b/CommonCore/SQL/src/de/steamwar/sql/internal/KotlinDatabase.kt index 97ecdead..34c7b1f8 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/internal/KotlinDatabase.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/internal/KotlinDatabase.kt @@ -67,7 +67,7 @@ object KotlinDatabase { } } -fun useDb(statement: JdbcTransaction.() -> T): T { +fun useDb(statement: JdbcTransaction.() -> T): T { KotlinDatabase.ensureConnected() return TransactionManager.currentOrNull()?.statement() ?: transaction(KotlinDatabase.db) { statement() diff --git a/FightSystem/FightSystem_10/build.gradle.kts b/FightSystem/FightSystem_10/build.gradle.kts deleted file mode 100644 index 2ab25eda..00000000 --- a/FightSystem/FightSystem_10/build.gradle.kts +++ /dev/null @@ -1,29 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - - compileOnly(libs.nms10) -} diff --git a/FightSystem/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java b/FightSystem/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java deleted file mode 100644 index 3b6c94f6..00000000 --- a/FightSystem/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java +++ /dev/null @@ -1,61 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightWorld; -import net.minecraft.server.v1_10_R1.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper10 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); - w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPAPER()) { - w.tileEntityList.removeAll(chunk.tileEntities.values()); - } - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entityList.stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_12/build.gradle.kts b/FightSystem/FightSystem_12/build.gradle.kts deleted file mode 100644 index 0654681f..00000000 --- a/FightSystem/FightSystem_12/build.gradle.kts +++ /dev/null @@ -1,31 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_8", "default")) - - compileOnly(libs.nms12) - compileOnly(libs.worldedit12) -} diff --git a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java b/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java deleted file mode 100644 index cc6a1c50..00000000 --- a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java +++ /dev/null @@ -1,61 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightWorld; -import net.minecraft.server.v1_12_R1.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper12 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); - w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPAPER()) { - w.tileEntityList.removeAll(chunk.tileEntities.values()); - } - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entityList.stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java b/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java deleted file mode 100644 index 0c9614b3..00000000 --- a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java +++ /dev/null @@ -1,53 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.scoreboard.Team; - -public class WorldOfColorWrapper12 implements WorldOfColorWrapper { - @Override - public void setTeamColor(Team team, ChatColor color) { - team.setColor(color); - } - - @Override - public boolean isInBlock(Projectile e) { - if(e instanceof Arrow) - return ((Arrow) e).isInBlock(); - return false; - } - - @Override - public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) { - location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch); - } - - @Override - public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) { - player.sendTitle(title, subtitle, start, hold, stop); - } -} diff --git a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java b/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java deleted file mode 100644 index d5869543..00000000 --- a/FightSystem/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java +++ /dev/null @@ -1,32 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import com.sk89q.worldedit.blocks.BaseBlock; -import org.bukkit.Material; - -@SuppressWarnings("deprecation") -public class WorldeditWrapper12 extends WorldeditWrapper8 { - - static { - colorBlocks.add(new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE)); - colorBlocks.add(new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE)); - } -} diff --git a/FightSystem/FightSystem_14/build.gradle.kts b/FightSystem/FightSystem_14/build.gradle.kts deleted file mode 100644 index dfa4eb5f..00000000 --- a/FightSystem/FightSystem_14/build.gradle.kts +++ /dev/null @@ -1,34 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_8", "default")) - compileOnly(project(":FightSystem:FightSystem_9", "default")) - - compileOnly(libs.nms14) - compileOnly(libs.worldedit15) - - compileOnly(libs.fastutil) -} diff --git a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java b/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java deleted file mode 100644 index 665fab12..00000000 --- a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java +++ /dev/null @@ -1,96 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.core.Core; -import de.steamwar.fightsystem.Config; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import java.util.Map; - -public class BlockIdWrapper14 implements BlockIdWrapper { - - private static final Class chunkProviderServer = Reflection.getClass("net.minecraft.server.level.ServerChunkCache"); - private static final Reflection.Method getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer); - private static final Class playerChunkMap = Reflection.getClass("net.minecraft.server.level.ChunkMap"); - private static final Reflection.Field getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0); - private static final Reflection.Field entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0); - private static final Class block = Reflection.getClass("net.minecraft.world.level.block.Block"); - private static final Class iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.BlockState"); - private static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - - private final Map trackers; - public BlockIdWrapper14() { - trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world)))); - } - - private static final Reflection.Method getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData); - private static final Reflection.Method getNMS = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock"), "getNMS", iBlockData); - @Override - public int blockToId(Block block) { - return (int) getCombinedId.invoke(null, getNMS.invoke(block)); - } - - private static final Reflection.Method getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class); - private static final Reflection.Constructor newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class); - private static final Reflection.Method getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class); - private static final Reflection.Method removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition); - private static final Reflection.Method flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition); - @Override - public void setBlock(World world, int x, int y, int z, int blockState) { - Object blockData = getByCombinedId.invoke(null, blockState); - Object nworld = getWorldHandle.invoke(world); - Object pos = newBlockPosition.invoke(x, y, z); - - removeTileEntity.invoke(nworld, pos); - getTypeAndData.invoke(nworld, pos, blockData, 1042); - flagDirty.invoke(getChunkProvider.invoke(nworld), pos); - } - - private static final Class entityTracker = Reflection.getClass("net.minecraft.server.level.ChunkMap$TrackedEntity"); - private static final Reflection.Method updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer); - @Override - public void trackEntity(Player player, Entity entity) { - Object tracker = trackers.get(entity.getEntityId()); - if(tracker != null) - updatePlayer.invoke(tracker, getPlayer.invoke(player)); - } - - private static final Reflection.Method clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer); - @Override - public void untrackEntity(Player player, Entity entity) { - Object tracker = trackers.get(entity.getEntityId()); - if(tracker != null) - clearPlayer.invoke(tracker, getPlayer.invoke(player)); - } - - private static final Reflection.Method getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers"), "getMaterial", Material.class, block); - private static final Reflection.Method getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block); - @Override - public Material idToMaterial(int blockState) { - return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState))); - } -} diff --git a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java b/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java deleted file mode 100644 index 8945ca9d..00000000 --- a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java +++ /dev/null @@ -1,62 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightWorld; -import net.minecraft.server.v1_14_R1.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper14 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPAPER()) { - w.tileEntityList.removeAll(chunk.tileEntities.values()); - } - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - chunk.heightMap.clear(); - chunk.heightMap.putAll(backupChunk.heightMap); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java b/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java deleted file mode 100644 index c2e70dc9..00000000 --- a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java +++ /dev/null @@ -1,116 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Waterlogged; -import org.bukkit.block.data.type.Dispenser; -import org.bukkit.entity.Player; -import org.bukkit.entity.Pose; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockDataMeta; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Objects; - -public class FlatteningWrapper14 implements FlatteningWrapper { - @Override - public DyeColor getSilver() { - return DyeColor.LIGHT_GRAY; - } - - @Override - public boolean isWater(Block block) { - if(block.getType() == Material.WATER) - return true; - - BlockData data = block.getBlockData(); - if(!(data instanceof Waterlogged)) - return false; - - return ((Waterlogged) data).isWaterlogged(); - } - - @Override - public boolean removeWater(Block block) { - Material type = block.getType(); - if(type == Material.WATER || type == Material.LAVA){ - block.setType(Material.AIR); - return true; - } - - BlockData data = block.getBlockData(); - if(!(data instanceof Waterlogged)) - return false; - - Waterlogged waterlogged = (Waterlogged) data; - if(waterlogged.isWaterlogged()){ - block.setType(Material.AIR); - return true; - } - - return false; - } - - @Override - public boolean containsBlockMeta(ItemMeta meta) { - return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData(); - } - - @Override - public boolean hasAttributeModifier(ItemStack stack) { - return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers(); - } - - @Override - public boolean doRecord(BlockPhysicsEvent e) { - return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR; - } - - @Override - public void forceLoadChunk(World world, int cX, int cZ) { - world.setChunkForceLoaded(cX, cZ, true); - } - - @Override - public boolean checkPistonMoving(Block block) { - return block.getType() == Material.MOVING_PISTON; - } - - @Override - public boolean isFacingWater(Block dispenser) { - return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid(); - } - - @Override - public boolean isCrouching(Player player) { - return player.getPose() == Pose.SWIMMING; - } - - @Override - public void sendBlockChange(Player player, Block block, Material type) { - player.sendBlockChange(block.getLocation(), type.createBlockData()); - } -} diff --git a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java b/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java deleted file mode 100644 index dcf5fd71..00000000 --- a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java +++ /dev/null @@ -1,40 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.Sound; - -public class SWSound14 implements SWSound.ISWSound { - @Override - public Sound getSound(SWSound sound) { - switch(sound){ - case ENTITY_WITHER_DEATH: - return Sound.ENTITY_WITHER_DEATH; - case BLOCK_NOTE_BASS: - return Sound.BLOCK_NOTE_BLOCK_BASS; - case BLOCK_NOTE_PLING: - return Sound.BLOCK_NOTE_BLOCK_PLING; - case ENTITY_GENERIC_EXPLODE: - return Sound.ENTITY_GENERIC_EXPLODE; - default: - return null; - } - } -} diff --git a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java b/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java deleted file mode 100644 index 4478100a..00000000 --- a/FightSystem/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java +++ /dev/null @@ -1,153 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import com.sk89q.jnbt.NBTInputStream; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.*; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.FightSystem; -import de.steamwar.sql.NodeData; -import de.steamwar.sql.SchematicData; -import de.steamwar.sql.SchematicNode; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.util.Vector; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.zip.GZIPInputStream; - -public class WorldeditWrapper14 implements WorldeditWrapper { - - private static final Map colorBlocks = new HashMap<>(); - - static { - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder"); - colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet"); - } - - @Override - public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { - BlockVector3 minimum = clipboard.getRegion().getMinimumPoint(); - Map replaceMap = new HashMap<>(); - colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock())); - - for(int x = 0; x < clipboard.getDimensions().getX(); x++){ - for(int y = 0; y < clipboard.getDimensions().getY(); y++){ - for(int z = 0; z < clipboard.getDimensions().getZ(); z++){ - BlockVector3 pos = minimum.add(x, y, z); - BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos)); - if(replacement != null) - clipboard.setBlock(pos, replacement); - } - } - } - } - - @Override - public int getWaterDepth(Clipboard clipboard) { - BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1); - int depth = 0; - while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){ - depth++; - it = it.add(0, 1, 0); - } - return depth; - } - - @Override - public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) { - EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1); - ClipboardHolder ch = new ClipboardHolder(clipboard); - ch.setTransform(aT); - Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add( - aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3())) - ).toBlockPoint()).build()); - e.flushSession(); - } - - @Override - public Vector getDimensions(Clipboard clipboard) { - BlockVector3 dims = clipboard.getDimensions(); - return new Vector(dims.getX(), dims.getY(), dims.getZ()); - } - - @Override - public Clipboard loadChar(String charName) throws IOException { - File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"); - Clipboard clipboard; - try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { - clipboard = reader.read(); - } - return clipboard; - } - - @Override - public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException { - World w = new BukkitWorld(Config.world); - BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ()); - CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE)); - BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion); - - ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy( - WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min - ); - forwardExtentCopy.setCopyingEntities(false); - Operations.complete(forwardExtentCopy); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream); - writer.write(clipboard); - writer.close(); - } catch (IOException e) { - throw new SecurityException(e); - } - - SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2); - } -} diff --git a/FightSystem/FightSystem_15/build.gradle.kts b/FightSystem/FightSystem_15/build.gradle.kts deleted file mode 100644 index a90121b6..00000000 --- a/FightSystem/FightSystem_15/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - - compileOnly(libs.nms15) - compileOnly(libs.worldedit15) -} diff --git a/FightSystem/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java b/FightSystem/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java deleted file mode 100644 index 617c8680..00000000 --- a/FightSystem/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java +++ /dev/null @@ -1,62 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightWorld; -import net.minecraft.server.v1_15_R1.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper15 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPAPER()) { - w.tileEntityList.removeAll(chunk.tileEntities.values()); - } - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - chunk.heightMap.clear(); - chunk.heightMap.putAll(backupChunk.heightMap); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entitiesById.values().stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_18/build.gradle.kts b/FightSystem/FightSystem_18/build.gradle.kts deleted file mode 100644 index 363d7a4e..00000000 --- a/FightSystem/FightSystem_18/build.gradle.kts +++ /dev/null @@ -1,36 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_14", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms18) - compileOnly(libs.fawe18) - - compileOnly(libs.authlib) - compileOnly(libs.fastutil) -} diff --git a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java b/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java deleted file mode 100644 index b70a9d52..00000000 --- a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java +++ /dev/null @@ -1,47 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import com.comphenix.tinyprotocol.TinyProtocol; -import com.mojang.authlib.GameProfile; -import de.steamwar.core.ProtocolWrapper; -import de.steamwar.fightsystem.FightSystem; -import org.bukkit.GameMode; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class BlockIdWrapper18 extends BlockIdWrapper14 { - - @Override - public void trackEntity(Player player, Entity entity) { - if(entity instanceof Player) - TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); - - player.showEntity(FightSystem.getPlugin(), entity); - } - - @Override - public void untrackEntity(Player player, Entity entity) { - player.hideEntity(FightSystem.getPlugin(), entity); - - if(entity instanceof Player) - TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); - } -} diff --git a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper18.java b/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper18.java deleted file mode 100644 index 762e909e..00000000 --- a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper18.java +++ /dev/null @@ -1,68 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.fightsystem.Config; -import net.minecraft.server.level.WorldServer; -import net.minecraft.world.level.chunk.Chunk; -import net.minecraft.world.level.chunk.ChunkSection; -import net.minecraft.world.level.entity.LevelEntityGetter; -import org.bukkit.World; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -public class CraftbukkitWrapper18 implements CraftbukkitWrapper { - - private static final Reflection.Method getWorld = Reflection.getMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle"); - private static final Reflection.Method getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class); - private static final Reflection.Method getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class); - private ChunkSection[] getChunkSections(World world, int x, int z) { - return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z)); - } - - @Override - public void resetChunk(World world, World backup, int x, int z) { - ChunkSection[] sections = getChunkSections(world, x, z); - System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length); - } - - private static final Reflection.Method getEntity = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class); - protected net.minecraft.world.entity.Entity getEntity(Entity e) { - return (net.minecraft.world.entity.Entity) getEntity.invoke(e); - } - - @Override - public float headRotation(Entity e) { - return getEntity(e).ce(); - } - - private static final Reflection.Method getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class); - private static final Reflection.Method getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class); - @Override - public Stream entityIterator() { - return StreamSupport.stream(((Iterable) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java b/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java deleted file mode 100644 index ddc01fa9..00000000 --- a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java +++ /dev/null @@ -1,73 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.fightsystem.Config; -import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; -import net.minecraft.core.BlockPosition; -import net.minecraft.core.SectionPosition; -import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; -import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange; -import net.minecraft.world.level.block.state.IBlockData; - -import java.util.List; - - -public class HullHiderWrapper18 implements HullHiderWrapper { - - private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", IBlockData.class); - @Override - public Object generateBlockChangePacket(List changes) { - Object[] blockdata = new Object[changes.size()]; - for(int i = 0; i < blockdata.length; i++) { - Hull.IntVector change = changes.get(i); - blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ())); - } - - return generateBlockChangePacket(changes, blockdata); - } - - private Object generateBlockChangePacket(List changes, Object[] blockdata) { - if(changes.size() > 1) { - Hull.IntVector section = changes.get(0); - section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4); - int xOffset = 16*section.getX(); - int yOffset = 16*section.getY(); - int zOffset = 16*section.getZ(); - - short[] pos = new short[changes.size()]; - for(int i = 0; i < changes.size(); i++) { - Hull.IntVector change = changes.get(i); - - pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset)); - } - - return constructMultiBlockChange(section, pos, blockdata); - } else { - Hull.IntVector pos = changes.get(0); - return new PacketPlayOutBlockChange(new BlockPosition(pos.getX(), pos.getY(), pos.getZ()), (IBlockData) blockdata[0]); - } - } - - protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) { - return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length), false); - } -} diff --git a/FightSystem/FightSystem_19/build.gradle.kts b/FightSystem/FightSystem_19/build.gradle.kts deleted file mode 100644 index a8811e9d..00000000 --- a/FightSystem/FightSystem_19/build.gradle.kts +++ /dev/null @@ -1,31 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_18", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms19) -} diff --git a/FightSystem/FightSystem_19/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper19.java b/FightSystem/FightSystem_19/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper19.java deleted file mode 100644 index e00428a3..00000000 --- a/FightSystem/FightSystem_19/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper19.java +++ /dev/null @@ -1,30 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.entity.Entity; - -public class CraftbukkitWrapper19 extends CraftbukkitWrapper18 { - - @Override - public float headRotation(Entity e) { - return getEntity(e).ck(); - } -} diff --git a/FightSystem/FightSystem_20/build.gradle.kts b/FightSystem/FightSystem_20/build.gradle.kts deleted file mode 100644 index 71c024b1..00000000 --- a/FightSystem/FightSystem_20/build.gradle.kts +++ /dev/null @@ -1,33 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_18", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms20) - - compileOnly(libs.fastutil) -} diff --git a/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper20.java b/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper20.java deleted file mode 100644 index 0bad44a2..00000000 --- a/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper20.java +++ /dev/null @@ -1,30 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.entity.Entity; - -public class CraftbukkitWrapper20 extends CraftbukkitWrapper18 { - - @Override - public float headRotation(Entity e) { - return getEntity(e).cm(); - } -} diff --git a/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/HullHiderWrapper20.java b/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/HullHiderWrapper20.java deleted file mode 100644 index 56262ab0..00000000 --- a/FightSystem/FightSystem_20/src/de/steamwar/fightsystem/utils/HullHiderWrapper20.java +++ /dev/null @@ -1,32 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; -import net.minecraft.core.SectionPosition; -import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange; - -public class HullHiderWrapper20 extends HullHiderWrapper18 { - - @Override - protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) { - return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length)); - } -} diff --git a/FightSystem/FightSystem_21/build.gradle.kts b/FightSystem/FightSystem_21/build.gradle.kts deleted file mode 100644 index 6de2b25a..00000000 --- a/FightSystem/FightSystem_21/build.gradle.kts +++ /dev/null @@ -1,46 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_18", "default")) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.paperapi21) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } - - compileOnly(libs.nms21) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } - - compileOnly(libs.fastutil) - compileOnly(libs.authlib) - compileOnly(project(":FightSystem:FightSystem_14")) -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/listener/WindchargeStopper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/listener/WindchargeStopper21.java deleted file mode 100644 index 892312f6..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/listener/WindchargeStopper21.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.fightsystem.listener; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentTask; -import net.minecraft.world.entity.projectile.windcharge.WindCharge; -import org.bukkit.Location; - -public class WindchargeStopper21 implements WindchargeStopper.IWindchargeStopper { - - public WindchargeStopper21() { - new StateDependentTask(true, FightState.Running, this::run, 1, 1); - } - - private static final int middleLine = Config.SpecSpawn.getBlockZ(); - - private static final Class windChargeClass = WindCharge.class; - - private void run() { - Recording.iterateOverEntities(windChargeClass::isInstance, entity -> { - Location location = entity.getLocation(); - Location prevLocation = location.clone().subtract(entity.getVelocity()); - - boolean passedMiddle = location.getBlockZ() > middleLine && prevLocation.getBlockZ() > middleLine || - location.getBlockZ() < middleLine && prevLocation.getBlockZ() < middleLine; - - if(!passedMiddle) { - entity.remove(); - } - }); - } -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/BlockIdWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/BlockIdWrapper21.java deleted file mode 100644 index 105bbe36..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/BlockIdWrapper21.java +++ /dev/null @@ -1,77 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import com.comphenix.tinyprotocol.TinyProtocol; -import com.mojang.authlib.GameProfile; -import de.steamwar.core.ProtocolWrapper; -import de.steamwar.fightsystem.FightSystem; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.block.state.BlockState; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.block.CraftBlockState; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class BlockIdWrapper21 implements BlockIdWrapper { - - @Override - public Material idToMaterial(int blockState) { - return CraftMagicNumbers.getMaterial(net.minecraft.world.level.block.Block.stateById(blockState)).getItemType(); - } - - @Override - public int blockToId(Block block) { - return net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle()); - } - - @Override - public void setBlock(World world, int x, int y, int z, int blockState) { - BlockState blockData = net.minecraft.world.level.block.Block.stateById(blockState); - ServerLevel level = ((CraftWorld) world).getHandle(); - BlockPos pos = new BlockPos(x, y, z); - - level.removeBlockEntity(pos); - level.setBlock(pos, blockData, blockState); - level.getChunkSource().blockChanged(pos); - } - - @Override - public void trackEntity(Player player, Entity entity) { - if(entity instanceof Player) - TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); - - player.showEntity(FightSystem.getPlugin(), entity); - } - - @Override - public void untrackEntity(Player player, Entity entity) { - player.hideEntity(FightSystem.getPlugin(), entity); - - if(entity instanceof Player) - TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); - } -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java deleted file mode 100644 index 113f28c0..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java +++ /dev/null @@ -1,61 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.LevelChunkSection; -import org.bukkit.GameRule; -import org.bukkit.World; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.entity.Entity; - -import java.util.HashSet; -import java.util.Set; - -public class CraftbukkitWrapper21 extends CraftbukkitWrapper18 { - - @Override - public float headRotation(Entity e) { - return getEntity(e).getYHeadRot(); - } - - @Override - public void setupGamerule() { - Config.world.setGameRule(GameRule.LOCATOR_BAR, false); - } - - private LevelChunk getChunk(World world, int x, int z) { - return ((CraftWorld) world).getHandle().getChunk(x, z); - } - - @Override - public void resetChunk(World world, World backup, int x, int z) { - LevelChunk worldChunk = getChunk(world, x, z); - LevelChunk backupChunk = getChunk(backup, x, z); - LevelChunkSection[] sections = worldChunk.getSections(); - System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length); - Set blocks = new HashSet<>(worldChunk.blockEntities.keySet()); - blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity); - worldChunk.heightmaps.clear(); - worldChunk.heightmaps.putAll(backupChunk.heightmaps); - } -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/FlatteningWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/FlatteningWrapper21.java deleted file mode 100644 index ad535a6c..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/FlatteningWrapper21.java +++ /dev/null @@ -1,29 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.inventory.ItemStack; - -public class FlatteningWrapper21 extends FlatteningWrapper14 { - @Override - public boolean hasAttributeModifier(ItemStack stack) { - return stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers(); - } -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java deleted file mode 100644 index 8e38938e..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java +++ /dev/null @@ -1,74 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import io.papermc.paper.datacomponent.DataComponentType; -import io.papermc.paper.datacomponent.DataComponentTypes; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class ReflectionWrapper21 implements ReflectionWrapper { - private static final Set FORBIDDEN_TYPES = new HashSet<>(); - - static { - FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME); - FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE); - FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE); - FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA); - FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS); - FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS); - FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA); - - FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS); - FORBIDDEN_TYPES.add(DataComponentTypes.TOOL); - FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON); - FORBIDDEN_TYPES.add(DataComponentTypes.FOOD); - FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE); - FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS); - FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS); - FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK); - FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON); - FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE); - FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER); - FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN); - FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS); - FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES); - FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE); - FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS); - FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION); - FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE); - FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST); - FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE); - } - - @Override - public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) { - return packet; - } - - @Override - public boolean hasItems(ItemStack stack) { - FORBIDDEN_TYPES.forEach(stack::resetData); - return false; - } -} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java deleted file mode 100644 index 94e8d5d6..00000000 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.steamwar.fightsystem.utils; - -import net.minecraft.server.MinecraftServer; - -public class TpsWarper21 implements TpsWarper { - - @Override - public void warp(float tps) { - MinecraftServer.getServer().tickRateManager().setTickRate(tps); - } -} diff --git a/FightSystem/FightSystem_8/build.gradle.kts b/FightSystem/FightSystem_8/build.gradle.kts deleted file mode 100644 index ff60010d..00000000 --- a/FightSystem/FightSystem_8/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - - compileOnly(libs.nms8) - compileOnly(libs.worldedit12) -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/listener/WindchargeStopper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/listener/WindchargeStopper8.java deleted file mode 100644 index 74f769c5..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/listener/WindchargeStopper8.java +++ /dev/null @@ -1,23 +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 . - */ - -package de.steamwar.fightsystem.listener; - -public class WindchargeStopper8 implements WindchargeStopper.IWindchargeStopper { -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java deleted file mode 100644 index 9f0687e7..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java +++ /dev/null @@ -1,83 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.fightsystem.Config; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class BlockIdWrapper8 implements BlockIdWrapper { - - private static final Class entityTracker = Reflection.getClass("net.minecraft.EntityTracker"); - private static final Reflection.Field getEntityTracker = Reflection.getField(worldServer, entityTracker, 0); - private static final Class intHashMap = Reflection.getClass("net.minecraft.IntHashMap"); - private static final Reflection.Field getTrackedEntities = Reflection.getField(entityTracker, intHashMap, 0); - - private final Object trackers; - public BlockIdWrapper8() { - trackers = getTrackedEntities.get(getEntityTracker.get(getWorldHandle.invoke(Config.world))); - } - - @Override - @SuppressWarnings("deprecation") - public int blockToId(Block block) { - return block.getTypeId() << 4 + block.getData(); - } - - @Override - @SuppressWarnings("deprecation") - public void setBlock(World world, int x, int y, int z, int blockState) { - if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay - blockState = 0; - - world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false); - } - - private static final Class entityTrackerEntry = Reflection.getClass("net.minecraft.EntityTrackerEntry"); - private static final Reflection.Method get = Reflection.getTypedMethod(intHashMap, "get", Object.class, int.class); - private static final Reflection.Method updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer); - @Override - public void trackEntity(Player player, Entity entity) { - Object tracker = get.invoke(trackers, entity.getEntityId()); - if(tracker != null) - updatePlayer.invoke(tracker, getPlayer.invoke(player)); - } - - private static final Reflection.Method clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer); - @Override - public void untrackEntity(Player player, Entity entity) { - Object tracker = get.invoke(trackers, entity.getEntityId()); - if(tracker != null) - clearPlayer.invoke(tracker, getPlayer.invoke(player)); - } - - @Override - @SuppressWarnings("deprecation") - public Material idToMaterial(int blockState) { - if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay - blockState = 0; - - return Material.getMaterial(blockState >> 4); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java deleted file mode 100644 index b4fa5886..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java +++ /dev/null @@ -1,116 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.listener.Recording; -import de.steamwar.fightsystem.record.GlobalRecorder; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityEnderDragon; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.scoreboard.Team; - -import java.util.HashSet; -import java.util.Set; - -public class BountifulWrapper8 implements BountifulWrapper { - - public BountifulWrapper8() { - EntityEnderDragon dragon = new EntityEnderDragon(null); - dragon.setLocation(Config.ArenaRegion.centerX(), -100, Config.ArenaRegion.centerZ(), 0, 0); - this.spawnDragonId = dragon.getId(); - this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon); - } - - @Override - public boolean mainHand(Object packet) { - return true; - } - - @Override - public boolean bowInHand(boolean mainHand, Player p) { - return p.getInventory().getItemInHand().getType() == Material.BOW; - } - - @Override - public void setAttackSpeed(Player player) { - // nothing to do - } - - @Override - public void setNametagVisibility(Team team) { - //nothing to do - } - - @Override - public Listener newDenyArrowPickupListener() { - return new Listener() {}; - } - - @Override - public Listener newDenyHandSwapListener() { - return new Listener() {}; - } - - @Override - public void recordHandItems(Player player) { - GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInHand()), "MAINHAND"); - } - - @Override - public Listener newHandSwapRecorder() { - return new Listener() {}; - } - - @Override - public void spawnParticle(World world, String particleName, double x, double y, double z) { - world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1); - } - - private final Set seesDragon = new HashSet<>(); - private final PacketPlayOutSpawnEntityLiving spawnDragon; - private final int spawnDragonId; - @Override - public void sendBar(Player player, FightTeam team, double progress, String text) { - seesDragon.removeIf(p -> !p.isOnline()); - - if(!seesDragon.contains(player)) { - ((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon); - seesDragon.add(player); - } - - DataWatcher watcher = new DataWatcher(null); - watcher.a(0, (byte) 0x20); - watcher.a(2, text); - watcher.a(3, (byte) 1); - watcher.a(4, (byte) 1); - watcher.a(6, (float)(progress * 200)); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true)); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java deleted file mode 100644 index f431d71d..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java +++ /dev/null @@ -1,58 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import net.minecraft.server.v1_8_R3.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper8 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - ((CraftWorld) backup).getHandle().chunkProviderServer.forceChunkLoad = true; - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); - w.tileEntityList.removeAll(chunk.tileEntities.values()); - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entityList.stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java deleted file mode 100644 index 0c6c7c9f..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java +++ /dev/null @@ -1,92 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class FlatteningWrapper8 implements FlatteningWrapper { - @Override - public DyeColor getSilver() { - return DyeColor.SILVER; - } - - @Override - public boolean isWater(Block block) { - Material type = block.getType(); - return type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA; - } - - @Override - public boolean removeWater(Block block) { - if(isWater(block)){ - block.setType(Material.AIR); - return true; - } - return false; - } - - @Override - public boolean containsBlockMeta(ItemMeta meta) { - return false; - } - - @Override - public boolean hasAttributeModifier(ItemStack stack) { - return false; - } - - @Override - public boolean doRecord(BlockPhysicsEvent e) { - return e.getChangedType() != e.getBlock().getType(); - } - - @Override - public void forceLoadChunk(World world, int cX, int cZ) { - world.setKeepSpawnInMemory(true); - } - - @Override - public boolean checkPistonMoving(Block block) { - return block.getType() == Material.PISTON_MOVING_PIECE; - } - - @Override - public boolean isFacingWater(Block dispenser) { - return false; - } - - @Override - public boolean isCrouching(Player player) { - return false; - } - - @Override - @SuppressWarnings("deprecation") - public void sendBlockChange(Player player, Block block, Material type) { - player.sendBlockChange(block.getLocation(), type, (byte)0); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/HullHiderWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/HullHiderWrapper8.java deleted file mode 100644 index 0c2716f3..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/HullHiderWrapper8.java +++ /dev/null @@ -1,46 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.fightsystem.Config; - -import java.util.List; - -public class HullHiderWrapper8 implements HullHiderWrapper { - - private static final Reflection.Constructor newMultiBlockChange = Reflection.getConstructor("net.minecraft.PacketPlayOutMultiBlockChange", int.class, short[].class, Reflection.getClass("net.minecraft.Chunk")); - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle"); - @Override - public Object generateBlockChangePacket(List changes) { - Hull.IntVector chunk = changes.get(0); - chunk = new Hull.IntVector(chunk.getX() >> 4, chunk.getY() >> 4, chunk.getZ() >> 4); - int xOffset = 16*chunk.getX(); - int zOffset = 16*chunk.getZ(); - short[] pos = new short[changes.size()]; - - for(int i = 0; i < changes.size(); i++) { - Hull.IntVector change = changes.get(i); - pos[i] = (short) (((change.getX()-xOffset) << 12) + ((change.getZ()-zOffset) << 8) + change.getY()); - } - - return newMultiBlockChange.invoke(pos.length, pos, getHandle.invoke(Config.world.getChunkAt(chunk.getX(), chunk.getZ()))); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/ReflectionWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/ReflectionWrapper8.java deleted file mode 100644 index 6da5308a..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/ReflectionWrapper8.java +++ /dev/null @@ -1,59 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Function; - -public class ReflectionWrapper8 implements ReflectionWrapper { - - private static final Class packetPlayOutExplosion = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); - private static final Reflection.Field explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0); - private static final Function explosionLocation = HullHider.posPacketToLocation(packetPlayOutExplosion, double.class, 1.0); - - @Override - public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) { - if(explosionBlocks.get(packet).isEmpty()) - return packetHiderFunction.hide(player, packet, explosionLocation.apply(packet)); - - return packet; - } - - - private static final Class itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack"); - private static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class); - private static final Class nbtTagCompound = Reflection.getClass("net.minecraft.nbt.CompoundTag"); - private static final Reflection.Method getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound); - private static final Reflection.Method getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class); - @Override - public boolean hasItems(ItemStack stack) { - Set keys = new HashSet<>((Set) getKeys.invoke(getTag.invoke(asNMSCopy.invoke(null, stack)))); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java deleted file mode 100644 index 00fb6956..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java +++ /dev/null @@ -1,40 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.Sound; - -public class SWSound8 implements SWSound.ISWSound { - @Override - public Sound getSound(SWSound sound) { - switch(sound){ - case ENTITY_WITHER_DEATH: - return Sound.WITHER_DEATH; - case BLOCK_NOTE_BASS: - return Sound.NOTE_BASS; - case BLOCK_NOTE_PLING: - return Sound.NOTE_PLING; - case ENTITY_GENERIC_EXPLODE: - return Sound.EXPLODE; - default: - return null; - } - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java deleted file mode 100644 index 3e73cb4b..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.steamwar.fightsystem.utils; - -import de.steamwar.core.TPSWarpUtils; - -public class TpsWarper8 implements TpsWarper { - - @Override - public void warp(float tps) { - TPSWarpUtils.warp(tps); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java deleted file mode 100644 index 549f5492..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java +++ /dev/null @@ -1,50 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.scoreboard.Team; - -public class WorldOfColorWrapper8 implements WorldOfColorWrapper { - @Override - public void setTeamColor(Team team, ChatColor color) { - team.setPrefix("§" + color.getChar()); - } - - @Override - public boolean isInBlock(Projectile e) { - return false; - } - - @Override - public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) { - location.getWorld().playSound(location, sound, volume, pitch); - } - - @SuppressWarnings("deprecation") - @Override - public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) { - player.sendTitle(title, subtitle); - } -} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java deleted file mode 100644 index 6581566c..00000000 --- a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java +++ /dev/null @@ -1,145 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import com.sk89q.jnbt.NBTInputStream; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; -import com.sk89q.worldedit.extent.clipboard.io.SchematicReader; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.FightSystem; -import de.steamwar.sql.NodeData; -import de.steamwar.sql.SchematicData; -import de.steamwar.sql.SchematicNode; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.Material; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.zip.GZIPInputStream; - -@SuppressWarnings("deprecation") -public class WorldeditWrapper8 implements WorldeditWrapper { - - protected static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData(); - protected static final Set colorBlocks = new HashSet<>(); - - static { - colorBlocks.add(new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE)); - colorBlocks.add(new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE)); - colorBlocks.add(new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE)); - colorBlocks.add(new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE)); - colorBlocks.add(new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE)); - } - - @Override - public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { - Vector minimum = clipboard.getRegion().getMinimumPoint(); - Map replaceMap = new HashMap<>(); - colorBlocks.forEach(base -> replaceMap.put(base, new BaseBlock(base.getId(), c.getWoolData()))); - - for(int x = 0; x < clipboard.getDimensions().getX(); x++){ - for(int y = 0; y < clipboard.getDimensions().getY(); y++){ - for(int z = 0; z < clipboard.getDimensions().getZ(); z++){ - Vector pos = minimum.add(x, y, z); - BaseBlock replacement = replaceMap.get(clipboard.getBlock(pos)); - if(replacement != null) - clipboard.setBlock(pos, replacement); - } - } - } - } - - @Override - public int getWaterDepth(Clipboard clipboard) { - Vector it = clipboard.getMinimumPoint().add(0, 0, 1); - int depth = 0; - while(!clipboard.getBlock(it).isAir()) { - depth++; - it = it.add(0, 1, 0); - } - return depth; - } - - @Override - public void pasteClipboard(Clipboard clipboard, Location position, org.bukkit.util.Vector offset, AffineTransform aT) { - World w = new BukkitWorld(position.getWorld()); - EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); - ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData()); - ch.setTransform(aT); - Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add( - aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint())) - ).toBlockPoint()).build()); - e.flushQueue(); - } - - @Override - public org.bukkit.util.Vector getDimensions(Clipboard clipboard) { - Vector dims = clipboard.getDimensions(); - return new org.bukkit.util.Vector(dims.getBlockX(), dims.getBlockY(), dims.getBlockZ()); - } - - @Override - public Clipboard loadChar(String charName) throws IOException { - return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Config.world).getWorldData()); - } - - @Override - public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException { - World w = new BukkitWorld(Config.world); - Vector min = new Vector(region.getMinX(), minY, region.getMinZ()); - CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE)); - BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion); - - ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy( - WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min - ); - Operations.complete(forwardExtentCopy); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - ClipboardWriter writer = ClipboardFormat.SCHEMATIC.getWriter(outputStream); - writer.write(clipboard, w.getWorldData()); - writer.close(); - } catch (IOException e) { - throw new SecurityException(e); - } - - SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.MCEDIT); - } -} diff --git a/FightSystem/FightSystem_9/build.gradle.kts b/FightSystem/FightSystem_9/build.gradle.kts deleted file mode 100644 index ec63f4ae..00000000 --- a/FightSystem/FightSystem_9/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":FightSystem:FightSystem_Core", "default")) - compileOnly(project(":FightSystem:FightSystem_8", "default")) - - compileOnly(libs.nms9) -} diff --git a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java b/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java deleted file mode 100644 index 8d89a718..00000000 --- a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java +++ /dev/null @@ -1,170 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.Reflection; -import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.listener.Recording; -import de.steamwar.fightsystem.record.GlobalRecorder; -import org.bukkit.*; -import org.bukkit.attribute.Attribute; -import org.bukkit.attribute.AttributeInstance; -import org.bukkit.boss.BarColor; -import org.bukkit.boss.BarStyle; -import org.bukkit.boss.BossBar; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerPickupArrowEvent; -import org.bukkit.event.player.PlayerSwapHandItemsEvent; -import org.bukkit.scoreboard.Team; - -import java.util.HashMap; -import java.util.Map; - -public class BountifulWrapper9 implements BountifulWrapper { - - private static final Class enumHand = Reflection.getClass("net.minecraft.world.InteractionHand"); - private static final Object mainHand = enumHand.getEnumConstants()[0]; - private static final Reflection.Field blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0); - - @Override - public boolean mainHand(Object packet) { - return blockPlaceHand.get(packet) == mainHand; - } - - @Override - public boolean bowInHand(boolean mainHand, Player p) { - return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW; - } - - @Override - public void setAttackSpeed(Player player) { - AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); - attribute.setBaseValue(16); - } - - @Override - public void setNametagVisibility(Team team) { - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); - } - - @Override - public Listener newDenyArrowPickupListener() { - return new Listener() { - @EventHandler - public void onArrowPickup(PlayerPickupArrowEvent e){ - if(Fight.fighting(e.getPlayer())) - e.setCancelled(true); - } - }; - } - - @Override - public Listener newDenyHandSwapListener() { - return new Listener() { - @EventHandler - public void onSwapItems(PlayerSwapHandItemsEvent event) { - if(Fight.fighting(event.getPlayer())) - event.setCancelled(true); - } - }; - } - - @Override - public void recordHandItems(Player player) { - GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND"); - GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND"); - } - - @Override - public Listener newHandSwapRecorder() { - return new Listener() { - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onItemSwap(PlayerSwapHandItemsEvent e){ - if(Recording.isNotSent(e.getPlayer())) - return; - - Player player = e.getPlayer(); - GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND"); - GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND"); - } - }; - } - - @Override - public void spawnParticle(World world, String particleName, double x, double y, double z) { - world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1); - } - - private final Map barMap = new HashMap<>(); - @Override - public void sendBar(Player player, FightTeam team, double progress, String text) { - barMap.keySet().removeIf(p -> !p.isOnline()); - - if(!barMap.containsKey(player)) { - BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID); - barMap.put(player, bar); - bar.addPlayer(player); - } - - BossBar bar = barMap.get(player); - BarColor color = chat2bar(team.getColor()); - if(bar.getColor() != color) - bar.setColor(color); - - if(bar.getProgress() != progress) - bar.setProgress(progress); - - if(!bar.getTitle().equals(text)) - bar.setTitle(text); - } - - private BarColor chat2bar(ChatColor color) { - switch(color) { - case DARK_BLUE: - case DARK_AQUA: - case BLUE: - case AQUA: - return BarColor.BLUE; - case GREEN: - case DARK_GREEN: - return BarColor.GREEN; - case DARK_RED: - case RED: - return BarColor.RED; - case DARK_PURPLE: - return BarColor.PURPLE; - case GOLD: - case YELLOW: - return BarColor.YELLOW; - case LIGHT_PURPLE: - return BarColor.PINK; - case BLACK: - case WHITE: - case GRAY: - case DARK_GRAY: - default: - return BarColor.WHITE; - } - } -} diff --git a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java b/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java deleted file mode 100644 index 305f21ab..00000000 --- a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java +++ /dev/null @@ -1,61 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.FightWorld; -import net.minecraft.server.v1_9_R2.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; -import org.bukkit.entity.Entity; - -import java.util.stream.Stream; - -public class CraftbukkitWrapper9 implements CraftbukkitWrapper { - @Override - public void resetChunk(World world, World backup, int x, int z) { - net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.getChunkAt(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); - - System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); - System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); - w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPAPER()) { - w.tileEntityList.removeAll(chunk.tileEntities.values()); - } - chunk.tileEntities.clear(); - chunk.tileEntities.putAll(backupChunk.tileEntities); - } - - @Override - public float headRotation(Entity e) { - return ((CraftEntity)e).getHandle().getHeadRotation(); - } - - @Override - public Stream entityIterator() { - return ((CraftWorld) Config.world).getHandle().entityList.stream(); - } - - @Override - public void setupGamerule() { } -} diff --git a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java b/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java deleted file mode 100644 index d1f7692d..00000000 --- a/FightSystem/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java +++ /dev/null @@ -1,40 +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 . - */ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.Sound; - -public class SWSound9 implements SWSound.ISWSound { - @Override - public Sound getSound(SWSound sound){ - switch(sound){ - case ENTITY_WITHER_DEATH: - return Sound.ENTITY_WITHER_DEATH; - case BLOCK_NOTE_BASS: - return Sound.BLOCK_NOTE_BASS; - case BLOCK_NOTE_PLING: - return Sound.BLOCK_NOTE_PLING; - case ENTITY_GENERIC_EXPLODE: - return Sound.ENTITY_GENERIC_EXPLODE; - default: - return null; - } - } -} diff --git a/FightSystem/FightSystem_Core/build.gradle.kts b/FightSystem/FightSystem_Core/build.gradle.kts index caa83e0d..b346e97c 100644 --- a/FightSystem/FightSystem_Core/build.gradle.kts +++ b/FightSystem/FightSystem_Core/build.gradle.kts @@ -21,15 +21,20 @@ plugins { steamwar.java } +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) - - compileOnly(libs.worldedit15) + compileOnly(libs.netty) + compileOnly(libs.paperapi) compileOnly(libs.fastutil) compileOnly(libs.authlib) - compileOnly(libs.netty) + compileOnly(libs.nms) + compileOnly(libs.fawe) } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index a8c8019e..8716b5c4 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem; -import de.steamwar.sql.GameModeConfig; import de.steamwar.data.GameModeConfigUtils; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.winconditions.Winconditions; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 011d36f6..40dd8b34 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -98,13 +98,7 @@ public class FightSystem extends JavaPlugin { new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); 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); - if (Core.getVersion() >= 19) { - try { - Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode)); - } catch (Exception e) { - // Ignore if failed! - } - } + Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode)); techHider = new TechHiderWrapper(); hullHider = new HullHider(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java index 1ed59d98..9f8383cf 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.ai; -import de.steamwar.Reflection; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.FightTeam; @@ -30,28 +29,30 @@ import org.bukkit.Material; import java.util.Arrays; import java.util.List; import java.util.function.BooleanSupplier; +import java.util.function.Function; import java.util.stream.Collectors; @AllArgsConstructor public class AIManager { private static final List AIs = Arrays.asList( - new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) + new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) ); public static List availableAIs() { return AIs.stream().filter(manager -> manager.available.getAsBoolean()).collect(Collectors.toList()); } - private final Class aiClass; + private final String name; + private final Function constructor; @Getter private final Material icon; private final BooleanSupplier available; public String name() { - return aiClass.getSimpleName(); + return name; } public void join(FightTeam team) { - Reflection.getConstructor(aiClass, FightTeam.class).invoke(team); + constructor.apply(team); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java index e25ca065..99196f65 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java index 7119173e..5e4ecc45 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.commands; -import de.steamwar.Reflection; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -33,15 +32,14 @@ import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; +import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Player; @UtilityClass public class Commands { - private static final Reflection.Field commandMap = Reflection.getField("org.bukkit.craftbukkit.CraftServer", "commandMap", SimpleCommandMap.class); public static void injectCommand(Command cmd) { - commandMap.get(Bukkit.getServer()).register("FightSystem", cmd); + ((CraftServer) Bukkit.getServer()).getCommandMap().register("FightSystem", cmd); } private static void errNoTeam(Player p){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java index 99236c84..e8e1b689 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -42,7 +42,6 @@ import org.bukkit.event.inventory.ClickType; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import java.util.function.Consumer; import java.util.stream.Collectors; public class GUI { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java index d8809691..e556786e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java @@ -25,7 +25,6 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; -import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java index 3d7684b2..52210b16 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -26,7 +26,10 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.linkage.Linked; -import de.steamwar.sql.*; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java index 42bd72d6..e6755bb9 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java @@ -17,7 +17,6 @@ package de.steamwar.fightsystem.commands; -import de.steamwar.core.TPSWarpUtils; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java index d97103ed..6e89d727 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -70,7 +70,7 @@ public class TechhiderbugCommand implements CommandExecutor { writer.append(TinyProtocol.instance.toString()).append('\n'); writer.append('\n').append("Netty pipelines:\n"); - Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n')); + Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getChannel(p).pipeline().names())).append('\n')); } catch (Exception e) { writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n'); Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 8d983b56..fc455d74 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.record.GlobalRecorder; @@ -84,10 +83,7 @@ public class Fight { public static void playSound(Sound sound, float volume, float pitch) { GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch); //volume: max. 100, pitch: max. 2 - if(Core.getVersion() >= 18) - Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch)); - else - Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch)); + Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch)); } public static FightTeam getTeamByName(String name) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java index afc735a2..92c70ba7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.states.FightState; @@ -51,7 +50,7 @@ public class HotbarKitListener implements Listener { @EventHandler public void handlePlayerInteract(PlayerInteractEvent event) { - if (event.getAction() == Action.PHYSICAL || (Core.getVersion() > 8 && event.getHand() != EquipmentSlot.HAND)) + if (event.getAction() == Action.PHYSICAL || event.getHand() != EquipmentSlot.HAND) return; Player player = event.getPlayer(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java index f5489be1..6476951c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.Reflection; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.commands.Commands; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 19d2db5f..29ef298f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.WorldOfColorWrapper; import de.steamwar.linkage.Linked; +import net.minecraft.world.entity.projectile.AbstractArrow; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -43,9 +44,8 @@ public class ArrowStopper { new StateDependentTask(Config.GameModeConfig.Techhider.Active, FightState.Running, this::run, 1, 1); } - private static final Class entityArrow = Reflection.getClass("net.minecraft.world.entity.projectile.AbstractArrow"); private void run() { - Recording.iterateOverEntities(entityArrow::isInstance, entity -> { + Recording.iterateOverEntities(AbstractArrow.class::isInstance, entity -> { Projectile arrow = (Projectile) entity; if (invalidEntity(arrow)) return; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java index 0777bcc7..540577ab 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -19,12 +19,11 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import org.bukkit.entity.Player; import java.io.*; @@ -44,8 +43,7 @@ public class ClickAnalyzer { public ClickAnalyzer() { TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); - if(Core.getVersion() > 8) - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), this::onBlockPlace); + TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::onBlockPlace); } public Object onBlockPlace(Player player, Object packet) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index 9d353d30..14b0a8ff 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -181,7 +181,12 @@ public class Permanent implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onExplosion(EntityExplodeEvent e) { - if (!(e.getEntity() instanceof TNTPrimed)) return; + if (!(e.getEntity() instanceof TNTPrimed)) { + if (Config.GameModeConfig.Schematic.Type.toDB().equals("wargearseason26")) { + e.blockList().clear(); + } + return; + } if (!Config.GameModeConfig.Arena.WaterDamage) return; e.blockList().removeIf(block -> { if(block.getType() == Material.TNT) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java index e0b446d5..c02c9574 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java @@ -22,7 +22,6 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -35,10 +34,12 @@ import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.*; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.Map; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PlayerJoinListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PlayerJoinListener.java new file mode 100644 index 00000000..71ecf2a7 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PlayerJoinListener.java @@ -0,0 +1,74 @@ +package de.steamwar.fightsystem.listener; + +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ClientboundForgetLevelChunkPacket; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +@Linked +public class PlayerJoinListener implements Listener { + + public PlayerJoinListener() { + new StateDependentListener(true, FightState.All, this); + } + + @EventHandler() + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + World world = player.getWorld(); + + Location loc = player.getLocation(); + int viewDistance = Bukkit.getViewDistance(); + + int chunkX = loc.getChunk().getX(); + int chunkZ = loc.getChunk().getZ(); + + // Iterate through the chunks around the player and force a resend + for (int x = -viewDistance; x <= viewDistance; x++) { + for (int z = -viewDistance; z <= viewDistance; z++) { + Chunk chunk = world.getChunkAt(chunkX + x, chunkZ + z); + this.forceRefreshChunkForPlayer(player, chunk); + } + } + } + + public void forceRefreshChunkForPlayer(Player player, Chunk bukkitChunk) { + ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); + CraftWorld craftWorld = (CraftWorld) bukkitChunk.getWorld(); + + int chunkX = bukkitChunk.getX(); + int chunkZ = bukkitChunk.getZ(); + + LevelChunk nmsChunk = craftWorld.getHandle().getChunkSource().getChunk(chunkX, chunkZ, false); + if (nmsChunk == null) { + // Chunk isn't loaded in memory on the server side; + return; + } + + ClientboundForgetLevelChunkPacket unloadPacket = new ClientboundForgetLevelChunkPacket(new ChunkPos(chunkX, chunkZ)); + serverPlayer.connection.send(unloadPacket); + + ClientboundLevelChunkWithLightPacket loadPacket = new ClientboundLevelChunkWithLightPacket( + nmsChunk, + craftWorld.getHandle().getLightEngine(), + null, + null, + true + ); + serverPlayer.connection.send(loadPacket); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index 15935410..2a7fdcae 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -19,8 +19,8 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; @@ -40,6 +40,9 @@ import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundUseItemPacket; +import net.minecraft.world.entity.item.PrimedTnt; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -79,10 +82,9 @@ public class Recording implements Listener { return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE; } - public static final Class primedTnt = Reflection.getClass("net.minecraft.world.entity.item.PrimedTnt"); - private static final Reflection.Method getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.world.entity.Entity"), "getBukkitEntity", null); + public static final Class primedTnt = PrimedTnt.class; public static void iterateOverEntities(Predicate filter, Consumer consumer) { - CraftbukkitWrapper.impl.entityIterator().filter(filter).map(entity -> (Entity) getBukkitEntity.invoke(entity)).forEach(consumer); + CraftbukkitWrapper.impl.entityIterator().filter(filter).map(net.minecraft.world.entity.Entity::getBukkitEntity).forEach(consumer); } public Recording() { @@ -131,7 +133,7 @@ public class Recording implements Listener { GlobalRecorder.getInstance().entitySpeed(entity); } - private static final Class blockDigPacket = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket"); + private static final Class blockDigPacket = ServerboundPlayerActionPacket.class; private static final Class playerDigType = blockDigPacket.getDeclaredClasses()[0]; private static final Reflection.Field blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0); private static final Object releaseUseItem = playerDigType.getEnumConstants()[5]; @@ -141,7 +143,7 @@ public class Recording implements Listener { return packet; } - public static final Class blockPlacePacket = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemPacket"); + public static final Class blockPlacePacket = ServerboundUseItemPacket.class; private Object blockPlace(Player p, Object packet) { boolean mainHand = BountifulWrapper.impl.mainHand(packet); if(!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p)) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java index 879e61f4..f7dc3ef0 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java @@ -19,9 +19,16 @@ package de.steamwar.fightsystem.listener; -import java.util.HashSet; -import java.util.Set; - +import com.comphenix.tinyprotocol.TinyProtocol; +import com.mojang.authlib.GameProfile; +import de.steamwar.core.ProtocolWrapper; +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -33,17 +40,8 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import com.comphenix.tinyprotocol.TinyProtocol; -import com.mojang.authlib.GameProfile; - -import de.steamwar.core.ProtocolWrapper; -import de.steamwar.fightsystem.ArenaMode; -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightPlayer; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.fightsystem.states.StateDependentTask; +import java.util.HashSet; +import java.util.Set; @Linked public class Spectator implements Listener { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index ab453eeb..3d4deafe 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -19,12 +19,6 @@ package de.steamwar.fightsystem.listener; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.events.BoardingEvent; @@ -37,6 +31,11 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentListener; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; public class TeamArea implements Listener { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WindchargeStopper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WindchargeStopper.java index 0218f58d..be0c5641 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WindchargeStopper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WindchargeStopper.java @@ -19,17 +19,35 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.linkage.Linked; +import org.bukkit.Location; +import org.bukkit.entity.WindCharge; @Linked public class WindchargeStopper { - static { - VersionDependent.getVersionImpl(FightSystem.getPlugin()); + public WindchargeStopper() { + new StateDependentTask(true, FightState.Running, this::run, 1, 1); } - public interface IWindchargeStopper { + private static final int middleLine = Config.SpecSpawn.getBlockZ(); + + private static final Class windChargeClass = WindCharge.class; + + private void run() { + Recording.iterateOverEntities(windChargeClass::isInstance, entity -> { + Location location = entity.getLocation(); + Location prevLocation = location.clone().subtract(entity.getVelocity()); + + boolean passedMiddle = location.getBlockZ() > middleLine && prevLocation.getBlockZ() > middleLine || + location.getBlockZ() < middleLine && prevLocation.getBlockZ() < middleLine; + + if(!passedMiddle) { + entity.remove(); + } + }); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java index 3a1525b0..be550042 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java @@ -25,7 +25,9 @@ import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.net.Socket; import java.util.logging.Level; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 2e2aa21c..b3a0eb75 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -329,7 +329,7 @@ public class PacketProcessor implements Listener { ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1); if(enchanted) - stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + stack.addUnsafeEnchantment(Enchantment.UNBREAKING, 1); Object slot; switch(slotName){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java index 1a496970..a91de770 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java @@ -19,29 +19,55 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.Reflection; -import de.steamwar.core.VersionDependent; +import com.comphenix.tinyprotocol.TinyProtocol; +import com.mojang.authlib.GameProfile; +import de.steamwar.core.ProtocolWrapper; import de.steamwar.fightsystem.FightSystem; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.state.BlockState; +import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -public interface BlockIdWrapper { - Class worldServer = Reflection.getClass("net.minecraft.server.level.ServerLevel"); - Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", worldServer); +public class BlockIdWrapper { + public static final BlockIdWrapper impl = new BlockIdWrapper(); - Class craftPlayer = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer"); - Class entityPlayer = Reflection.getClass("net.minecraft.server.level.ServerPlayer"); - Reflection.Method getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer); + public Material idToMaterial(int blockState) { + return CraftMagicNumbers.getMaterial(net.minecraft.world.level.block.Block.stateById(blockState)).getItemType(); + } - BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); + public int blockToId(Block block) { + return net.minecraft.world.level.block.Block.getId(((CraftBlockState) block.getState()).getHandle()); + } - Material idToMaterial(int blockState); - int blockToId(Block block); - void setBlock(World world, int x, int y, int z, int blockState); + public void setBlock(World world, int x, int y, int z, int blockState) { + BlockState blockData = net.minecraft.world.level.block.Block.stateById(blockState); + ServerLevel level = ((CraftWorld) world).getHandle(); + BlockPos pos = new BlockPos(x, y, z); - void trackEntity(Player player, Entity entity); - void untrackEntity(Player player, Entity entity); + level.removeBlockEntity(pos); + level.setBlock(pos, blockData, blockState); + level.getChunkSource().blockChanged(pos); + } + + public void trackEntity(Player player, Entity entity) { + if(entity instanceof Player) + TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); + + player.showEntity(FightSystem.getPlugin(), entity); + } + + public void untrackEntity(Player player, Entity entity) { + player.hideEntity(FightSystem.getPlugin(), entity); + + if(entity instanceof Player) + TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java index 3600127e..2723f23d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -19,31 +19,144 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import de.steamwar.Reflection; +import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; -import org.bukkit.World; +import de.steamwar.fightsystem.listener.Recording; +import de.steamwar.fightsystem.record.GlobalRecorder; +import net.minecraft.world.InteractionHand; +import org.bukkit.*; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerPickupArrowEvent; +import org.bukkit.event.player.PlayerSwapHandItemsEvent; import org.bukkit.scoreboard.Team; -public interface BountifulWrapper { - BountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +import java.util.HashMap; +import java.util.Map; - boolean mainHand(Object packet); - boolean bowInHand(boolean mainHand, Player p); +public class BountifulWrapper { + public static final BountifulWrapper impl = new BountifulWrapper(); - void setAttackSpeed(Player player); + private static final Class enumHand = InteractionHand.class; + private static final Object mainHand = enumHand.getEnumConstants()[0]; + private static final Reflection.Field blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0); - void setNametagVisibility(Team team); + public boolean mainHand(Object packet) { + return blockPlaceHand.get(packet) == mainHand; + } - Listener newDenyArrowPickupListener(); - Listener newDenyHandSwapListener(); + public boolean bowInHand(boolean mainHand, Player p) { + return (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW; + } - void recordHandItems(Player player); - Listener newHandSwapRecorder(); + public void setAttackSpeed(Player player) { + AttributeInstance attribute = player.getAttribute(Attribute.ATTACK_SPEED); + attribute.setBaseValue(16); + } - void spawnParticle(World world, String particleName, double x, double y, double z); + public void setNametagVisibility(Team team) { + team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); + } - void sendBar(Player player, FightTeam team, double progress, String text); + public Listener newDenyArrowPickupListener() { + return new Listener() { + @EventHandler + public void onArrowPickup(PlayerPickupArrowEvent e){ + if(Fight.fighting(e.getPlayer())) + e.setCancelled(true); + } + }; + } + + public Listener newDenyHandSwapListener() { + return new Listener() { + @EventHandler + public void onSwapItems(PlayerSwapHandItemsEvent event) { + if(Fight.fighting(event.getPlayer())) + event.setCancelled(true); + } + }; + } + + public void recordHandItems(Player player) { + GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInMainHand()), "MAINHAND"); + GlobalRecorder.getInstance().item(player, Recording.disarmNull(player.getInventory().getItemInOffHand()), "OFFHAND"); + } + + public Listener newHandSwapRecorder() { + return new Listener() { + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onItemSwap(PlayerSwapHandItemsEvent e){ + if(Recording.isNotSent(e.getPlayer())) + return; + + Player player = e.getPlayer(); + GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getMainHandItem()), "MAINHAND"); + GlobalRecorder.getInstance().item(player, Recording.disarmNull(e.getOffHandItem()), "OFFHAND"); + } + }; + } + + public void spawnParticle(World world, String particleName, double x, double y, double z) { + world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1); + } + + private final Map barMap = new HashMap<>(); + public void sendBar(Player player, FightTeam team, double progress, String text) { + barMap.keySet().removeIf(p -> !p.isOnline()); + + if(!barMap.containsKey(player)) { + BossBar bar = Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID); + barMap.put(player, bar); + bar.addPlayer(player); + } + + BossBar bar = barMap.get(player); + BarColor color = chat2bar(team.getColor()); + if(bar.getColor() != color) + bar.setColor(color); + + if(bar.getProgress() != progress) + bar.setProgress(progress); + + if(!bar.getTitle().equals(text)) + bar.setTitle(text); + } + + private BarColor chat2bar(ChatColor color) { + switch(color) { + case DARK_BLUE: + case DARK_AQUA: + case BLUE: + case AQUA: + return BarColor.BLUE; + case GREEN: + case DARK_GREEN: + return BarColor.GREEN; + case DARK_RED: + case RED: + return BarColor.RED; + case DARK_PURPLE: + return BarColor.PURPLE; + case GOLD: + case YELLOW: + return BarColor.YELLOW; + case LIGHT_PURPLE: + return BarColor.PINK; + case BLACK: + case WHITE: + case GRAY: + case DARK_GRAY: + default: + return BarColor.WHITE; + } + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java index 1100a272..6a4518c8 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java @@ -19,20 +19,52 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.Config; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; +import org.bukkit.GameRule; import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.entity.Entity; +import java.util.HashSet; +import java.util.Set; import java.util.stream.Stream; +import java.util.stream.StreamSupport; -public interface CraftbukkitWrapper { - CraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class CraftbukkitWrapper { + public static final CraftbukkitWrapper impl = new CraftbukkitWrapper(); - void resetChunk(World world, World backup, int x, int z); - float headRotation(Entity e); + protected net.minecraft.world.entity.Entity getEntity(Entity e) { + return ((CraftEntity) e).getHandle(); + } - Stream entityIterator(); + public float headRotation(Entity e) { + return getEntity(e).getYHeadRot(); + } - void setupGamerule(); + public Stream entityIterator() { + return StreamSupport.stream(((CraftWorld) Config.world).getHandle().getEntities().getAll().spliterator(), false); + } + + public void setupGamerule() { + Config.world.setGameRule(GameRule.LOCATOR_BAR, false); + } + + private LevelChunk getChunk(World world, int x, int z) { + return ((CraftWorld) world).getHandle().getChunk(x, z); + } + + public void resetChunk(World world, World backup, int x, int z) { + LevelChunk worldChunk = getChunk(world, x, z); + LevelChunk backupChunk = getChunk(backup, x, z); + LevelChunkSection[] sections = worldChunk.getSections(); + System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length); + Set blocks = new HashSet<>(worldChunk.blockEntities.keySet()); + blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity); + worldChunk.heightmaps.clear(); + worldChunk.heightmaps.putAll(backupChunk.heightmaps); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java index 14e4c941..8cf0dc3d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java @@ -19,36 +19,87 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Dispenser; import org.bukkit.entity.Player; +import org.bukkit.entity.Pose; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.ItemMeta; -public interface FlatteningWrapper { - FlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class FlatteningWrapper { + public static final FlatteningWrapper impl = new FlatteningWrapper(); - DyeColor getSilver(); + public DyeColor getSilver() { + return DyeColor.LIGHT_GRAY; + } - boolean isWater(Block block); - boolean removeWater(Block block); + public boolean isWater(Block block) { + if(block.getType() == Material.WATER) + return true; - boolean containsBlockMeta(ItemMeta meta); - boolean hasAttributeModifier(ItemStack stack); + BlockData data = block.getBlockData(); + if(!(data instanceof Waterlogged)) + return false; - boolean doRecord(BlockPhysicsEvent e); + return ((Waterlogged) data).isWaterlogged(); + } - void forceLoadChunk(World world, int cX, int cZ); + public boolean removeWater(Block block) { + Material type = block.getType(); + if(type == Material.WATER || type == Material.LAVA){ + block.setType(Material.AIR); + return true; + } - boolean checkPistonMoving(Block block); + BlockData data = block.getBlockData(); + if(!(data instanceof Waterlogged)) + return false; - boolean isFacingWater(Block dispenser); + Waterlogged waterlogged = (Waterlogged) data; + if(waterlogged.isWaterlogged()){ + block.setType(Material.AIR); + return true; + } - boolean isCrouching(Player player); - void sendBlockChange(Player player, Block block, Material type); + return false; + } + + public boolean containsBlockMeta(ItemMeta meta) { + return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData(); + } + + public boolean hasAttributeModifier(ItemStack stack) { + return stack.hasItemMeta() && stack.getItemMeta() != null && stack.getItemMeta().hasAttributeModifiers(); + } + + public boolean doRecord(BlockPhysicsEvent e) { + return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR; + } + + public void forceLoadChunk(World world, int cX, int cZ) { + world.setChunkForceLoaded(cX, cZ, true); + } + + public boolean checkPistonMoving(Block block) { + return block.getType() == Material.MOVING_PISTON; + } + + public boolean isFacingWater(Block dispenser) { + return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid(); + } + + public boolean isCrouching(Player player) { + return player.getPose() == Pose.SWIMMING; + } + + public void sendBlockChange(Player player, Block block, Material type) { + player.sendBlockChange(block.getLocation(), type.createBlockData()); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java index 074a9e4d..29751f50 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java @@ -19,9 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.core.Core; +import de.steamwar.Reflection; import de.steamwar.entity.REntity; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; @@ -34,6 +33,11 @@ import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.techhider.TechHider; import lombok.Getter; +import net.minecraft.core.Vec3i; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; +import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -49,7 +53,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.BiFunction; @@ -62,7 +65,7 @@ public class HullHider implements Listener { private final Hull[] hulls; private final Map, BiFunction> packetHiders = new HashMap<>(); - private static final Class packetPlayOutExplosion = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); + private static final Class packetPlayOutExplosion = ClientboundExplodePacket.class; public HullHider() { if(!TechHiderWrapper.ENABLED) { hulls = new Hull[0]; @@ -74,10 +77,8 @@ public class HullHider implements Listener { packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider); packetHiders.put(packetPlayOutExplosion, this::explosionHider); - posHiderGenerator("net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket", Core.getVersion() >= 18 ? double.class : float.class, 1.0); - posHiderGenerator("net.minecraft.network.protocol.game.ClientboundSoundPacket", int.class, 8.0); - if(Core.getVersion() >= 9 && Core.getVersion() < 18) - posHiderGenerator("net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect", int.class, 8.0); + posHiderGenerator(ClientboundLevelParticlesPacket.class, double.class, 1.0); + posHiderGenerator(ClientboundSoundPacket.class, int.class, 8.0); new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this); new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) { @@ -201,9 +202,9 @@ public class HullHider implements Listener { } - private static final Class packetPlayOutWorldEvent = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelEventPacket"); + private static final Class packetPlayOutWorldEvent = ClientboundLevelEventPacket.class; private static final Reflection.Field worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0); - public static final Reflection.Field blockPositionY = Reflection.getField("net.minecraft.core.Vec3i", int.class, 1); + public static final Reflection.Field blockPositionY = Reflection.getField(Vec3i.class, int.class, 1); private Object worldEventHider(Player player, Object packet) { Object baseBlock = worldEventPosition.get(packet); return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock))); @@ -213,8 +214,7 @@ public class HullHider implements Listener { return ReflectionWrapper.impl.explosionHider(player, packet, this::packetHider); } - private void posHiderGenerator(String typeName, Class posType, double factor) { - Class type = Reflection.getClass(typeName); + private void posHiderGenerator(Class type, Class posType, double factor) { Function location = posPacketToLocation(type, posType, factor); packetHiders.put(type, (player, packet) -> packetHider(player, packet, location.apply(packet))); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java index ca33a517..378c3efc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java @@ -19,13 +19,53 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.Config; +import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; +import net.minecraft.world.level.block.state.BlockState; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import java.util.List; -public interface HullHiderWrapper { - HullHiderWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class HullHiderWrapper { + public static final HullHiderWrapper impl = new HullHiderWrapper(); - Object generateBlockChangePacket(List changes); + public Object generateBlockChangePacket(List changes) { + Object[] blockdata = new Object[changes.size()]; + for(int i = 0; i < blockdata.length; i++) { + Hull.IntVector change = changes.get(i); + blockdata[i] = ((CraftBlockData) Config.world.getBlockData(change.getX(), change.getY(), change.getZ())).getState(); + } + + return generateBlockChangePacket(changes, blockdata); + } + + private Object generateBlockChangePacket(List changes, Object[] blockdata) { + if(changes.size() > 1) { + Hull.IntVector section = changes.get(0); + section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4); + int xOffset = 16*section.getX(); + int yOffset = 16*section.getY(); + int zOffset = 16*section.getZ(); + + short[] pos = new short[changes.size()]; + for(int i = 0; i < changes.size(); i++) { + Hull.IntVector change = changes.get(i); + + pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset)); + } + + return constructMultiBlockChange(section, pos, blockdata); + } else { + Hull.IntVector pos = changes.get(0); + return new ClientboundBlockUpdatePacket(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), (BlockState) blockdata[0]); + } + } + + protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) { + return new ClientboundSectionBlocksUpdatePacket(SectionPos.of(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length)); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java index ddc92242..2ab96689 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java @@ -44,7 +44,7 @@ public class ItemBuilder { } public ItemBuilder enchant() { - meta.addEnchant(Enchantment.DURABILITY, 1, true); + meta.addEnchant(Enchantment.UNBREAKING, 1, true); return this; } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ReflectionWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ReflectionWrapper.java index cbc9f807..9044f7d0 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ReflectionWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/ReflectionWrapper.java @@ -19,17 +19,59 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import io.papermc.paper.datacomponent.DataComponentType; +import io.papermc.paper.datacomponent.DataComponentTypes; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public interface ReflectionWrapper { - ReflectionWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +import java.util.HashSet; +import java.util.Set; - Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction); - boolean hasItems(ItemStack stack); +public class ReflectionWrapper { + public static final ReflectionWrapper impl = new ReflectionWrapper(); + + private static final Set FORBIDDEN_TYPES = new HashSet<>(); + + static { + FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME); + FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE); + FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE); + FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA); + FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS); + FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS); + FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA); + + FORBIDDEN_TYPES.add(DataComponentTypes.ATTRIBUTE_MODIFIERS); + FORBIDDEN_TYPES.add(DataComponentTypes.TOOL); + FORBIDDEN_TYPES.add(DataComponentTypes.WEAPON); + FORBIDDEN_TYPES.add(DataComponentTypes.FOOD); + FORBIDDEN_TYPES.add(DataComponentTypes.CONSUMABLE); + FORBIDDEN_TYPES.add(DataComponentTypes.POTION_CONTENTS); + FORBIDDEN_TYPES.add(DataComponentTypes.STORED_ENCHANTMENTS); + FORBIDDEN_TYPES.add(DataComponentTypes.CAN_BREAK); + FORBIDDEN_TYPES.add(DataComponentTypes.CAN_PLACE_ON); + FORBIDDEN_TYPES.add(DataComponentTypes.MAX_DAMAGE); + FORBIDDEN_TYPES.add(DataComponentTypes.USE_REMAINDER); + FORBIDDEN_TYPES.add(DataComponentTypes.USE_COOLDOWN); + FORBIDDEN_TYPES.add(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS); + FORBIDDEN_TYPES.add(DataComponentTypes.CHARGED_PROJECTILES); + FORBIDDEN_TYPES.add(DataComponentTypes.INTANGIBLE_PROJECTILE); + FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORKS); + FORBIDDEN_TYPES.add(DataComponentTypes.FIREWORK_EXPLOSION); + FORBIDDEN_TYPES.add(DataComponentTypes.EQUIPPABLE); + FORBIDDEN_TYPES.add(DataComponentTypes.REPAIR_COST); + FORBIDDEN_TYPES.add(DataComponentTypes.ENCHANTABLE); + } + + public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) { + return packet; + } + + public boolean hasItems(ItemStack stack) { + FORBIDDEN_TYPES.forEach(stack::resetData); + return false; + } public interface PacketHiderFunction { Object hide(Player player, Object packet, Location location); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java index 1022445d..7b7f97eb 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java @@ -19,8 +19,6 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; import org.bukkit.Sound; public enum SWSound { @@ -29,13 +27,18 @@ public enum SWSound { BLOCK_NOTE_BASS, ENTITY_GENERIC_EXPLODE; - private static final ISWSound impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); - public Sound getSound() { - return impl.getSound(this); - } - - public interface ISWSound { - Sound getSound(SWSound sound); + switch(this){ + case ENTITY_WITHER_DEATH: + return Sound.ENTITY_WITHER_DEATH; + case BLOCK_NOTE_BASS: + return Sound.BLOCK_NOTE_BLOCK_BASS; + case BLOCK_NOTE_PLING: + return Sound.BLOCK_NOTE_BLOCK_PLING; + case ENTITY_GENERIC_EXPLODE: + return Sound.ENTITY_GENERIC_EXPLODE; + default: + return null; + } } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java index de7f5b31..7f45d87c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java @@ -1,10 +1,11 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; +import net.minecraft.server.MinecraftServer; -public interface TpsWarper { - TpsWarper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class TpsWarper { + public static final TpsWarper impl = new TpsWarper(); - void warp(float tps); + public void warp(float tps) { + MinecraftServer.getServer().tickRateManager().setTickRate(tps); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java index 32fef89a..9ed9de95 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java @@ -19,22 +19,33 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionDependent; -import de.steamwar.fightsystem.FightSystem; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.scoreboard.Team; -public interface WorldOfColorWrapper { - WorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class WorldOfColorWrapper { + public static final WorldOfColorWrapper impl = new WorldOfColorWrapper(); - void setTeamColor(Team team, ChatColor color); - boolean isInBlock(Projectile e); + public void setTeamColor(Team team, ChatColor color) { + team.setColor(color); + } - void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch); + public boolean isInBlock(Projectile e) { + if(e instanceof Arrow) + return ((Arrow) e).isInBlock(); + return false; + } - void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop); + public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) { + location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch); + } + + public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) { + player.sendTitle(title, subtitle, start, hold, stop); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java index dff1df66..20d9b96f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java @@ -19,25 +19,131 @@ package de.steamwar.fightsystem.utils; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.function.operation.ForwardExtentCopy; +import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; -import de.steamwar.core.VersionDependent; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockTypes; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.sql.NodeData; +import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.util.Vector; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; -public interface WorldeditWrapper { - WorldeditWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); +public class WorldeditWrapper { + public static final WorldeditWrapper impl = new WorldeditWrapper(); - void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException; - int getWaterDepth(Clipboard clipboard); - void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT); - Vector getDimensions(Clipboard clipboard); - Clipboard loadChar(String charName) throws IOException; - void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException; + private static final Map colorBlocks = new HashMap<>(); + + static { + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(), "_wool"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(), "_terracotta"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(), "_stained_glass"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(), "_stained_glass_pane"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(), "_concrete"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(), "_concrete_powder"); + colorBlocks.put(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(), "_carpet"); + } + + public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { + BlockVector3 minimum = clipboard.getRegion().getMinimumPoint(); + Map replaceMap = new HashMap<>(); + colorBlocks.forEach((base, postfix) -> replaceMap.put(base, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + postfix)).getDefaultState().toBaseBlock())); + + for(int x = 0; x < clipboard.getDimensions().getX(); x++){ + for(int y = 0; y < clipboard.getDimensions().getY(); y++){ + for(int z = 0; z < clipboard.getDimensions().getZ(); z++){ + BlockVector3 pos = minimum.add(x, y, z); + BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos)); + if(replacement != null) + clipboard.setBlock(pos, replacement); + } + } + } + } + + public int getWaterDepth(Clipboard clipboard) { + BlockVector3 it = clipboard.getMinimumPoint().add(0, 0, 1); + int depth = 0; + while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){ + depth++; + it = it.add(0, 1, 0); + } + return depth; + } + + public void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT) { + EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1); + ClipboardHolder ch = new ClipboardHolder(clipboard); + ch.setTransform(aT); + Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add( + aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3())) + ).toBlockPoint()).build()); + e.flushSession(); + } + + public Vector getDimensions(Clipboard clipboard) { + BlockVector3 dims = clipboard.getDimensions(); + return new Vector(dims.getX(), dims.getY(), dims.getZ()); + } + + public Clipboard loadChar(String charName) throws IOException { + File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"); + Clipboard clipboard; + try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { + clipboard = reader.read(); + } + return clipboard; + } + + public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException { + World w = new BukkitWorld(Config.world); + BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ()); + CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE)); + BlockArrayClipboard clipboard = new BlockArrayClipboard(cuboidRegion); + + ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy( + WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1), cuboidRegion, clipboard, min + ); + forwardExtentCopy.setCopyingEntities(false); + Operations.complete(forwardExtentCopy); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try { + ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream); + writer.write(clipboard); + writer.close(); + } catch (IOException e) { + throw new SecurityException(e); + } + + SchematicData.saveFromBytes(schem, outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java index 733b0e5f..77ffa1aa 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java @@ -91,7 +91,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr @EventHandler public void onEntityExplode(EntityExplodeEvent event) { if ( - event.getEntityType() != EntityType.PRIMED_TNT || + event.getEntityType() != EntityType.TNT || !team.getExtendRegion().inRegion(event.getEntity().getLocation()) || (!Config.GameModeConfig.WinConditionParams.PercentEntern && !Config.GameModeConfig.EnterStages.isEmpty() && Config.GameModeConfig.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft()) ) { diff --git a/FightSystem/FightSystem_Standalone/build.gradle.kts b/FightSystem/FightSystem_Standalone/build.gradle.kts index c237d262..eb12e184 100644 --- a/FightSystem/FightSystem_Standalone/build.gradle.kts +++ b/FightSystem/FightSystem_Standalone/build.gradle.kts @@ -29,13 +29,4 @@ tasks.build { dependencies { implementation(project(":SpigotCore")) implementation(project(":FightSystem:FightSystem_Core")) - implementation(project(":FightSystem:FightSystem_8")) - implementation(project(":FightSystem:FightSystem_9")) - implementation(project(":FightSystem:FightSystem_10")) - implementation(project(":FightSystem:FightSystem_12")) - implementation(project(":FightSystem:FightSystem_14")) - implementation(project(":FightSystem:FightSystem_15")) - implementation(project(":FightSystem:FightSystem_18")) - implementation(project(":FightSystem:FightSystem_19")) - implementation(project(":FightSystem:FightSystem_20")) } diff --git a/FightSystem/build.gradle.kts b/FightSystem/build.gradle.kts index b999bdef..6f0c40a7 100644 --- a/FightSystem/build.gradle.kts +++ b/FightSystem/build.gradle.kts @@ -28,16 +28,6 @@ tasks.build { dependencies { implementation(project(":FightSystem:FightSystem_Core")) - implementation(project(":FightSystem:FightSystem_8")) - implementation(project(":FightSystem:FightSystem_9")) - implementation(project(":FightSystem:FightSystem_10")) - implementation(project(":FightSystem:FightSystem_12")) - implementation(project(":FightSystem:FightSystem_14")) - implementation(project(":FightSystem:FightSystem_15")) - implementation(project(":FightSystem:FightSystem_18")) - implementation(project(":FightSystem:FightSystem_19")) - implementation(project(":FightSystem:FightSystem_20")) - implementation(project(":FightSystem:FightSystem_21")) } tasks.register("WarGear20") { diff --git a/KotlinCore/build.gradle.kts b/KotlinCore/build.gradle.kts index c68c5fb5..6c56593d 100644 --- a/KotlinCore/build.gradle.kts +++ b/KotlinCore/build.gradle.kts @@ -31,7 +31,7 @@ tasks.shadowJar { } dependencies { - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) compileOnly(project(":SpigotCore")) implementation(libs.exposedCore) diff --git a/LegacyBauSystem/build.gradle.kts b/LegacyBauSystem/build.gradle.kts deleted file mode 100644 index 139fec4d..00000000 --- a/LegacyBauSystem/build.gradle.kts +++ /dev/null @@ -1,29 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.nms12) - compileOnly(libs.worldedit12) -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/BauSystem.java b/LegacyBauSystem/src/de/steamwar/bausystem/BauSystem.java deleted file mode 100644 index 5c6fcf1b..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/BauSystem.java +++ /dev/null @@ -1,198 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.commands.*; -import de.steamwar.bausystem.world.*; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.core.Core; -import de.steamwar.providers.BauServerInfo; -import de.steamwar.scoreboard.SWScoreboard; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitTask; - -import java.util.UUID; -import java.util.logging.Level; - -public class BauSystem extends JavaPlugin implements Listener { - - private static BauSystem plugin; - private static Integer owner; - public static final String PREFIX = "§eBauSystem§8» §7"; - - private BukkitTask autoShutdown; - - @Override - public void onEnable() { - Core.setServerName("Dev"); - plugin = this; - - Mapper.init(); - - new CommandTrace(); - new CommandTPSLimiter(); - new CommandNV(); - new CommandReset(); - new CommandSpeed(); - new CommandTNT(); - new CommandGamemode(); - new CommandClear(); - new CommandTime(); - new CommandTeleport(); - new CommandFire(); - new CommandFreeze(); - new CommandTestblock(); - new CommandInfo(); - new CommandProtect(); - new CommandSkull(); - new CommandLoader(); - new CommandLockschem(); - new CommandDebugStick(); - new CommandGills(); - new CommandDetonator(); - new CommandScript(); - new CommandScriptVars(); - new CommandRedstoneTester(); - new CommandGUI(); - new CommandWorldSpawn(); - new CommandRegion(); - new CommandSelect(); - new CommandKillAll(); - - if (Core.getVersion() > 14 && Region.buildAreaEnabled()) { - new CommandColor(); - } - - Bukkit.getPluginManager().registerEvents(this, this); - Bukkit.getPluginManager().registerEvents(new RegionListener(), this); - Bukkit.getPluginManager().registerEvents(new ScriptListener(), this); - Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); - Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this); - Bukkit.getPluginManager().registerEvents(new CommandGUI(), this); - Bukkit.getPluginManager().registerEvents(new DetonatorListener(), this); - Bukkit.getPluginManager().registerEvents(new ItemFrameListener(), this); - new AFKStopper(); - - autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200); - TPSUtils.init(); - } - - @Override - public void onDisable() { - Region.save(); - } - - public static BauSystem getPlugin() { - return plugin; - } - - public static UUID getOwner() { - return SteamwarUser.byId(getOwnerID()).getUUID(); - } - - public static int getOwnerID() { - //Lazy loading to improve startup time of the server in 1.15 - if (owner == null) { - owner = BauServerInfo.getOwnerId(); - } - return owner; - } - - @EventHandler - public void onDeath(PlayerDeathEvent e) { - e.setDeathMessage(null); - } - - @EventHandler - public void onJoin(PlayerLoginEvent e) { - if (autoShutdown != null) { - autoShutdown.cancel(); - autoShutdown = null; - } - - Player p = e.getPlayer(); - p.setOp(true); - } - - @EventHandler - public void onLeave(PlayerQuitEvent e) { - Player p = e.getPlayer(); - SWScoreboard.impl.removeScoreboard(p); - if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(p))) { - if (autoShutdown != null) { - autoShutdown.cancel(); - } - CommandTPSLimiter.setTPS(20.0); - autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() { - int count = 0; - - @Override - public void run() { - if (count >= 300) { - Bukkit.shutdown(); - return; - } - count++; - try { - if (RamUsage.getUsage() > 0.8) { - Bukkit.shutdown(); - } - } catch (Throwable throwable) { - Bukkit.getLogger().log(Level.WARNING, throwable.getMessage(), throwable); - Bukkit.shutdown(); - } - } - }, 20, 20); - } - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent e) { - ItemStack stack = e.getCursor(); - if (stack == null || !stack.hasItemMeta()) - return; - assert stack.getItemMeta() != null; - if (stack.getItemMeta().hasEnchants()) { - for (Enchantment en : Enchantment.values()) { - if (stack.getEnchantmentLevel(en) > en.getMaxLevel()) - stack.removeEnchantment(en); - } - } - - Material material = stack.getType(); - if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) { - stack.setType(Material.MILK_BUCKET); - } - - e.setCurrentItem(stack); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper.java b/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper.java deleted file mode 100644 index 580ca89c..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper.java +++ /dev/null @@ -1,43 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.tracer.AbstractTraceEntity; -import de.steamwar.core.VersionDependent; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class CraftbukkitWrapper { - private CraftbukkitWrapper() {} - - public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin()); - - public interface ICraftbukkitWrapper { - void initTPS(); - void createTickCache(World world); - void sendTickPackets(); - - void openSignEditor(Player player, Location location); - - AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper12.java b/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper12.java deleted file mode 100644 index d2e6bc06..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/CraftbukkitWrapper12.java +++ /dev/null @@ -1,80 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.world.TPSUtils; -import net.minecraft.server.v1_12_R1.*; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.List; - -public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - private final List> packets = new ArrayList<>(); - - @Override - public void initTPS() { - TPSUtils.disableWarp(); - } - - @Override - public void createTickCache(World world) { - packets.clear(); - world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> { - packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0)); - packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - - if (entity instanceof TNTPrimed) { - net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); - } - }); - } - - @Override - public void sendTickPackets() { - Bukkit.getOnlinePlayers().forEach(player -> { - PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; - for (Packet p : packets) { - connection.sendPacket(p); - } - }); - } - - @Override - public void openSignEditor(Player player, Location location) { - PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - - @Override - public AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) { - return new TraceEntity12(world, tntPosition, tnt); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper.java b/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper.java deleted file mode 100644 index 55efd292..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper.java +++ /dev/null @@ -1,53 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.world.Detoloader; -import de.steamwar.core.VersionDependent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -public class FlatteningWrapper { - private FlatteningWrapper(){} - - public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin()); - - public interface IFlatteningWrapper { - boolean tntPlaceActionPerform(Location location); - boolean setRedstone(Location location, boolean active); - Detoloader onPlayerInteractLoader(PlayerInteractEvent event); - boolean getLever(Block block); - - boolean isNoBook(ItemStack item); - - boolean inWater(World world, Vector tntPosition); - Material getTraceShowMaterial(); - Material getTraceHideMaterial(); - Material getTraceXZMaterial(); - - void giveStick(Player player); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper12.java b/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper12.java deleted file mode 100644 index bcad7aef..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/FlatteningWrapper12.java +++ /dev/null @@ -1,148 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.world.Detoloader; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.stream.Collectors; - -public class FlatteningWrapper12 implements FlatteningWrapper.IFlatteningWrapper { - - @Override - public boolean tntPlaceActionPerform(Location location) { - Material m = location.getBlock().getType(); - if (m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER) - return false; - - location.getBlock().setType(Material.TNT); - return true; - } - - @Override - @SuppressWarnings("deprecation") - public boolean setRedstone(Location location, boolean active) { - Block block = location.getBlock(); - Material material = block.getType(); - if (material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON) { - if (active) - block.setData((byte) (block.getData() | 8)); - else - block.setData((byte) (block.getData() & -9)); - } else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) { - if (active) - block.setData((byte) 1); - else - block.setData((byte) 0); - } else if (material == Material.TRIPWIRE) { - if (active) { - ArmorStand armorStand = (ArmorStand) Bukkit.getWorlds().get(0).spawnEntity(location, EntityType.ARMOR_STAND); - armorStand.setVisible(false); - armorStand.setBasePlate(false); - armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()); - } else { - List entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity -> - entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ())) - .limit(1) - .collect(Collectors.toList()); - if (entityList.isEmpty()) return false; - entityList.get(0).remove(); - } - } else { - return false; - } - block.getState().update(true); - return true; - } - - @Override - @SuppressWarnings("deprecation") - public Detoloader onPlayerInteractLoader(PlayerInteractEvent event) { - Block block = event.getClickedBlock(); - Material material = block.getType(); - if (material == Material.LEVER) { - if ((block.getData() & 8) == 8) { - return new Detoloader("Hebel", 0).setActive(false); - } else { - return new Detoloader("Hebel", 0).setActive(true); - } - } else if (material == Material.STONE_BUTTON) { - return new Detoloader("Knopf", Detoloader.STONE_BUTTON); - } else if (material == Material.WOOD_BUTTON) { - return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON); - } else if (material == Material.NOTE_BLOCK) { - return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK); - } else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) { - return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE); - } else if (material == Material.TRIPWIRE) { - return new Detoloader("Tripwire", Detoloader.TRIPWIRE); - } - return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false); - } - - @Override - @SuppressWarnings("deprecation") - public boolean getLever(Block block) { - return (block.getData() & 8) == 8; - } - - @Override - public boolean isNoBook(ItemStack item) { - return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK; - } - - @Override - public boolean inWater(World world, Vector tntPosition) { - Material material = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()).getType(); - return material == Material.WATER || material == Material.STATIONARY_WATER; - } - - @Override - public Material getTraceShowMaterial() { - return Material.CONCRETE; - } - - @Override - public Material getTraceHideMaterial() { - return Material.CONCRETE; - } - - @Override - public Material getTraceXZMaterial() { - return Material.STEP; - } - - @Override - public void giveStick(Player player) { - player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/Mapper.java b/LegacyBauSystem/src/de/steamwar/bausystem/Mapper.java deleted file mode 100644 index f22a8332..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/Mapper.java +++ /dev/null @@ -1,87 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.tracer.show.ShowModeParameterType; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import de.steamwar.sql.BauweltMember; -import de.steamwar.sql.SteamwarUser; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - - -public class Mapper { - - private Mapper() { - throw new IllegalStateException("Utility Class"); - } - - public static void init() { - SWCommandUtils.addMapper(ShowModeParameterType.class, showModeParameterTypesTypeMapper()); - SWCommandUtils.addMapper(BauweltMember.class, bauweltMemberTypeMapper()); - } - - private static TypeMapper showModeParameterTypesTypeMapper() { - Map showModeParameterTypesMap = new HashMap<>(); - showModeParameterTypesMap.put("-water", ShowModeParameterType.WATER); - - showModeParameterTypesMap.put("-interpolatey", ShowModeParameterType.INTERPOLATE_Y); - showModeParameterTypesMap.put("-interpolate-y", ShowModeParameterType.INTERPOLATE_Y); - showModeParameterTypesMap.put("-interpolate_y", ShowModeParameterType.INTERPOLATE_Y); - showModeParameterTypesMap.put("-y", ShowModeParameterType.INTERPOLATE_Y); - - showModeParameterTypesMap.put("-interpolatex", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate-x", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate_x", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-x", ShowModeParameterType.INTERPOLATE_XZ); - - showModeParameterTypesMap.put("-interpolatez", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate-z", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate_z", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-z", ShowModeParameterType.INTERPOLATE_XZ); - - showModeParameterTypesMap.put("-interpolatexz", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate-xz", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-interpolate_xz", ShowModeParameterType.INTERPOLATE_XZ); - showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ); - - showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED); - showModeParameterTypesMap.put("-a", ShowModeParameterType.ADVANCED); - showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED); - showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED); - - List tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet()); - return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes); - } - - private static TypeMapper bauweltMemberTypeMapper() { - return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.getOwnerID()) - .stream() - .filter(m -> SteamwarUser.byId(m.getMemberID()).getUserName().equals(s)).findFirst().orElse(null), - s -> BauweltMember.getMembers(BauSystem.getOwnerID()) - .stream() - .map(m -> SteamwarUser.byId(m.getMemberID()).getUserName()) - .collect(Collectors.toList())); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/Permission.java b/LegacyBauSystem/src/de/steamwar/bausystem/Permission.java deleted file mode 100644 index 472941e4..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/Permission.java +++ /dev/null @@ -1,26 +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 . - */ - -package de.steamwar.bausystem; - -public enum Permission { - WORLD, - WORLDEDIT, - MEMBER -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/RamUsage.java b/LegacyBauSystem/src/de/steamwar/bausystem/RamUsage.java deleted file mode 100644 index 2638b83f..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/RamUsage.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.bausystem; - -import org.bukkit.Bukkit; - -import java.lang.management.ManagementFactory; -import java.util.logging.Level; - -public class RamUsage { - - private RamUsage() { - throw new IllegalStateException("Utility Class"); - } - - public static double getUsage() { - try { - long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); - long freeMemory = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getFreePhysicalMemorySize(); - return (memorySize - freeMemory) / (double) memorySize; - } catch (Throwable throwable) { - Bukkit.getLogger().log(Level.WARNING, throwable.getMessage(), throwable); - return 1D; - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/SWUtils.java b/LegacyBauSystem/src/de/steamwar/bausystem/SWUtils.java deleted file mode 100644 index cdc9a7a3..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/SWUtils.java +++ /dev/null @@ -1,64 +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 . - */ - -package de.steamwar.bausystem; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - -public class SWUtils { - - public static void giveItemToPlayer(Player player, ItemStack itemStack) { - if (itemStack == null || itemStack.getType() == Material.AIR) { - return; - } - for (int i = 0; i < player.getInventory().getSize(); i++) { - ItemStack current = player.getInventory().getItem(i); - if (current != null && current.isSimilar(itemStack)) { - player.getInventory().setItem(i, null); - itemStack = current; - break; - } - } - ItemStack current = player.getInventory().getItemInMainHand(); - player.getInventory().setItemInMainHand(itemStack); - if (current.getType() != Material.AIR) { - player.getInventory().addItem(current); - } - } - - public static List manageList(List strings, String[] args, int index) { - strings = new ArrayList<>(strings); - for (int i = strings.size() - 1; i >= 0; i--) { - if (!strings.get(i).startsWith(args[index])) { - strings.remove(i); - } - } - return strings; - } - - public static List manageList(List strings, String[] args) { - return manageList(strings, args, args.length - 1); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/TraceEntity12.java b/LegacyBauSystem/src/de/steamwar/bausystem/TraceEntity12.java deleted file mode 100644 index 1e8d8c5a..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/TraceEntity12.java +++ /dev/null @@ -1,77 +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 . - */ - -package de.steamwar.bausystem; - -import de.steamwar.bausystem.tracer.AbstractTraceEntity; -import net.minecraft.server.v1_12_R1.*; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -class TraceEntity12 extends EntityFallingBlock implements AbstractTraceEntity { - - private boolean exploded; - private int references; - - public TraceEntity12(World world, Vector position, boolean tnt) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData()); - - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player, boolean exploded) { - if (!this.exploded && exploded) { - this.setCustomNameVisible(true); - this.setCustomName("Bumm"); - this.exploded = true; - if (references++ > 0) - sendDestroy(player); - } else if (references++ > 0) - return; - - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 70, Block.getCombinedId(getBlock())); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); - - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && --references > 0) - return false; - - sendDestroy(player); - die(); - return true; - } - - private void sendDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper.java b/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper.java deleted file mode 100644 index c6ee9ce3..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.bausystem; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.bausystem.world.regions.PasteOptions; -import de.steamwar.bausystem.world.regions.Point; -import de.steamwar.core.VersionDependent; -import org.bukkit.entity.Player; - -import java.io.File; - -public class WorldeditWrapper { - private WorldeditWrapper() {} - - public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin()); - - public interface IWorldeditWrapper { - void setSelection(Player p, Point minPoint, Point maxPoint); - - EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions); - EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions); - - boolean isWorldEditCommand(String command); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper12.java b/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper12.java deleted file mode 100644 index 1ee68074..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/WorldeditWrapper12.java +++ /dev/null @@ -1,114 +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 . - */ - -package de.steamwar.bausystem; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockID; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import de.steamwar.bausystem.world.regions.PasteOptions; -import de.steamwar.bausystem.world.regions.Point; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Objects; - -public class WorldeditWrapper12 implements WorldeditWrapper.IWorldeditWrapper { - - private final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); - private final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); - - @Override - public void setSelection(Player p, Point minPoint, Point maxPoint) { - WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toVector(minPoint), toVector(maxPoint))); - } - - @Override - public EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { - World w = new BukkitWorld(Bukkit.getWorlds().get(0)); - Clipboard clipboard; - try { - clipboard = Objects.requireNonNull(ClipboardFormat.findByFile(file)).getReader(new FileInputStream(file)).read(w.getWorldData()); - } catch (NullPointerException | IOException e) { - throw new SecurityException("Bausystem schematic not found", e); - } - - return paste(clipboard, x, y, z, pasteOptions); - } - - @Override - public EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) { - World w = new BukkitWorld(Bukkit.getWorlds().get(0)); - - Vector dimensions = clipboard.getDimensions(); - Vector v = new Vector(x, y, z); - Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - AffineTransform aT = new AffineTransform(); - if (pasteOptions.isRotate()) { - aT = aT.rotateY(180); - v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); - } else { - v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset); - } - - EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); - ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData()); - ch.setTransform(aT); - - if (pasteOptions.isReset()) { - try { - e.setBlocks(new CuboidRegion(toVector(pasteOptions.getMinPoint()), toVector(pasteOptions.getMaxPoint())), new BaseBlock(BlockID.AIR)); - } catch (MaxChangedBlocksException ex) { - throw new SecurityException("Max blocks changed?", ex); - } - } - Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build()); - return e; - } - - @Override - public boolean isWorldEditCommand(String command) { - if (command.startsWith("/")) { - command = command.replaceFirst("/", ""); - } - command = command.toLowerCase(); - return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager() - .getCommandManager().getDispatcher().get(command) != null; - } - - private Vector toVector(Point point) { - return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ()); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandClear.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandClear.java deleted file mode 100644 index 391dc3c8..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandClear.java +++ /dev/null @@ -1,71 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class CommandClear extends SWCommand { - - public CommandClear() { - super("clear"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eclear §8- §7Leere dein Inventar"); - p.sendMessage("§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); - } - - @Register - public void genericClearCommand(Player p) { - clear(p); - p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert."); - } - - @Register - public void clearPlayerCommand(Player p, Player target) { - if (!permissionCheck(p)) return; - clear(target); - target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von " + p.getDisplayName() + " §7geleert."); - p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine fremden Inventare leeren."); - return false; - } - return true; - } - - private void clear(Player player) { - player.getInventory().clear(); - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - player.getInventory().setChestplate(new ItemStack(Material.AIR)); - player.getInventory().setLeggings(new ItemStack(Material.AIR)); - player.getInventory().setBoots(new ItemStack(Material.AIR)); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandColor.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandColor.java deleted file mode 100644 index 2a7874dc..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandColor.java +++ /dev/null @@ -1,92 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.world.Color; -import de.steamwar.bausystem.world.regions.GlobalRegion; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - - -public class CommandColor extends SWCommand { - - private static CommandColor instance = null; - - public CommandColor() { - super("color"); - instance = this; - } - - public static CommandColor getInstance() { - return instance; - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region"); - p.sendMessage("§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global"); - } - - @Register - public void genericColor(Player p, Color color) { - genericColorSet(p, color, ColorizationType.LOCAL); - } - - @Register - public void genericColorSet(Player p, Color color, ColorizationType colorizationType) { - if (!permissionCheck(p)) { - return; - } - if (colorizationType == ColorizationType.GLOBAL) { - Region.setGlobalColor(color); - p.sendMessage(BauSystem.PREFIX + "Alle Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt"); - return; - } - Region region = Region.getRegion(p.getLocation()); - if (GlobalRegion.isGlobalRegion(region)) { - p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return; - } - region.setColor(color); - p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt"); - } - - @Register - public void genericColorSet(Player p, ColorizationType colorizationType, Color color) { - genericColorSet(p, color, colorizationType); - } - - private boolean permissionCheck(Player p) { - if (!BauSystem.getOwner().equals(p.getUniqueId())) { - p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); - return false; - } else { - return true; - } - } - - public enum ColorizationType { - LOCAL, - GLOBAL - } - -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDebugStick.java deleted file mode 100644 index 0c6aa4a5..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ /dev/null @@ -1,41 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.FlatteningWrapper; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - -public class CommandDebugStick extends SWCommand { - - public CommandDebugStick() { - super("debugstick"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§edebugstick §8- §7Erhalte einen DebugStick"); - } - - @Register - public void genericCommand(Player p) { - FlatteningWrapper.impl.giveStick(p); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDetonator.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDetonator.java deleted file mode 100644 index df5fa6d3..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ /dev/null @@ -1,114 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.world.Detonator; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - -public class CommandDetonator extends SWCommand { - - public CommandDetonator() { - super ("detonator", "dt"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar"); - p.sendMessage("§8/§edetonator detonate §8- §7Benutzt den nächst besten Fernzünder"); - p.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen"); - p.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder"); - } - - @Register("wand") - public void wandCommand(Player p) { - if (!permissionCheck(p)) return; - SWUtils.giveItemToPlayer(p, Detonator.WAND); - } - - @Register("detonator") - public void detonatorCommand(Player p) { - if (!permissionCheck(p)) return; - SWUtils.giveItemToPlayer(p, Detonator.WAND); - } - - @Register("item") - public void itemCommand(Player p) { - if (!permissionCheck(p)) return; - SWUtils.giveItemToPlayer(p, Detonator.WAND); - } - - - @Register("remove") - public void removeCommand(Player p) { - if (!permissionCheck(p)) return; - p.getInventory().removeItem(Detonator.WAND); - } - - - @Register("detonate") - public void detonateCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.execute(p); - } - - @Register("click") - public void clickCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.execute(p); - } - - @Register("use") - public void useCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.execute(p); - } - - - @Register("clear") - public void clearCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.clear(p); - } - - @Register("delete") - public void deleteCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.clear(p); - } - - @Register("reset") - public void resetCommand(Player p) { - if (!permissionCheck(p)) return; - Detonator.clear(p); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); - return false; - } - return true; - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFire.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFire.java deleted file mode 100644 index b35c2e25..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFire.java +++ /dev/null @@ -1,92 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockSpreadEvent; - -public class CommandFire extends SWCommand implements Listener { - - public CommandFire() { - super("fire"); - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§efire §8- §7Toggle Feuerschaden"); - } - - @Register - public void toggleCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if (toggle(region)) { - RegionUtils.actionBar(region, getEnableMessage()); - } else { - RegionUtils.actionBar(region, getDisableMessage()); - } - } - - private String getNoPermMessage() { - return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren"; - } - - private String getEnableMessage() { - return "§cRegions Feuerschaden deaktiviert"; - } - - private String getDisableMessage() { - return "§aRegions Feuerschaden aktiviert"; - } - - private boolean toggle(Region region) { - region.setFire(!region.isFire()); - return region.isFire(); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); - return false; - } - return true; - } - - @EventHandler - public void onFireDamage(BlockBurnEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true); - } - - @EventHandler - public void onFireSpread(BlockSpreadEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFreeze.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFreeze.java deleted file mode 100644 index 114817e9..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ /dev/null @@ -1,148 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.*; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.inventory.InventoryMoveItemEvent; - -public class CommandFreeze extends SWCommand implements Listener { - - public CommandFreeze() { - super("freeze", "stoplag"); - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§efreeze §8- §7Toggle Freeze"); - } - - @Register - public void toggleCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if (toggle(region)) { - RegionUtils.actionBar(region, getEnableMessage()); - } else { - RegionUtils.actionBar(region, getDisableMessage()); - } - } - - private String getNoPermMessage() { - return "§cDu darfst diese Welt nicht einfrieren"; - } - - private String getEnableMessage(){ - return "§cRegion eingefroren"; - } - - private String getDisableMessage(){ - return "§aRegion aufgetaut"; - } - - private boolean toggle(Region region) { - region.setFreeze(!region.isFreeze()); - return region.isFreeze(); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); - return false; - } - return true; - } - - @EventHandler - public void onEntitySpawn(EntitySpawnEvent e) { - if (!Region.getRegion(e.getLocation()).isFreeze()) return; - e.setCancelled(true); - if (e.getEntityType() == EntityType.PRIMED_TNT) { - Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> { - e.getLocation().getBlock().setType(Material.TNT, false); - }, 1L); - } - } - - @EventHandler - public void onBlockCanBuild(BlockCanBuildEvent e) { - if (Core.getVersion() == 12) return; - if (!e.isBuildable()) return; - if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return; - if (e.getMaterial() == Material.TNT) { - e.setBuildable(false); - e.getBlock().setType(Material.TNT, false); - } - } - - @EventHandler - public void onEntityChangeBlock(EntityChangeBlockEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onPhysicsEvent(BlockPhysicsEvent e){ - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onPistonExtend(BlockPistonExtendEvent e){ - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onPistonRetract(BlockPistonRetractEvent e){ - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onBlockGrow(BlockGrowEvent e){ - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onRedstoneEvent(BlockRedstoneEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent()); - } - - @EventHandler - public void onBlockDispense(BlockDispenseEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); - } - - @EventHandler - public void onInventoryMoveEvent(InventoryMoveItemEvent e){ - if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGUI.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGUI.java deleted file mode 100644 index 6c0658e0..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGUI.java +++ /dev/null @@ -1,530 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.tracer.show.TraceShowManager; -import de.steamwar.bausystem.world.*; -import de.steamwar.bausystem.world.regions.GlobalRegion; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; -import de.steamwar.inventory.SWAnvilInv; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; -import de.steamwar.sql.BauweltMember; -import de.steamwar.sql.SteamwarUser; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerSwapHandItemsEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.potion.PotionEffectType; - -import java.util.*; - -public class CommandGUI extends SWCommand implements Listener { - - private static final Set OPEN_INVS = new HashSet<>(); - private static final Set OPEN_TRACER_INVS = new HashSet<>(); - private static final Set LAST_F_PLAYER = new HashSet<>(); - private static boolean isRefreshing = false; - - public CommandGUI() { - super("gui"); - Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§egui §8- §7Öffne die GUI"); - p.sendMessage("§8/§egui item §8- §7Gebe das GUI item"); - } - - @Register - public void genericCommand(Player p) { - openBauGui(p); - OPEN_INVS.add(p); - } - - @Register({"item"}) - public void itemCommand(Player p) { - SWUtils.giveItemToPlayer(p, new ItemStack(Material.NETHER_STAR)); - } - - public static void openBauGui(Player player) { - Region region = Region.getRegion(player.getLocation()); - SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau"); - inv.setCallback(-1, clickType -> { - if (!isRefreshing) - OPEN_INVS.remove(player); - }); - - inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> { - }); - inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> { - player.closeInventory(); - player.performCommand("gui item"); - }); - - ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte"); - inv.setItem(39, dtWand, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.closeInventory(); - player.performCommand("dt wand"); - }); - - ItemStack redstoneWand = wand(player, CommandRedstoneTester.WAND, "§8/§7redstonetester", null, ""); - inv.setItem(37, redstoneWand, clickType -> { - player.closeInventory(); - player.performCommand("redstonetester"); - }); - - inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.WORLDEDIT), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.closeInventory(); - player.performCommand("/wand"); - }); - inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.closeInventory(); - player.performCommand("debugstick"); - }); - - inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren"); - anvilInv.setItem(Material.COMPASS); - anvilInv.setCallback(s -> player.performCommand("tpslimit " + s)); - anvilInv.open(); - }); - inv.setItem(5, Material.FEATHER, "§7Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + player.getFlySpeed() * 10, "§8/§7speed §8[§e1 - 10§8]"), false, clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(player, "Geschwindigkeit"); - anvilInv.setItem(Material.FEATHER); - anvilInv.setCallback(s -> player.performCommand("speed " + s)); - anvilInv.open(); - }); - - if (player.getUniqueId().equals(BauSystem.getOwner())) { - SWItem skull = SWItem.getPlayerSkull(player.getName()); - skull.setName("§7Bau verwalten"); - List skullLore = new ArrayList<>(); - skullLore.add("§7TNT: §e" + region.getTntMode().getName()); - skullLore.add("§7StopLag: §e" + (region.isFreeze() ? "Eingeschaltet" : "Ausgeschaltet")); - skullLore.add("§7Fire: §e" + (region.isFire() ? "Ausgeschaltet" : "Eingeschaltet")); - skullLore.add("§7Members: §e" + (BauweltMember.getMembers(BauSystem.getOwnerID()).size() - 1)); - skull.setLore(skullLore); - inv.setItem(4, skull); - } - - inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + PredefinedBook.getBookCount() + " §7Bücher"), true, clickType -> { - player.closeInventory(); - scriptBooksGUI(player); - }); - - inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.closeInventory(); - OPEN_TRACER_INVS.add(player); - traceGUI(player); - }); - - inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.closeInventory(); - autoLoaderGUI(player); - }); - - inv.setItem(17, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe"); - anvilInv.setItem(Material.NAME_TAG); - anvilInv.setCallback(s -> player.performCommand("skull " + s)); - anvilInv.open(); - }); - - if (GlobalRegion.isGlobalRegion(region)) { - inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> { - }); - inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> { - }); - inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> { - }); - } else { - inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player)); - }); - - if (region.hasProtection()) { - inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)); - }); - } else { - inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> { - }); - } - - if (region.hasTestblock()) { - inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)); - }); - } else { - inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> { - }); - } - } - - if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { - inv.setItem(26, Material.POTION, "§7Nightvision: §eEingeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> { - CommandNV.toggleNightvision(player); - openBauGui(player); - }); - } else { - inv.setItem(26, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> { - CommandNV.toggleNightvision(player); - openBauGui(player); - }); - } - - if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { - inv.setItem(35, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> { - CommandGills.toggleGills(player); - openBauGui(player); - }); - } else { - inv.setItem(35, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> { - CommandGills.toggleGills(player); - openBauGui(player); - }); - } - - boolean isBuildArea = region.hasBuildRegion(); - List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD); - switch (region.getTntMode()) { - case OFF: - inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("tnt " + (isBuildArea ? "tb" : "on")); - updateInventories(); - }); - break; - case ONLY_TB: - inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("tnt on"); - updateInventories(); - }); - break; - default: - inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("tnt off"); - updateInventories(); - }); - } - - if (region.isFreeze()) { - inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("freeze"); - updateInventories(); - }); - } else { - inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("freeze"); - updateInventories(); - }); - } - - if (region.isFire()) { - inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("fire"); - updateInventories(); - }); - } else { - inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { - if (Welt.noPermission(player, Permission.WORLD)) - return; - player.performCommand("fire"); - updateInventories(); - }); - } - - inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "", null), false, clickType -> { - List> playerSWListEntry = new ArrayList<>(); - Bukkit.getOnlinePlayers().forEach(player1 -> { - if (player1.equals(player)) - return; - playerSWListEntry.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(player1.getName()), player1.getName())); - }); - SWListInv playerSWListInv = new SWListInv<>(player, "Teleporter", playerSWListEntry, (clickType1, player1) -> { - player.closeInventory(); - player.performCommand("tp " + player1); - }); - playerSWListInv.open(); - }); - - inv.open(); - } - - private static void traceGUI(Player player) { - SWInventory inv = new SWInventory(player, 9, "Tracer"); - inv.setCallback(-1, clickType -> { - if (!isRefreshing) - OPEN_TRACER_INVS.remove(player); - }); - List stateLore = Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName(), "§8/§7trace §8[§estart§8, stop §8oder §eauto§8]"); - switch (RecordStateMachine.getRecordStatus()) { - case IDLE: - inv.setItem(0, getMaterial("SNOWBALL", "SNOW_BALL"), "§7Tracerstatus", stateLore, false, clickType -> { - RecordStateMachine.commandAuto(); - updateInventories(); - }); - break; - case IDLE_AUTO: - inv.setItem(0, Material.ENDER_PEARL, "§7Tracerstatus", stateLore, false, clickType -> { - RecordStateMachine.commandStart(); - updateInventories(); - }); - break; - case RECORD: - case RECORD_AUTO: - inv.setItem(0, getMaterial("ENDER_EYE", "EYE_OF_ENDER"), "§7Tracerstatus", stateLore, false, clickType -> { - RecordStateMachine.commandStop(); - updateInventories(); - }); - } - if (TraceShowManager.hasActiveShow(player)) { - inv.setItem(2, Material.TNT, "§7Showstatus", Arrays.asList("§7Aktuell: §eGezeigt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> { - player.performCommand("trace hide"); - traceGUI(player); - }); - } else { - inv.setItem(2, Material.GLASS, "§7Showstatus", Arrays.asList("§7Aktuell: §eVersteckt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> { - player.performCommand("trace show"); - traceGUI(player); - }); - } - - inv.setItem(4, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7Trace GUI", Collections.singletonList("§8/§7trace show gui"), false, clickType -> { - player.closeInventory(); - player.performCommand("trace show gui"); - }); - - inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> { - })); - - inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> { - player.closeInventory(); - openBauGui(player); - OPEN_INVS.add(player); - }); - - inv.open(); - } - - private static void scriptBooksGUI(Player player) { - List> entries = new ArrayList<>(); - List books = PredefinedBook.getBooks(); - books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> { - }), predefinedBook))); - SWListInv inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> { - player.closeInventory(); - player.getInventory().addItem(predefinedBook.toItemStack()); - }); - inv.open(); - } - - private static void autoLoaderGUI(Player player) { - SWInventory inv = new SWInventory(player, 9, "Autoloader"); - - boolean hasLoader = AutoLoader.hasLoader(player); - - if (hasLoader) { - AutoLoader loader = AutoLoader.getLoader(player); - if (loader.isSetup()) { - inv.setItem(0, Material.DROPPER, "§7Loader Starten", Collections.singletonList("§8/§7loader start"), false, clickType -> { - loader.start(); - autoLoaderGUI(player); - }); - - inv.setItem(2, Material.ARROW, "§7Letzte Aktion entfernen", Collections.singletonList("§8/§7loader undo"), false, clickType -> { - - }); - } else { - inv.setItem(0, Material.BLAZE_ROD, "§7Loader Bearbeiten", Collections.singletonList("§8/§7loader setup"), false, clickType -> { - loader.setup(); - autoLoaderGUI(player); - }); - } - - inv.setItem(4, Material.COMPASS, "§7Schuss Delay", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenShots(), "§8/§7loader wait §8[§eTicks§8]"), false, clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(player, "Schuss Delay", loader.getTicksBetweenShots() + ""); - anvilInv.setItem(Material.STONE); - anvilInv.setCallback(s -> { - player.performCommand("loader wait " + s); - autoLoaderGUI(player); - }); - anvilInv.open(); - }); - - inv.setItem(6, getMaterial("CLOCK", "WATCH"), "§7Block platzier Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenBlocks(), "§8/§7loader speed §8[§eTicks§8]"), false, clickType -> { - SWAnvilInv anvilInv = new SWAnvilInv(player, "Platzier Geschwindigkeit", loader.getTicksBetweenBlocks() + ""); - anvilInv.setItem(Material.STONE); - anvilInv.setCallback(s -> { - player.performCommand("loader speed " + s); - autoLoaderGUI(player); - }); - anvilInv.open(); - }); - - inv.setItem(8, Material.BARRIER, "§7Loader löschen", Collections.singletonList("§8/§7loader stop"), false, clickType -> confirmationInventory(player, "Loader löschen?", () -> { - loader.stop(); - autoLoaderGUI(player); - }, () -> autoLoaderGUI(player))); - } else { - inv.setItem(4, Material.GOLD_NUGGET, "§eNeuer Autoloader", clickType -> { - AutoLoader.getLoader(player); - player.closeInventory(); - }); - inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> { - player.closeInventory(); - openBauGui(player); - OPEN_INVS.add(player); - }); - } - - inv.open(); - } - - - private static void confirmChatMessage(Player player, String command) { - player.sendMessage(BauSystem.PREFIX + "§7Klicke auf die Nachricht zum bestätigen"); - TextComponent t = new TextComponent(); - t.setText("[Hier]"); - t.setColor(ChatColor.YELLOW); - t.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); - t.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§7" + command))); - player.spigot().sendMessage(t); - } - - private static List getNoPermsLore(List lore, Player player, String noPerms, Permission perm) { - if (perm != null && Welt.noPermission(player, perm)) { - lore = new ArrayList<>(lore); - lore.add(noPerms); - } - return lore; - } - - private static void updateInventories() { - isRefreshing = true; - OPEN_INVS.forEach(CommandGUI::openBauGui); - OPEN_TRACER_INVS.forEach(CommandGUI::traceGUI); - isRefreshing = false; - } - - private static void confirmationInventory(Player player, String title, Runnable confirm, Runnable decline) { - SWInventory inv = new SWInventory(player, 9, title); - inv.setItem(0, SWItem.getDye(1), (byte) 1, "§cAbbrechen", clickType -> { - player.closeInventory(); - decline.run(); - }); - inv.setItem(8, SWItem.getDye(10), (byte) 10, "§aBestätigen", clickType -> { - player.closeInventory(); - confirm.run(); - }); - inv.open(); - } - - private static Material getMaterial(String... names) { - for (String name : names) { - try { - return Material.valueOf(name); - } catch (IllegalArgumentException ignored) { - //Ignored /\ - } - } - return null; - } - - private static ItemStack wand(Player player, ItemStack base, String command, Permission permission, String noPermissionMessage) { - base = base.clone(); - ItemMeta meta = base.getItemMeta(); - List lore = meta.getLore(); - lore.add(command); - if (permission != null && Welt.noPermission(player, permission)) - lore.add(noPermissionMessage); - meta.setLore(lore); - base.setItemMeta(meta); - return base; - } - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - if (event.getItem() == null || event.getItem().getType() != Material.NETHER_STAR) - return; - openBauGui(event.getPlayer()); - OPEN_INVS.add(event.getPlayer()); - } - - @EventHandler - public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { - if (LAST_F_PLAYER.contains(event.getPlayer())) { - openBauGui(event.getPlayer()); - OPEN_INVS.add(event.getPlayer()); - } else { - LAST_F_PLAYER.add(event.getPlayer()); - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGamemode.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGamemode.java deleted file mode 100644 index 0a717412..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ /dev/null @@ -1,50 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.command.SWCommand; -import org.bukkit.GameMode; -import org.bukkit.entity.Player; - -public class CommandGamemode extends SWCommand { - - public CommandGamemode() { - super("gamemode", "gm", "g"); - } - - @Register(help = true) - public void gamemodeHelp(Player p, String... args) { - p.sendMessage("§cUnbekannter Spielmodus"); - } - - @Register - public void genericCommand(Player p) { - if (p.getGameMode() == GameMode.CREATIVE) { - p.setGameMode(GameMode.SPECTATOR); - } else { - p.setGameMode(GameMode.CREATIVE); - } - } - - @Register - public void gamemodeCommand(Player p, GameMode gameMode) { - p.setGameMode(gameMode); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGills.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGills.java deleted file mode 100644 index 1330ded1..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandGills.java +++ /dev/null @@ -1,53 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class CommandGills extends SWCommand { - - public CommandGills() { - super("watervision", "wv"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ewatervision §8- §7Toggle WaterBreathing"); - } - - @Register - public void genericCommand(Player p) { - toggleGills(p); - } - - public static void toggleGills(Player player) { - if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { - player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert"); - player.removePotionEffect(PotionEffectType.WATER_BREATHING); - return; - } - player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false)); - player.sendMessage(BauSystem.PREFIX + "Wassersicht aktiviert"); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandInfo.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandInfo.java deleted file mode 100644 index 269e0638..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandInfo.java +++ /dev/null @@ -1,80 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.world.TPSUtils; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.command.SWCommand; -import de.steamwar.core.TPSWatcher; -import de.steamwar.sql.BauweltMember; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.entity.Player; - -import java.util.List; - -import static de.steamwar.bausystem.world.TPSUtils.getTps; - -public class CommandInfo extends SWCommand { - - public CommandInfo() { - super("bauinfo"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau"); - } - - @Register - public void genericCommand(Player p) { - CommandInfo.sendBauInfo(p); - } - - public static void sendBauInfo(Player p) { - p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.byId(BauSystem.getOwnerID()).getUserName()); - Region region = Region.getRegion(p.getLocation()); - p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); - if (region.hasProtection()) { - p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + (region.isProtect() ? "§aAN" : "§cAUS")); - } - - List members = BauweltMember.getMembers(BauSystem.getOwnerID()); - StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); - - for (BauweltMember member : members) { - membermessage.append("§e").append(SteamwarUser.byId(member.getMemberID()).getUserName()).append("§8["); - membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,"); - membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" "); - } - p.sendMessage(membermessage.toString()); - - StringBuilder tpsMessage = new StringBuilder(); - tpsMessage.append(BauSystem.PREFIX).append("TPS:§e"); - tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND)); - tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS)); - if (!TPSUtils.isWarping()) { - tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE)); - tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)); - tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); - } - p.sendMessage(tpsMessage.toString()); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandKillAll.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandKillAll.java deleted file mode 100644 index 36b5b29e..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandKillAll.java +++ /dev/null @@ -1,74 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.world.regions.*; -import de.steamwar.command.SWCommand; -import java.util.concurrent.atomic.AtomicLong; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; - -public class CommandKillAll extends SWCommand { - - private static final World WORLD = Bukkit.getWorlds().get(0); - - public CommandKillAll() { - super("killall", "removeall"); - } - - @Register(help = true) - public void genericHelp(Player player, String... args) { - player.sendMessage("§8/§ekillall §8- §7Entferne alle Entities aus deiner Region"); - player.sendMessage("§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global"); - } - - @Register - public void genericCommand(Player player) { - genericCommand(player, RegionSelectionType.LOCAL); - } - - @Register - public void genericCommand(Player player, RegionSelectionType regionSelectionType) { - Region region = Region.getRegion(player.getLocation()); - AtomicLong removedEntities = new AtomicLong(); - if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.isGlobalRegion(region)) { - WORLD.getEntities() - .stream() - .filter(e -> !(e instanceof Player)) - .forEach(entity -> { - entity.remove(); - removedEntities.getAndIncrement(); - }); - RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities.get() + " Entities aus der Welt entfernt"); - } else { - WORLD.getEntities() - .stream() - .filter(e -> !(e instanceof Player)) - .filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) - .forEach(entity -> { - entity.remove(); - removedEntities.getAndIncrement(); - }); - RegionUtils.actionBar(region, "§a" + removedEntities.get() + " Entities aus der Region entfernt"); - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLoader.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLoader.java deleted file mode 100644 index 60504d69..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLoader.java +++ /dev/null @@ -1,134 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.AutoLoader; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - -public class CommandLoader extends SWCommand { - - public CommandLoader() { - super("loader"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen"); - p.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion"); - p.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab"); - p.sendMessage("§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen"); - p.sendMessage("§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen"); - p.sendMessage("§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen"); - p.sendMessage("§7Der AutoLader arbeitet mit §eIngame§8-§eTicks §8(20 Ticks pro Sekunde)"); - } - - @Register({"setup"}) - public void setupCommand(Player p) { - setup(p); - } - - @Register({"undo"}) - public void undoCommand(Player p) { - undo(p); - } - - @Register({"start"}) - public void startCommand(Player p) { - start(p); - } - - @Register({"stop"}) - public void stopCommand(Player p) { - stop(p); - } - - @Register({"wait"}) - public void waitCommand(Player p, int time) { - wait(p, time); - } - - @Register({"speed"}) - public void speedCommand(Player p, int time) { - speed(p, time); - } - - private void setup(Player player) { - AutoLoader.getLoader(player).setup(); - } - - private void undo(Player player) { - AutoLoader loader = loader(player); - if (loader == null) - return; - - if (!loader.isSetup()) { - player.sendMessage("§cDer AutoLader wird in den Setup-Zustand versetzt"); - setup(player); - } - - loader.undo(); - } - - private void start(Player player) { - AutoLoader loader = loader(player); - if (loader == null) - return; - - loader.start(); - } - - private void stop(Player player) { - if (!AutoLoader.hasLoader(player)) { - player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader"); - return; - } - AutoLoader.getLoader(player).stop(); - } - - private void wait(Player player, int time) { - AutoLoader loader = loader(player); - if (loader == null) { - loader = AutoLoader.getLoader(player); - } - loader.wait(time); - } - - private void speed(Player player, int time) { - AutoLoader loader = loader(player); - if (loader == null) { - loader = AutoLoader.getLoader(player); - } - loader.blockWait(time); - } - - private AutoLoader loader(Player player) { - if (AutoLoader.hasLoader(player)) { - return AutoLoader.getLoader(player); - } - player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader"); - player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet"); - setup(player); - return null; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLockschem.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLockschem.java deleted file mode 100644 index 2d45f7d9..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ /dev/null @@ -1,67 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.command.SWCommand; -import de.steamwar.sql.*; -import org.bukkit.entity.Player; - -public class CommandLockschem extends SWCommand { - - public CommandLockschem() { - super("lockschem"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) { - return; - } - - sendHelp(p); - } - - @Register - public void genericCommand(Player p, String owner, String schematicName) { - if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) { - return; - } - - SteamwarUser schemOwner = SteamwarUser.get(owner); - if (schemOwner == null) { - p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); - return; - } - SchematicNode node = SchematicNode.getNodeFromPath(schemOwner, schematicName); - if (node == null) { - p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); - return; - } - p.sendMessage(BauSystem.PREFIX + "Schematic " + node .getName() + " von " + - SteamwarUser.byId(node.getOwner()).getUserName() + " von " + node.getSchemtype().toString() + - " auf NORMAL zurückgesetzt!"); - node.setSchemtype(SchematicType.Normal); - } - - private void sendHelp(Player player) { - player.sendMessage("§8/§eschemlock §8[§7Owner§8] §8[§7Schematic§8] §8- §7 Sperre eine Schematic"); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandNV.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandNV.java deleted file mode 100644 index b37d21ae..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandNV.java +++ /dev/null @@ -1,54 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class CommandNV extends SWCommand { - - public CommandNV() { - super("nightvision", "nv"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§enightvision §8- §7Toggle NightVision"); - } - - @Register - public void genericCommand(Player p) { - toggleNightvision(p); - } - - public static void toggleNightvision(Player player) { - if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { - player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert"); - player.removePotionEffect(PotionEffectType.NIGHT_VISION); - return; - } - - player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false)); - player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert"); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandProtect.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandProtect.java deleted file mode 100644 index 93551f8e..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandProtect.java +++ /dev/null @@ -1,127 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.command.SWCommand; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; - -import java.io.IOException; -import java.util.logging.Level; - -public class CommandProtect extends SWCommand implements Listener { - - public CommandProtect() { - super("protect"); - if (Region.buildAreaEnabled()) { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eprotect §8- §7Schütze die Region"); - p.sendMessage("§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic"); - } - - @Register - public void genericProtectCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = regionCheck(p); - if (region == null) return; - if (Region.buildAreaEnabled()) { - region.setProtect(!region.isProtect()); - if (region.isProtect()) { - RegionUtils.actionBar(region, "§aBoden geschützt"); - } else { - RegionUtils.actionBar(region, "§cBoden Schutz aufgehoben"); - } - return; - } - try { - region.protect(null); - p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); - } - } - - @Register - public void schematicProtectCommand(Player p, String s) { - if (!permissionCheck(p)) return; - if (Region.buildAreaEnabled()) { - genericHelp(p); - return; - } - Region region = regionCheck(p); - if (region == null) return; - SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); - SchematicNode schem = SchematicNode.getNodeFromPath(owner, s); - if (schem == null) { - p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); - return; - } - try { - region.protect(schem); - p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); - } - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLDEDIT)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen"); - return false; - } - return true; - } - - private Region regionCheck(Player player) { - Region region = Region.getRegion(player.getLocation()); - if (!region.hasProtection()) { - player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region"); - return null; - } - return region; - } - - @EventHandler - public void onExplode(EntityExplodeEvent event) { - Region region = Region.getRegion(event.getLocation()); - if (!region.isProtect() || !region.hasProtection()) { - return; - } - event.blockList().removeIf(block -> { - return block.getY() < region.getProtectYLevel(); - }); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java deleted file mode 100644 index 30972ff2..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ /dev/null @@ -1,52 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.command.SWCommand; -import de.steamwar.inventory.SWItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; - -public class CommandRedstoneTester extends SWCommand { - - public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack(); - - public CommandRedstoneTester() { - super("redstonetester", "rt"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eredstonetester §8- §7Gibt den RedstoneTester"); - } - - @Register - public void genericCommand(Player p) { - p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); - SWUtils.giveItemToPlayer(p, WAND); - } - - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRegion.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRegion.java deleted file mode 100644 index d779c2a5..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandRegion.java +++ /dev/null @@ -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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Color; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.GlobalRegion; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.regions.RegionExtensionType; -import de.steamwar.bausystem.world.regions.RegionType; -import de.steamwar.command.SWCommand; -import de.steamwar.sql.SchematicNode; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.logging.Level; - -public class CommandRegion extends SWCommand { - - public CommandRegion() { - super("region", "rg"); - } - - @Register - public void genericCommand(Player player) { - genericHelp(player); - } - - @Register(help = true) - public void genericHelp(Player player, String... args) { - player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig"); - player.sendMessage("§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo"); - player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen"); - player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); - player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); - player.sendMessage("§8/§eregion color §8[§7Color§8] §8- §7Ändere die Regions Farbe"); - } - - @Register("undo") - public void undoCommand(Player p) { - if(!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if(checkGlobalRegion(region, p)) return; - - if (region.undo()) { - p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht"); - } else { - p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen"); - } - } - - @Register("redo") - public void redoCommand(Player p) { - if (!permissionCheck(p)) { - return; - } - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - - if (region.redo()) { - p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt"); - } else { - p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen"); - } - } - - @Register - public void baurahmenCommand(Player p, RegionType regionType) { - CommandSelect.getInstance().baurahmenCommand(p, regionType, RegionExtensionType.NORMAL); - } - - @Register - public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { - CommandSelect.getInstance().baurahmenCommand(p, regionType, regionExtensionType); - } - - @Register("restore") - public void genericRestoreCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if(checkGlobalRegion(region, p)) return; - - if (region == null) return; - try { - region.reset(null, true); - p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); - } - } - - @Register("restore") - public void schematicRestoreCommand(Player p, SchematicNode schem) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if(checkGlobalRegion(region, p)) return; - - if (region == null) return; - try { - region.reset(schem, true); - p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); - } - } - - @Register("color") - public void colorCommand(Player p, Color color) { - CommandColor.getInstance().genericColor(p, color); - } - - static boolean checkGlobalRegion(Region region, Player p) { - if (GlobalRegion.isGlobalRegion(region)) { - p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region"); - return true; - } - return false; - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLDEDIT)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern"); - return false; - } - return true; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandReset.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandReset.java deleted file mode 100644 index 3424b192..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandReset.java +++ /dev/null @@ -1,91 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.GlobalRegion; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.command.SWCommand; -import de.steamwar.sql.SchematicNode; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.logging.Level; - -public class CommandReset extends SWCommand { - - public CommandReset() { - super("reset"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ereset §8- §7Setzte die Region zurück"); - p.sendMessage("§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück"); - } - - @Register - public void genericResetCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = regionCheck(p); - if (region == null) return; - try { - region.reset(null, false); - p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); - } - } - - @Register - public void schematicResetCommand(Player p, SchematicNode schem) { - if (!permissionCheck(p)) return; - Region region = regionCheck(p); - if (region == null) return; - try { - region.reset(schem, false); - p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); - } - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen"); - return false; - } - return true; - } - - private Region regionCheck(Player player) { - Region region = Region.getRegion(player.getLocation()); - if (region == GlobalRegion.getInstance()) { - player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return null; - } - return region; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScript.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScript.java deleted file mode 100644 index 4563baa0..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScript.java +++ /dev/null @@ -1,92 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.command.SWCommand; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -import java.util.ArrayList; -import java.util.List; - -public class CommandScript extends SWCommand { - - public CommandScript() { - super("script"); - } - - public static final ItemStack BOOK = new ItemStack(Material.WRITTEN_BOOK, 1); - - static { - List pages = new ArrayList<>(); - pages.add("§6Script System§8\n\n- Commands\n- Kommentare\n- Scriptausführung\n- Sleep\n- Variablen\n- Konstanten\n- Abfragen\n- Schleifen\n- \"echo\"\n- \"input\"\n- Arithmetik\n- Logik"); - pages.add("§6Commands§8\n\nEin minecraft Befehl wird im Scriptbuch so hingeschrieben. Dabei kann man ein '/' weglassen. Um Befehle zu trennen kommen diese in neue Zeilen.\n\nStatt\n/tnt -> tnt\n//pos1 -> /pos1"); - pages.add("§6Kommentare§8\n\nFür ein Kommentar fängt die Zeile mit einem '#' an. Diese Zeilen werden bei dem Ausführen dann ignoriert.\n\nBeispiel:\n§9# TNT an/aus\ntnt"); - pages.add("§6Scriptausführung§8\n\nWenn du mit dem Buch in der Hand links klickst wird dieses ausgeführt."); - pages.add("§6Sleep§8\n\nUm Sachen langsamer zu machen kann man ein 'sleep' in sein Script schreiben. Danach kommt eine Zahl mit der Anzahl der GameTicks die zu schlafen sind.\n\nBeispiel:\n§9# 1 Sekunde schlafen\nsleep 20"); - pages.add("§6Variablen§8\n\nMit Variablen kann man sich Zahlen speichern. Man definiert diese mit 'var '.\n\nBeispiel:\n§9# Setze i zu 0\nvar i 0§8\n\nEs gibt einige spezial values. Dazu zählen"); - pages.add("§8'true', 'yes', 'false' und 'no', welche für 1, 1, 0 und 0 stehen.\n\nMan kann eine Variable auch um einen erhöhen oder verkleinern. Hierfür schreibt man statt einer Zahl '++', 'inc' oder '--', 'dec'.\n\nBeispiel:\n§9var i ++"); - pages.add("§8Variablen kann man referenzieren\ndurch '<' vor dem Variablennamen und '>' nach diesem. Diese kann man in jedem Befehl verwenden.\n\nBeispiel:\n§9# Stacked um 10\nvar stacks 10\n/stack "); - pages.add("§8Man kann auch explizit eine globale, locale, oder konstante variable referenzieren, indem 'global.', 'local.' oder 'const.' vor den Namen in die Klammern zu schreiben."); - pages.add("§8Um Variablen über das Script ausführen zu speichern gibt es 'global' und 'unglobal' als Befehle. Der erste speichert eine locale Variable global und das zweite löscht eine globale wieder."); - pages.add("§8Des weiteren kann man Lokale Variablen mit 'unvar' löschen. Nach dem verlassen einer Welt werden alle Globalen Variablen gelöscht. Globale Variablen kann man mit '/scriptvars' einsehen."); - pages.add("§6Konstanten§8\n\nNeben den variablen gibt es noch 5 Konstante Werte, welche nicht mit dem 'var' Befehl verändert werden können.\n\nDiese sind:\n- trace/autotrace\n- tnt\n- freeze\n- fire"); - pages.add("§8Des weiteren gibt es 3 weitere Variablen, welche explizit Spieler gebunden sind\n\nDiese sind:\n- x\n- y\n- z"); - pages.add("§6Abfragen§8\n\nMit Abfragen kann man nur Gleichheit von 2 Werten überprüft werden. Hierfür verwendet man\n'if '.\nNach den zwei Werten kann man ein oder 2 Jump-Points schreiben\n'if [...] (JP)'."); - pages.add("§8Des weiteren kann man überprüfen, ob eine Variable existiert mit 'if exists' wonach dann wieder 1 oder 2 Jump-Points sein müssen."); - pages.add("§8Ein Jump-Point ist eine Zeile Script, wohin man springen kann. Dieser wird mit einem '.' am Anfang der Zeile beschrieben und direkt danach der Jump-Point Namen ohne Leerzeichen.\n\nBeispiel:\n§9# Jump-Point X\n.X§8"); - pages.add("§8Um zu einem Jump-Point ohne Abfrage zu springen kann man den\n'jump ' Befehl verwenden."); - pages.add("§6Schleifen§8\n\nSchleifen werden mit Jump-Points, if Abfragen und Jumps gebaut.\n\nBeispiel:\n§9var i 0\n.JUMP\nvar i ++\nif i 10 END JUMP\n.END§8"); - pages.add("§6\"echo\"§8\n\nDer echo Befehl ist da um Ausgaben zu tätigen. Hier drin kann man sowohl Variablen ausgeben, als auch Farbcodes verwenden. Es wird alles nach dem Befehl ausgegeben.\n\nBeispiel:\n§9echo &eSteam&8war &7war hier!"); - pages.add("§6\"input\"§8\n\nDer input Befehl ist eine Aufforderung einer Eingabe des Users. Die Argumente sind eine Variable und ein Text als Nachricht.\n\nBeispiel:\n§9input age &eDein Alter?"); - pages.add("§6Arithmetik§8\n\nEs gibt 4 Arithmetische Befehle:\n- add\n- sub\n- mul\n- div\n\nDer erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein"); - pages.add("§8Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen.\n\nBeispiel:\n§9var i 2\nvar j 3\nadd i j\necho $i"); - pages.add("§8Man kann auch 3 Argumente angeben. Dann wird die arithmetische Operation zwischen den letzten beiden Argumenten berechnet und als Variable des ersten Arguments abgespeichert. \n\nBeispiel auf der nächsten Seite -->"); - pages.add("§8Beispiel:\n§9var i 2\nvar j 2\nadd k i j\necho $k"); - pages.add("§6Logik§8\n\nEs gibt 3 Vergleichs Befehle:\n- equal\n- less\n- greater\n\nUnd 3 Logik Befehle:\n- and\n- or\n- not"); - pages.add("§8Der erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen. Dies gilt nicht für den 'not' Befehl, welcher"); - pages.add("§8nur 2 Parameter nimmt. Der erste die Variable und der zweite eine optionale Variable oder ein Wert. Equal vergleicht 2 Werte, less gibt zurück ob der erste kleiner als der zweite Wert ist, greater gibt zurück ob der erste größer als der zweite Wert ist."); - pages.add("§8And vergleicht ob 2 Werte true (1) sind. Or vergleicht ob 1 Wert oder 2 Werte true (1) ist/sind. Not invertiert den Wert von true (1) auf false und anders rum."); - pages.add("§8Beispiel:\n§9var i 1\nvar j 1\n#Ist i und j gleich\nequal k i j\nvar j 0\n#Ist i kleiner j\nless k i j\n#Ist i größer j\ngreater k i j\n#Ist i und j true\nand k i j\n#Beispiel weiter auf nächster Seite"); - pages.add("§9#Ist i oder j true\nor k i j\n#Invertiere i\nnot k i"); - - BookMeta bookMeta = (BookMeta) BOOK.getItemMeta(); - bookMeta.setGeneration(BookMeta.Generation.ORIGINAL); - bookMeta.setAuthor("§eSteam§8war"); - bookMeta.setTitle("§7Script Buch"); - bookMeta.setDisplayName("§7Script Buch"); - bookMeta.setPages(pages); - BOOK.setItemMeta(bookMeta); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§escript §8- §7Gibt das Script Buch"); - } - - @Register - public void giveCommand(Player p) { - SWUtils.giveItemToPlayer(p, BOOK); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScriptVars.java deleted file mode 100644 index 961d909e..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ /dev/null @@ -1,120 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.world.ScriptListener; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import org.bukkit.entity.Player; - -import java.util.*; - -public class CommandScriptVars extends SWCommand { - - public CommandScriptVars() { - super("scripvars"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf"); - p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück"); - p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert"); - p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable"); - } - - @Register - public void genericCommand(Player p) { - Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p); - if (globalVariables == null) { - p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - return; - } - int i = 0; - p.sendMessage(BauSystem.PREFIX + globalVariables.size() + " Variable(n)"); - for (Map.Entry var : globalVariables.entrySet()) { - if (i++ >= 40) break; - p.sendMessage("- " + var.getKey() + "=" + var.getValue()); - } - } - - @Register - public void removeCommand(Player p, String varName) { - Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p); - if (globalVariables == null) { - p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - return; - } - if (!globalVariables.containsKey(varName)) { - p.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable"); - return; - } - p.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName)); - } - - @Register - public void booleanValueCommand(Player p, String varName, int value) { - ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value); - p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); - } - - @Register - public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) { - if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) { - p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - return; - } - ScriptListener.GLOBAL_VARIABLES.get(p).remove(varName); - p.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht"); - } - - @ClassMapper(value = String.class, local = true) - public TypeMapper stringTypeMapper() { - return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> { - if (commandSender instanceof Player) { - Player player = (Player) commandSender; - return new ArrayList<>(ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).keySet()); - } - return null; - }); - } - - @Mapper(value = "Delete", local = true) - public TypeMapper clearStringTypeMapper() { - List tabCompletes = Arrays.asList("delete", "clear", "remove"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) { - return s; - } - return null; - }, s -> tabCompletes); - } - - @ClassMapper(value = int.class, local = true) - public TypeMapper integerTypeMapper() { - List tabCompletes = Arrays.asList("true", "false", "yes", "no"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null; - return ScriptListener.parseValue(s); - }, s -> tabCompletes); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSelect.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSelect.java deleted file mode 100644 index e99cb8fb..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSelect.java +++ /dev/null @@ -1,143 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.WorldeditWrapper; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.*; -import de.steamwar.command.SWCommand; -import lombok.Getter; -import org.bukkit.entity.Player; - - -public class CommandSelect extends SWCommand { - - @Getter - private static CommandSelect instance = null; - - public CommandSelect() { - super("select"); - } - - { - instance = this; - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); - p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); - } - - @Register - public void baurahmenCommand(Player p, RegionType regionType) { - if (!permissionCheck(p)) { - return; - } - - Region region = Region.getRegion(p.getLocation()); - - if (GlobalRegion.isGlobalRegion(region)) { - p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen"); - return; - } - - if (regionType == RegionType.TESTBLOCK) { - if (!region.hasTestblock()) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock"); - return; - } - setSelection(regionType, RegionExtensionType.NORMAL, region, p); - return; - } - - if (regionType == RegionType.BUILD) { - if (!region.hasBuildRegion()) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea"); - return; - } - setSelection(regionType, RegionExtensionType.NORMAL, region, p); - return; - } - - setSelection(regionType, RegionExtensionType.NORMAL, region, p); - } - - @Register - public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { - if (!permissionCheck(p)) { - return; - } - - Region region = Region.getRegion(p.getLocation()); - - if (GlobalRegion.isGlobalRegion(region)) { - p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen"); - return; - } - - if (regionType == RegionType.TESTBLOCK) { - if (!region.hasTestblock()) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock"); - return; - } - if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße"); - return; - } - setSelection(regionType, regionExtensionType, region, p); - return; - } - - if (regionType == RegionType.BUILD) { - if (!region.hasBuildRegion()) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea"); - return; - } - if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) { - p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße"); - return; - } - setSelection(regionType, regionExtensionType, region, p); - return; - } - - setSelection(regionType, regionExtensionType, region, p); - } - - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLDEDIT)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Select verwenden"); - return false; - } - return true; - } - - private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) { - Point minPoint = region.getMinPoint(regionType, regionExtensionType); - Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); - - WorldeditWrapper.impl.setSelection(p, minPoint, maxPoint); - p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt"); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSkull.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSkull.java deleted file mode 100644 index 1fdc4164..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSkull.java +++ /dev/null @@ -1,49 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.command.SWCommand; -import de.steamwar.inventory.SWItem; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -public class CommandSkull extends SWCommand { - - public CommandSkull() { - super("skull"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf"); - } - - @Register - public void giveCommand(Player p, String skull) { - ItemStack is = SWItem.getPlayerSkull(skull).getItemStack(); - SkullMeta sm = (SkullMeta) is.getItemMeta(); - assert sm != null; - sm.setDisplayName("§e" + skull + "§8s Kopf"); - is.setItemMeta(sm); - SWUtils.giveItemToPlayer(p, is); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSpeed.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSpeed.java deleted file mode 100644 index ed6943c8..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ /dev/null @@ -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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import org.bukkit.entity.Player; - -import java.util.Arrays; -import java.util.List; - -public class CommandSpeed extends SWCommand { - - public CommandSpeed() { - super("speed"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit"); - } - - @Register({"default"}) - public void defaultCommand(Player p) { - speedCommand(p, 1); - } - - @Register - public void speedCommand(Player p, float speed) { - if (speed < 0 || speed > 10) { - p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); - return; - } - - p.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt"); - p.setFlySpeed(speed / 10); - p.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10); - } - - @ClassMapper(value = float.class, local = true) - public TypeMapper doubleTypeMapper() { - List tabCompletes = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); - return SWCommandUtils.createMapper(s -> { - try { - return Float.parseFloat(s.replace(',', '.')); - } catch (NumberFormatException e) { - return null; - } - }, s -> tabCompletes); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTNT.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTNT.java deleted file mode 100644 index d7dc91ff..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTNT.java +++ /dev/null @@ -1,173 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.RegionExtensionType; -import de.steamwar.bausystem.world.regions.RegionType; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class CommandTNT extends SWCommand implements Listener { - - public enum TNTMode { - ON("§aan"), - ONLY_TB("§7Kein §eBaurahmen"), - OFF("§caus"); - - private String name; - - TNTMode(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - - public CommandTNT() { - super("tnt"); - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§etnt §8- §7Ändere das TNT verhalten"); - p.sendMessage("§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus"); - } - - @Register - public void toggleCommand(Player p) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - tntToggle(region, null, null); - } - - @Register - public void setCommand(Player p, TNTMode tntMode) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - - String requestedMessage = null; - switch (tntMode) { - case ON: - requestedMessage = getEnableMessage(); - break; - case OFF: - requestedMessage = getDisableMessage(); - break; - case ONLY_TB: - requestedMessage = getTestblockEnableMessage(); - break; - } - tntToggle(region, tntMode, requestedMessage); - } - - private boolean permissionCheck(Player p) { - if (Welt.noPermission(p, Permission.WORLD)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); - return false; - } - return true; - } - - @ClassMapper(value = TNTMode.class, local = true) - public TypeMapper tntModeTypeMapper() { - Map tntModeMap = new HashMap<>(); - tntModeMap.put("an", TNTMode.ON); - tntModeMap.put("on", TNTMode.ON); - tntModeMap.put("aus", TNTMode.OFF); - tntModeMap.put("off", TNTMode.OFF); - if (Region.buildAreaEnabled()) { - tntModeMap.put("testblock", TNTMode.ONLY_TB); - tntModeMap.put("tb", TNTMode.ONLY_TB); - } - List tabCompletes = new ArrayList<>(tntModeMap.keySet()); - return SWCommandUtils.createMapper(s -> tntModeMap.getOrDefault(s, null), s -> tabCompletes); - } - - private String getEnableMessage() { - return "§aTNT-Schaden aktiviert"; - } - - private String getDisableMessage() { - return "§cTNT-Schaden deaktiviert"; - } - - private String getTestblockEnableMessage() { - return "§aTNT-Schaden außerhalb Baurahmen aktiviert"; - } - - private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { - if (requestedMode != null && region.hasTestblock()) { - region.setTntMode(requestedMode); - RegionUtils.actionBar(region, requestedMessage); - return; - } - switch (region.getTntMode()) { - case ON: - case ONLY_TB: - region.setTntMode(TNTMode.OFF); - RegionUtils.actionBar(region, getDisableMessage()); - break; - case OFF: - if (Region.buildAreaEnabled() && region.hasTestblock()) { - region.setTntMode(TNTMode.ONLY_TB); - RegionUtils.actionBar(region, getTestblockEnableMessage()); - } else { - region.setTntMode(TNTMode.ON); - RegionUtils.actionBar(region, getEnableMessage()); - } - break; - } - } - - @EventHandler - public void onExplode(EntityExplodeEvent event) { - event.blockList().removeIf(block -> { - Region region = Region.getRegion(block.getLocation()); - if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) { - RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); - return true; - } - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) { - RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); - return true; - } - return region.getTntMode() == TNTMode.OFF; - }); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java deleted file mode 100644 index 53ec3832..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ /dev/null @@ -1,176 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.CraftbukkitWrapper; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.TPSUtils; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitTask; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class CommandTPSLimiter extends SWCommand { - - private static CommandTPSLimiter instance = null; - - { - instance = this; - } - - private static final World WORLD = Bukkit.getWorlds().get(0); - private static double currentTPSLimit = 20; - - private long lastTime = System.nanoTime(); - private long currentTime = System.nanoTime(); - - private double delay = 0; - private int loops = 0; - private long sleepDelay = 0; - - private BukkitTask tpsLimiter = null; - - private List tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); - - public CommandTPSLimiter() { - super("tpslimit"); - if (TPSUtils.isWarpAllowed()) { - for (int i = 20; i <= 60; i += 5) { - tabCompletions.add(i + ""); - } - } - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit); - p.sendMessage("§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau"); - } - - @Register({"default"}) - public void defaultCommand(Player p) { - if (!permissionCheck(p)) return; - currentTPSLimit = 20; - sendNewTPSLimitMessage(); - tpsLimiter(); - } - - @Register - public void valueCommand(Player p, double tpsLimitDouble) { - if (!permissionCheck(p)) return; - if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 60 : 20)) { - sendInvalidArgumentMessage(p); - return; - } - currentTPSLimit = tpsLimitDouble; - sendNewTPSLimitMessage(); - tpsLimiter(); - } - - @ClassMapper(value = double.class, local = true) - public TypeMapper doubleTypeMapper() { - return SWCommandUtils.createMapper(s -> { - try { - return Double.parseDouble(s.replace(',', '.')); - } catch (NumberFormatException e) { - return 0D; - } - }, s -> tabCompletions); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen"); - return false; - } - return true; - } - - private void sendNewTPSLimitMessage() { - Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§eTPS limit auf " + currentTPSLimit + " gesetzt."))); - } - - private void sendInvalidArgumentMessage(Player player) { - player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und " + (TPSUtils.isWarpAllowed() ? 60 : 20) + ", und 'default' erlaubt."); - } - - private void tpsLimiter() { - delay = 20 / currentTPSLimit; - loops = (int) Math.ceil(delay); - sleepDelay = (long) (50 * delay) / loops; - - TPSUtils.setTPS(currentTPSLimit); - if (currentTPSLimit >= 20) { - if (tpsLimiter == null) return; - tpsLimiter.cancel(); - tpsLimiter = null; - } else { - if (tpsLimiter != null) return; - tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - CraftbukkitWrapper.impl.createTickCache(WORLD); - - for (int i = 0; i < loops; i++) { - sleepUntilNextTick(sleepDelay); - CraftbukkitWrapper.impl.sendTickPackets(); - } - }, 0, 1); - } - } - - private void sleepUntilNextTick(long neededDelta) { - lastTime = currentTime; - currentTime = System.nanoTime(); - - long timeDelta = (currentTime - lastTime) / 1000000; - if (neededDelta - timeDelta < 0) return; - - try { - Thread.sleep(neededDelta - timeDelta); - currentTime = System.nanoTime(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - public static double getCurrentTPSLimit() { - return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D; - } - - public static void setTPS(double d) { - if (d < 0.5) d = 0.5; - if (d > (TPSUtils.isWarpAllowed() ? 60 : 20)) d = (TPSUtils.isWarpAllowed() ? 60 : 20); - if (instance != null) { - currentTPSLimit = d; - instance.tpsLimiter(); - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTeleport.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTeleport.java deleted file mode 100644 index cb7fbdc6..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ /dev/null @@ -1,46 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -public class CommandTeleport extends SWCommand { - - public CommandTeleport() { - super("teleport", "tp"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler"); - } - - @Register - public void genericCommand(Player p, Player target) { - if (p.getUniqueId().equals(target.getUniqueId())) { - p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); - return; - } - p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTestblock.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTestblock.java deleted file mode 100644 index cbc71be6..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ /dev/null @@ -1,128 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.tracer.show.ShowModeParameterType; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.bausystem.world.regions.RegionExtensionType; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; - -public class CommandTestblock extends SWCommand { - - public CommandTestblock() { - super("testblock", "tb"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§etestblock §8- §7Setzte den Testblock zurück"); - p.sendMessage("§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück"); - } - - @Register - public void genericTestblockCommand(Player p) { - genericTestblockCommand(p, RegionExtensionType.NORMAL); - } - - @Register - public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) { - if (!permissionCheck(p)) return; - Region region = regionCheck(p); - if (region == null) return; - try { - region.resetTestblock(null, regionExtensionType == RegionExtensionType.EXTENSION); - p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); - } - } - - - @Register - public void schematicTestblockCommand(Player p, SchematicNode schem) { - schematicTestblockCommand(p, schem, RegionExtensionType.NORMAL); - } - - @Register - public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, SchematicNode schem) { - schematicTestblockCommand(p, schem, regionExtensionType); - } - - @Register - public void schematicTestblockCommand(Player p, SchematicNode schem, RegionExtensionType regionExtensionType) { - if (!permissionCheck(p)) return; - Region region = regionCheck(p); - if (region == null) return; - try { - region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION); - p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); - } catch (IOException e) { - p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); - } - } - - @ClassMapper(value = RegionExtensionType.class, local = true) - private TypeMapper regionExtensionTypeTypeMapper() { - Map showModeParameterTypesMap = new HashMap<>(); - showModeParameterTypesMap.put("-normal", RegionExtensionType.NORMAL); - showModeParameterTypesMap.put("-n", RegionExtensionType.NORMAL); - showModeParameterTypesMap.put("-extension", RegionExtensionType.EXTENSION); - showModeParameterTypesMap.put("-e", RegionExtensionType.EXTENSION); - - List tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet()); - return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes); - } - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLDEDIT)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen"); - return false; - } - return true; - } - - private Region regionCheck(Player player) { - Region region = Region.getRegion(player.getLocation()); - if (!region.hasTestblock()) { - player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return null; - } - return region; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTime.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTime.java deleted file mode 100644 index c209ae1d..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTime.java +++ /dev/null @@ -1,99 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import java.util.Arrays; -import java.util.List; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class CommandTime extends SWCommand { - - private static List tabCompletions = Arrays.asList("0", "6000", "12000", "18000"); - - public CommandTime() { - super("time"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau"); - } - - @Register - public void genericCommand(Player p, int time) { - if (Welt.noPermission(p, Permission.WORLD)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); - return; - } - if (time < 0 || time > 24000) { - p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return; - } - Bukkit.getWorlds().get(0).setTime(time); - } - - @Register - public void genericCommand(Player p, Time time) { - if (Welt.noPermission(p, Permission.WORLD)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); - return; - } - Bukkit.getWorlds().get(0).setTime(time.getValue()); - } - - @ClassMapper(value = int.class, local = true) - public TypeMapper doubleTypeMapper() { - return SWCommandUtils.createMapper(s -> { - try { - return Integer.parseInt(s); - } catch (NumberFormatException e) { - return 0; - } - }, s -> tabCompletions); - } - - public enum Time { - NIGHT(18000), - DAY(6000), - DAWN(0), - SUNSET(12000), - NACHT(18000), - TAG(6000), - MORGEN(0), - ABEND(12000); - - private int value; - - private Time(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTrace.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTrace.java deleted file mode 100644 index 615b4387..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandTrace.java +++ /dev/null @@ -1,132 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.gui.GuiTraceShow; -import de.steamwar.bausystem.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.tracer.show.ShowModeParameterType; -import de.steamwar.bausystem.tracer.show.StoredRecords; -import de.steamwar.bausystem.tracer.show.TraceShowManager; -import de.steamwar.bausystem.tracer.show.mode.EntityShowMode; -import de.steamwar.bausystem.world.Welt; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - -public class CommandTrace extends SWCommand { - - public CommandTrace() { - super("trace"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen"); - p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer"); - p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart"); - p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui"); - p.sendMessage("§8/§etrace show §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen"); - p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen"); - p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen"); - // p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); - // p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an"); - // p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]"); - } - - @Register({"start"}) - public void startCommand(Player p) { - if (!permissionCheck(p)) return; - RecordStateMachine.commandStart(); - p.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet"); - } - - @Register({"stop"}) - public void stopCommand(Player p) { - if (!permissionCheck(p)) return; - RecordStateMachine.commandStop(); - p.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); - } - - @Register({"toggleauto"}) - public void toggleAutoCommand(Player p) { - autoCommand(p); - } - - @Register({"auto"}) - public void autoCommand(Player p) { - if (!permissionCheck(p)) return; - RecordStateMachine.commandAuto(); - p.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage()); - } - - @Register({"clear"}) - public void clearCommand(Player p) { - deleteCommand(p); - } - - @Register({"delete"}) - public void deleteCommand(Player p) { - if (!permissionCheck(p)) return; - StoredRecords.clear(); - p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht"); - } - - @Register({"show"}) - public void showCommand(Player p) { - if (!permissionCheck(p)) return; - TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter())); - p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); - } - - @Register({"show"}) - public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) { - if (!permissionCheck(p)) return; - ShowModeParameter showModeParameter = new ShowModeParameter(); - for (ShowModeParameterType showModeParameterType : showModeParameterTypes) { - showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); - } - TraceShowManager.show(p, new EntityShowMode(p, showModeParameter)); - p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); - } - - @Register({"show", "gui"}) - public void showGuiCommand(Player p) { - if (!permissionCheck(p)) return; - GuiTraceShow.openGui(p); - } - - @Register({"hide"}) - public void hideCommand(Player p) { - if (!permissionCheck(p)) return; - TraceShowManager.hide(p); - p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet"); - } - - - private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); - return false; - } - return true; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java deleted file mode 100644 index 90d3f5c5..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java +++ /dev/null @@ -1,45 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.command.SWCommand; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -public class CommandWorldSpawn extends SWCommand { - - private World world = Bukkit.getWorlds().get(0); - - public CommandWorldSpawn() { - super("worldspawn"); - } - - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§eworldspawn §8- §7Teleportiere dich zum Spawn"); - } - - @Register - public void genericCommand(Player p) { - p.teleport(world.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.COMMAND); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/commands/RegionUtils.java b/LegacyBauSystem/src/de/steamwar/bausystem/commands/RegionUtils.java deleted file mode 100644 index 21f610bc..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/commands/RegionUtils.java +++ /dev/null @@ -1,42 +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 . - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.world.regions.GlobalRegion; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.regions.RegionExtensionType; -import de.steamwar.bausystem.world.regions.RegionType; -import lombok.experimental.UtilityClass; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; - -@UtilityClass -public class RegionUtils { - - public static void actionBar(Region region, String s) { - if (GlobalRegion.isGlobalRegion(region)) { - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); - } else { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/gui/GuiTraceShow.java b/LegacyBauSystem/src/de/steamwar/bausystem/gui/GuiTraceShow.java deleted file mode 100644 index 193bece5..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/gui/GuiTraceShow.java +++ /dev/null @@ -1,131 +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 . - */ - -package de.steamwar.bausystem.gui; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.FlatteningWrapper; -import de.steamwar.bausystem.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.tracer.show.TraceShowManager; -import de.steamwar.bausystem.tracer.show.mode.EntityShowMode; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -public class GuiTraceShow { - - private static final Map ShowModeParameterMap = new HashMap<>(); - - private GuiTraceShow() { - - } - - public static void openGui(Player player) { - ShowModeParameter playerShowMode = new ShowModeParameter(); - playerShowMode.setInterpolate_Y(false); - playerShowMode.setInterpolate_XZ(false); - ShowModeParameterMap.put(player, playerShowMode); - - SWInventory swInventory = new SWInventory(player, 9, "Trace Show GUI"); - swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player)); - setActiveShow(player, swInventory); - - SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> { - }); - swInventory.setItem(5, water); - swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water)); - - SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> { - }); - swInventory.setItem(6, interpolateY); - swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY)); - - Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial(); - SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> { - }); - swInventory.setItem(7, interpolateXZ); - swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ)); - // Water Bucket (-water) - // TNT (-water-exploded) - // Quartz_Stair (-interpolate-y) - // Quartz_Slab (-interpolate-xz) - swInventory.open(); - } - - private static void setActiveShow(Player player, SWInventory swInventory) { - if (TraceShowManager.hasActiveShow(player)) { - Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial(); - SWItem shown = new SWItem(showMaterial, (byte) 5, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> { - TraceShowManager.hide(player); - player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet"); - setActiveShow(player, swInventory); - }); - swInventory.setItem(1, shown); - } else { - Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial(); - SWItem hidden = new SWItem(hideMaterial, (byte) 14, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> { - show(player); - player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); - setActiveShow(player, swInventory); - }); - swInventory.setItem(1, hidden); - } - } - - private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setWater(!showModeParameter.isWater()); - show(player); - - swItem.setEnchanted(showModeParameter.isWater()); - swInventory.setItem(5, swItem); - swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem)); - } - - private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y()); - show(player); - - swItem.setEnchanted(showModeParameter.isInterpolate_Y()); - swInventory.setItem(6, swItem); - swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem)); - } - - private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ()); - show(player); - - swItem.setEnchanted(showModeParameter.isInterpolate_XZ()); - swInventory.setItem(7, swItem); - swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem)); - } - - private static void show(Player player) { - TraceShowManager.show(player, new EntityShowMode(player, ShowModeParameterMap.get(player))); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/AbstractTraceEntity.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/AbstractTraceEntity.java deleted file mode 100644 index e04e2eb7..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/AbstractTraceEntity.java +++ /dev/null @@ -1,34 +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 . - */ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public interface AbstractTraceEntity { - - void display(Player player, boolean exploded); - - boolean hide(Player player, boolean always); - - int getId(); - - Entity getBukkitEntity(); -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java deleted file mode 100644 index 5b669944..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java +++ /dev/null @@ -1,63 +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 . - */ - -package de.steamwar.bausystem.tracer; - -import org.bukkit.util.Vector; - -import java.util.Objects; - -public class RoundedTNTPosition { - - private static final int factor = 10; - - private int x; - private int y; - private int z; - - public RoundedTNTPosition(TNTPosition tntPosition) { - this(tntPosition.getLocation().getX(), tntPosition.getLocation().getY(), tntPosition.getLocation().getZ()); - } - - public RoundedTNTPosition(Vector vector) { - this(vector.getX(), vector.getY(), vector.getZ()); - } - - public RoundedTNTPosition(double x, double y, double z) { - this.x = (int) (x * factor); - this.y = (int) (y * factor); - this.z = (int) (z * factor); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof RoundedTNTPosition)) return false; - RoundedTNTPosition that = (RoundedTNTPosition) o; - return x == that.x && - y == that.y && - z == that.z; - } - - @Override - public int hashCode() { - return Objects.hash(x, y, z); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/TNTPosition.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/TNTPosition.java deleted file mode 100644 index 2d96cdac..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/TNTPosition.java +++ /dev/null @@ -1,63 +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 . - */ - -package de.steamwar.bausystem.tracer; - -import de.steamwar.bausystem.tracer.show.Record; -import org.bukkit.entity.Entity; -import org.bukkit.util.Vector; - -public class TNTPosition { - - private final Record.TNTRecord record; - private final Vector location; - private final Vector previousLocation; - private final boolean exploded; - - public TNTPosition(Record.TNTRecord record, Entity entity, Vector previousLocation, boolean exploded) { - this.location = entity.getLocation().toVector(); - this.record = record; - this.previousLocation = previousLocation; - this.exploded = exploded; - } - - public Vector getLocation() { - return location; - } - - public Vector getPreviousLocation() { - return previousLocation; - } - - public boolean isExploded() { - return exploded; - } - - public Record.TNTRecord getRecord() { - return record; - } - - @Override - public String toString() { - return "Position{" + - "location=" + location + - '}'; - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java deleted file mode 100644 index 32333d41..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java +++ /dev/null @@ -1,94 +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 . - */ - -package de.steamwar.bausystem.tracer.record; - -public class RecordStateMachine { - private RecordStateMachine() { - } - - private static final TraceAutoHandler autoHandler = new TraceAutoHandler(); - - private static RecordStatus recordStatus = RecordStatus.IDLE; - private static Recorder recorder = null; - - public static void commandStart() { - autoHandler.disable(); - recordStart(); - recordStatus = RecordStatus.RECORD; - } - - public static void commandStop() { - autoHandler.disable(); - recordStop(); - recordStatus = RecordStatus.IDLE; - } - - public static void commandAuto() { - if (recordStatus.isTracing()) - return; - - if (recordStatus == RecordStatus.IDLE_AUTO) { - recordStatus = RecordStatus.IDLE; - autoHandler.disable(); - } else { - recordStatus = RecordStatus.IDLE_AUTO; - autoHandler.enable(); - } - } - - static void autoRecord() { - recordStart(); - recordStatus = RecordStatus.RECORD_AUTO; - } - - static void autoIdle() { - recordStop(); - recordStatus = RecordStatus.IDLE_AUTO; - } - - private static void recordStart() { - if (recordStatus.isTracing()) return; - recorder = new Recorder(); - } - - private static void recordStop() { - if (!recordStatus.isTracing()) return; - recorder.stopRecording(); - } - - public static RecordStatus getRecordStatus() { - return recordStatus; - } - - public static int size() { - if (recorder == null) return 0; - return recorder.size(); - } - - public static long getStartTime() { - if (recorder == null) return 0; - return recorder.getStartTime(); - } - - public static void postClear() { - if (recorder == null) return; - recorder.postClear(); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStatus.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStatus.java deleted file mode 100644 index 38e45d2b..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/RecordStatus.java +++ /dev/null @@ -1,55 +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 . - */ - -package de.steamwar.bausystem.tracer.record; - -public enum RecordStatus { - - RECORD("§aan", true, "§cTNT-Tracer muss gestoppt werden"), - RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"), - IDLE("§caus", false, "§cAuto-Tracer gestoppt"), - IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet"); - - String name; - boolean tracing; - String autoMessage; - - RecordStatus(String value, boolean tracing, String autoMessage) { - this.name = value; - this.tracing = tracing; - this.autoMessage = autoMessage; - } - - public String getName() { - return name; - } - - public boolean isTracing() { - return tracing; - } - - public boolean isAutoTrace() { - return this == RECORD_AUTO || this == IDLE_AUTO; - } - - public String getAutoMessage() { - return autoMessage; - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/Recorder.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/Recorder.java deleted file mode 100644 index e1f5fb91..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/Recorder.java +++ /dev/null @@ -1,96 +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 . - */ - -package de.steamwar.bausystem.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.show.Record; -import de.steamwar.bausystem.tracer.show.StoredRecords; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.scheduler.BukkitTask; - -import java.util.HashMap; -import java.util.Map; - -public class Recorder implements Listener { - - private static final World world = Bukkit.getWorlds().get(0); - - private final Map recordMap = new HashMap<>(); - private final BukkitTask task; - private final Record record; - - Recorder() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1); - record = new Record(); - - // To trace TNT initial positions with AutoTracer - run(); - } - - void stopRecording() { - HandlerList.unregisterAll(this); - task.cancel(); - } - - int size() { - return record.size(); - } - - long getStartTime() { - return record.getStartTime(); - } - - void postClear() { - record.clear(); - recordMap.clear(); - StoredRecords.add(record); - } - - private void run() { - world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed)); - } - - @EventHandler - public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) - return; - TNTPrimed tntPrimed = (TNTPrimed) event.getEntity(); - - get(tntPrimed).explode(tntPrimed); - recordMap.remove(tntPrimed); - } - - private Record.TNTRecord get(TNTPrimed tntPrimed) { - Record.TNTRecord tntRecord = recordMap.get(tntPrimed); - if (tntRecord != null) - return tntRecord; - - tntRecord = this.record.spawn(); - recordMap.put(tntPrimed, tntRecord); - return tntRecord; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java deleted file mode 100644 index 4b0cdd44..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java +++ /dev/null @@ -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 . - */ - -package de.steamwar.bausystem.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Bukkit; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.scheduler.BukkitTask; - -public class TraceAutoHandler implements Listener { - /* This listener handles the en- and disabling of the Tracer in AUTO mode */ - - private BukkitTask task; - private int lastExplosion = 0; // Time since the last explosion in ticks - - public void enable() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - - public void disable() { - HandlerList.unregisterAll(this); - if (task != null) { - task.cancel(); - task = null; - } - } - - @EventHandler - public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) - return; - - lastExplosion = 0; - if (task == null) { - RecordStateMachine.autoRecord(); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1); - } - } - - private void run() { - lastExplosion++; - - if (lastExplosion > 80) { - RecordStateMachine.autoIdle(); - task.cancel(); - task = null; - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/Record.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/Record.java deleted file mode 100644 index 598f4656..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/Record.java +++ /dev/null @@ -1,94 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -import de.steamwar.bausystem.tracer.TNTPosition; -import org.bukkit.entity.TNTPrimed; - -import java.util.ArrayList; -import java.util.List; - -public class Record { - - private final long startTime; - private final List tnt = new ArrayList<>(); - - public int size() { - return tnt.size(); - } - - public long getStartTime() { - return startTime; - } - - public void showAll(ShowMode mode) { - for (TNTRecord record : tnt) - record.showAll(mode); - } - - /* The following methods should only be called by a recorder */ - public Record() { - startTime = System.currentTimeMillis(); - StoredRecords.add(this); - } - - public TNTRecord spawn() { - TNTRecord record = new TNTRecord(); - tnt.add(record); - return record; - } - - public void clear() { - tnt.clear(); - } - - public static class TNTRecord { - private final List positions = new ArrayList<>(41); - - public void showAll(ShowMode mode) { - for (TNTPosition position : positions) - mode.show(position); - } - - /* The following methods should only be called by a recorder */ - public void add(TNTPrimed tntPrimed) { - add(tntPrimed, false); - } - - private void add(TNTPrimed tntPrimed, boolean exploded) { - TNTPosition position; - if (positions.isEmpty()) { - position = new TNTPosition(this, tntPrimed, null, exploded); - } else { - position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), exploded); - } - positions.add(position); - TraceShowManager.show(position); - } - - public void explode(TNTPrimed tntPrimed) { - add(tntPrimed, true); - } - - public List getPositions() { - return positions; - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowMode.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowMode.java deleted file mode 100644 index a86824b0..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowMode.java +++ /dev/null @@ -1,28 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -import de.steamwar.bausystem.tracer.TNTPosition; - -public interface ShowMode { - void show(TNTPosition position); - - void hide(); -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java deleted file mode 100644 index 18a39f7b..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java +++ /dev/null @@ -1,55 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -public class ShowModeParameter { - - private boolean water = false; - private boolean interpolate_Y = false; - private boolean interpolate_XZ = false; - - public ShowModeParameter() { - - } - - public boolean isWater() { - return water; - } - - public boolean isInterpolate_Y() { - return interpolate_Y; - } - - public boolean isInterpolate_XZ() { - return interpolate_XZ; - } - - public void setWater(boolean water) { - this.water = water; - } - - public void setInterpolate_Y(boolean interpolate_Y) { - this.interpolate_Y = interpolate_Y; - } - - public void setInterpolate_XZ(boolean interpolate_XZ) { - this.interpolate_XZ = interpolate_XZ; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java deleted file mode 100644 index b85a0928..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -import java.util.function.Consumer; - -public enum ShowModeParameterType { - - WATER(showModeParameter -> showModeParameter.setWater(true)), - INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true)), - INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true)), - ADVANCED(showModeParameter -> { - showModeParameter.setInterpolate_Y(true); - showModeParameter.setInterpolate_XZ(true); - }); - - private final Consumer showModeParameterConsumer; - - public Consumer getShowModeParameterConsumer() { - return showModeParameterConsumer; - } - - ShowModeParameterType(Consumer showModeParameterConsumer) { - this.showModeParameterConsumer = showModeParameterConsumer; - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/StoredRecords.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/StoredRecords.java deleted file mode 100644 index 4ce637f7..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/StoredRecords.java +++ /dev/null @@ -1,45 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -import de.steamwar.bausystem.tracer.record.RecordStateMachine; - -import java.util.ArrayList; -import java.util.List; - -public class StoredRecords { - - private static final List records = new ArrayList<>(); - - public static void add(Record record) { - records.add(record); - } - - public static void showAll(ShowMode mode) { - for (Record record : records) record.showAll(mode); - } - - public static void clear() { - records.clear(); - TraceShowManager.clear(); - RecordStateMachine.postClear(); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java deleted file mode 100644 index 2cce039e..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java +++ /dev/null @@ -1,78 +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 . - */ - -package de.steamwar.bausystem.tracer.show; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.tracer.TNTPosition; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.HashMap; -import java.util.Map; - -public class TraceShowManager implements Listener { - private TraceShowManager() { - } - - private static final Map showModes = new HashMap<>(); - - public static void show(Player player, ShowMode showMode) { - hide(player); - showModes.put(player, showMode); - StoredRecords.showAll(showMode); - } - - public static void hide(Player player) { - ShowMode showMode = showModes.remove(player); - if (showMode == null) - return; - showMode.hide(); - } - - /* Only to be called by record */ - static void show(TNTPosition tnt) { - for (ShowMode mode : showModes.values()) - mode.show(tnt); - } - - /* Only to be called by StoredRecords */ - static void clear() { - for (ShowMode mode : showModes.values()) - mode.hide(); - } - - /* Internal if player leaves*/ - static { - Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getPlugin()); - } - - @EventHandler - public void onLeave(PlayerQuitEvent event) { - showModes.remove(event.getPlayer()); - } - - public static boolean hasActiveShow(Player player) { - return showModes.containsKey(player); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/mode/EntityShowMode.java b/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/mode/EntityShowMode.java deleted file mode 100644 index bbb6057c..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/tracer/show/mode/EntityShowMode.java +++ /dev/null @@ -1,118 +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 . - */ - -package de.steamwar.bausystem.tracer.show.mode; - -import de.steamwar.bausystem.CraftbukkitWrapper; -import de.steamwar.bausystem.FlatteningWrapper; -import de.steamwar.bausystem.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.tracer.RoundedTNTPosition; -import de.steamwar.bausystem.tracer.TNTPosition; -import de.steamwar.bausystem.tracer.show.ShowMode; -import de.steamwar.bausystem.tracer.show.ShowModeParameter; -import org.bukkit.entity.Player; -import org.bukkit.util.Consumer; -import org.bukkit.util.Vector; - -import java.util.HashMap; -import java.util.Map; - -public class EntityShowMode implements ShowMode { - - protected final Player player; - protected final ShowModeParameter showModeParameter; - - private final Map tntEntityMap = new HashMap<>(); - private final Map updateEntityMap = new HashMap<>(); - - public EntityShowMode(Player player, ShowModeParameter showModeParameter) { - this.player = player; - this.showModeParameter = showModeParameter; - } - - @Override - public void show(TNTPosition position) { - if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) { - // Basic - for (TNTPosition pos : position.getRecord().getPositions()) { - RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos); - tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> { - return tnt.hide(player, false) ? null : tnt; - }); - } - // Advanced - for (TNTPosition pos : position.getRecord().getPositions()) { - applyOnPosition(pos, updatePointPosition -> { - updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> { - return point.hide(player, false) ? null : point; - }); - }); - } - return; - } - - RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position); - AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(player, position.getLocation(), true)); - entity.display(player, position.isExploded()); - - applyOnPosition(position, updatePointPosition -> { - updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> { - return createEntity(player, updatePointPosition, false); - }).display(player, position.isExploded()); - }); - } - - private boolean checkWater(Vector position) { - return FlatteningWrapper.impl.inWater(player.getWorld(), position); - } - - public static AbstractTraceEntity createEntity(Player player, Vector position, boolean tnt) { - return CraftbukkitWrapper.impl.create(player.getWorld(), position, tnt); - } - - private void applyOnPosition(TNTPosition position, Consumer function) { - if (position.getPreviousLocation() == null) return; - - if (showModeParameter.isInterpolate_Y()) { - Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY()); - if (!position.getLocation().equals(updatePointY)) { - function.accept(updatePointY); - } - } - - if (showModeParameter.isInterpolate_XZ()) { - Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation()); - Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ()) - ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) - : position.getLocation().clone().setX(position.getPreviousLocation().getX()); - if (!position.getLocation().equals(updatePointXZ)) { - function.accept(updatePointXZ); - } - } - } - - @Override - public void hide() { - tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true)); - tntEntityMap.clear(); - updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true)); - updateEntityMap.clear(); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/AFKStopper.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/AFKStopper.java deleted file mode 100644 index 74eb8f86..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/AFKStopper.java +++ /dev/null @@ -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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -public class AFKStopper implements Listener { - - private static final String afkWarning = BauSystem.PREFIX + "§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt"; - - private int minutesAfk; - - public AFKStopper() { - minutesAfk = 0; - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - switch (minutesAfk) { - case 5: - for (Player p : Bukkit.getOnlinePlayers()) - p.kickPlayer("§cAuf diesem Server ist seit 5 Minuten nichts passiert."); - break; - case 4: - Bukkit.broadcastMessage(afkWarning); - default: - minutesAfk++; - } - }, 1200, 1200); //every minute - } - - @EventHandler - public void onPlayerMove(PlayerMoveEvent event) { - minutesAfk = 0; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/AbstractAutoLoader.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/AbstractAutoLoader.java deleted file mode 100644 index 70cf1487..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/AbstractAutoLoader.java +++ /dev/null @@ -1,122 +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 . - */ - -package de.steamwar.bausystem.world; - -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.util.LinkedList; - -abstract class AbstractAutoLoader { - - abstract Player getPlayer(); - abstract boolean setRedstone(Location location, boolean active); - abstract LinkedList getActions(); - abstract void resetLastActivation(); - abstract int getLastActivation(); - - void print(String message, boolean withSize){ - if(withSize) - getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getActions().size())); - else - getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); - } - - abstract static class LoaderAction { - - final Location location; - final AbstractAutoLoader loader; - - LoaderAction(AbstractAutoLoader loader, Location location){ - this.location = location; - this.loader = loader; - loader.getActions().add(this); - loader.resetLastActivation(); - } - - abstract boolean perform(); - abstract int ticks(); - } - - static class RedstoneActivation extends LoaderAction{ - - final boolean active; - final int length; - int status; - - RedstoneActivation(AbstractAutoLoader loader, Location location, int ticks, boolean active){ - super(loader, location); - this.length = ticks; - this.active = active; - status = 0; - } - - @Override - public boolean perform() { - status++; - if(status < length) - return false; - - if(!loader.setRedstone(location, active)) - return false; - status = 0; - return true; - } - - @Override - int ticks() { - return 1; - } - } - - static class TemporaryActivation extends LoaderAction{ - - final int length; - int status; - - TemporaryActivation(AbstractAutoLoader loader, Location location, int ticks){ - super(loader, location); - this.length = ticks; - status = 0; - } - - @Override - public boolean perform() { - if(status == 0){ - if(!loader.setRedstone(location, true)) - return false; - }else if(status == length){ - if(!loader.setRedstone(location, false)) - return false; - status = 0; - return true; - } - status++; - return false; - } - - @Override - int ticks() { - return 1; - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/AutoLoader.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/AutoLoader.java deleted file mode 100644 index 5b3caec6..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/AutoLoader.java +++ /dev/null @@ -1,266 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.FlatteningWrapper; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitTask; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.ListIterator; -import java.util.Map; - -public class AutoLoader extends AbstractAutoLoader implements Listener { - - private static final Map players = new HashMap<>(); - - public static AutoLoader getLoader(Player player){ - if(!players.containsKey(player)) - return new AutoLoader(player); - return players.get(player); - } - - public static boolean hasLoader(Player player){ - return players.containsKey(player); - } - - private final Player player; - private final BukkitTask task; - - private final LinkedList actions = new LinkedList<>(); - private int ticksBetweenShots = 80; - private int ticksBetweenBlocks = 1; - - private int lastActivation; - private int waitTicks; - private ListIterator lastAction; - private boolean setup; - private Location lastLocation; - - private AutoLoader(Player player){ - this.player = player; - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1); - players.put(player, this); - player.sendMessage(BauSystem.PREFIX + "§7Schieße bitte einmal die Kanone ab"); - player.sendMessage(BauSystem.PREFIX + "§7Und starte anschließend den AutoLader mit §8/§eloader start"); - setup(); - } - - public void setup(){ - print("§aAutoLader im Setup-Modus", false); - setup = true; - waitTicks = 0; - lastActivation = 0; - } - - public void start(){ - if(actions.isEmpty()){ - print("§cKeine Aktion vorhanden", false); - return; - } - - if(!setup){ - print("§cAutoLader läuft bereits", false); - return; - } - - setup = false; - waitTicks = 0; - lastActivation = 0; - lastAction = actions.listIterator(); - print("§aAutoLader gestartet", false); - } - - public void stop(){ - print("§cAutoLader gestoppt", false); - players.remove(player); - HandlerList.unregisterAll(this); - if(task != null) - task.cancel(); - } - - public void undo(){ - if(actions.isEmpty()){ - print("§cKeine Aktion vorhanden", false); - return; - } - - actions.removeLast(); - print("§aUndo erfolgreich", true); - } - - public void wait(int time){ - if(time < 1){ - print("§cDie Wartezeit ist zu klein", false); - return; - } - - print("§aSchusswartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenShots, false); - ticksBetweenShots = time; - } - - public void blockWait(int time){ - if(time < 1){ - print("§cDie Wartezeit ist zu klein", false); - return; - } - - print("§aSetzwartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenBlocks, false); - ticksBetweenBlocks = time; - } - - public int getTicksBetweenShots() { - return ticksBetweenShots; - } - - public int getTicksBetweenBlocks() { - return ticksBetweenBlocks; - } - - public boolean isSetup() { - return setup; - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event){ - if(!setup || !event.getPlayer().equals(player)) - return; - if(event.getBlock().getType() != Material.TNT) - return; - - new TNTPlaceAction(this, event.getBlock().getLocation()); - print("§eTNT platziert", true); - } - - //BlockRedstoneEvent? - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event){ - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) - return; - if (event.getClickedBlock().getType() == Material.OBSERVER) - return; - if (event.getPlayer().isSneaking()) - return; - - if (!setup || !event.getPlayer().equals(player)) - return; - - Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event); - if (detoloader == null || detoloader.getActivation() < 0) return; - - if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return; - - if (detoloader.useActive) { - new AbstractAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() - , detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation() - , detoloader.isActive()); - } else { - new AbstractAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation() - , detoloader.getActivation()); - } - print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" : - detoloader.getBlock(), detoloader.addBack); - lastLocation = event.getClickedBlock().getLocation(); - } - - @EventHandler - public void onLeave(PlayerQuitEvent event){ - if(!event.getPlayer().equals(player)) - return; - stop(); - } - - private void run(){ - lastActivation++; - if(setup) - return; - while(lastActivation >= waitTicks){ - lastActivation = 0; - - LoaderAction action = lastAction.next(); - if(action.perform()){ - waitTicks = action.ticks(); - }else{ - waitTicks = 1; - lastAction.previous(); - } - - if(!lastAction.hasNext()){ - lastAction = actions.listIterator(); - waitTicks = ticksBetweenShots; - } - } - } - - @Override - Player getPlayer() { - return player; - } - - @Override - boolean setRedstone(Location location, boolean active){ - return FlatteningWrapper.impl.setRedstone(location, active); - } - - @Override - LinkedList getActions() { - return actions; - } - - @Override - void resetLastActivation() { - lastActivation = 0; - } - - @Override - int getLastActivation() { - return lastActivation; - } - - class TNTPlaceAction extends AbstractAutoLoader.LoaderAction { - - TNTPlaceAction(AbstractAutoLoader loader, Location location){ - super(loader, location); - } - - @Override - public boolean perform() { - return FlatteningWrapper.impl.tntPlaceActionPerform(location); - } - - @Override - int ticks(){ - return ticksBetweenBlocks; - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/BauScoreboard.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/BauScoreboard.java deleted file mode 100644 index 0d1a5fdd..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/BauScoreboard.java +++ /dev/null @@ -1,111 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.commands.CommandTPSLimiter; -import de.steamwar.bausystem.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.core.TPSWatcher; -import de.steamwar.scoreboard.SWScoreboard; -import de.steamwar.scoreboard.ScoreboardCallback; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; - -public class BauScoreboard implements Listener { - - @EventHandler - public void handlePlayerJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - - SWScoreboard.impl.createScoreboard(player, new ScoreboardCallback() { - @Override - public HashMap getData() { - return sidebar(player); - } - - @Override - public String getTitle() { - return "§eSteam§8War"; - } - }); - } - - private HashMap sidebar(Player p) { - List strings = new ArrayList<>(); - strings.add("§1"); - strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); - strings.add("§2"); - Region region = Region.getRegion(p.getLocation()); - strings.add("§eTNT§8: " + region.getTntMode().getName()); - strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus")); - strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can")); - strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName()); - strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus")); - if (region.hasProtection()) { - strings.add("§eProtect§8: " + (region.isProtect() ? "§aan" : "§caus")); - } - - if (RecordStateMachine.getRecordStatus().isTracing()) { - strings.add("§3"); - strings.add("§eTicks§8: §7" + traceTicks()); - strings.add("§eAnzahl TNT§8: §7" + RecordStateMachine.size()); - } - - strings.add("§4"); - strings.add("§eTPS§8: " + tpsColor() + TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); - - int i = strings.size(); - HashMap result = new HashMap<>(); - for (String s : strings) - result.put(s, i--); - return result; - } - - private long traceTicks() { - return (System.currentTimeMillis() - RecordStateMachine.getStartTime()) / 50; - } - - private String tpsColor() { - double tps = TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND); - if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) { - return "§a"; - } - if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.5) { - return "§e"; - } - return "§c"; - } - - private String tpsLimit() { - if (CommandTPSLimiter.getCurrentTPSLimit() == 20) { - return ""; - } - return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit(); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/ClipboardListener.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/ClipboardListener.java deleted file mode 100644 index bbf70596..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/ClipboardListener.java +++ /dev/null @@ -1,63 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.sql.SchematicData; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -public class ClipboardListener implements Listener { - - private static final String CLIPBOARD_SCHEMNAME = "//copy"; - - @EventHandler - public void onLogin(PlayerJoinEvent e) { - try { - SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); - if (schematic != null) { - new SchematicData(schematic).loadToPlayer(e.getPlayer()); - } - } catch (Exception ex) { - // ignore cause players do all kind of stuff with schematics.... like massively oversized schems - } - } - - @EventHandler - public void onLogout(PlayerQuitEvent e) { - SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); - boolean newSchem = false; - if (schematic == null) { - schematic = SchematicNode.createSchematic(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, null); - newSchem = true; - } - - try { - SchematicData.saveFromPlayer(e.getPlayer(), schematic); - } catch (Exception ex) { - if (newSchem) { - schematic.delete(); - } - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/Color.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/Color.java deleted file mode 100644 index 0b74a868..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/Color.java +++ /dev/null @@ -1,39 +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 . - */ - -package de.steamwar.bausystem.world; - -public enum Color { - WHITE, - ORANGE, - MAGENTA, - LIGHT_BLUE, - YELLOW, - LIME, - PINK, - GRAY, - LIGHT_GRAY, - CYAN, - PURPLE, - BLUE, - BROWN, - GREEN, - RED, - BLACK; -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/Detoloader.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/Detoloader.java deleted file mode 100644 index 0016d167..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/Detoloader.java +++ /dev/null @@ -1,87 +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 . - */ - -package de.steamwar.bausystem.world; - -import org.bukkit.Location; - -public class Detoloader { - - String message; - int activation; - boolean active, addBack = true, useActive = false; - - public Detoloader(String message, int activation) { - this.message = message; - this.activation = activation; - } - - public String getBlock() { - return message; - } - - public void setBlock(String message) { - this.message = message; - } - - public int getActivation() { - return activation; - } - - public boolean isActive() { - return active; - } - - public Detoloader setActive(boolean active) { - useActive = true; - this.active = active; - return this; - } - - public boolean isAddBack() { - return addBack; - } - - public Detoloader setAddBack(boolean addBack) { - this.addBack = addBack; - return this; - } - - static class DetonatorActivation { - - int activation = -1; - Location location; - - public DetonatorActivation(Location location) { - this.location = location; - } - - public DetonatorActivation(int activation, Location location) { - this.activation = activation; - this.location = location; - } - } - - //Timings - public static final int STONE_BUTTON = 20; - public static final int WOODEN_BUTTON = 30; - public static final int PRESSURE_PLATE = 20; - public static final int NOTE_BLOCK = 1; - public static final int TRIPWIRE = 20; -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/Detonator.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/Detonator.java deleted file mode 100644 index d29ba59d..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/Detonator.java +++ /dev/null @@ -1,120 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.FlatteningWrapper; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.*; - -public class Detonator implements Listener { - - public static final ItemStack WAND; - - public static final Map> PLAYER_LOCS = new HashMap<>(); - - static { - WAND = new ItemStack(Material.BLAZE_ROD, 1); - ItemMeta im = WAND.getItemMeta(); - - im.setDisplayName("§eFernzünder"); - - List lorelist = Arrays.asList("§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren", - "§eLinks Klick + Shift §8- §7Füge einen Punkt hinzu", "§eRechts Klick §8- §7Löse alle Punkte aus"); - im.setLore(lorelist); - - WAND.setItemMeta(im); - } - - public static Detonator getDetonator(Player player, ItemStack item) { - return new Detonator(player, PLAYER_LOCS.get(player)); - } - - public static ItemStack setLocation(Player player, ItemStack item, Detoloader.DetonatorActivation detoloader) { - PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear(); - PLAYER_LOCS.get(player).add(detoloader); - return item; - } - - public static ItemStack toggleLocation(ItemStack item, Player player, Detoloader detoloader, Location location) { - if (PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location))) { - DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" : - detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() - 1); - PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location)); - return item; - } else { - DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" : - detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() + 1); - if (detoloader.getActivation() == 0) { - PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location)); - return item; - } else { - PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(detoloader.getActivation(), location)); - return item; - } - } - } - - public static void execute(Player player) { - execute(player, PLAYER_LOCS.get(player)); - } - - private static void execute(Player player, Set locs) { - for (Detoloader.DetonatorActivation activation : locs) { - - if (activation.activation == -1) { - FlatteningWrapper.impl.setRedstone(activation.location, !FlatteningWrapper.impl.getLever(activation.location.getBlock())); - } else { - FlatteningWrapper.impl.setRedstone(activation.location, true); - Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> FlatteningWrapper.impl.setRedstone(activation.location, false), activation.activation); - } - } - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§e" + locs.size() + " §7Punkt" + (locs.size() > 1 ? "e" : "") + " ausgelöst!")); - } - - public static void clear(Player player) { - PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear(); - } - - private final Set locs; - private final Player player; - - private Detonator(Player player, Set locs) { - this.player = player; - this.locs = locs; - } - - public Set getLocs() { - return locs; - } - - public Player getPlayer() { - return player; - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/DetonatorListener.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/DetonatorListener.java deleted file mode 100644 index afdd6e9d..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/DetonatorListener.java +++ /dev/null @@ -1,84 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.FlatteningWrapper; -import de.steamwar.bausystem.Permission; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -public class DetonatorListener implements Listener { - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getItem() == null) return; - if (event.getItem().isSimilar(Detonator.WAND)) { - Player player = event.getPlayer(); - if (Welt.noPermission(player, Permission.WORLD)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); - return; - } - ItemStack item = event.getItem(); - event.setCancelled(true); - switch (event.getAction()) { - case LEFT_CLICK_BLOCK: - Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event); - - if (detoloader == null) { - return; - } else if (detoloader.activation == -1) { - print(player, detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0); - return; - } - - if (event.getPlayer().isSneaking()) { - player.getInventory().setItemInMainHand(Detonator.toggleLocation(item, player, detoloader, event.getClickedBlock().getLocation())); - } else { - if (detoloader.getActivation() == 0) { - player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()))); - } else { - player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(detoloader.activation, event.getClickedBlock().getLocation()))); - } - print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " gesetzt" : - detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0); - } - break; - case RIGHT_CLICK_AIR: - case RIGHT_CLICK_BLOCK: - Detonator.execute(player); - break; - } - } - } - - public static void print(Player player, String message, int size) { - if (size == 0) { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); - } else { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + size)); - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/ItemFrameListener.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/ItemFrameListener.java deleted file mode 100644 index f7058fe7..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/ItemFrameListener.java +++ /dev/null @@ -1,52 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.SWUtils; -import org.bukkit.Material; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; - -public class ItemFrameListener implements Listener { - - @EventHandler - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (!(event.getDamager() instanceof Player)) { - return; - } - if (!(event.getEntity() instanceof ItemFrame)) { - return; - } - event.setCancelled(true); - ItemFrame itemFrame = (ItemFrame) event.getEntity(); - ItemStack itemStack = itemFrame.getItem(); - if (itemStack.getType() != Material.AIR) { - SWUtils.giveItemToPlayer((Player) event.getDamager(), itemFrame.getItem()); - itemFrame.setItem(null); - } else { - itemFrame.remove(); - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/PredefinedBook.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/PredefinedBook.java deleted file mode 100644 index 21250c01..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/PredefinedBook.java +++ /dev/null @@ -1,143 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -public class PredefinedBook { - - private static final FileConfiguration configuration; - private static List bookCache; - - static { - configuration = YamlConfiguration.loadConfiguration(new File(BauSystem.getPlugin().getDataFolder(), "books.yml")); - } - - public static List getBooks() { - if (bookCache != null) - return bookCache; - List books = new ArrayList<>(); - for (String book : configuration.getKeys(false)) { - ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book)); - books.add(new PredefinedBook(section)); - } - bookCache = books; - return books; - } - - public static int getBookCount() { - return configuration.getKeys(false).size(); - } - - private List lines; - private List lore; - private String author; - private String name; - private ItemStack finishedBook; - - PredefinedBook(ConfigurationSection section) { - this.lines = section.getStringList("lines"); - this.lore = section.getStringList("lore"); - this.author = section.getString("author", "§8Steam§eWar"); - this.name = section.getName(); - } - - public ItemStack toItemStack() { - if (finishedBook != null) - return finishedBook; - ItemStack book = new ItemStack(getBookMat()); - BookMeta meta = (BookMeta) book.getItemMeta(); - meta.setPages(getPages()); - meta.setDisplayName(name); - meta.setTitle(name); - meta.setAuthor(author); - meta.setGeneration(BookMeta.Generation.ORIGINAL); - meta.setLore(lore); - book.setItemMeta(meta); - finishedBook = book; - return book; - } - - public Material getBookMat() { - return Material.WRITTEN_BOOK; - } - - public List getLines() { - return lines; - } - - public String getAuthor() { - return author; - } - - public String getName() { - return name; - } - - public List getLore() { - return lore; - } - - private String[] getPages() { - List pages = new ArrayList<>(); - pages.add(0, new StringBuilder()); - int charsPerLine = 19; - int currentLine = 0; - int currentpage = 0; - boolean first = true; - for (String line : lines) { - int linesPlus = (int) Math.ceil((double) line.length() / charsPerLine); - currentLine += linesPlus; - if (currentLine >= 14 || line.equals("!")) { - currentLine = linesPlus; - currentpage++; - if (currentpage > 50) - throw new IllegalStateException("Book " + name + " has more pages than 50"); - pages.add(currentpage, new StringBuilder()); - first = true; - if (line.equals("!")) - continue; - } - if (!first) { - pages.get(currentpage).append("\n"); - } else { - first = false; - } - pages.get(currentpage).append(line); - } - - String[] finalPages = new String[pages.size()]; - for (int i = 0; i < pages.size(); i++) { - finalPages[i] = pages.get(i).toString(); - } - return finalPages; - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/RegionListener.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/RegionListener.java deleted file mode 100644 index 4b835876..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/RegionListener.java +++ /dev/null @@ -1,137 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.CraftbukkitWrapper; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.WorldeditWrapper; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; - -import java.util.ArrayList; -import java.util.List; - -public class RegionListener implements Listener { - - private final List signEditing = new ArrayList<>(); - - private static final Class updateSign = Reflection.getClass("{nms}.PacketPlayInUpdateSign"); - private static final Class blockPosition = Reflection.getClass("{nms}.BlockPosition"); - private static final Reflection.Field blockPos = Reflection.getField(updateSign, blockPosition, 0); - private static final Reflection.Field signText = Reflection.getField(updateSign, String[].class, 0); - private static final Class baseBlockPosition = Reflection.getClass("{nms}.BaseBlockPosition"); - private static final Reflection.Field blockPosX = Reflection.getField(baseBlockPosition, int.class, 0); - private static final Reflection.Field blockPosY = Reflection.getField(baseBlockPosition, int.class, 1); - private static final Reflection.Field blockPosZ = Reflection.getField(baseBlockPosition, int.class, 2); - public RegionListener() { - TinyProtocol.instance.addFilter(updateSign, (player, packet) -> { - if(!signEditing.contains(player)) - return packet; - - String[] lines = signText.get(packet); - Object pos = blockPos.get(packet); - - Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> { - Block signLoc = new Location(player.getWorld(), blockPosX.get(pos), blockPosY.get(pos), blockPosZ.get(pos)).getBlock(); - if (!signLoc.getType().name().contains("SIGN")) - return; - - Sign sign = ((Sign) signLoc.getState()); - for (int i = 0; i < lines.length; i++) { - sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i])); - } - sign.update(); - - signEditing.remove(player); - }); - - return packet; - }); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void playerCommandHandler(PlayerCommandPreprocessEvent e) { - if (!isWorldEditCommand(e.getMessage().split(" ")[0])) - return; - - Player p = e.getPlayer(); - - if (Welt.noPermission(p, Permission.WORLDEDIT)) { - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); - e.setCancelled(true); - } - } - - private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; - - private boolean isWorldEditCommand(String command) { - for (String shortcut : shortcutCommands) - if (command.startsWith(shortcut)) - return true; - - return WorldeditWrapper.impl.isWorldEditCommand(command); - } - - @EventHandler - public void onSignChange(SignChangeEvent event) { - for (int i = 0; i <= 3; ++i) { - String line = event.getLine(i); - if (line == null) - continue; - line = ChatColor.translateAlternateColorCodes('&', line); - event.setLine(i, line); - } - } - - @EventHandler - public void editSign(PlayerInteractEvent event) { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK || - !event.getClickedBlock().getType().name().contains("SIGN") || - !event.getPlayer().isSneaking() || - (event.getItem() != null && event.getItem().getType() != Material.AIR)) - return; - - Player player = event.getPlayer(); - Sign sign = (Sign) event.getClickedBlock().getState(); - String[] lines = sign.getLines(); - for (int i = 0; i < lines.length; i++) { - sign.setLine(i, lines[i].replace('\u00A7' /* WINDOWS \u00A7 -> § */, '&')); - } - sign.update(); - - CraftbukkitWrapper.impl.openSignEditor(player, event.getClickedBlock().getLocation()); - signEditing.add(player); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/ScriptListener.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/ScriptListener.java deleted file mode 100644 index 23bbbb45..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/ScriptListener.java +++ /dev/null @@ -1,542 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.FlatteningWrapper; -import de.steamwar.bausystem.commands.CommandScript; -import de.steamwar.bausystem.commands.CommandTNT; -import de.steamwar.bausystem.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.inventory.SWAnvilInv; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -import java.util.*; -import java.util.function.Function; -import java.util.function.IntBinaryOperator; -import java.util.function.IntUnaryOperator; -import java.util.logging.Level; - -public class ScriptListener implements Listener { - - public static final Map> GLOBAL_VARIABLES = new HashMap<>(); - private static final Map> CONSTANTS = new HashMap<>(); - - static { - CONSTANTS.put("trace", player -> RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0); - CONSTANTS.put("autotrace", player -> RecordStateMachine.getRecordStatus().isAutoTrace() ? 1 : 0); - CONSTANTS.put("tnt", player -> Region.getRegion(player.getLocation()).getTntMode() == CommandTNT.TNTMode.OFF ? 0 : 1); - CONSTANTS.put("freeze", player -> Region.getRegion(player.getLocation()).isFreeze() ? 1 : 0); - CONSTANTS.put("fire", player -> Region.getRegion(player.getLocation()).isFire() ? 1 : 0); - CONSTANTS.put("x", player -> player.getLocation().getBlockX()); - CONSTANTS.put("y", player -> player.getLocation().getBlockY()); - CONSTANTS.put("z", player -> player.getLocation().getBlockZ()); - } - - private Set playerSet = new HashSet<>(); - - public ScriptListener() { - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), playerSet::clear, 5, 5); - } - - @EventHandler(priority = EventPriority.HIGH) - public void onLeftClick(PlayerInteractEvent event) { - ItemStack item = event.getItem(); - if (item == null || isNoBook(item) || item.getItemMeta() == null) - return; - - if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) { - return; - } - - if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) { - if (event.getAction() == Action.RIGHT_CLICK_AIR) { - playerSet.add(event.getPlayer()); - } - return; - } - if (playerSet.remove(event.getPlayer())) { - return; - } - - event.setCancelled(true); - new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer()); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - GLOBAL_VARIABLES.remove(event.getPlayer()); - } - - private boolean isNoBook(ItemStack item) { - return FlatteningWrapper.impl.isNoBook(item); - } - - private static class ScriptExecutor { - - private final Player player; - private final List commands = new ArrayList<>(); - private final Map jumpPoints = new HashMap<>(); - private Map variables = new HashMap<>(); - - private int index = 0; - - public ScriptExecutor(BookMeta bookMeta, Player player) { - this.player = player; - - for (String page : bookMeta.getPages()) { - for (String command : page.split("\n")) { - command = command.replaceAll(" +", " "); - if (command.startsWith("#") || command.trim().isEmpty()) continue; - if (command.startsWith(".")) { - jumpPoints.put(command.substring(1), commands.size()); - continue; - } - commands.add(command); - } - } - if (commands.isEmpty()) return; - resume(); - } - - private void resume() { - if (!player.isOnline()) { - return; - } - - int executionPoints = 0; - - while (index < commands.size()) { - String command = commands.get(index++); - if (executionPoints++ > 200) { - player.sendMessage(BauSystem.PREFIX + "§cFüge ein sleep in dein Script ein"); - return; - } - - String firstArg = command; - if (command.contains(" ")) { - firstArg = command.substring(0, command.indexOf(' ')); - } - switch (firstArg.toLowerCase()) { - case "sleep": - ScriptListener.sleepCommand(this, generateArgumentArray("sleep", this, command)); - return; - case "exit": - return; - case "jump": - int jumpIndex = ScriptListener.jumpCommand(this, generateArgumentArray("jump", this, command)); - if (jumpIndex != -1) { - index = jumpIndex; - } else { - player.sendMessage(BauSystem.PREFIX + "§cUnbekannter Jump Punkt: " + command); - } - continue; - case "echo": - ScriptListener.echoCommand(this, generateArgumentArray("echo", this, command)); - continue; - case "input": - ScriptListener.inputCommand(this, generateArgumentArray("input", this, command)); - return; - case "var": - ScriptListener.variableCommand(this, generateArgumentArray("var", this, command)); - continue; - case "unvar": - ScriptListener.unvariableCommand(this, generateArgumentArray("unvar", this, command)); - continue; - case "global": - ScriptListener.globalCommand(this, generateArgumentArray("global", this, command)); - continue; - case "unglobal": - ScriptListener.unglobalCommand(this, generateArgumentArray("unglobal", this, command)); - continue; - case "add": - ScriptListener.arithmeticCommand(this, generateArgumentArray("add", this, command), (left, right) -> left + right); - continue; - case "sub": - ScriptListener.arithmeticCommand(this, generateArgumentArray("sub", this, command), (left, right) -> left - right); - continue; - case "mul": - ScriptListener.arithmeticCommand(this, generateArgumentArray("mul", this, command), (left, right) -> left * right); - continue; - case "div": - ScriptListener.arithmeticCommand(this, generateArgumentArray("div", this, command), (left, right) -> left / right); - continue; - case "equal": - ScriptListener.arithmeticCommand(this, generateArgumentArray("equal", this, command), (left, right) -> left == right ? 1 : 0); - continue; - case "less": - ScriptListener.arithmeticCommand(this, generateArgumentArray("less", this, command), (left, right) -> left < right ? 1 : 0); - continue; - case "greater": - ScriptListener.arithmeticCommand(this, generateArgumentArray("greater", this, command), (left, right) -> left > right ? 1 : 0); - continue; - case "not": - ScriptListener.arithmeticInfixCommand(this, generateArgumentArray("not", this, command), (left) -> left == 1 ? 0 : 1); - continue; - case "and": - ScriptListener.arithmeticCommand(this, generateArgumentArray("and", this, command), (left, right) -> left == 1 && right == 1 ? 1 : 0); - continue; - case "or": - ScriptListener.arithmeticCommand(this, generateArgumentArray("or", this, command), (left, right) -> left == 1 || right == 1 ? 1 : 0); - continue; - case "if": - int ifJumpIndex = ScriptListener.ifCommand(this, generateArgumentArray("if", this, command)); - if (ifJumpIndex != -1) { - index = ifJumpIndex; - } - continue; - default: - break; - } - - PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command); - Bukkit.getServer().getPluginManager().callEvent(preprocessEvent); - if (preprocessEvent.isCancelled()) { - continue; - } - - // Variable Replaces in commands. - command = String.join(" ", generateArgumentArray("", this, command)); - - Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); - Bukkit.getServer().dispatchCommand(player, command); - } - } - - } - - private static String[] generateArgumentArray(String command, ScriptExecutor scriptExecutor, String fullCommand) { - String[] strings; - if (command.isEmpty()) { - strings = fullCommand.split(" "); - } else { - strings = fullCommand.substring(command.length()).trim().split(" "); - } - return replaceVariables(scriptExecutor, strings); - } - - private static void sleepCommand(ScriptExecutor scriptExecutor, String[] args) { - int sleepTime = 1; - if (args.length > 0) { - try { - sleepTime = Integer.parseInt(args[0]); - if (sleepTime <= 0) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie Zeit muss eine Zahl großer 0 sein."); - sleepTime = 1; - } - } catch (NumberFormatException e) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie Zeit darf nur aus Zahlen bestehen."); - } - } - Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), scriptExecutor::resume, sleepTime); - } - - private static int jumpCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cEin Jump Punkt muss angegeben sein."); - return -1; - } - return scriptExecutor.jumpPoints.getOrDefault(args[0], -1); - } - - private static String[] replaceVariables(ScriptExecutor scriptExecutor, String[] args) { - // Legacy '$' notation for variable reference, could be removed later on. - for (int i = 0; i < args.length; i++) { - if (args[i].startsWith("$") && isVariable(scriptExecutor, args[i].substring(1))) { - args[i] = getValue(scriptExecutor, args[i].substring(1)) + ""; - } - } - - String s = String.join(" ", args); - Set variables = new HashSet<>(scriptExecutor.variables.keySet()); - variables.addAll(CONSTANTS.keySet()); - if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) { - variables.addAll(GLOBAL_VARIABLES.get(scriptExecutor.player).keySet()); - } - for (String variable : variables) { - s = s.replace("<" + variable + ">", getValue(scriptExecutor, variable) + ""); - } - for (String constVariable : CONSTANTS.keySet()) { - s = s.replace("", getConstantValue(scriptExecutor, constVariable) + ""); - } - for (String localVariable : scriptExecutor.variables.keySet()) { - s = s.replace("", getLocalValue(scriptExecutor, localVariable) + ""); - } - for (String globalVariable : GLOBAL_VARIABLES.getOrDefault(scriptExecutor.player, new HashMap<>()).keySet()) { - s = s.replace("", getGlobalValue(scriptExecutor, globalVariable) + ""); - } - return s.split(" "); - } - - private static void echoCommand(ScriptExecutor scriptExecutor, String[] args) { - scriptExecutor.player.sendMessage("§eInfo§8» §7" + ChatColor.translateAlternateColorCodes('&', String.join(" ", replaceVariables(scriptExecutor, args)))); - } - - private static void variableCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen und Zahlen/Boolsche Wert fehlt."); - return; - } - if (args.length < 2) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cZahlen/Boolsche Wert fehlt."); - return; - } - switch (args[1]) { - case "inc": - case "increment": - case "++": - add(scriptExecutor, args[0], 1); - return; - case "dec": - case "decrement": - case "--": - add(scriptExecutor, args[0], -1); - return; - default: - break; - } - setValue(scriptExecutor, args[0], parseValue(args[1])); - } - - private static void unvariableCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt."); - return; - } - if (!isLocalVariable(scriptExecutor, args[0])) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert"); - return; - } - scriptExecutor.variables.remove(args[0]); - } - - private static void globalCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt."); - return; - } - if (!isLocalVariable(scriptExecutor, args[0])) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert"); - return; - } - GLOBAL_VARIABLES.computeIfAbsent(scriptExecutor.player, player -> new HashMap<>()).put(args[0], scriptExecutor.variables.getOrDefault(args[0], 0)); - } - - private static void unglobalCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt."); - return; - } - if (!isGlobalVariable(scriptExecutor, args[0])) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert"); - return; - } - if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) { - GLOBAL_VARIABLES.get(scriptExecutor.player).remove(args[0]); - } - } - - private static int ifCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 2) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie ersten beiden Argumente sind Zahlen/Boolsche Werte oder Variablen."); - return -1; - } - if (args.length < 3) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas dritte Argument muss ein JumpPoint sein."); - return -1; - } - - int jumpTruePoint = scriptExecutor.jumpPoints.getOrDefault(args[2], -1); - int jumpFalsePoint = args.length > 3 ? scriptExecutor.jumpPoints.getOrDefault(args[3], -1) : -1; - - if (args[1].equals("exists")) { - if (isVariable(scriptExecutor, args[0])) { - return jumpTruePoint; - } else { - return jumpFalsePoint; - } - } - int firstValue = getValueOrParse(scriptExecutor, args[0]); - int secondValue = getValueOrParse(scriptExecutor, args[1]); - if (firstValue == secondValue) { - return jumpTruePoint; - } else { - return jumpFalsePoint; - } - } - - private static void arithmeticCommand(ScriptExecutor scriptExecutor, String[] args, IntBinaryOperator operation) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable"); - return; - } - if (args.length < 2) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls zweites Argument fehlt eine Zahl oder Variable"); - return; - } - - int firstValue; - int secondValue; - if (args.length < 3) { - if (!isVariable(scriptExecutor, args[0])) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas erste Argument muss eine Variable sein"); - return; - } - firstValue = getValue(scriptExecutor, args[0]); - secondValue = getValueOrParse(scriptExecutor, args[1]); - } else { - firstValue = getValue(scriptExecutor, args[1]); - secondValue = getValueOrParse(scriptExecutor, args[2]); - } - setValue(scriptExecutor, args[0], operation.applyAsInt(firstValue, secondValue)); - } - - private static void arithmeticInfixCommand(ScriptExecutor scriptExecutor, String[] args, IntUnaryOperator operation) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable"); - return; - } - - int firstValue; - if (args.length < 2) { - if (!isVariable(scriptExecutor, args[0])) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas erste Argument muss eine Variable sein"); - return; - } - firstValue = getValue(scriptExecutor, args[0]); - } else { - firstValue = getValue(scriptExecutor, args[1]); - } - setValue(scriptExecutor, args[0], operation.applyAsInt(firstValue)); - } - - private static void inputCommand(ScriptExecutor scriptExecutor, String[] args) { - if (args.length < 1) { - scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable"); - return; - } - String varName = args[0]; - StringBuilder st = new StringBuilder(); - for (int i = 1; i < args.length; i++) { - if (i != 1) { - st.append(" "); - } - st.append(args[i]); - } - - SWAnvilInv swAnvilInv = new SWAnvilInv(scriptExecutor.player, ChatColor.translateAlternateColorCodes('&', st.toString())); - swAnvilInv.setCallback(s -> { - int value = parseValue(s); - setValue(scriptExecutor, varName, value); - scriptExecutor.resume(); - }); - swAnvilInv.open(); - } - - private static void setValue(ScriptExecutor scriptExecutor, String key, int value) { - scriptExecutor.variables.put(key, value); - } - - private static void add(ScriptExecutor scriptExecutor, String key, int value) { - if (!isVariable(scriptExecutor, key)) { - scriptExecutor.variables.put(key, 0); - } - scriptExecutor.variables.put(key, scriptExecutor.variables.get(key) + value); - } - - private static int getValueOrParse(ScriptExecutor scriptExecutor, String key) { - if (isVariable(scriptExecutor, key)) { - return getValue(scriptExecutor, key); - } else { - return parseValue(key); - } - } - - private static int getValue(ScriptExecutor scriptExecutor, String key) { - if (CONSTANTS.containsKey(key)) { - return CONSTANTS.get(key).apply(scriptExecutor.player); - } - if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player) && GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key)) { - return GLOBAL_VARIABLES.get(scriptExecutor.player).get(key); - } - return scriptExecutor.variables.getOrDefault(key, 0); - } - - private static int getConstantValue(ScriptExecutor scriptExecutor, String key) { - return CONSTANTS.getOrDefault(key, player -> 0).apply(scriptExecutor.player); - } - - private static int getGlobalValue(ScriptExecutor scriptExecutor, String key) { - if (!GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) { - return 0; - } - return GLOBAL_VARIABLES.get(scriptExecutor.player).getOrDefault(key, 0); - } - - private static int getLocalValue(ScriptExecutor scriptExecutor, String key) { - return scriptExecutor.variables.getOrDefault(key, 0); - } - - private static boolean isVariable(ScriptExecutor scriptExecutor, String key) { - if (CONSTANTS.containsKey(key)) { - return true; - } - if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player) && GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key)) { - return true; - } - return scriptExecutor.variables.containsKey(key); - } - - private static boolean isLocalVariable(ScriptExecutor scriptExecutor, String key) { - return isVariable(scriptExecutor, key) && !isGlobalVariable(scriptExecutor, key); - } - - private static boolean isGlobalVariable(ScriptExecutor scriptExecutor, String key) { - if (!GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) { - return false; - } - return GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key); - } - - public static int parseValue(String value) { - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")) { - return 1; - } else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no")) { - return 0; - } - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - return 0; - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/SizedStack.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/SizedStack.java deleted file mode 100644 index ed62f6b1..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/SizedStack.java +++ /dev/null @@ -1,142 +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 . - */ - -package de.steamwar.bausystem.world; - -@SuppressWarnings({"unused", "UnusedReturnValue"}) -public class SizedStack { - - private final int maxSize; - private final T[] data; - private int size; - private int head; - - public SizedStack(int size) { - this.maxSize = size; - this.data = (T[]) new Object[this.maxSize]; - this.head = 0; - this.size = 0; - } - - public T push(final T element) { - this.data[this.head] = element; - this.increaseHead(); - this.increaseSize(); - return element; - } - - public T pop() { - this.decreaseHead(); - this.decreaseSize(); - final T result = this.data[this.head]; - this.data[this.head] = null; - return result; - } - - public T peek() { - return this.data[this.head]; - } - - public boolean empty() { - return this.size == 0; - } - - protected boolean canEqual(final Object other) { - return other instanceof SizedStack; - } - - private void increaseHead() { - this.head++; - while (this.head > this.maxSize - 1) { - this.head -= this.maxSize; - } - } - - private void decreaseHead() { - this.head--; - while (this.head < 0) { - this.head += this.maxSize; - } - } - - private void increaseSize() { - if (this.size < this.maxSize) { - this.size++; - } - } - - private void decreaseSize() { - if (this.size > 0) { - this.size--; - } - } - - @Override - public int hashCode() { - final int PRIME = 59; - int result = 1; - result = result * PRIME + this.maxSize; - result = result * PRIME + this.toString().hashCode(); - result = result * PRIME + this.size; - return result; - } - - @Override - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof SizedStack)) { - return false; - } - final SizedStack other = (SizedStack) o; - if (!other.canEqual(this)) { - return false; - } - if (this.maxSize != other.maxSize) { - return false; - } - if (this.size != other.size) { - return false; - } - if (!this.data.getClass().equals(other.data.getClass())) { - return false; - } - return this.toString().equals(other.toString()); - } - - public int getMaxSize() { - return maxSize; - } - - public int getSize() { - return size; - } - - @Override - public String toString() { - final StringBuilder result = new StringBuilder("["); - for (int i = 0; i < this.size - 1; i++) { - result.append(this.data[(this.head - i - 1 < 0) ? (this.head - i - 1 + this.maxSize) : (this.head - i - 1)]).append(","); - } - result.append(this.data[(this.head - this.size < 0) ? (this.head - this.size + this.maxSize) : (this.head - this.size)]); - result.append("]"); - return result.toString(); - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/TPSUtils.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/TPSUtils.java deleted file mode 100644 index cb253d9e..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/TPSUtils.java +++ /dev/null @@ -1,76 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.CraftbukkitWrapper; -import de.steamwar.bausystem.commands.CommandTPSLimiter; -import de.steamwar.core.TPSWatcher; -import org.bukkit.Bukkit; - -import java.util.function.Supplier; - -public class TPSUtils { - - private TPSUtils() { - throw new IllegalStateException("Utility Class"); - } - - private static boolean warp = true; - private static long nanoOffset = 0; - private static long nanoDOffset = 0; - - public static void disableWarp() { - warp = false; - } - - public static long getNanoOffset() { - return nanoOffset; - } - - private static long ticksSinceServerStart = 0; - public static final Supplier currentTick = () -> ticksSinceServerStart; - - public static void init() { - CraftbukkitWrapper.impl.initTPS(); - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1); - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> ticksSinceServerStart++, 1, 1); - } - - public static void setTPS(double tps) { - double d = 50 - (50 / (tps / 20.0)); - nanoDOffset = Math.max(0, Math.min((long) (d * 1000000), 37500000)); - } - - public static boolean isWarpAllowed() { - return warp; - } - - public static boolean isWarping() { - return nanoDOffset > 0; - } - - public static double getTps(TPSWatcher.TPSType tpsType) { - if (TPSUtils.isWarping()) - return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); - return TPSWatcher.getTPS(tpsType); - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/Welt.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/Welt.java deleted file mode 100644 index 459f3f7f..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/Welt.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.bausystem.world; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.sql.BauweltMember; -import org.bukkit.entity.Player; - -public class Welt { - - private Welt() { - } - - public static boolean noPermission(Player member, Permission perm) { - if (member.getUniqueId().equals(BauSystem.getOwner())) - return false; - - BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId()); - if (member1 == null) - return true; - - switch (perm) { - case WORLDEDIT: - return !member1.isWorldEdit(); - case WORLD: - return !member1.isWorld(); - case MEMBER: - return false; - default: - return true; - } - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/GlobalRegion.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/GlobalRegion.java deleted file mode 100644 index 4846bc3d..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/GlobalRegion.java +++ /dev/null @@ -1,64 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -import org.bukkit.Location; - -public class GlobalRegion extends Region { - - private static final GlobalRegion GLOBAL_REGION = new GlobalRegion(); - - public static GlobalRegion getInstance() { - return GLOBAL_REGION; - } - - public static boolean isGlobalRegion(Region region) { - return region == GLOBAL_REGION; - } - - public GlobalRegion() { - super("Global"); - } - - @Override - public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { - return true; - } - - @Override - public boolean hasBuildRegion() { - return false; - } - - @Override - public boolean hasTestblock() { - return false; - } - - @Override - public boolean hasProtection() { - return false; - } - - @Override - public boolean hasExtensionArea(RegionType regionType) { - return false; - } -} \ No newline at end of file diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/PasteOptions.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/PasteOptions.java deleted file mode 100644 index fca143cc..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/PasteOptions.java +++ /dev/null @@ -1,99 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -import de.steamwar.bausystem.world.Color; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class PasteOptions { - - /** - * Used in 1.12 and 1.15 - */ - private boolean rotate = false; - - /** - * Used in 1.12 and 1.15 - */ - private boolean ignoreAir = false; - - /** - * Used in 1.15 - */ - private Color color = Color.YELLOW; - - /** - * Used in 1.15 - */ - private boolean reset = false; - - /** - * Used in 1.15 - */ - private Point minPoint = null; - - /** - * Used in 1.15 - */ - private Point maxPoint = null; - - /** - * Used in 1.15 - */ - private int waterLevel = 0; - - public PasteOptions(boolean rotate) { - this.rotate = rotate; - } - - public PasteOptions(boolean rotate, Color color) { - this.rotate = rotate; - this.color = color; - } - - public PasteOptions(boolean rotate, boolean ignoreAir) { - this.rotate = rotate; - this.ignoreAir = ignoreAir; - } - - public PasteOptions(boolean rotate, boolean ignoreAir, boolean reset) { - this.rotate = rotate; - this.ignoreAir = ignoreAir; - this.reset = reset; - } - - public PasteOptions(boolean rotate, Color color, boolean reset) { - this.rotate = rotate; - this.color = color; - this.reset = reset; - } - - public PasteOptions(boolean rotate, boolean ignoreAir, Color color) { - this.rotate = rotate; - this.ignoreAir = ignoreAir; - this.color = color; - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Point.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Point.java deleted file mode 100644 index c85a5f6f..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Point.java +++ /dev/null @@ -1,31 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class Point { - final int x; - final int y; - final int z; -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Prototype.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Prototype.java deleted file mode 100644 index 49edd4e8..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Prototype.java +++ /dev/null @@ -1,204 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.bausystem.WorldeditWrapper; -import de.steamwar.bausystem.world.Color; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.SchematicData; -import de.steamwar.sql.SchematicNode; -import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class Prototype { - static final Map prototypes = new HashMap<>(); - - private final int sizeX; - private final int sizeY; - private final int sizeZ; - - private final int offsetX; - private final int offsetY; - private final int offsetZ; - - private final int extensionPositiveZ; - private final int extensionNegativeZ; - private final int extensionPositiveY; - private final int extensionAxisX; - final boolean extensionPrototypeArea; - - private final int waterLevel; - - private final String schematic; - private final boolean rotate; - - final Prototype testblock; //nullable - final Prototype buildArea; //nullable - - private final String protectSchematic; //nullable - - Prototype(ConfigurationSection config) { - sizeX = config.getInt("sizeX"); - sizeY = config.getInt("sizeY"); - sizeZ = config.getInt("sizeZ"); - schematic = config.getString("schematic"); - offsetX = config.getInt("offsetX", 0); - offsetY = config.getInt("offsetY", 0); - offsetZ = config.getInt("offsetZ", 0); - extensionPositiveZ = config.getInt("extensionPositiveZ", 0); - extensionNegativeZ = config.getInt("extensionNegativeZ", 0); - extensionPositiveY = config.getInt("extensionPositiveY", 0); - extensionAxisX = config.getInt("extensionAxisX", 0); - if (config.contains("extensionPositiveZ") || config.contains("extensionNegativeZ") || config.contains("extensionPositiveY") || config.contains("extensionAxisX")) { - Region.extensionArea = true; - } - extensionPrototypeArea = extensionNegativeZ != 0 || extensionPositiveZ != 0 || extensionPositiveY != 0 || extensionAxisX != 0; - waterLevel = config.getInt("waterLevel", 0); - rotate = config.getBoolean("rotate", false); - - ConfigurationSection testblockSection = config.getConfigurationSection("testblock"); - testblock = testblockSection != null ? new Prototype(testblockSection) : null; - - ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea"); - buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null; - if (buildArea != null) { - Region.buildArea = true; - } - - protectSchematic = config.getString("protection", null); - - if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) - prototypes.put(config.getName(), this); - } - - public Point getMinPoint(Region region, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ - ); - default: - case NORMAL: - return new Point( - region.minPoint.getX() + offsetX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - ); - } - } - - public Point getMaxPoint(Region region, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2) - 1, - region.minPoint.getY() + offsetY + sizeY + extensionPositiveY - 1, - region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) - 1 - ); - default: - case NORMAL: - return new Point( - region.minPoint.getX() + offsetX + sizeX - 1, - region.minPoint.getY() + offsetY + sizeY - 1, - region.minPoint.getZ() + offsetZ + sizeZ - 1 - ); - } - } - - public boolean inRegion(Region region, Location l, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); - default: - case NORMAL: - return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); - } - } - - public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException { - return reset(region, schem, ignoreAir, color, false); - } - - public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException { - PasteOptions pasteOptions; - if (reset) { - pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION), waterLevel); - } else { - pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color); - } - - int x = region.minPoint.getX() + offsetX + sizeX / 2; - int y = region.minPoint.getY() + offsetY; - int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) { - return paste(new File(schematic), x, y, z, pasteOptions); - } else { - return paste(new SchematicData(schem).load(), x, y, z, pasteOptions); - } - } - - public boolean hasProtection() { - return protectSchematic != null; - } - - public EditSession protect(Region region, SchematicNode schem) throws IOException, NoClipboardException { - int x = region.minPoint.getX() + offsetX + sizeX / 2; - int y = region.minPoint.getY() + testblock.offsetY - 1; - int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) { - return paste(new File(protectSchematic), x, y, z, new PasteOptions(rotate, false, Color.YELLOW)); - } else { - return paste(new SchematicData(schem).load(), x, y, z, new PasteOptions(rotate, false, Color.YELLOW)); - } - } - - public boolean hasTestblock() { - return testblock != null; - } - - public EditSession resetTestblock(Region region, SchematicNode schem, Color color, boolean reset) throws IOException, NoClipboardException { - return testblock.reset(region, schem, false, color, reset && waterLevel == 0); - } - - private static boolean inRange(double l, int min, int size) { - return min <= l && l < min + size; - } - - private static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { //Type of protect - return WorldeditWrapper.impl.paste(file, x, y, z, pasteOptions); - } - - private static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) { - return WorldeditWrapper.impl.paste(clipboard, x, y, z, pasteOptions); - } -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Region.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Region.java deleted file mode 100644 index 1d602b64..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/Region.java +++ /dev/null @@ -1,388 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSyntaxException; -import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.commands.CommandTNT.TNTMode; -import de.steamwar.bausystem.world.Color; -import de.steamwar.bausystem.world.SizedStack; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.SchematicNode; -import lombok.Getter; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.Consumer; -import java.util.logging.Level; - -public class Region { - - private static final List regions = new ArrayList<>(); - static boolean buildArea = false; - static boolean extensionArea = false; - private static JsonObject regionsObject = new JsonObject(); - - static { - File regionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json"); - if (regionsFile.exists()) { - try { - regionsObject = new JsonParser().parse(new FileReader(regionsFile)).getAsJsonObject(); - } catch (JsonSyntaxException | IOException e) { - Bukkit.getLogger().log(Level.WARNING, "Item JSON error"); - } - } - - YamlConfiguration config = new YamlConfiguration(); - try { - config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); - } catch (InvalidConfigurationException | IOException e) { - Bukkit.getLogger().log(Level.SEVERE, "Failed to load sections.yml", e); - } - - ConfigurationSection prototypes = config.getConfigurationSection("prototypes"); - assert prototypes != null; - for (String prototype : prototypes.getKeys(false)) { - new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype))); - } - - ConfigurationSection regions = config.getConfigurationSection("regions"); - assert regions != null; - for (String region : regions.getKeys(false)) { - new Region(Objects.requireNonNull(regions.getConfigurationSection(region))); - } - } - - public static boolean buildAreaEnabled() { - return buildArea; - } - - public static boolean extensionAreaEnabled() { - return extensionArea; - } - - public static Region getRegion(Location location) { - for (Region region : regions) { - if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) { - return region; - } - } - return GlobalRegion.getInstance(); - } - - public static void setGlobalColor(Color color) { - for (Region region : regions) { - region.setColor(color); - } - } - - public static void save() { - File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json"); - if (!colorsFile.exists()) { - try { - colorsFile.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - return; - } - } - try (FileOutputStream fileOutputStream = new FileOutputStream(colorsFile)) { - fileOutputStream.write(regionsObject.toString().getBytes()); - } catch (IOException e) { - e.printStackTrace(); - // Ignored - } - } - - private final String name; - final Point minPoint; - private final Prototype prototype; - private final String optionsLinkedWith; // nullable - private Region linkedRegion = null; // nullable - private SizedStack undosessions; - private SizedStack redosessions; - - private JsonObject regionOptions = new JsonObject(); - - @Getter - private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; - - @Getter - private boolean freeze = false; - - @Getter - private boolean fire = false; - - @Getter - private boolean protect = false; - - @Getter - private Color color = Color.YELLOW; - - private Region(ConfigurationSection config) { - name = config.getName(); - minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); - prototype = Prototype.prototypes.get(config.getString("prototype")); - optionsLinkedWith = config.getString("optionsLinkedWith", null); - if (!hasTestblock()) tntMode = TNTMode.OFF; - regions.add(this); - load(); - } - - public Region(String name) { - this.name = name; - this.minPoint = new Point(0, 0, 0); - this.prototype = null; - this.optionsLinkedWith = null; - tntMode = TNTMode.OFF; - load(); - } - - private void load() { - if (regionsObject.has(name)) { - regionOptions = regionsObject.getAsJsonObject(name); - if (regionOptions.has("tnt")) { - String tntName = regionsObject.getAsJsonObject(name).getAsJsonPrimitive("tnt").getAsString(); - try { - tntMode = TNTMode.valueOf(tntName); - } catch (Exception e) { - // Ignored - } - } - - if (regionOptions.has("fire")) { - fire = regionOptions.getAsJsonPrimitive("fire").getAsBoolean(); - } - - if (regionOptions.has("freeze")) { - freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean(); - } - - if (regionOptions.has("protect")) { - protect = regionOptions.getAsJsonPrimitive("protect").getAsBoolean(); - } - - if (regionOptions.has("color")) { - String colorName = regionOptions.getAsJsonPrimitive("color").getAsString(); - try { - color = Color.valueOf(colorName); - } catch (Exception e) { - // Ignored - } - } - } else { - regionsObject.add(name, regionOptions); - } - } - - public void setColor(Color color) { - this.color = color; - regionOptions.add("color", new JsonPrimitive(color.name())); - } - - private void setLinkedRegion(Consumer regionConsumer) { - if (optionsLinkedWith == null) { - return; - } - if (linkedRegion != null) { - regionConsumer.accept(linkedRegion); - return; - } - for (Region region : regions) { - if (region.name.equals(name)) { - linkedRegion = region; - regionConsumer.accept(linkedRegion); - return; - } - } - } - - public void setTntMode(TNTMode tntMode) { - this.tntMode = tntMode; - setLinkedRegion(region -> { - region.tntMode = tntMode; - region.regionOptions.add("tnt", new JsonPrimitive(tntMode.name())); - }); - regionOptions.add("tnt", new JsonPrimitive(tntMode.name())); - } - - public void setFreeze(boolean freeze) { - this.freeze = freeze; - setLinkedRegion(region -> { - region.freeze = freeze; - region.regionOptions.add("freeze", new JsonPrimitive(freeze)); - }); - regionOptions.add("freeze", new JsonPrimitive(freeze)); - } - - public void setFire(boolean fire) { - this.fire = fire; - setLinkedRegion(region -> { - region.fire = fire; - region.regionOptions.add("fire", new JsonPrimitive(fire)); - }); - regionOptions.add("fire", new JsonPrimitive(fire)); - } - - public void setProtect(boolean protect) { - this.protect = protect; - setLinkedRegion(region -> { - region.protect = protect; - region.regionOptions.add("protect", new JsonPrimitive(protect)); - }); - regionOptions.add("protect", new JsonPrimitive(protect)); - } - - public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD: - return prototype.buildArea.getMinPoint(this, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.getMinPoint(this, regionExtensionType); - default: - case NORMAL: - return prototype.getMinPoint(this, regionExtensionType); - } - } - - public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD: - return prototype.buildArea.getMaxPoint(this, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.getMaxPoint(this, regionExtensionType); - default: - case NORMAL: - return prototype.getMaxPoint(this, regionExtensionType); - } - } - - public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD: - return prototype.buildArea.inRegion(this, l, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.inRegion(this, l, regionExtensionType); - default: - case NORMAL: - return prototype.inRegion(this, l, regionExtensionType); - } - } - - public boolean hasBuildRegion() { - return prototype.buildArea != null; - } - - public void reset(SchematicNode schem, boolean ignoreAir) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.reset(this, schem, ignoreAir, color)); - } - - public boolean hasTestblock() { - return prototype.hasTestblock(); - } - - public void resetTestblock(SchematicNode schem, boolean reset) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.resetTestblock(this, schem, color, reset)); - } - - public boolean hasProtection() { - return prototype.hasProtection(); - } - - public void protect(SchematicNode schem) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.protect(this, schem)); - } - - public int getProtectYLevel() { - return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY(); - } - - public boolean hasExtensionArea(RegionType regionType) { - switch (regionType) { - case BUILD: - return prototype.buildArea.extensionPrototypeArea; - case TESTBLOCK: - return prototype.testblock.extensionPrototypeArea; - default: - case NORMAL: - return prototype.extensionPrototypeArea; - } - } - - private void initSessions() { - if (undosessions == null) { - undosessions = new SizedStack<>(20); - redosessions = new SizedStack<>(20); - } - } - - public boolean undo() { - initSessions(); - EditSession session = null; - try { - session = undosessions.pop(); - if (session == null) { - return false; - } - session.undo(session); - redosessions.push(session); - return true; - } finally { - if (session != null) { - session.flushQueue(); - } - } - } - - public boolean redo() { - initSessions(); - EditSession session = null; - try { - session = redosessions.pop(); - if (session == null) { - return false; - } - session.redo(session); - undosessions.push(session); - return true; - } finally { - if (session != null) { - session.flushQueue(); - } - } - } - -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java deleted file mode 100644 index b7f80a9a..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java +++ /dev/null @@ -1,25 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -public enum RegionExtensionType { - NORMAL, - EXTENSION -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionSelectionType.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionSelectionType.java deleted file mode 100644 index 58a32986..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionSelectionType.java +++ /dev/null @@ -1,25 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -public enum RegionSelectionType { - GLOBAL, - LOCAL -} diff --git a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionType.java b/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionType.java deleted file mode 100644 index da4a071a..00000000 --- a/LegacyBauSystem/src/de/steamwar/bausystem/world/regions/RegionType.java +++ /dev/null @@ -1,26 +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 . - */ - -package de.steamwar.bausystem.world.regions; - -public enum RegionType { - NORMAL, - BUILD, - TESTBLOCK -} diff --git a/LegacyBauSystem/src/plugin.yml b/LegacyBauSystem/src/plugin.yml deleted file mode 100644 index cef3aacc..00000000 --- a/LegacyBauSystem/src/plugin.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: BauSystem -authors: [Lixfel, YoyoNow, Chaoscaot, Zeanon] -version: "1.0" -depend: [WorldEdit, SpigotCore] -load: POSTWORLD -main: de.steamwar.bausystem.BauSystem -api-version: "1.13" -website: "https://steamwar.de" -description: "So unseriös wie wir sind: BauSystem nur besser. Jaja" diff --git a/LobbySystem/build.gradle.kts b/LobbySystem/build.gradle.kts index f658af8f..a97d8394 100644 --- a/LobbySystem/build.gradle.kts +++ b/LobbySystem/build.gradle.kts @@ -21,20 +21,15 @@ plugins { steamwar.java } -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) - compileOnly(libs.nms20) - compileOnly(libs.worldedit15) + compileOnly(libs.nms) + compileOnly(libs.fawe) } tasks.register("DevLobby20") { diff --git a/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java b/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java index e61533e0..72803871 100644 --- a/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java +++ b/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java @@ -62,7 +62,7 @@ public class BoatRace implements EventListener, Listener { REntity starter = new REntity(boatNpcServer, EntityType.VILLAGER, BoatRacePositions.NPC); boatNpcServer.setCallback((player, rEntity, entityAction) -> { if (rEntity != starter) return; - Bukkit.getWorlds().get(0).getEntities().stream().filter(entity -> entity.getType() == EntityType.ENDER_CRYSTAL).forEach(Entity::remove); + Bukkit.getWorlds().get(0).getEntities().stream().filter(entity -> entity.getType() == EntityType.END_CRYSTAL).forEach(Entity::remove); if (entityAction == REntityServer.EntityAction.INTERACT && !oneNotStarted) { oneNotStarted = true; new BoatRace(player); diff --git a/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java b/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java index 6069a3c4..f659eaf1 100644 --- a/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java @@ -36,7 +36,7 @@ import lombok.Data; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -128,7 +128,7 @@ public class PortalCommand extends SWCommand { private Location locationOfPlayer(Player player) { Location l = player.getLocation(); - l.setYaw(((CraftPlayer)player).getHandle().cm()); + l.setYaw(((CraftPlayer)player).getHandle().getYHeadRot()); return l; } @@ -189,6 +189,6 @@ public class PortalCommand extends SWCommand { } private Location adapt(World world, BlockVector3 blockVector3) { - return new Location(world, blockVector3.getBlockX() + 0.5, blockVector3.getBlockY(), blockVector3.getBlockZ() + 0.5); + return new Location(world, blockVector3.x() + 0.5, blockVector3.y(), blockVector3.z() + 0.5); } } diff --git a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java index fae3e909..cc6835be 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java @@ -31,10 +31,10 @@ import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDismountEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; -import org.spigotmc.event.entity.EntityDismountEvent; import java.util.HashSet; import java.util.Set; diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/EasterParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/EasterParticle.java index 0833468b..3e3fdabf 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/EasterParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/EasterParticle.java @@ -40,15 +40,15 @@ public enum EasterParticle implements ParticleEnum { new Always(new Floor(new Sneaking(new SimpleParticle(Particle.GLOW_SQUID_INK, 0.4F, 0.9F, 0.4F, 0.01))))) ), EGG_HUNT_HARD(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, - new Always(new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1, null), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1, null)), 0, 0.5, 0))) + new Always(new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0.01, 1, null), new DustParticle(Particle.DUST, 0, 0, 0, 0.01, 1, null)), 0, 0.5, 0))) ), EGG_HUNT_EXTREME(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_OBSIDIAN_TEAR, 0.5F, 0.1F, 0.5F, 1, 1), 0, 2.2, 0))) ), EGG_HUNT_ADVANCED(new ParticleData(Material.BLACK_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, new Always(new Sneaking(new LocationMutator(new Group( - new SimpleParticle(Particle.SMOKE_NORMAL, 0.02F, 0, 0.02F, 0.05, 1), - new SimpleParticle(Particle.SMOKE_LARGE, 0.02F, 0, 0.02F, 0.05, 1), + new SimpleParticle(Particle.SMOKE, 0.02F, 0, 0.02F, 0.05, 1), + new SimpleParticle(Particle.LARGE_SMOKE, 0.02F, 0, 0.02F, 0.05, 1), particleTickData -> { Player player = particleTickData.getPlayer(); player.setVelocity(player.getVelocity().add(new Vector(0, 0.1, 0))); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticle.java index 531e2051..4617bd5e 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticle.java @@ -35,10 +35,10 @@ import org.bukkit.Particle; public enum EventParticle implements ParticleEnum { WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIPPING_WATER), 0, 1.1, 0)))) ), LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIPPING_LAVA), 0, 1.1, 0)))) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java index f599ac28..7d033509 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java @@ -33,7 +33,7 @@ import org.bukkit.Particle; public enum EventParticleParticipation implements ParticleEnum { WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + new SimpleParticle(Particle.ENCHANT)) ), AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), new SimpleParticle(Particle.CLOUD)) @@ -42,13 +42,13 @@ public enum EventParticleParticipation implements ParticleEnum { new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) ), Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), - new SimpleParticle(Particle.DRIP_WATER)) + new SimpleParticle(Particle.DRIPPING_WATER)) ), AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), - new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) + new Group(new SimpleParticle(Particle.DRIPPING_WATER), new SimpleParticle(Particle.UNDERWATER, 0.2F, 0.2F, 0.2F, 0.01))) ), MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), - new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) + new Circle(new SimpleParticle(Particle.UNDERWATER, 0, 0, 0, 0))) ), UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), new Always(new RandomParticle(RainCloudParticle.values()))) diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 096d5d7b..e98f40d8 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -33,7 +33,7 @@ import org.bukkit.Particle; public enum EventParticlePlacement implements ParticleEnum { WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01), 0, 1.1, 0))) )), AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) @@ -42,25 +42,25 @@ public enum EventParticlePlacement implements ParticleEnum { new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) )), Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), - new Cloud(new SimpleParticle(Particle.DRIP_WATER))) + new Cloud(new SimpleParticle(Particle.DRIPPING_WATER))) ), AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(32, 9, 205, 210), - new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) + new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIPPING_WATER), new SimpleParticle(Particle.UNDERWATER, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) ), MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.UNDERWATER, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) ), Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) ), UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) ), WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) ), WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/PlayerParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/PlayerParticle.java index 21bd86ec..508eb598 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/PlayerParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -36,13 +36,13 @@ public enum PlayerParticle implements ParticleEnum { new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) ), SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", - new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) + new SimpleParticle(Particle.SMOKE, 0.2F, 0.2F, 0.2F, 0.01)) ), FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", - new SimpleParticle(Particle.DRIP_LAVA)) + new SimpleParticle(Particle.DRIPPING_LAVA)) ), WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", - new SimpleParticle(Particle.DRIP_WATER)) + new SimpleParticle(Particle.DRIPPING_WATER)) ), HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) @@ -54,25 +54,25 @@ public enum PlayerParticle implements ParticleEnum { new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) ), SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", - new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) + new SimpleParticle(Particle.SNOWFLAKE, 0.2F, 0.2F ,0.2F, 0.01)) ), EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", - new DustParticle(Particle.REDSTONE, 0, 0.2F, 0, 0.01, 5, null)) + new DustParticle(Particle.DUST, 0, 0.2F, 0, 0.01, 5, null)) ), CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) ), MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", - new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) + new SimpleParticle(Particle.CRIT, 0.2F, 0.2F, 0.2F, 0.01)) ), ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", - new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) + new SimpleParticle(Particle.ANGRY_VILLAGER, 0.2F, 0.2F, 0.2F, 0.01)) ), SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", - new SimpleParticle(Particle.SLIME)) + new SimpleParticle(Particle.ITEM_SLIME)) ), MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", - new SimpleParticle(Particle.SPELL_MOB)) + new SimpleParticle(Particle.SOUL)) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/RainCloudParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/RainCloudParticle.java index a9da53e7..7df64822 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/RainCloudParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/RainCloudParticle.java @@ -35,10 +35,10 @@ import org.bukkit.Particle; public enum RainCloudParticle implements ParticleEnum { Raincloud(new ParticleData(Material.BLUE_CARPET, "PARTICLE_RAINCLOUD_NORMAL", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.RAIN, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIPPING_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Red_Raincloud(new ParticleData(Material.RED_CARPET, "PARTICLE_RAINCLOUD_RED", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIPPING_LAVA, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Yellow_Raincloud(new ParticleData(Material.YELLOW_CARPET, "PARTICLE_RAINCLOUD_YELLOW", ParticleRequirement.HAS_TEAM, new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.FALLING_NECTAR, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) @@ -56,19 +56,19 @@ public enum RainCloudParticle implements ParticleEnum { new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.NAUTILUS, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Enchantment_Raincloud(new ParticleData(Material.ENCHANTED_BOOK, "PARTICLE_RAINCLOUD_ENCHANTMENT", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.ENCHANT, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Slime_Raincloud(new ParticleData(Material.GREEN_CARPET, "PARTICLE_RAINCLOUD_SLIME", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.SLIME, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.ITEM_SLIME, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Hail_Raincloud(new ParticleData(Material.LIGHT_GRAY_CARPET, "PARTICLE_RAINCLOUD_HAIL", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.SNOWBALL, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.ITEM_SNOWBALL, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Snow_Raincloud(new ParticleData(Material.WHITE_CARPET, "PARTICLE_RAINCLOUD_SNOW", ParticleRequirement.HAS_TEAM, new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.SNOWFLAKE, 0.3F, 0.0F, 0.3F, 0.01), 0, -0.3, 0)), 0, 2.4, 0))) ), Totem_Raincloud(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_RAINCLOUD_TOTEM", ParticleRequirement.HAS_TEAM, - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.TOTEM, 0.3F, 0.0F, 0.3F, 0.01, 2), 0, -0.3, 0)), 0, 2.4, 0))) + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.TOTEM_OF_UNDYING, 0.3F, 0.0F, 0.3F, 0.01, 2), 0, -0.3, 0)), 0, 2.4, 0))) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index ec0d81da..84b543eb 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -33,10 +33,10 @@ import org.bukkit.Particle; public enum ServerTeamParticle implements ParticleEnum { WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.SPELL_WITCH)) + new SimpleParticle(Particle.WITCH)) ), ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + new SimpleParticle(Particle.ENCHANT)) ), HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) @@ -51,10 +51,10 @@ public enum ServerTeamParticle implements ParticleEnum { new Cloud(new SimpleParticle(Particle.CLOUD))) ), TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) + new Cloud(new SimpleParticle(Particle.TOTEM_OF_UNDYING, 0.2F, 0.2F, 0.2F, 0.01))) ), ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) + new Cloud(new SimpleParticle(Particle.ENCHANT))) ), FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, new Cloud(new SimpleParticle(Particle.FLAME))) @@ -63,52 +63,52 @@ public enum ServerTeamParticle implements ParticleEnum { new Cloud(new SimpleParticle(Particle.SNEEZE))) ), SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.SLIME))) + new Cloud(new SimpleParticle(Particle.ITEM_SLIME))) ), SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) ), TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOWN_AURA))) + new Cloud(new SimpleParticle(Particle.RAID_OMEN))) ), FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) ), ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) + new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANT, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) ), NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) ), WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIPPING_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIPPING_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) ), WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIPPING_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIPPING_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) ), MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01)), 0, 1.1, 0)) ), MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01)), 0, 1.1, 0))) ), MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTED_HIT, 0, 0, 0, 0.01), 0, 1.1, 0)))) ), FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) ), FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORK, 0, 0, 0, 0.01), 0, 1.1, 0)))) ), WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.RAIN, 0, 0, 0, 0.01), 0, 1.1, 0)))) ), ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01)), 0, 2.2, 0))) ), EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/TeamParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/TeamParticle.java index 7cf3ef7d..c988316d 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/TeamParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/TeamParticle.java @@ -47,7 +47,7 @@ public enum TeamParticle implements ParticleEnum { new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) ), FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, - new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) + new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) ), DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java index 3d8c704e..b2d74d1b 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java @@ -39,40 +39,40 @@ public enum CustomEasterParticle implements ParticleEnum { new Always( new DoubleCircle( new DoubleCircle( - new YOffset(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01, 1), 20, 0, 2, true, true), - new YOffset(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01, 1), 20, 0, 2, false, true), 0.5, 4), + new YOffset(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01, 1), 20, 0, 2, true, true), + new YOffset(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01, 1), 20, 0, 2, false, true), 0.5, 4), new DoubleCircle( - new YOffset(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01, 1), 20, 0, 2, false, true), - new YOffset(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01, 1), 20, 0, 2, true, true), 0.5, 4), 1.5, 1) + new YOffset(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01, 1), 20, 0, 2, false, true), + new YOffset(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0.01, 1), 20, 0, 2, true, true), 0.5, 4), 1.5, 1) )) ), PLAYER_10916(new ParticleData(Material.TORCHFLOWER, "PARTICLE_PLAYER_10916_AURA", ParticleRequirement.easterEventSpecificPlayer(10916), new Always(new NonMoving(new Group( - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.5, 10), location -> location.add(0, 0.2, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.5, 10), location -> location.add(0, 0.3, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.55, 10), location -> location.add(0, 0.4, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.55, 10), location -> location.add(0, 0.5, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.65, 10), location -> location.add(0, 0.6, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.65, 10), location -> location.add(0, 0.7, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 0.8, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 0.9, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 1.0, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.1, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.2, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.3, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.4, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.5, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.6, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.7, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.8, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.9, 0)), - new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.9, 10), location -> location.add(0, 2.0, 0)) + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.5, 10), location -> location.add(0, 0.2, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.5, 10), location -> location.add(0, 0.3, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.55, 10), location -> location.add(0, 0.4, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.55, 10), location -> location.add(0, 0.5, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.65, 10), location -> location.add(0, 0.6, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.65, 10), location -> location.add(0, 0.7, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 0.8, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 0.9, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.7, 10), location -> location.add(0, 1.0, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.1, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.2, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.75, 10), location -> location.add(0, 1.3, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.4, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.5, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.8, 10), location -> location.add(0, 1.6, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.7, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.8, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.85, 10), location -> location.add(0, 1.9, 0)), + new LocationMutator(new DoubleCircle(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.RED)), 0.9, 10), location -> location.add(0, 2.0, 0)) )))) ), PLAYER_10697(new ParticleData(Material.GUNPOWDER, "PARTICLE_PLAYER_10697_AURA", ParticleRequirement.easterEventSpecificPlayer(10697), new Always(new Sneaking(new Group( - new OnlySelf(new Delayed(new SimpleParticle(Particle.EXPLOSION_HUGE, 0, 0, 0, 0.01, 1), 20)), - new OnlyOthers(new Delayed(new SimpleParticle(Particle.EXPLOSION_HUGE, 0, 0, 0, 0.01, 1), 2)) + new OnlySelf(new Delayed(new SimpleParticle(Particle.EXPLOSION, 0, 0, 0, 0.01, 1), 20)), + new OnlyOthers(new Delayed(new SimpleParticle(Particle.EXPLOSION, 0, 0, 0, 0.01, 1), 2)) )))) ), PLAYER_64(new ParticleData(Material.PUFFERFISH_BUCKET, "PARTICLE_PLAYER_64", ParticleRequirement.easterEventSpecificPlayer(64), @@ -86,9 +86,9 @@ public enum CustomEasterParticle implements ParticleEnum { ), PLAYER_153(new ParticleData(Material.OAK_SIGN, "PARTICLE_PLAYER_153", ParticleRequirement.easterEventSpecificPlayer(153), new Always(new Delayed(new NonFlying(new Group( - new Wing(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.DARK_GRAY)), 0.15, WingDesign.ELY_E), - new Wing(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.GREEN)), 0.15, WingDesign.ELY_L), - new Wing(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0, 1, new Gradient(Color.GRAY)), 0.15, WingDesign.ELY_Y) + new Wing(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.DARK_GRAY)), 0.15, WingDesign.ELY_E), + new Wing(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.GREEN)), 0.15, WingDesign.ELY_L), + new Wing(new DustParticle(Particle.DUST, 0, 0, 0, 0, 1, new Gradient(Color.GRAY)), 0.15, WingDesign.ELY_Y) )), 10))) ), // TODO: Implement zSalos! -> Team @@ -101,9 +101,9 @@ public enum CustomEasterParticle implements ParticleEnum { new Group( new Always(new Sneaking(new LocationMutator(new None(), location -> location))), new Always(new NonFlying(new LocationMutator(new TrippleCircle( - new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), - new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), - new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), + new DustParticle(Particle.DUST, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), + new DustParticle(Particle.DUST, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), + new DustParticle(Particle.DUST, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)), 0.7, 0.5), location -> location.add(0, 0.6, 0) )))) @@ -113,10 +113,10 @@ public enum CustomEasterParticle implements ParticleEnum { // TODO: Implement SchwarzerFuerst // TODO: Implement byVallu TEAM_158_1(new ParticleData(Material.ENCHANTED_BOOK, "PARTICLE_TEAM_158_1", ParticleRequirement.easterEventSpecificTeam(158), - new Always(new NonFlying(new Delayed(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.2, WingDesign.EV), 15)))) + new Always(new NonFlying(new Delayed(new Wing(new SimpleParticle(Particle.CRIT, 0, 0, 0, 0, 1), 0.2, WingDesign.EV), 15)))) ), TEAM_158_2(new ParticleData(Material.ENDER_EYE, "PARTICLE_TEAM_158_2", ParticleRequirement.easterEventSpecificTeam(158), - new Always(new NonFlying(new YOffset(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0.01f, 0.01f, 0.01f, 0.1, 1, new Gradient(Color.RED)), new DustParticle(Particle.REDSTONE, 0.01f, 0.01f, 0.01f, 0.1, 1, new Gradient(Color.BLUE)), 0.7, 1), 40, 0, 2, false, false)))) + new Always(new NonFlying(new YOffset(new DoubleCircle(new DustParticle(Particle.CRIT, 0.01f, 0.01f, 0.01f, 0.1, 1, new Gradient(Color.RED)), new DustParticle(Particle.DUST, 0.01f, 0.01f, 0.01f, 0.1, 1, new Gradient(Color.BLUE)), 0.7, 1), 40, 0, 2, false, false)))) ), ; public static ParticleEnum[] particles = values(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java index f27da88c..c9036408 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java @@ -35,8 +35,8 @@ public enum CustomPlayerParticle implements ParticleEnum { Haylim_(new ParticleData(Material.WHITE_CANDLE, "PARTICLE_PLAYER_HAYLIM_AURA", ParticleRequirement.specificPlayer(9426), new Always(new NonMoving(new NonFlying(new Group( - new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01, 5), 40, 0, 2, false, false), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,5), 40, 0, 2, true, false)), - new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01, 5), 40, 0, 2, true, false), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,5), 40, 0, 2, false, false)) + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01, 5), 40, 0, 2, false, false), new YOffset(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.0,5), 40, 0, 2, true, false)), + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.01, 5), 40, 0, 2, true, false), new YOffset(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0.0,5), 40, 0, 2, false, false)) ))))) ), ; diff --git a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java index 6159aacb..9da1f443 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java @@ -41,7 +41,7 @@ public enum CustomTeamParticle implements ParticleEnum { new Always(new NonMoving(new PulseShimmer(new SimpleParticle(Particle.END_ROD, 0, 0, 0, 0, 1), 80, 2)))) ), Pulse_2(new ParticleData(Material.WHITE_CANDLE, "PARTICLE_TEAM_PULSE_AURA_3", ParticleRequirement.specificTeam(210), - new Always(new NonMoving(new PulseShimmer(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0, 5), 80, 2)))) + new Always(new NonMoving(new PulseShimmer(new SimpleParticle(Particle.ENCHANT, 0, 0, 0, 0, 5), 80, 2)))) ), Pulse_Logo(new ParticleData(Material.ENDER_CHEST, "PARTICLE_TEAM_PULSE_LOGO", ParticleRequirement.specificTeam(210), new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.END_ROD, 0, 0, 0, 0, 1), 0.15, WingDesign.PL)), 80))) diff --git a/LobbySystem/src/de/steamwar/lobby/util/ItemBuilder.java b/LobbySystem/src/de/steamwar/lobby/util/ItemBuilder.java index 562154e6..f05233d0 100644 --- a/LobbySystem/src/de/steamwar/lobby/util/ItemBuilder.java +++ b/LobbySystem/src/de/steamwar/lobby/util/ItemBuilder.java @@ -49,7 +49,7 @@ public class ItemBuilder { meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_PLACED_ON); - meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + meta.addItemFlags(ItemFlag.HIDE_STORED_ENCHANTS); return this; } diff --git a/MissileWars/build.gradle.kts b/MissileWars/build.gradle.kts index d5dffa66..b85213d3 100644 --- a/MissileWars/build.gradle.kts +++ b/MissileWars/build.gradle.kts @@ -21,18 +21,13 @@ plugins { steamwar.java } -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) - compileOnly(libs.nms20) - compileOnly(libs.fawe18) + compileOnly(libs.nms) + compileOnly(libs.worldedit) } diff --git a/MissileWars/src/de/steamwar/misslewars/FightWorld.java b/MissileWars/src/de/steamwar/misslewars/FightWorld.java index 1187d840..501c18a2 100644 --- a/MissileWars/src/de/steamwar/misslewars/FightWorld.java +++ b/MissileWars/src/de/steamwar/misslewars/FightWorld.java @@ -20,15 +20,19 @@ package de.steamwar.misslewars; import de.steamwar.core.CraftbukkitWrapper; -import net.minecraft.world.level.chunk.Chunk; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; -import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.HashSet; +import java.util.Set; import java.util.function.ObjIntConsumer; public class FightWorld { @@ -71,10 +75,14 @@ public class FightWorld { } private static void resetChunk(World world, World backup, int x, int z) { - Chunk chunk = ((CraftWorld) world).getHandle().d(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z); - - System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length); + LevelChunk worldChunk = ((CraftWorld) world).getHandle().getChunk(x, z); + LevelChunk backupChunk = ((CraftWorld) backup).getHandle().getChunk(x, z); + LevelChunkSection[] sections = worldChunk.getSections(); + System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length); + Set blocks = new HashSet<>(worldChunk.blockEntities.keySet()); + blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity); + worldChunk.heightmaps.clear(); + worldChunk.heightmaps.putAll(backupChunk.heightmaps); for(Player p : Bukkit.getOnlinePlayers()) CraftbukkitWrapper.impl.sendChunk(p, x, z); diff --git a/MissileWars/src/de/steamwar/misslewars/MWTeam.java b/MissileWars/src/de/steamwar/misslewars/MWTeam.java index 88d9692d..ff13ab18 100644 --- a/MissileWars/src/de/steamwar/misslewars/MWTeam.java +++ b/MissileWars/src/de/steamwar/misslewars/MWTeam.java @@ -39,10 +39,10 @@ public class MWTeam { static { ItemMeta bowMeta = Objects.requireNonNull(bow.getItemMeta()); - bowMeta.addEnchant(Enchantment.ARROW_FIRE, 1, true); - bowMeta.addEnchant(Enchantment.ARROW_KNOCKBACK, 1, true); + bowMeta.addEnchant(Enchantment.FLAME, 1, true); + bowMeta.addEnchant(Enchantment.PUNCH, 1, true); bowMeta.addEnchant(Enchantment.KNOCKBACK, 1, true); - bowMeta.addEnchant(Enchantment.DAMAGE_ALL, 2, true); + bowMeta.addEnchant(Enchantment.POWER, 2, true); bowMeta.setUnbreakable(true); bow.setItemMeta(bowMeta); } diff --git a/MissileWars/src/de/steamwar/misslewars/items/Missile.java b/MissileWars/src/de/steamwar/misslewars/items/Missile.java index d89448e0..f3452177 100644 --- a/MissileWars/src/de/steamwar/misslewars/items/Missile.java +++ b/MissileWars/src/de/steamwar/misslewars/items/Missile.java @@ -30,6 +30,8 @@ import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.util.SideEffect; +import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.misslewars.MissileWars; @@ -105,7 +107,7 @@ public class Missile extends SpecialItem { else if (yaw > 135 && yaw <= 225) aT = aT.rotateY(180); else if (yaw > 225 && yaw <= 315) aT = aT.rotateY(90); - v = v.subtract(dimensions.getX()/2, dimensions.getY() + 2, -2).subtract(offset); + v = v.subtract(dimensions.x()/2, dimensions.y() + 2, -2).subtract(offset); v = aT.apply(v.toVector3()).toBlockPoint(); v = v.add(location.getBlockX(), location.getBlockY(), location.getBlockZ()); diff --git a/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java b/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java index 7d3ff5a9..44895eeb 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java @@ -49,7 +49,7 @@ public class SpaceListener extends BasicListener { if (!Config.Space) return; Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> { Player player = event.getPlayer(); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 3)); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, Integer.MAX_VALUE, 3)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, Integer.MAX_VALUE, 3)); player.setHealth(0.5); player.setHealthScale(0.5); @@ -61,7 +61,7 @@ public class SpaceListener extends BasicListener { if (!Config.Space) return; Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> { Player player = event.getPlayer(); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 3)); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, Integer.MAX_VALUE, 3)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, Integer.MAX_VALUE, 3)); player.setHealth(0.5); player.setHealthScale(0.5); diff --git a/MissileWars/src/de/steamwar/misslewars/scripts/implemented/SoundScript.java b/MissileWars/src/de/steamwar/misslewars/scripts/implemented/SoundScript.java index 98d376c6..cdd0e67a 100644 --- a/MissileWars/src/de/steamwar/misslewars/scripts/implemented/SoundScript.java +++ b/MissileWars/src/de/steamwar/misslewars/scripts/implemented/SoundScript.java @@ -23,6 +23,8 @@ import com.google.gson.JsonObject; import de.steamwar.misslewars.scripts.RunnableScript; import de.steamwar.misslewars.scripts.RunnableScriptEvent; import de.steamwar.misslewars.scripts.ScriptedItem; +import net.kyori.adventure.key.Key; +import org.bukkit.Registry; import org.bukkit.Sound; import static de.steamwar.misslewars.scripts.utils.JsonUtils.getFloat; @@ -35,7 +37,7 @@ public class SoundScript implements RunnableScript { private float pitch; public SoundScript(JsonObject sound) { - getString(sound, "sound", value -> this.sound = Sound.valueOf(value)); + getString(sound, "sound", value -> this.sound = Registry.SOUNDS.get(Key.key("minecraft", value))); volume = getFloat(sound, "volume", 100); pitch = getFloat(sound, "pitch", 1); } diff --git a/MissileWars/src/de/steamwar/misslewars/scripts/utils/EntityUtils.java b/MissileWars/src/de/steamwar/misslewars/scripts/utils/EntityUtils.java index 101dd08c..72183fa9 100644 --- a/MissileWars/src/de/steamwar/misslewars/scripts/utils/EntityUtils.java +++ b/MissileWars/src/de/steamwar/misslewars/scripts/utils/EntityUtils.java @@ -38,7 +38,6 @@ public class EntityUtils { } public static void setProjectileOptions(Projectile projectile, JsonObject jsonObject) { - getBoolean(jsonObject, "bounce", projectile::setBounce); setEntityOptions(projectile, jsonObject); } diff --git a/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java b/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java index 4630784d..c5e01cc4 100644 --- a/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java +++ b/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java @@ -19,9 +19,10 @@ package de.steamwar.misslewars.slowmo; -import de.steamwar.Reflection; +import net.minecraft.server.level.ServerLevel; import org.bukkit.Bukkit; import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; import java.lang.reflect.Field; @@ -30,7 +31,6 @@ public class SlowMoUtils { private static final Field field; public static final boolean freezeEnabled; - private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", null); private static boolean frozen = false; private static final World world; @@ -38,7 +38,7 @@ public class SlowMoUtils { static { Field temp; try { - temp = Reflection.getClass("net.minecraft.server.level.ServerLevel").getField("freezed"); + temp = ServerLevel.class.getField("freezed"); } catch (NoSuchFieldException e) { temp = null; } @@ -64,7 +64,7 @@ public class SlowMoUtils { if (freezeEnabled) { if (frozen == state) return; try { - field.set(getWorldHandle.invoke(world), state); + field.set(((CraftWorld) world).getHandle(), state); frozen = state; } catch (IllegalAccessException e) { // Ignored; diff --git a/Realtime/build.gradle.kts b/Realtime/build.gradle.kts index df761ff0..98ae77c9 100644 --- a/Realtime/build.gradle.kts +++ b/Realtime/build.gradle.kts @@ -22,5 +22,5 @@ plugins { } dependencies { - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) } diff --git a/SchematicSystem/SchematicSystem_15/build.gradle.kts b/SchematicSystem/SchematicSystem_15/build.gradle.kts deleted file mode 100644 index 281e62fc..00000000 --- a/SchematicSystem/SchematicSystem_15/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - - compileOnly(libs.nms15) - compileOnly(libs.worldedit15) -} diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java deleted file mode 100644 index 8ed1bd4c..00000000 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ /dev/null @@ -1,143 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; -import de.steamwar.core.Core; -import de.steamwar.sql.GameModeConfig; -import de.steamwar.sql.SchematicType; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -public class AutoChecker15 implements AutoChecker.IAutoChecker { - - public AutoChecker.BlockScanResult scan(Clipboard clipboard) { - AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); - BlockVector3 min = clipboard.getMinimumPoint(); - BlockVector3 max = clipboard.getMaximumPoint(); - for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ - for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z)); - final Material material = Material.matchMaterial(block.getBlockType().getId()); - if(material == null) { - continue; - } - - result.getBlockCounts().merge(material, 1, Integer::sum); - - if(AutoCheckerItems.impl.getInventoryMaterials().contains(material)) { - checkInventory(result, block, material, new BlockPos(x, y, z)); - } - - if(x == min.getBlockX() || x == max.getBlockX() || y == max.getBlockY() || z == min.getBlockZ() || z == max.getBlockZ()) { - result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z)); - } - } - } - } - return result; - } - - private static final Map> itemsInInv = new EnumMap<>(Material.class); - - static { - itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.TNT, EnumSet.of( - Material.CHEST, Material.BARREL, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, - Material.RED_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX - )); - itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER)); - AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials())); - } - - private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { - CompoundTag nbt = block.getNbtData(); - if(nbt == null) { - result.getDefunctNbt().add(pos); - return; - } - - - if(material == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){ - result.getRecords().add(pos); - return; - } - - List items = nbt.getList("Items", CompoundTag.class); - if(items.isEmpty()) - return; //Leeres Inventar - - int counter = 0; - for(CompoundTag item : items){ - if(!item.containsKey("id")){ - result.getDefunctNbt().add(pos); - continue; - } - - Material itemType = Material.matchMaterial(item.getString("id")); - if(itemType == null) //Leere Slots - continue; - - if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { - result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); - } else if(material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { - counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); - } - if (item.containsKey("tag")) { - result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); - } - } - result.getDispenserItems().put(pos, counter); - } - - @Override - public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .blockScanResult(scan(clipboard)) - .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) - .build(); - } - - @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .build(); - } -} diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java deleted file mode 100644 index 0a04e8b2..00000000 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java +++ /dev/null @@ -1,96 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import org.bukkit.Material; - -import java.util.EnumSet; -import java.util.Set; - -public class AutoCheckerItems15 implements AutoCheckerItems { - - private static final Set INVENTORY = EnumSet.of( - Material.BARREL, - Material.BLAST_FURNACE, - Material.BREWING_STAND, - Material.CAMPFIRE, - Material.CHEST, - Material.DISPENSER, - Material.DROPPER, - Material.FURNACE, - Material.HOPPER, - Material.JUKEBOX, - Material.SHULKER_BOX, - Material.WHITE_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, - Material.MAGENTA_SHULKER_BOX, - Material.LIGHT_BLUE_SHULKER_BOX, - Material.YELLOW_SHULKER_BOX, - Material.LIME_SHULKER_BOX, - Material.PINK_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, - Material.CYAN_SHULKER_BOX, - Material.PURPLE_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, - Material.BROWN_SHULKER_BOX, - Material.GREEN_SHULKER_BOX, - Material.RED_SHULKER_BOX, - Material.BLACK_SHULKER_BOX, - Material.SMOKER, - Material.TRAPPED_CHEST); - - private static final Set FLOWERS = EnumSet.of( - Material.CORNFLOWER, - Material.POPPY, - Material.FERN, - Material.DANDELION, - Material.BLUE_ORCHID, - Material.ALLIUM, - Material.AZURE_BLUET, - Material.RED_TULIP, - Material.ORANGE_TULIP, - Material.WHITE_TULIP, - Material.PINK_TULIP, - Material.OXEYE_DAISY, - Material.LILY_OF_THE_VALLEY, - Material.WITHER_ROSE, - Material.SUNFLOWER, - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_HORSE_ARMOR, - Material.LEATHER_HORSE_ARMOR, - Material.HONEY_BOTTLE, - Material.LILAC, - Material.ROSE_BUSH, - Material.PEONY, - Material.TALL_GRASS, - Material.LARGE_FERN); - - @Override - public Set getInventoryMaterials() { - return INVENTORY; - } - - @Override - public Set getAllowedMaterialsInInventory() { - return FLOWERS; - } -} diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts deleted file mode 100644 index 0536403a..00000000 --- a/SchematicSystem/SchematicSystem_19/build.gradle.kts +++ /dev/null @@ -1,33 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_15", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms19) - compileOnly(libs.fawe18) -} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java deleted file mode 100644 index 59bfc397..00000000 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java +++ /dev/null @@ -1,81 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import org.bukkit.Material; - -import java.util.EnumSet; -import java.util.Set; - -public class AutoCheckerItems19 extends AutoCheckerItems15 { - - private static final Set ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of( - // 64-stackable Items - Material.CORNFLOWER, - Material.POPPY, - Material.FERN, - Material.DANDELION, - Material.BLUE_ORCHID, - Material.ALLIUM, - Material.AZURE_BLUET, - Material.RED_TULIP, - Material.ORANGE_TULIP, - Material.WHITE_TULIP, - Material.PINK_TULIP, - Material.OXEYE_DAISY, - Material.LILY_OF_THE_VALLEY, - Material.WITHER_ROSE, - Material.SUNFLOWER, - Material.LILAC, - Material.ROSE_BUSH, - Material.PEONY, - Material.TALL_GRASS, - Material.LARGE_FERN, - // 16-stackable Items - Material.HONEY_BOTTLE, - // Non-stackable items - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_HORSE_ARMOR, - Material.LEATHER_HORSE_ARMOR, - // Disks - Material.MUSIC_DISC_11, - Material.MUSIC_DISC_13, - Material.MUSIC_DISC_CAT, - Material.MUSIC_DISC_BLOCKS, - Material.MUSIC_DISC_CHIRP, - Material.MUSIC_DISC_FAR, - Material.MUSIC_DISC_MALL, - Material.MUSIC_DISC_MELLOHI, - Material.MUSIC_DISC_STAL, - Material.MUSIC_DISC_STRAD, - Material.MUSIC_DISC_WAIT, - Material.MUSIC_DISC_WARD, - Material.MUSIC_DISC_OTHERSIDE, - Material.MUSIC_DISC_PIGSTEP, - Material.MUSIC_DISC_RELIC, - Material.MUSIC_DISC_5 - ); - - @Override - public Set getAllowedMaterialsInInventory() { - return ALLOWED_ITEMS_IN_INVENTORY; - } -} diff --git a/SchematicSystem/SchematicSystem_20/build.gradle.kts b/SchematicSystem/SchematicSystem_20/build.gradle.kts deleted file mode 100644 index 048f1a64..00000000 --- a/SchematicSystem/SchematicSystem_20/build.gradle.kts +++ /dev/null @@ -1,34 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_19", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_15", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.nms19) - compileOnly(libs.fawe18) -} diff --git a/SchematicSystem/SchematicSystem_20/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems20.java b/SchematicSystem/SchematicSystem_20/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems20.java deleted file mode 100644 index 8f180af8..00000000 --- a/SchematicSystem/SchematicSystem_20/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems20.java +++ /dev/null @@ -1,82 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import org.bukkit.Material; - -import java.util.EnumSet; -import java.util.Set; - -public class AutoCheckerItems20 extends AutoCheckerItems19 { - - private static final Set ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of( - // 64-stackable Items - Material.CORNFLOWER, - Material.POPPY, - Material.FERN, - Material.DANDELION, - Material.BLUE_ORCHID, - Material.ALLIUM, - Material.AZURE_BLUET, - Material.RED_TULIP, - Material.ORANGE_TULIP, - Material.WHITE_TULIP, - Material.PINK_TULIP, - Material.OXEYE_DAISY, - Material.LILY_OF_THE_VALLEY, - Material.WITHER_ROSE, - Material.SUNFLOWER, - Material.LILAC, - Material.ROSE_BUSH, - Material.PEONY, - Material.TALL_GRASS, - Material.LARGE_FERN, - Material.TORCHFLOWER, - // 16-stackable Items - Material.HONEY_BOTTLE, - // Non-stackable items - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_HORSE_ARMOR, - Material.LEATHER_HORSE_ARMOR, - // Disks - Material.MUSIC_DISC_11, - Material.MUSIC_DISC_13, - Material.MUSIC_DISC_CAT, - Material.MUSIC_DISC_BLOCKS, - Material.MUSIC_DISC_CHIRP, - Material.MUSIC_DISC_FAR, - Material.MUSIC_DISC_MALL, - Material.MUSIC_DISC_MELLOHI, - Material.MUSIC_DISC_STAL, - Material.MUSIC_DISC_STRAD, - Material.MUSIC_DISC_WAIT, - Material.MUSIC_DISC_WARD, - Material.MUSIC_DISC_OTHERSIDE, - Material.MUSIC_DISC_PIGSTEP, - Material.MUSIC_DISC_RELIC, - Material.MUSIC_DISC_5 - ); - - @Override - public Set getAllowedMaterialsInInventory() { - return ALLOWED_ITEMS_IN_INVENTORY; - } -} diff --git a/SchematicSystem/SchematicSystem_21/build.gradle.kts b/SchematicSystem/SchematicSystem_21/build.gradle.kts deleted file mode 100644 index 2654c5b7..00000000 --- a/SchematicSystem/SchematicSystem_21/build.gradle.kts +++ /dev/null @@ -1,37 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - - compileOnly(libs.paperapi21) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } - - compileOnly(libs.nms21) - compileOnly(libs.fawe21) -} diff --git a/SchematicSystem/SchematicSystem_8/build.gradle.kts b/SchematicSystem/SchematicSystem_8/build.gradle.kts deleted file mode 100644 index 77bba6f4..00000000 --- a/SchematicSystem/SchematicSystem_8/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore", "default")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) - - compileOnly(libs.nms8) - compileOnly(libs.worldedit12) -} diff --git a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java deleted file mode 100644 index c98b136a..00000000 --- a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/autocheck/AutoChecker8.java +++ /dev/null @@ -1,175 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.regions.Region; -import de.steamwar.sql.GameModeConfig; -import de.steamwar.sql.SchematicType; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -@SuppressWarnings("deprecation") -public class AutoChecker8 implements AutoChecker.IAutoChecker { - private static final int DISPENSER = Material.DISPENSER.getId(); - private static final int JUKEBOX = Material.JUKEBOX.getId(); - private static final int CHEST = Material.CHEST.getId(); - private static final Set INVENTORY = new HashSet<>(); - private static final Set FLOWERS; - - static{ - INVENTORY.add(CHEST); - INVENTORY.add(Material.TRAPPED_CHEST.getId()); - INVENTORY.add(Material.HOPPER.getId()); - INVENTORY.add(Material.FURNACE.getId()); - INVENTORY.add(Material.BURNING_FURNACE.getId()); - INVENTORY.add(JUKEBOX); //RecordItem - INVENTORY.add(DISPENSER); - INVENTORY.add(Material.DROPPER.getId()); - INVENTORY.add(Material.ANVIL.getId()); - INVENTORY.add(Material.BREWING_STAND.getId()); - for(int i = 219; i <= 234; i++) { - INVENTORY.add(i); // ShulkerBoxes - } - - Set flowers = new HashSet<>(); - flowers.add(Material.YELLOW_FLOWER); - flowers.add(Material.RED_ROSE); - flowers.add(Material.DOUBLE_PLANT); - flowers.add(Material.DIAMOND_BARDING); - flowers.add(Material.IRON_BARDING); - flowers.add(Material.GOLD_BARDING); - FLOWERS = flowers; - } - - public void scan(AutoChecker.BlockScanResult result, Clipboard clipboard) { - Region region = clipboard.getRegion(); - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); - - for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ - for(int y = min.getBlockY(); y <= max.getBlockY(); y++){ - for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){ - final BaseBlock block = clipboard.getBlock(new Vector(x, y, z)); - final int blockId = block.getId(); - final Material material = Material.getMaterial(blockId); - - result.getBlockCounts().merge(material, 1, Integer::sum); - - if(INVENTORY.contains(blockId)){ - checkInventory(result, block, blockId, new BlockPos(x, y, z)); - } - - if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) { - result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z)); - } - } - } - } - } - - private static final Map> itemsInInv = new EnumMap<>(Material.class); - - static { - itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.TNT, EnumSet.of(Material.CHEST)); - itemsInInv.put(Material.FIREBALL, EnumSet.of(Material.DISPENSER)); - itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER)); - FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY.stream().map(Material::getMaterial).collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class))))); - } - - private static void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, int blockId, BlockPos pos) { - CompoundTag nbt = block.getNbtData(); - if(nbt == null){ - result.getDefunctNbt().add(pos); - return; - } - - if(blockId == JUKEBOX && nbt.getValue().containsKey("RecordItem")){ - result.getRecords().add(pos); - return; - } - - List items = nbt.getList("Items", CompoundTag.class); - if(items.isEmpty()) - return; //Leeres Inventar - - int counter = 0; - for(CompoundTag item : items){ - if(!item.containsKey("id")){ - result.getDefunctNbt().add(pos); - continue; - } - - String materialName = item.getString("id"); - if(materialName.contains(":")) - materialName = materialName.split(":")[1]; - materialName = materialName.toUpperCase().replace("SHOVEL", "SPADE"); - Material itemType = Material.getMaterial(materialName); - if(itemType == null && item.getString("id").equals("minecraft:fire_charge")) - itemType = Material.FIREBALL; - if(itemType == null) //Leere Slots - continue; - - - if(!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(Material.getMaterial(blockId))) { - result.getForbiddenItems().computeIfAbsent(pos, blockPos -> new HashSet<>()).add(Material.getMaterial(blockId)); - } else if(blockId == DISPENSER && (itemType.equals(Material.FIREBALL) || itemType.equals(Material.ARROW))) { - counter += item.getByte("Count"); - } - if(item.containsKey("tag")) { - result.getForbiddenNbt().computeIfAbsent(pos, blockPos -> new HashSet<>()).add(Material.getMaterial(blockId)); - } - } - - result.getDispenserItems().put(pos, counter); - } - - @Override - public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { - AutoChecker.BlockScanResult blockScanResult = new AutoChecker.BlockScanResult(); - scan(blockScanResult, clipboard); - - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .blockScanResult(blockScanResult) - .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) - .build(); - } - - @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .build(); - } -} diff --git a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java b/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java deleted file mode 100644 index e873ea49..00000000 --- a/SchematicSystem/SchematicSystem_8/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand8.java +++ /dev/null @@ -1,43 +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 . - */ - -package de.steamwar.schematicsystem.commands.schematiccommand; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operations; -import de.steamwar.sql.GameModeConfig; -import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; -import de.steamwar.sql.SchematicType; -import org.bukkit.Material; - -public class SchematicCommand8 implements SchematicCommand.ISchematicCommand { - - @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { - return null; - } - - @Override - public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { - Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); - } -} diff --git a/SchematicSystem/SchematicSystem_Core/build.gradle.kts b/SchematicSystem/SchematicSystem_Core/build.gradle.kts deleted file mode 100644 index c18b3964..00000000 --- a/SchematicSystem/SchematicSystem_Core/build.gradle.kts +++ /dev/null @@ -1,31 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(libs.classindex) - annotationProcessor(libs.classindex) - compileOnly(project(":SpigotCore", "default")) - - compileOnly(libs.spigotapi) - compileOnly(libs.worldedit15) -} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java deleted file mode 100644 index 7d17e8f9..00000000 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java +++ /dev/null @@ -1,62 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.core.VersionDependent; -import de.steamwar.sql.GameModeConfig; -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.sql.SchematicType; -import lombok.Getter; -import lombok.ToString; -import org.bukkit.Material; - -import java.util.*; - -public class AutoChecker { - - public static AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { - return impl.check(clipboard, type); - } - - public static AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { - return impl.sizeCheck(clipboard, type); - } - - private static final IAutoChecker impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); - - public interface IAutoChecker { - AutoCheckerResult check(Clipboard clipboard, GameModeConfig type); - AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type); - } - - @Getter - @ToString - public static class BlockScanResult { - private final Map blockCounts = new EnumMap<>(Material.class); - private final List defunctNbt = new ArrayList<>(); - private final List records = new ArrayList<>(); - private final Map> designBlocks = new EnumMap<>(Material.class); - private final Map dispenserItems = new HashMap<>(); - private final Map windChargeCount = new HashMap<>(); - private final Map> forbiddenItems = new HashMap<>(); - private final Map> forbiddenNbt = new HashMap<>(); - } -} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java deleted file mode 100644 index c3d63c9b..00000000 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java +++ /dev/null @@ -1,34 +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 . - */ - -package de.steamwar.schematicsystem.autocheck; - -import de.steamwar.core.VersionDependent; -import de.steamwar.schematicsystem.SchematicSystem; -import org.bukkit.Material; - -import java.util.Set; - -public interface AutoCheckerItems { - - AutoCheckerItems impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); - - Set getInventoryMaterials(); - Set getAllowedMaterialsInInventory(); -} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java deleted file mode 100644 index 90c6d3c7..00000000 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java +++ /dev/null @@ -1,156 +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 . - */ - -package de.steamwar.schematicsystem.commands.schematiccommand; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.command.AbstractSWCommand; -import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; -import de.steamwar.core.VersionDependent; -import de.steamwar.sql.GameModeConfig; -import de.steamwar.linkage.Linked; -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; -import de.steamwar.sql.*; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*; -import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.togglePublic; - -@SuppressWarnings("unused") -@Linked -public class SchematicCommand extends SWCommand { - - public SchematicCommand() { - super("schematic", new String[] {"schem", "/schem", "/schematic"}); - } - - @Register("help") - public void pagedHelp(Player player, HelpPage page) { - printHelpPage(player, page); - } - - @Register - public void genericHelp(Player player, String... args) { - printHelpMainPage(player); - } - - @Register(value = "togglepublic", noTabComplete = true) - public void togglePublicMode(Player player) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if (!user.hasPerm(UserPerm.MODERATION)) { - genericHelp(player); - return; - } - - if (togglePublic(player)) { - SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_ON", player); - } else { - SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_OFF", player); - } - } - - @Mapper("publicMapper") - public TypeMapper publicNodeTypeMapper() { - return SchematicMapper.publicNodeTypeMapper(); - } - - @Mapper("memberMapper") - public static TypeMapper nodeMemberTypeMapper() { - return SchematicMapper.nodeMemberTypeMapper(); - } - - @Mapper("dirMapper") - public static TypeMapper dirNodeTypeMapper() { - return SchematicMapper.dirNodeTypeMapper(); - } - - @Mapper("publicDirMapper") - public static TypeMapper publicDirNodeTypeMapper() { - return SchematicMapper.publicDirNodeTypeMapper(); - } - - @Mapper("dirStringMapper") - public static TypeMapper stringTabMapper() { - return SchematicMapper.stringTabMapper(); - } - - @Mapper("stringMapper") - public static TypeMapper stringMapper() { - return SchematicMapper.stringMapper(); - } - - @ClassMapper(SchematicType.class) - public static TypeMapper typeTypeMapper() { - return SchematicMapper.typeTypeMapper(); - } - - @AbstractSWCommand.ClassMapper(value = SchematicNode.class, local = true) - public static TypeMapper nodeTypeMapper() { - return SchematicMapper.nodeTypeMapper(); - } - - @ClassMapper(value = GameModeConfig.class, local = true) - public static TypeMapper> gameModeConfigTypeMapper() { - return SchematicMapper.gameModeConfigTypeMapper(); - } - - @Override - protected void sendMessage(CommandSender sender, String message, Object[] args) { - SchematicSystem.MESSAGE.send(message, sender, args); - } - - @Validator(value = "isSchemValidator", local = true) - public static TypeValidator isSchemValidator() { - return SchematicValidator.isSchemValidator(); - } - - @Validator(value = "isDirValidator", local = true) - public static TypeValidator isDirValidator() { - return SchematicValidator.isDirValidator(); - } - - @Validator(value = "isOwnerValidator", local = true) - public static TypeValidator isOwnerValidator() { - return SchematicValidator.isOwnerValidator(); - } - - @Validator(value = "isOwnerSchematicValidator", local = true) - public static TypeValidator isOwnerSchematicValidator() { - return SchematicValidator.isOwnerSchematicValidator(); - } - - public enum Extend { - AUSFAHREN, - NORMAL - } - - public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); - - public interface ISchematicCommand { - Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception; - void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException; - } -} diff --git a/SchematicSystem/build.gradle.kts b/SchematicSystem/build.gradle.kts index 947812e3..b48fc815 100644 --- a/SchematicSystem/build.gradle.kts +++ b/SchematicSystem/build.gradle.kts @@ -19,6 +19,7 @@ plugins { `java-library` + steamwar.java alias(libs.plugins.shadow) } @@ -27,10 +28,10 @@ tasks.build { } dependencies { - implementation(project(":SchematicSystem:SchematicSystem_Core")) - implementation(project(":SchematicSystem:SchematicSystem_8")) - implementation(project(":SchematicSystem:SchematicSystem_15")) - implementation(project(":SchematicSystem:SchematicSystem_19")) - implementation(project(":SchematicSystem:SchematicSystem_20")) - implementation(project(":SchematicSystem:SchematicSystem_21")) + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) + compileOnly(project(":SpigotCore", "default")) + + compileOnly(libs.paperapi) + compileOnly(libs.fawe) } diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem/src/SchematicSystem.properties similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/SchematicSystem.properties rename to SchematicSystem/src/SchematicSystem.properties diff --git a/SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem/src/SchematicSystem_de.properties similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/SchematicSystem_de.properties rename to SchematicSystem/src/SchematicSystem_de.properties diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java b/SchematicSystem/src/de/steamwar/schematicsystem/SafeSchematicNode.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SafeSchematicNode.java rename to SchematicSystem/src/de/steamwar/schematicsystem/SafeSchematicNode.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem/src/de/steamwar/schematicsystem/SchematicSystem.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java rename to SchematicSystem/src/de/steamwar/schematicsystem/SchematicSystem.java diff --git a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java similarity index 87% rename from SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java rename to SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java index ad8acd39..2e8a2024 100644 --- a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoChecker21.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java @@ -1,7 +1,7 @@ /* * 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 * it under the terms of the GNU Affero General Public License as published by @@ -26,12 +26,30 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import de.steamwar.core.Core; import de.steamwar.sql.GameModeConfig; +import lombok.Getter; +import lombok.ToString; import org.bukkit.Material; import java.util.*; import java.util.stream.Collectors; -public class AutoChecker21 implements AutoChecker.IAutoChecker { +public class AutoChecker { + + public static final AutoChecker impl = new AutoChecker(); + + public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { + return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX()) + .depth(clipboard.getDimensions().getBlockZ()).blockScanResult(scan(clipboard, type)) + .entities(clipboard.getEntities().stream().map(Entity::getLocation) + .map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())) + .collect(Collectors.toList())) + .build(); + } + + public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { + return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX()) + .depth(clipboard.getDimensions().getBlockZ()).build(); + } public AutoChecker.BlockScanResult scan(Clipboard clipboard, GameModeConfig type) { AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); @@ -109,7 +127,7 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); } else if (material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { - counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); + counter += item.getInt("count"); } if (item.containsKey("tag")) { result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); @@ -119,19 +137,16 @@ public class AutoChecker21 implements AutoChecker.IAutoChecker { result.getWindChargeCount().put(pos, windChargeCount); } - @Override - public AutoCheckerResult check(Clipboard clipboard, GameModeConfig type) { - return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()).blockScanResult(scan(clipboard, type)) - .entities(clipboard.getEntities().stream().map(Entity::getLocation) - .map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())) - .collect(Collectors.toList())) - .build(); - } - - @Override - public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig type) { - return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()).build(); + @Getter + @ToString + public static class BlockScanResult { + private final Map blockCounts = new EnumMap<>(Material.class); + private final List defunctNbt = new ArrayList<>(); + private final List records = new ArrayList<>(); + private final Map> designBlocks = new EnumMap<>(Material.class); + private final Map dispenserItems = new HashMap<>(); + private final Map windChargeCount = new HashMap<>(); + private final Map> forbiddenItems = new HashMap<>(); + private final Map> forbiddenNbt = new HashMap<>(); } } diff --git a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems21.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java similarity index 67% rename from SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems21.java rename to SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java index af50a3fa..12268656 100644 --- a/SchematicSystem/SchematicSystem_21/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems21.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java @@ -1,18 +1,20 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 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. + * 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 . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package de.steamwar.schematicsystem.autocheck; @@ -22,7 +24,9 @@ import org.bukkit.Material; import java.util.EnumSet; import java.util.Set; -public class AutoCheckerItems21 implements AutoCheckerItems { +public class AutoCheckerItems { + + public static final AutoCheckerItems impl = new AutoCheckerItems(); private static final Set INVENTORY = EnumSet.of(Material.BARREL, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CAMPFIRE, Material.CHEST, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.JUKEBOX, Material.SHULKER_BOX, @@ -37,12 +41,10 @@ public class AutoCheckerItems21 implements AutoCheckerItems { Material.GOLDEN_HORSE_ARMOR, Material.LEATHER_HORSE_ARMOR, Material.HONEY_BOTTLE, Material.LILAC, Material.ROSE_BUSH, Material.PEONY, Material.TALL_GRASS, Material.LARGE_FERN); - @Override public Set getInventoryMaterials() { return INVENTORY; } - @Override public Set getAllowedMaterialsInInventory() { return FLOWERS; } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java similarity index 93% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java rename to SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java index 0cb6e386..e216282b 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java @@ -172,16 +172,14 @@ public class AutoCheckerResult { blockScanResult.getDefunctNbt().forEach(blockVector3 -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); }); - if(Core.getVersion() > 12) { - blockScanResult.getDesignBlocks().forEach((material, poss) -> { - if (material == Material.WATER || material == Material.LAVA) return; - if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) { - poss.forEach(pos -> { - SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); - }); - } - }); - } + blockScanResult.getDesignBlocks().forEach((material, poss) -> { + if (material == Material.WATER || material == Material.LAVA) return; + if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) { + poss.forEach(pos -> { + SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + }); + } + }); entities.forEach(blockPos -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ()); }); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/BlockPos.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/BlockPos.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/BlockPos.java rename to SchematicSystem/src/de/steamwar/schematicsystem/autocheck/BlockPos.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/DownloadCommand.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/DownloadCommand.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java similarity index 99% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java index 287d9b65..f40ae8ec 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java @@ -244,7 +244,7 @@ public class GUI { Clipboard finalClipboard = clipboard; List types = SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) - .filter(type -> finalClipboard == null || SchematicSystem.getGameModeConfig(type) == null || AutoChecker.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) + .filter(type -> finalClipboard == null || SchematicSystem.getGameModeConfig(type) == null || AutoChecker.impl.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) .collect(Collectors.toList()); List> items = types.stream() diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java similarity index 60% rename from SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java index 05036a9a..b3399344 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java @@ -31,27 +31,139 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.core.Core; -import de.steamwar.sql.GameModeConfig; +import de.steamwar.command.AbstractSWCommand; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeMapper; +import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.BlockPos; -import de.steamwar.sql.SchematicType; +import de.steamwar.sql.*; import org.bukkit.Material; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.util.*; -import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; -public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { - private static final Function getCount = item -> Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); - private static final BiFunction setCount = (item, count) -> Core.getVersion() >= 21 ? - item.createBuilder().putInt("count", count).build() : - item.createBuilder().putByte("Count", count.byteValue()).build(); +import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*; +import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.togglePublic; + +@SuppressWarnings("unused") +@Linked +public class SchematicCommand extends SWCommand { + + public SchematicCommand() { + super("schematic", new String[] {"schem", "/schem", "/schematic"}); + } + + @Register("help") + public void pagedHelp(Player player, HelpPage page) { + printHelpPage(player, page); + } + + @Register + public void genericHelp(Player player, String... args) { + printHelpMainPage(player); + } + + @Register(value = "togglepublic", noTabComplete = true) + public void togglePublicMode(Player player) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + if (!user.hasPerm(UserPerm.MODERATION)) { + genericHelp(player); + return; + } + + if (togglePublic(player)) { + SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_ON", player); + } else { + SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_OFF", player); + } + } + + @Mapper("publicMapper") + public TypeMapper publicNodeTypeMapper() { + return SchematicMapper.publicNodeTypeMapper(); + } + + @Mapper("memberMapper") + public static TypeMapper nodeMemberTypeMapper() { + return SchematicMapper.nodeMemberTypeMapper(); + } + + @Mapper("dirMapper") + public static TypeMapper dirNodeTypeMapper() { + return SchematicMapper.dirNodeTypeMapper(); + } + + @Mapper("publicDirMapper") + public static TypeMapper publicDirNodeTypeMapper() { + return SchematicMapper.publicDirNodeTypeMapper(); + } + + @Mapper("dirStringMapper") + public static TypeMapper stringTabMapper() { + return SchematicMapper.stringTabMapper(); + } + + @Mapper("stringMapper") + public static TypeMapper stringMapper() { + return SchematicMapper.stringMapper(); + } + + @ClassMapper(SchematicType.class) + public static TypeMapper typeTypeMapper() { + return SchematicMapper.typeTypeMapper(); + } + + @AbstractSWCommand.ClassMapper(value = SchematicNode.class, local = true) + public static TypeMapper nodeTypeMapper() { + return SchematicMapper.nodeTypeMapper(); + } + + @ClassMapper(value = GameModeConfig.class, local = true) + public static TypeMapper> gameModeConfigTypeMapper() { + return SchematicMapper.gameModeConfigTypeMapper(); + } @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { + protected void sendMessage(CommandSender sender, String message, Object[] args) { + SchematicSystem.MESSAGE.send(message, sender, args); + } + + @Validator(value = "isSchemValidator", local = true) + public static TypeValidator isSchemValidator() { + return SchematicValidator.isSchemValidator(); + } + + @Validator(value = "isDirValidator", local = true) + public static TypeValidator isDirValidator() { + return SchematicValidator.isDirValidator(); + } + + @Validator(value = "isOwnerValidator", local = true) + public static TypeValidator isOwnerValidator() { + return SchematicValidator.isOwnerValidator(); + } + + @Validator(value = "isOwnerSchematicValidator", local = true) + public static TypeValidator isOwnerSchematicValidator() { + return SchematicValidator.isOwnerSchematicValidator(); + } + + public enum Extend { + AUSFAHREN, + NORMAL + } + + private static final Function getCount = item -> item.getInt("count"); + private static final BiFunction setCount = (item, count) -> item.createBuilder().putInt("count", count).build(); + + public static Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap()))); @@ -149,8 +261,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { return clipboard; } - @Override - public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { + public static void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); } } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandHelp.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandHelp.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandHelp.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandHelp.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java similarity index 99% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java index d52a5569..b4b2c74a 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java @@ -20,7 +20,6 @@ package de.steamwar.schematicsystem.commands.schematiccommand; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.sql.GameModeConfig; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.network.NetworkSender; @@ -312,7 +311,7 @@ public class SchematicCommandUtils { } public static void check(Player player, Clipboard clipboard, GameModeConfig type, String schemName, boolean gui) { - AutoCheckerResult result = AutoChecker.check(clipboard, type); + AutoCheckerResult result = AutoChecker.impl.check(clipboard, type); if(!result.isOk()) { result.sendErrorMessage(player, schemName); } else { @@ -462,7 +461,7 @@ public class SchematicCommandUtils { AutoCheckerResult result = null; try { - result = AutoChecker.check(new SchematicData(node).load(), checkSchemType); + result = AutoChecker.impl.check(new SchematicData(node).load(), checkSchemType); } catch (IOException e) { SchematicSystem.MESSAGE.send("UTIL_LOAD_ERROR", player); SchematicSystem.getInstance().getLogger().throwing(SchematicCommandUtils.class.getName(), "changeType", e); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java similarity index 97% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java index 73564422..9f66bb6c 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicMapper.java @@ -20,12 +20,8 @@ package de.steamwar.schematicsystem.commands.schematiccommand; import de.steamwar.command.TypeMapper; -import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.sql.NodeMember; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.*; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java similarity index 98% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java index bd02c3d2..a6774d5f 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicValidator.java @@ -23,8 +23,10 @@ import de.steamwar.command.AbstractValidator; import de.steamwar.command.TypeValidator; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; +import lombok.experimental.UtilityClass; import org.bukkit.entity.Player; +@UtilityClass public class SchematicValidator { private static boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java similarity index 90% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java index 9e3be830..d0134625 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java @@ -28,22 +28,20 @@ import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; -import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; +import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; import org.bukkit.Material; import org.bukkit.entity.Player; import java.io.IOException; import java.util.logging.Level; -import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand.impl; import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.check; @AbstractSWCommand.PartOf(SchematicCommand.class) @@ -77,7 +75,7 @@ public class CheckPart extends SWCommand { Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelection(new BukkitWorld(player.getWorld()))); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1); - impl.createCopy(editSession, clipboard); + SchematicCommand.createCopy(editSession, clipboard); check(player, clipboard, type, "selection", false); } catch (IncompleteRegionException e) { @@ -89,10 +87,6 @@ public class CheckPart extends SWCommand { @Register("fix") public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { - if(Core.getVersion() < 15) { - SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player); - return; - } Clipboard clipboard; try { clipboard = WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(); @@ -100,15 +94,15 @@ public class CheckPart extends SWCommand { SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player); return; } - AutoCheckerResult result = AutoChecker.check(clipboard, type); + AutoCheckerResult result = AutoChecker.impl.check(clipboard, type); if(result.isOk()) { SchematicSystem.MESSAGE.send("COMMAND_FIX_OK", player); return; } try { - clipboard = impl.fixClipboard(clipboard, result, type); + clipboard = SchematicCommand.fixClipboard(clipboard, result, type); WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).setClipboard(new ClipboardHolder(clipboard)); - AutoCheckerResult after = AutoChecker.check(clipboard, type); + AutoCheckerResult after = AutoChecker.impl.check(clipboard, type); if(after.isOk()) { SchematicSystem.MESSAGE.send("COMMAND_FIX_DONE", player); } else { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java similarity index 98% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java index 1dab46dc..2db55195 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java @@ -63,7 +63,7 @@ public class ModifyPart extends SWCommand { SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) - .filter(type -> SchematicSystem.getGameModeConfig(type) == null || AutoChecker.sizeCheck(clipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) + .filter(type -> SchematicSystem.getGameModeConfig(type) == null || AutoChecker.impl.sizeCheck(clipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) .forEach(type -> { TextComponent component = new TextComponent(type.name() + " "); component.setColor(ChatColor.GRAY); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/parts.info b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/parts.info similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/parts.info rename to SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/parts.info diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java b/SchematicSystem/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java rename to SchematicSystem/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java diff --git a/SchematicSystem/SchematicSystem_Core/src/plugin.yml b/SchematicSystem/src/plugin.yml similarity index 100% rename from SchematicSystem/SchematicSystem_Core/src/plugin.yml rename to SchematicSystem/src/plugin.yml diff --git a/SpigotCore/SpigotCore_10/build.gradle.kts b/SpigotCore/SpigotCore_10/build.gradle.kts deleted file mode 100644 index cff91969..00000000 --- a/SpigotCore/SpigotCore_10/build.gradle.kts +++ /dev/null @@ -1,28 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - - compileOnly(libs.nms10) -} diff --git a/SpigotCore/SpigotCore_12/build.gradle.kts b/SpigotCore/SpigotCore_12/build.gradle.kts deleted file mode 100644 index 79ec438a..00000000 --- a/SpigotCore/SpigotCore_12/build.gradle.kts +++ /dev/null @@ -1,29 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - - compileOnly(libs.nms12) -} diff --git a/SpigotCore/SpigotCore_12/src/de/steamwar/core/LocaleChangeWrapper12.java b/SpigotCore/SpigotCore_12/src/de/steamwar/core/LocaleChangeWrapper12.java deleted file mode 100644 index 718369d4..00000000 --- a/SpigotCore/SpigotCore_12/src/de/steamwar/core/LocaleChangeWrapper12.java +++ /dev/null @@ -1,34 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.sql.SteamwarUser; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerLocaleChangeEvent; - -import java.util.Locale; - -public class LocaleChangeWrapper12 implements LocaleChangeWrapper { - - @EventHandler - private void onLocale(PlayerLocaleChangeEvent event) { - SteamwarUser.get(event.getPlayer().getUniqueId()).setLocale(Locale.forLanguageTag(event.getLocale()), false); - } -} diff --git a/SpigotCore/SpigotCore_14/build.gradle.kts b/SpigotCore/SpigotCore_14/build.gradle.kts deleted file mode 100644 index e4746ba5..00000000 --- a/SpigotCore/SpigotCore_14/build.gradle.kts +++ /dev/null @@ -1,32 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - compileOnly(project(":SpigotCore:SpigotCore_8", "default")) - compileOnly(project(":SpigotCore:SpigotCore_9", "default")) - - compileOnly(libs.nms14) - compileOnly(libs.worldedit15) -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java deleted file mode 100644 index f751cf41..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ /dev/null @@ -1,361 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.World; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper { - - private static final Map renamedLegacy = new HashMap<>(); - - static{ - renamedLegacy.put("WOOD", Material.OAK_WOOD); - renamedLegacy.put("SAPLING", Material.OAK_SAPLING); - renamedLegacy.put("STATIONARY_WATER", Material.WATER); - renamedLegacy.put("STATIONARY_LAVA", Material.LAVA); - renamedLegacy.put("LOG", Material.OAK_LOG); - renamedLegacy.put("LEAVES", Material.OAK_LEAVES); - renamedLegacy.put("BED_BLOCK", Material.RED_BED); - renamedLegacy.put("BED", Material.RED_BED); - renamedLegacy.put("PISTON_STICKY_BASE", Material.STICKY_PISTON); - renamedLegacy.put("WEB", Material.COBWEB); - renamedLegacy.put("LONG_GRASS", Material.TALL_GRASS); - renamedLegacy.put("PISTON_BASE", Material.PISTON); - renamedLegacy.put("PISTON_EXTENSION", Material.PISTON_HEAD); - renamedLegacy.put("WOOL", Material.WHITE_WOOL); - renamedLegacy.put("PISTON_MOVING_PIECE", Material.MOVING_PISTON); - renamedLegacy.put("YELLOW_FLOWER", Material.DANDELION); - renamedLegacy.put("RED_ROSE", Material.POPPY); - renamedLegacy.put("DOUBLE_STEP", Material.SMOOTH_STONE); - renamedLegacy.put("STEP", Material.SMOOTH_STONE_SLAB); - renamedLegacy.put("MOB_SPAWNER", Material.SPAWNER); - renamedLegacy.put("WOOD_STAIRS", Material.OAK_STAIRS); - renamedLegacy.put("WORKBENCH", Material.CRAFTING_TABLE); - renamedLegacy.put("CROPS", Material.WHEAT_SEEDS); - renamedLegacy.put("SEEDS", Material.WHEAT_SEEDS); - renamedLegacy.put("SOIL", Material.FARMLAND); - renamedLegacy.put("BURNING_FURNACE", Material.FURNACE); - renamedLegacy.put("SIGN_POST", Material.OAK_SIGN); - renamedLegacy.put("SIGN", Material.OAK_SIGN); - renamedLegacy.put("WOODEN_DOOR", Material.OAK_DOOR); - renamedLegacy.put("WOOD_DOOR", Material.OAK_DOOR); - renamedLegacy.put("RAILS", Material.RAIL); - renamedLegacy.put("WALL_SIGN", Material.OAK_WALL_SIGN); - renamedLegacy.put("STONE_PLATE", Material.STONE_PRESSURE_PLATE); - renamedLegacy.put("WOOD_PLATE", Material.OAK_PRESSURE_PLATE); - renamedLegacy.put("GLOWING_REDSTONE_ORE", Material.REDSTONE_ORE); - renamedLegacy.put("REDSTONE_TORCH_OFF", Material.REDSTONE_TORCH); - renamedLegacy.put("REDSTONE_TORCH_ON", Material.REDSTONE_TORCH); - renamedLegacy.put("IRON_DOOR_BLOCK", Material.IRON_DOOR); - renamedLegacy.put("SUGAR_CANE_BLOCK", Material.SUGAR_CANE); - renamedLegacy.put("CAKE_BLOCK", Material.CAKE); - renamedLegacy.put("MELON_BLOCK", Material.MELON); - renamedLegacy.put("BEETROOT_BLOCK", Material.BEETROOT); - renamedLegacy.put("FENCE", Material.OAK_FENCE); - renamedLegacy.put("PORTAL", Material.NETHER_PORTAL); - renamedLegacy.put("DIODE_BLOCK_OFF", Material.REPEATER); - renamedLegacy.put("DIODE_BLOCK_ON", Material.REPEATER); - renamedLegacy.put("DIODE", Material.REPEATER); - renamedLegacy.put("STAINED_GLASS", Material.WHITE_STAINED_GLASS); - renamedLegacy.put("TRAP_DOOR", Material.OAK_TRAPDOOR); - renamedLegacy.put("MONSTER_EGGS", Material.SKELETON_SPAWN_EGG); - renamedLegacy.put("MONSTER_EGG", Material.SKELETON_SPAWN_EGG); - renamedLegacy.put("SMOOTH_BRICK", Material.STONE_BRICKS); - renamedLegacy.put("HUGE_MUSHROOM_1", Material.MUSHROOM_STEM); - renamedLegacy.put("HUGE_MUSHROOM_2", Material.RED_MUSHROOM); - renamedLegacy.put("IRON_FENCE", Material.IRON_BARS); - renamedLegacy.put("THIN_GLASS", Material.GLASS_PANE); - renamedLegacy.put("FENCE_GATE", Material.OAK_FENCE_GATE); - renamedLegacy.put("SMOOTH_STAIRS", Material.STONE_BRICK_STAIRS); - renamedLegacy.put("MYCEL", Material.MYCELIUM); - renamedLegacy.put("WATER_LILY", Material.LILY_PAD); - renamedLegacy.put("NETHER_FENCE", Material.NETHER_BRICK_FENCE); - renamedLegacy.put("NETHER_WARTS", Material.NETHER_WART); - renamedLegacy.put("NETHER_STALK", Material.NETHER_WART); - renamedLegacy.put("ENCHANTMENT_TABLE", Material.ENCHANTING_TABLE); - renamedLegacy.put("ENDER_PORTAL", Material.END_PORTAL); - renamedLegacy.put("ENDER_PORTAL_FRAME", Material.END_PORTAL_FRAME); - renamedLegacy.put("ENDER_STONE", Material.END_STONE); - renamedLegacy.put("REDSTONE_LAMP_OFF", Material.REDSTONE_LAMP); - renamedLegacy.put("REDSTONE_LAMP_ON", Material.REDSTONE_LAMP); - renamedLegacy.put("WOOD_DOUBLE_STEP", Material.OAK_SLAB); - renamedLegacy.put("WOOD_STEP", Material.OAK_SLAB); - renamedLegacy.put("SPRUCE_WOOD_STAIRS", Material.SPRUCE_STAIRS); - renamedLegacy.put("BIRCH_WOOD_STAIRS", Material.BIRCH_STAIRS); - renamedLegacy.put("JUNGLE_WOOD_STAIRS", Material.JUNGLE_STAIRS); - renamedLegacy.put("COMMAND", Material.COMMAND_BLOCK); - renamedLegacy.put("COBBLE_WALL", Material.COBBLESTONE_WALL); - renamedLegacy.put("WOOD_BUTTON", Material.OAK_BUTTON); - renamedLegacy.put("SKULL", Material.SKELETON_SKULL); - renamedLegacy.put("SKULL_ITEM", Material.SKELETON_SKULL); - renamedLegacy.put("GOLD_PLATE", Material.LIGHT_WEIGHTED_PRESSURE_PLATE); - renamedLegacy.put("IRON_PLATE", Material.HEAVY_WEIGHTED_PRESSURE_PLATE); - renamedLegacy.put("REDSTONE_COMPARATOR_OFF", Material.COMPARATOR); - renamedLegacy.put("REDSTONE_COMPARATOR_ON", Material.COMPARATOR); - renamedLegacy.put("REDSTONE_COMPARATOR", Material.COMPARATOR); - renamedLegacy.put("QUARTZ_ORE", Material.QUARTZ); - renamedLegacy.put("STAINED_CLAY", Material.WHITE_TERRACOTTA); - renamedLegacy.put("STAINED_GLASS_PANE", Material.WHITE_STAINED_GLASS_PANE); - renamedLegacy.put("LEAVES_2", Material.ACACIA_LEAVES); - renamedLegacy.put("LOG_2", Material.ACACIA_LOG); - renamedLegacy.put("CARPET", Material.WHITE_CARPET); - renamedLegacy.put("HARD_CLAY", Material.TERRACOTTA); - renamedLegacy.put("DOUBLE_PLANT", Material.SUNFLOWER); - renamedLegacy.put("STANDING_BANNER", Material.WHITE_BANNER); - renamedLegacy.put("BANNER", Material.WHITE_BANNER); - renamedLegacy.put("WALL_BANNER", Material.WHITE_WALL_BANNER); - renamedLegacy.put("DAYLIGHT_DETECTOR_INVERTED", Material.DAYLIGHT_DETECTOR); - renamedLegacy.put("DOUBLE_STONE_SLAB2", Material.RED_SANDSTONE_SLAB); - renamedLegacy.put("STONE_SLAB2", Material.RED_SANDSTONE_SLAB); - renamedLegacy.put("PURPUR_DOUBLE_SLAB", Material.PURPUR_SLAB); - renamedLegacy.put("END_BRICKS", Material.END_STONE_BRICKS); - renamedLegacy.put("COMMAND_REPEATING", Material.REPEATING_COMMAND_BLOCK); - renamedLegacy.put("COMMAND_CHAIN", Material.CHAIN_COMMAND_BLOCK); - renamedLegacy.put("MAGMA", Material.MAGMA_BLOCK); - renamedLegacy.put("RED_NETHER_BRICK", Material.RED_NETHER_BRICKS); - renamedLegacy.put("SILVER_SHULKER_BOX", Material.LIGHT_GRAY_SHULKER_BOX); - renamedLegacy.put("SILVER_GLAZED_TERRACOTTA", Material.LIGHT_GRAY_TERRACOTTA); - renamedLegacy.put("CONCRETE", Material.WHITE_CONCRETE); - renamedLegacy.put("CONCRETE_POWDER", Material.WHITE_CONCRETE_POWDER); - renamedLegacy.put("IRON_SPADE", Material.IRON_SHOVEL); - renamedLegacy.put("WOOD_SWORD", Material.WOODEN_SWORD); - renamedLegacy.put("WOOD_SPADE", Material.WOODEN_SHOVEL); - renamedLegacy.put("WOOD_PICKAXE", Material.WOODEN_PICKAXE); - renamedLegacy.put("WOOD_AXE", Material.WOODEN_AXE); - renamedLegacy.put("STONE_SPADE", Material.STONE_SHOVEL); - renamedLegacy.put("DIAMOND_SPADE", Material.DIAMOND_SHOVEL); - renamedLegacy.put("MUSHROOM_SOUP", Material.MUSHROOM_STEW); - renamedLegacy.put("GOLD_SWORD", Material.GOLDEN_SWORD); - renamedLegacy.put("GOLD_SPADE", Material.GOLDEN_SHOVEL); - renamedLegacy.put("GOLD_PICKAXE", Material.GOLDEN_PICKAXE); - renamedLegacy.put("GOLD_AXE", Material.GOLDEN_AXE); - renamedLegacy.put("SULPHUR", Material.GUNPOWDER); - renamedLegacy.put("WOOD_HOE", Material.WOODEN_HOE); - renamedLegacy.put("GOLD_HOE", Material.GOLDEN_HOE); - renamedLegacy.put("GOLD_HELMET", Material.GOLDEN_HELMET); - renamedLegacy.put("GOLD_CHESTPLATE", Material.GOLDEN_CHESTPLATE); - renamedLegacy.put("GOLD_LEGGINGS", Material.GOLDEN_LEGGINGS); - renamedLegacy.put("GOLD_BOOTS", Material.GOLDEN_BOOTS); - renamedLegacy.put("PORK", Material.PORKCHOP); - renamedLegacy.put("GRILLED_PORK", Material.COOKED_PORKCHOP); - renamedLegacy.put("SNOW_BALL", Material.SNOWBALL); - renamedLegacy.put("BOAT", Material.OAK_BOAT); - renamedLegacy.put("CLAY_BRICK", Material.BRICKS); - renamedLegacy.put("STORAGE_MINECART", Material.CHEST_MINECART); - renamedLegacy.put("POWERED_MINECART", Material.FURNACE_MINECART); - renamedLegacy.put("WATCH", Material.CLOCK); - renamedLegacy.put("RAW_FISH", Material.SALMON); - renamedLegacy.put("COOKED_FISH", Material.COOKED_SALMON); - renamedLegacy.put("INK_SACK", Material.INK_SAC); - renamedLegacy.put("RAW_BEEF", Material.BEEF); - renamedLegacy.put("RAW_CHICKEN", Material.CHICKEN); - renamedLegacy.put("EYE_OF_ENDER", Material.ENDER_EYE); - renamedLegacy.put("SPECKLED_MELON", Material.GLISTERING_MELON_SLICE); - renamedLegacy.put("EXP_BOTTLE", Material.EXPERIENCE_BOTTLE); - renamedLegacy.put("FIREBALL", Material.FIRE_CHARGE); - renamedLegacy.put("BOOK_AND_QUILL", Material.WRITABLE_BOOK); - renamedLegacy.put("FLOWER_POT_ITEM", Material.FLOWER_POT); - renamedLegacy.put("EMPTY_MAP", Material.MAP); - renamedLegacy.put("BREWING_STAND_ITEM", Material.BREWING_STAND); - renamedLegacy.put("CAULDRON_ITEM", Material.CAULDRON); - renamedLegacy.put("CARROT_ITEM", Material.CARROT); - renamedLegacy.put("POTATO_ITEM", Material.POTATO); - renamedLegacy.put("SPRUCE_DOOR_ITEM", Material.SPRUCE_DOOR); - renamedLegacy.put("BIRCH_DOOR_ITEM", Material.BIRCH_DOOR); - renamedLegacy.put("JUNGLE_DOOR_ITEM", Material.JUNGLE_DOOR); - renamedLegacy.put("ACACIA_DOOR_ITEM", Material.ACACIA_DOOR); - renamedLegacy.put("DARK_OAK_DOOR_ITEM", Material.DARK_OAK_DOOR); - renamedLegacy.put("CARROT_STICK", Material.CARROT_ON_A_STICK); - renamedLegacy.put("FIREWORK", Material.FIREWORK_ROCKET); - renamedLegacy.put("FIREWORK_CHARGE", Material.FIREWORK_STAR); - renamedLegacy.put("NETHER_BRICK_ITEM", Material.NETHER_BRICKS); - renamedLegacy.put("EXPLOSIVE_MINECART", Material.TNT_MINECART); - renamedLegacy.put("IRON_BARDING", Material.IRON_HORSE_ARMOR); - renamedLegacy.put("GOLD_BARDING", Material.GOLDEN_HORSE_ARMOR); - renamedLegacy.put("DIAMOND_BARDING", Material.DIAMOND_HORSE_ARMOR); - renamedLegacy.put("LEASH", Material.LEAD); - renamedLegacy.put("COMMAND_MINECART", Material.COMMAND_BLOCK_MINECART); - renamedLegacy.put("CHORUS_FRUIT_POPPED", Material.POPPED_CHORUS_FRUIT); - renamedLegacy.put("DRAGONS_BREATH", Material.DRAGON_BREATH); - renamedLegacy.put("BOAT_SPRUCE", Material.SPRUCE_BOAT); - renamedLegacy.put("BOAT_BIRCH", Material.BIRCH_BOAT); - renamedLegacy.put("BOAT_JUNGLE", Material.JUNGLE_BOAT); - renamedLegacy.put("BOAT_ACACIA", Material.ACACIA_BOAT); - renamedLegacy.put("BOAT_DARK_OAK", Material.DARK_OAK_BOAT); - renamedLegacy.put("TOTEM", Material.TOTEM_OF_UNDYING); - renamedLegacy.put("GOLD_RECORD", Material.MUSIC_DISC_13); - renamedLegacy.put("GREEN_RECORD", Material.MUSIC_DISC_CAT); - renamedLegacy.put("RECORD_3", Material.MUSIC_DISC_BLOCKS); - renamedLegacy.put("RECORD_4", Material.MUSIC_DISC_CHIRP); - renamedLegacy.put("RECORD_5", Material.MUSIC_DISC_FAR); - renamedLegacy.put("RECORD_6", Material.MUSIC_DISC_MALL); - renamedLegacy.put("RECORD_7", Material.MUSIC_DISC_MELLOHI); - renamedLegacy.put("RECORD_8", Material.MUSIC_DISC_STAL); - renamedLegacy.put("RECORD_9", Material.MUSIC_DISC_STRAD); - renamedLegacy.put("RECORD_10", Material.MUSIC_DISC_WARD); - renamedLegacy.put("RECORD_11", Material.MUSIC_DISC_11); - renamedLegacy.put("RECORD_12", Material.MUSIC_DISC_WAIT); - } - - private static final Reflection.Field scoreboardName = Reflection.getField(FlatteningWrapper.scoreboardObjective, Reflection.getClass("net.minecraft.network.chat.Component"), 0); - @Override - public void setScoreboardTitle(Object packet, String title) { - scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); - } - - private static final Class scoreActionEnum = Core.getVersion() < 21 ? Reflection.getClass("net.minecraft.server.ServerScoreboard$Method") : null; - private static final Reflection.Field scoreAction = Core.getVersion() < 21 ? Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0) : null; - private static final Object scoreActionChange = Core.getVersion() < 21 ? scoreActionEnum.getEnumConstants()[0] : null; - - @Override - public void setScoreAction(Object packet) { - scoreAction.set(packet, scoreActionChange); - } - - @Override - public Material getMaterial(String material) { - try{ - return Material.valueOf(material); - }catch(IllegalArgumentException e){ - return renamedLegacy.get(material); - } - } - - @Override - public Material getDye(int colorCode) { - switch(colorCode){ - case 1: - return Material.RED_DYE; - case 2: - return Material.GREEN_DYE; - case 3: - return Material.BROWN_DYE; - case 4: - return Material.LAPIS_LAZULI; - case 5: - return Material.PURPLE_DYE; - case 6: - return Material.CYAN_DYE; - case 7: - return Material.LIGHT_GRAY_DYE; - case 8: - return Material.GRAY_DYE; - case 9: - return Material.PINK_DYE; - case 10: - return Material.LIME_DYE; - case 11: - return Material.YELLOW_DYE; - case 12: - return Material.LIGHT_BLUE_DYE; - case 13: - return Material.MAGENTA_DYE; - case 14: - return Material.ORANGE_DYE; - case 15: - return Material.WHITE_DYE; - default: - return Material.BLACK_DYE; - } - } - - @SuppressWarnings("deprecation") - @Override - public ItemStack setSkullOwner(String player) { - ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); - SkullMeta headmeta = (SkullMeta) head.getItemMeta(); - assert headmeta != null; - headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player)); - headmeta.setDisplayName(player); - head.setItemMeta(headmeta); - return head; - } - - protected static final Class entityPose = Reflection.getClass("net.minecraft.world.entity.Pose"); - protected static final Object standing = entityPose.getEnumConstants()[0]; - protected static final Object swimming = entityPose.getEnumConstants()[3]; - protected static final Object sneaking = entityPose.getEnumConstants()[5]; - @Override - public Object getPose(FlatteningWrapper.EntityPose pose) { - switch (pose) { - case SNEAKING: - return sneaking; - case SWIMMING: - return swimming; - case NORMAL: - default: - return standing; - } - } - - @Override - public void setNamedSpawnPacketDataWatcher(Object packet) { - // field not present - } - - @Override - public Object formatDisplayName(String displayName) { - return displayName != null ? Optional.of(ChatWrapper.impl.stringToChatComponent(displayName)) : Optional.empty(); - } - - private static final Class registryBlocks = Reflection.getClass("net.minecraft.core.DefaultedRegistry"); - private static final Class entityTypes = Reflection.getClass("net.minecraft.world.entity.EntityType"); - private static final Object entityTypesRegistry = Reflection.getField(Reflection.getClass(Core.getVersion() > 18 ? "net.minecraft.core.registries.BuiltInRegistries" : "net.minecraft.core.IRegistry"), registryBlocks, 0, entityTypes).get(null); - private static final Reflection.Method get = Reflection.getMethod(registryBlocks, null, Reflection.getClass("net.minecraft.resources.ResourceLocation")); - private static final Reflection.Field spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0); - private static final Reflection.Field spawnLivingType = Core.getVersion() > 18 ? spawnType : Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); - private static final Reflection.Method toMinecraft = Reflection.getMethod("org.bukkit.craftbukkit.util.CraftNamespacedKey", "toMinecraft", NamespacedKey.class); - private static final Map types = new HashMap<>(); - static { - types.put(EntityType.ARMOR_STAND, 1); - } - @Override - public void setSpawnPacketType(Object packet, EntityType type) { - if(type.isAlive()) { - spawnLivingType.set(packet, Core.getVersion() > 18 ? get.invoke(entityTypesRegistry, toMinecraft.invoke(null, type.getKey())) : types.get(type)); - } else { - spawnType.set(packet, get.invoke(entityTypesRegistry, toMinecraft.invoke(null, type.getKey()))); - } - } - - @Override - public int getViewDistance(Player player) { - return player.getClientViewDistance(); - } - - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftWorld", "getHandle"); - private static final Reflection.Method save = Reflection.getMethod("net.minecraft.server.level.ServerLevel", null, Reflection.getClass("net.minecraft.util.ProgressListener"), boolean.class, boolean.class); - @Override - public void syncSave(World world) { - save.invoke(getHandle.invoke(world), null, true, false); - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java deleted file mode 100644 index d9b4bf17..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/RecipeDiscoverWrapper14.java +++ /dev/null @@ -1,30 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerRecipeDiscoverEvent; - -public class RecipeDiscoverWrapper14 implements RecipeDiscoverWrapper { - @EventHandler - public void onRecipeDiscover(PlayerRecipeDiscoverEvent e) { - e.setCancelled(true); - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java deleted file mode 100644 index 6b337111..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java +++ /dev/null @@ -1,30 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.Material; - -public class TrickyTrialsWrapper14 extends TrickyTrialsWrapper8 { - - @Override - public Material getTurtleScute() { - return Material.SCUTE; - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java deleted file mode 100644 index b0f0238e..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ /dev/null @@ -1,634 +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 . - */ - -package de.steamwar.core; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; -import com.sk89q.jnbt.*; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.*; -import com.sk89q.worldedit.extent.clipboard.io.legacycompat.*; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.DataFixer; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.LegacyMapper; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.NodeData; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.io.*; -import java.util.*; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; - -@SuppressWarnings("removal") -public class WorldEditWrapper14 implements WorldEditWrapper { - - @Override - public InputStream getPlayerClipboard(Player player) { - return WorldEditWrapper.getPlayerClipboard(player, (outputStream, clipboard, clipboardHolder) -> { - ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(outputStream); - writer.write(clipboard); - writer.close(); - }); - } - - @Override - public void setPlayerClipboard(Player player, Clipboard clipboard) { - Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player); - WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard)); - } - - @Override - public Clipboard getClipboard(NodeData data) throws IOException { - InputStream is = data.schemData(true); - return readClipboard(is, data.getNodeFormat()); - } - - @Override - public Clipboard getClipboard(InputStream inputStream) throws IOException { - return readClipboard(inputStream, getNativeFormat()); - } - - private Clipboard readClipboard(InputStream is, NodeData.SchematicFormat format) throws IOException { - switch (format) { - case SPONGE_V2: - case SPONGE_V3: - return new SpongeSchematicReader(new NBTInputStream(is), this).read(); - case MCEDIT: - return new MCEditSchematicReader(new NBTInputStream(is)).read(); - default: - throw new IOException("This schematic format is currently not supported"); - } - } - - @Override - public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { - return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ()); - } - - @Override - public Vector getMinimum(Region region) { - return new Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); - } - - @Override - public Vector getMaximum(Region region) { - return new Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); - } - - @Override - public Vector applyTransform(Vector vector, Transform transform) { - Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); - v = transform.apply(v); - return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ()); - } - - @Override - public NodeData.SchematicFormat getNativeFormat() { - return NodeData.SchematicFormat.SPONGE_V2; - } - - public Map applyDataFixer(DataFixer fixer, int dataVersion, Map values) { - return fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, new CompoundTag(values), dataVersion).getValue(); - } - - private static class MCEditSchematicReader extends NBTSchematicReader { - - private final NBTInputStream inputStream; - private final DataFixer fixer; - private boolean faweSchem = false; - private static final ImmutableList COMPATIBILITY_HANDLERS - = ImmutableList.of( - new SignCompatibilityHandler(), - new FlowerPotCompatibilityHandler(), - new NoteBlockCompatibilityHandler(), - new SkullBlockCompatibilityHandler() - ); - - /** - * Create a new instance. - * - * @param inputStream the input stream to read from - */ - MCEditSchematicReader(NBTInputStream inputStream) { - checkNotNull(inputStream); - this.inputStream = inputStream; - this.fixer = null; - } - - @Override - public Clipboard read() throws IOException { - // Schematic tag - NamedTag rootTag = inputStream.readNamedTag(); - if (!rootTag.getName().equals("Schematic")) { - throw new IOException("Tag 'Schematic' does not exist or is not first"); - } - CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); - - // Check - Map schematic = schematicTag.getValue(); - if (!schematic.containsKey("Blocks")) { - throw new IOException("Schematic file is missing a 'Blocks' tag"); - } - - // Check type of Schematic - String materials = requireTag(schematic, "Materials", StringTag.class).getValue(); - if (!materials.equals("Alpha")) { - throw new IOException("Schematic file is not an Alpha schematic"); - } - - // ==================================================================== - // Metadata - // ==================================================================== - - BlockVector3 origin; - Region region; - - // Get information - short width = requireTag(schematic, "Width", ShortTag.class).getValue(); - short height = requireTag(schematic, "Height", ShortTag.class).getValue(); - short length = requireTag(schematic, "Length", ShortTag.class).getValue(); - - int originX = 0; - int originY = 0; - int originZ = 0; - try { - originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue(); - originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue(); - originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue(); - BlockVector3 min = BlockVector3.at(originX, originY, originZ); - - int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue(); - int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue(); - int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue(); - BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ); - - origin = min.subtract(offset); - region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); - } catch (IOException ignored) { - origin = BlockVector3.ZERO; - region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); - } - - // ==================================================================== - // Blocks - // ==================================================================== - - // Get blocks - byte[] blockId = requireTag(schematic, "Blocks", ByteArrayTag.class).getValue(); - byte[] blockData = requireTag(schematic, "Data", ByteArrayTag.class).getValue(); - byte[] addId = new byte[0]; - short[] blocks = new short[blockId.length]; // Have to later combine IDs - - // We support 4096 block IDs using the same method as vanilla Minecraft, where - // the highest 4 bits are stored in a separate byte array. - if (schematic.containsKey("AddBlocks")) { - addId = requireTag(schematic, "AddBlocks", ByteArrayTag.class).getValue(); - } - - // Combine the AddBlocks data with the first 8-bit block ID - for (int index = 0; index < blockId.length; index++) { - if ((index >> 1) >= addId.length) { // No corresponding AddBlocks index - blocks[index] = (short) (blockId[index] & 0xFF); - } else { - if ((index & 1) == 0) { - blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF)); - } else { - blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF)); - } - } - } - - // Need to pull out tile entities - final ListTag tileEntityTag = getTag(schematic, "TileEntities", ListTag.class); - List tileEntities = tileEntityTag == null ? new ArrayList<>() : tileEntityTag.getValue(); - Map> tileEntitiesMap = new HashMap<>(); - Map blockStates = new HashMap<>(); - - for (Tag tag : tileEntities) { - if (!(tag instanceof CompoundTag)) continue; - CompoundTag t = (CompoundTag) tag; - int x = t.getInt("x"); - int y = t.getInt("y"); - int z = t.getInt("z"); - int index = y * width * length + z * width + x; - if(index < 0 || index >= blocks.length) - faweSchem = true; - } - - for (Tag tag : tileEntities) { - if (!(tag instanceof CompoundTag)) continue; - CompoundTag t = (CompoundTag) tag; - Map values = new HashMap<>(t.getValue()); - String id = t.getString("id"); - values.put("id", new StringTag(convertBlockEntityId(id))); - int x = t.getInt("x"); - int y = t.getInt("y"); - int z = t.getInt("z"); - if(faweSchem){ - x -= originX; - y -= originY; - z -= originZ; - } - - int index = y * width * length + z * width + x; - - try{ - BlockState block = getBlockState(blocks[index], blockData[index]); - BlockState newBlock = block; - if (newBlock != null) { - for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) { - if (handler.isAffectedBlock(newBlock)) { - newBlock = handler.updateNBT(block, values); - if (newBlock == null || values.isEmpty()) { - break; - } - } - } - } - if (values.isEmpty()) { - t = null; - } else { - t = new CompoundTag(values); - } - - if (fixer != null && t != null) { - t = fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, t, -1); - } - - BlockVector3 vec = BlockVector3.at(x, y, z); - if (t != null) { - tileEntitiesMap.put(vec, t.getValue()); - } - blockStates.put(vec, newBlock); - }catch(ArrayIndexOutOfBoundsException e){ - //ignored - } - } - - BlockArrayClipboard clipboard = new BlockArrayClipboard(region); - clipboard.setOrigin(origin); - - - for (int x = 0; x < width; ++x) { - for (int y = 0; y < height; ++y) { - for (int z = 0; z < length; ++z) { - int index = y * width * length + z * width + x; - BlockVector3 pt = BlockVector3.at(x, y, z); - BlockState state = blockStates.computeIfAbsent(pt, p -> getBlockState(blocks[index], blockData[index])); - - try { - if (state != null) { - if (tileEntitiesMap.containsKey(pt)) { - clipboard.setBlock(region.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))); - } else { - clipboard.setBlock(region.getMinimumPoint().add(pt), state); - } - } - } catch (WorldEditException ignored) { // BlockArrayClipboard won't throw this - } - } - } - } - - return clipboard; - } - - private String convertBlockEntityId(String id) { - switch (id) { - case "Cauldron": - return "brewing_stand"; - case "Control": - return "command_block"; - case "DLDetector": - return "daylight_detector"; - case "Trap": - return "dispenser"; - case "EnchantTable": - return "enchanting_table"; - case "EndGateway": - return "end_gateway"; - case "AirPortal": - return "end_portal"; - case "EnderChest": - return "ender_chest"; - case "FlowerPot": - return "flower_pot"; - case "RecordPlayer": - return "jukebox"; - case "MobSpawner": - return "mob_spawner"; - case "Music": - case "noteblock": - return "note_block"; - case "Structure": - return "structure_block"; - case "Chest": - return "chest"; - case "Sign": - return "sign"; - case "Banner": - return "banner"; - case "Beacon": - return "beacon"; - case "Comparator": - return "comparator"; - case "Dropper": - return "dropper"; - case "Furnace": - return "furnace"; - case "Hopper": - return "hopper"; - case "Skull": - return "skull"; - default: - return id; - } - } - - private BlockState getBlockState(int id, int data) { - return LegacyMapper.getInstance().getBlockFromLegacy(id, data); - } - - @Override - public void close() throws IOException { - inputStream.close(); - } - } - public static class SpongeSchematicReader extends NBTSchematicReader { - - private final NBTInputStream inputStream; - private DataFixer fixer = null; - private int schematicVersion = -1; - private int dataVersion = -1; - private boolean faweSchem = false; - private final WorldEditWrapper14 wrapper; - - /** - * Create a new instance. - * - * @param inputStream the input stream to read from - */ - public SpongeSchematicReader(NBTInputStream inputStream, WorldEditWrapper14 wrapper) { - checkNotNull(inputStream); - this.inputStream = inputStream; - this.wrapper = wrapper; - } - - @Override - public Clipboard read() throws IOException { - CompoundTag schematicTag = getBaseTag(); - Map schematic = schematicTag.getValue(); - - final Platform platform = WorldEdit.getInstance().getPlatformManager() - .queryCapability(Capability.WORLD_EDITING); - int liveDataVersion = platform.getDataVersion(); - - if (schematicVersion == 1) { - dataVersion = 1631; // this is a relatively safe assumption unless someone imports a schematic from 1.12, e.g. sponge 7.1- - fixer = platform.getDataFixer(); - return readVersion1(schematicTag); - } else if (schematicVersion == 2 || schematicVersion == 3) { - dataVersion = requireTag(schematic, "DataVersion", IntTag.class).getValue(); - if (dataVersion < liveDataVersion) { - fixer = platform.getDataFixer(); - } - - return readVersion1(schematicTag); - } - throw new IOException("This schematic version is currently not supported"); - } - - @Override - public OptionalInt getDataVersion() { - try { - CompoundTag schematicTag = getBaseTag(); - Map schematic = schematicTag.getValue(); - if (schematicVersion == 1) { - return OptionalInt.of(1631); - } else if (schematicVersion == 2) { - return OptionalInt.of(requireTag(schematic, "DataVersion", IntTag.class).getValue()); - } - return OptionalInt.empty(); - } catch (IOException e) { - return OptionalInt.empty(); - } - } - - private CompoundTag getBaseTag() throws IOException { - NamedTag rootTag = inputStream.readNamedTag(); - CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); - - // Check - Map schematic = schematicTag.getValue(); - - if (schematic.size() == 1) { - schematicTag = requireTag(schematic, "Schematic", CompoundTag.class); - schematic = schematicTag.getValue(); - } else if (!rootTag.getName().equals("Schematic")) { - throw new IOException("Tag 'Schematic' does not exist or is not first"); - } - - schematicVersion = requireTag(schematic, "Version", IntTag.class).getValue(); - return schematicTag; - } - - private BlockArrayClipboard readVersion1(CompoundTag schematicTag) throws IOException { - BlockVector3 origin; - Region region; - Map schematic = schematicTag.getValue(); - - int width = requireTag(schematic, "Width", ShortTag.class).getValue(); - int height = requireTag(schematic, "Height", ShortTag.class).getValue(); - int length = requireTag(schematic, "Length", ShortTag.class).getValue(); - - IntArrayTag offsetTag = getTag(schematic, "Offset", IntArrayTag.class); - int[] offsetParts; - if (offsetTag != null) { - offsetParts = offsetTag.getValue(); - if (offsetParts.length != 3) { - throw new IOException("Invalid offset specified in schematic."); - } - } else { - offsetParts = new int[] {0, 0, 0}; - } - - BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]); - - CompoundTag metadataTag = getTag(schematic, "Metadata", CompoundTag.class); - int offsetX = 0; - int offsetY = 0; - int offsetZ = 0; - if (metadataTag != null && metadataTag.containsKey("WEOffsetX")) { - // We appear to have WorldEdit Metadata - Map metadata = metadataTag.getValue(); - offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue(); - offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue(); - offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue(); - BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ); - origin = min.subtract(offset); - region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); - } else { - origin = min; - region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); - } - - Map blockContainer = null; - boolean v3Mode = false; - - if (schematicVersion == 3) { - blockContainer = requireTag(schematic, "Blocks", CompoundTag.class).getValue(); - v3Mode = true; - } - - Map paletteObject = requireTag(v3Mode ? blockContainer: schematic, "Palette", CompoundTag.class).getValue(); - - Map palette = new HashMap<>(); - - ParserContext parserContext = new ParserContext(); - parserContext.setRestricted(false); - parserContext.setTryLegacy(false); - parserContext.setPreferringWildcard(false); - - for (String palettePart : paletteObject.keySet()) { - int id = requireTag(paletteObject, palettePart, IntTag.class).getValue(); - if (fixer != null) { - palettePart = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, palettePart, dataVersion); - } - BlockState state; - try { - state = WorldEdit.getInstance().getBlockFactory().parseFromInput(palettePart, parserContext).toImmutableState(); - } catch (InputParseException e) { - state = BlockTypes.AIR.getDefaultState(); - } - palette.put(id, state); - } - - byte[] blocks = requireTag(v3Mode ? blockContainer: schematic, v3Mode ? "Data" : "BlockData", ByteArrayTag.class).getValue(); - - Map> tileEntitiesMap = new HashMap<>(); - ListTag tileEntities = getTag(v3Mode ? blockContainer: schematic, "BlockEntities", ListTag.class); - if (tileEntities == null) { - tileEntities = getTag(v3Mode ? blockContainer: schematic, "TileEntities", ListTag.class); - } - if (tileEntities != null) { - List> tileEntityTags = tileEntities.getValue().stream() - .map(tag -> (CompoundTag) tag) - .map(CompoundTag::getValue) - .collect(Collectors.toList()); - - for (Map tileEntity : tileEntityTags) { - int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); - if(pos[0] < 0 || pos[0] >= width || pos[1] < 0 || pos[1] >= height || pos[2] < 0 || pos[2] >= length) - faweSchem = true; - } - - for (Map tileEntity : tileEntityTags) { - int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); - final BlockVector3 pt = BlockVector3.at(pos[0], pos[1], pos[2]); - Map values = Maps.newHashMap(v3Mode ? requireTag(tileEntity, "Data", CompoundTag.class).getValue() : tileEntity); - if(faweSchem){ - values.put("x", new IntTag(pt.getBlockX() - offsetX)); - values.put("y", new IntTag(pt.getBlockY() - offsetY)); - values.put("z", new IntTag(pt.getBlockZ() - offsetZ)); - }else{ - values.putIfAbsent("x", new IntTag(pt.getBlockX())); - values.putIfAbsent("y", new IntTag(pt.getBlockY())); - values.putIfAbsent("z", new IntTag(pt.getBlockZ())); - } - values.putIfAbsent("id", values.get("Id")); - values.remove("Id"); - values.remove("Pos"); - if (fixer != null) { - tileEntity = wrapper.applyDataFixer(fixer, dataVersion, values); - } else { - tileEntity = values; - } - tileEntitiesMap.put(pt, tileEntity); - } - } - - BlockArrayClipboard clipboard = new BlockArrayClipboard(region); - clipboard.setOrigin(origin); - - int index = 0; - int i = 0; - int value; - int varintLength; - while (i < blocks.length) { - value = 0; - varintLength = 0; - - while (true) { - value |= (blocks[i] & 127) << (varintLength++ * 7); - if (varintLength > 5) { - throw new IOException("VarInt too big (probably corrupted data)"); - } - if ((blocks[i] & 128) != 128) { - i++; - break; - } - i++; - } - // index = (y * length * width) + (z * width) + x - int y = index / (width * length); - int z = (index % (width * length)) / width; - int x = (index % (width * length)) % width; - BlockState state = palette.get(value); - BlockVector3 pt = BlockVector3.at(x, y, z); - try { - if (tileEntitiesMap.containsKey(pt)) { - clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))); - } else { - clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state); - } - } catch (WorldEditException e) { - throw new IOException("Failed to load a block in the schematic"); - } - - index++; - } - - return clipboard; - } - - @Override - public void close() throws IOException { - inputStream.close(); - } - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java deleted file mode 100644 index 5b1a7b4c..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java +++ /dev/null @@ -1,73 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import com.google.common.collect.ImmutableList; -import org.bukkit.Material; - -import java.util.HashSet; -import java.util.Set; - -public class BlockIds14 implements BlockIds { - - private static final Class blockStateList = Reflection.getClass("net.minecraft.world.level.block.state.StateDefinition"); - private static final Class fluidTypeFlowing = Reflection.getClass("net.minecraft.world.level.material.FlowingFluid"); - private static final Class fluid = Reflection.getClass("net.minecraft.world.level.material.FluidState"); - - private static final Reflection.Method getBlockData = Reflection.getTypedMethod(TechHider.block, null, TechHider.iBlockData); - @Override - public int materialToId(Material material) { - return getCombinedId(getBlockData.invoke(getBlock(material))); - } - - private static final Reflection.Method getStates = Reflection.getTypedMethod(TechHider.block, null, blockStateList); - private static final Reflection.Method getStateList = Reflection.getTypedMethod(blockStateList, null, ImmutableList.class); - private static final Object water = Reflection.getTypedMethod(fluidTypeFlowing, null, fluid, boolean.class).invoke(Reflection.getField(Reflection.getClass("net.minecraft.world.level.material.Fluids"), fluidTypeFlowing, 1).get(null), false); - private static final Iterable registryBlockId = (Iterable) Reflection.getField(TechHider.block, Reflection.getClass("net.minecraft.core.IdMapper"), 0).get(null); - private static final Reflection.Method getFluid = Reflection.getTypedMethod(TechHider.iBlockData, null, fluid); - @Override - public Set materialToAllIds(Material material) { - Set ids = new HashSet<>(); - for(Object data : (ImmutableList) getStateList.invoke(getStates.invoke(getBlock(material)))) { - ids.add(getCombinedId(data)); - } - - if(material == Material.WATER) { - for(Object data : registryBlockId) { - if(getFluid.invoke(data) == water) { - ids.add(getCombinedId(data)); - } - } - } - - return ids; - } - - private static final Reflection.Method getBlock = Reflection.getTypedMethod(TechHider.craftMagicNumbers, "getBlock", TechHider.block, Material.class); - private Object getBlock(Material material) { - return getBlock.invoke(null, material); - } - - @Override - public int getCombinedId(Object blockData) { - return (int) getCombinedId.invoke(null, blockData); - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java deleted file mode 100644 index eade69b0..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ChunkHider14.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.techhider; - -public class ChunkHider14 extends ChunkHider9 { - - @Override - protected void dataHider(SectionHider section) { - section.copyBlockCount(); - section.copyBitsPerBlock(); - - boolean hasPalette = section.getBitsPerBlock() < 9; - if(hasPalette) - section.processPalette(); - - if(section.isSkipSection()) { - section.skipDataArray(); - } else { - if(hasPalette && !section.blockPrecise()) { - section.skipDataArray(); - return; - } - - processDataArray(section); - } - } -} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java deleted file mode 100644 index c68b6937..00000000 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java +++ /dev/null @@ -1,55 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import org.bukkit.entity.Player; - -import java.util.function.BiFunction; -import java.util.function.UnaryOperator; - -public class ProtocolWrapper14 extends ProtocolWrapper8 { - - @Override - public BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider) { - UnaryOperator blockBreakCloner = ProtocolUtils.shallowCloneGenerator(blockBreakPacket); - Reflection.Field blockBreakPosition = Reflection.getField(blockBreakPacket, TechHider.blockPosition, 0); - Reflection.Field blockBreakBlockData = Reflection.getField(blockBreakPacket, TechHider.iBlockData, 0); - - return (p, packet) -> { - switch (techHider.getLocationEvaluator().checkBlockPos(p, blockBreakPosition.get(packet))) { - case SKIP: - return packet; - case CHECK: - if(!techHider.iBlockDataHidden(blockBreakBlockData.get(packet))) - return packet; - case HIDE: - packet = blockBreakCloner.apply(packet); - blockBreakBlockData.set(packet, techHider.getObfuscationTarget()); - return packet; - case HIDE_AIR: - default: - packet = blockBreakCloner.apply(packet); - blockBreakBlockData.set(packet, TechHider.AIR); - return packet; - } - }; - } -} diff --git a/SpigotCore/SpigotCore_15/build.gradle.kts b/SpigotCore/SpigotCore_15/build.gradle.kts deleted file mode 100644 index d112f426..00000000 --- a/SpigotCore/SpigotCore_15/build.gradle.kts +++ /dev/null @@ -1,28 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - - compileOnly(libs.nms15) -} diff --git a/SpigotCore/SpigotCore_18/build.gradle.kts b/SpigotCore/SpigotCore_18/build.gradle.kts deleted file mode 100644 index 7c445409..00000000 --- a/SpigotCore/SpigotCore_18/build.gradle.kts +++ /dev/null @@ -1,40 +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 . - */ - -plugins { - steamwar.java -} - -tasks.compileJava { - options.isWarnings = false -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - compileOnly(project(":SpigotCore:SpigotCore_14", "default")) - - compileOnly(libs.spigotapi) - compileOnly(libs.nms18) - compileOnly(libs.fawe18) - - compileOnly(libs.datafixer) - compileOnly(libs.netty) - compileOnly(libs.authlib) -} diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java deleted file mode 100644 index 9e7c1785..00000000 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java +++ /dev/null @@ -1,40 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import net.minecraft.world.level.lighting.LightEngine; -import org.bukkit.entity.Player; - -public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle"); - private static final Reflection.Method getLightEngine = Reflection.getTypedMethod(World.class, null, LightEngine.class); - - @Override - public void sendChunk(Player p, int chunkX, int chunkZ) { - Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ)); - TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LightEngine) getLightEngine.invoke(chunk.q), null, null, false, true)); - } -} diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java deleted file mode 100644 index 544237ce..00000000 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java +++ /dev/null @@ -1,61 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.mojang.authlib.GameProfile; -import com.mojang.datafixers.util.Pair; -import org.bukkit.GameMode; - -import java.util.Collections; -import java.util.EnumMap; -import java.util.List; - -public class ProtocolWrapper18 implements ProtocolWrapper { - - private static final Reflection.Field equipmentStack = Reflection.getField(equipmentPacket, List.class, 0); - @Override - public void setEquipmentPacketStack(Object packet, Object slot, Object stack) { - equipmentStack.set(packet, Collections.singletonList(new Pair<>(slot, stack))); - } - - private static final Class playerInfoPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo"); - private static final Class playerInfoActionClass = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo$EnumPlayerInfoAction"); - private static final Reflection.Field playerInfoAction = Reflection.getField(playerInfoPacket, playerInfoActionClass, 0); - private static final Reflection.Field playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0); - private static final EnumMap actions = new EnumMap<>(PlayerInfoAction.class); - static { - Object[] nativeActions = playerInfoActionClass.getEnumConstants(); - actions.put(PlayerInfoAction.ADD, nativeActions[0]); - actions.put(PlayerInfoAction.GAMEMODE, nativeActions[1]); - actions.put(PlayerInfoAction.REMOVE, nativeActions[4]); - } - private static final Class iChatBaseComponent = Reflection.getClass("net.minecraft.network.chat.Component"); - private static final Reflection.Constructor playerInfoDataConstructor = Reflection.getConstructor("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo$PlayerInfoData", GameProfile.class, int.class, enumGamemode, iChatBaseComponent); - - @Override - @SuppressWarnings("deprecation") - public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) { - Object packet = Reflection.newInstance(playerInfoPacket); - playerInfoAction.set(packet, actions.get(action)); - playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(profile, 0, ProtocolWrapper.getGameModeById.invoke(null, mode.getValue()), null))); - return packet; - } -} diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java deleted file mode 100644 index 111265cc..00000000 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java +++ /dev/null @@ -1,36 +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 . - */ - -package de.steamwar.core; - -import com.sk89q.jnbt.AdventureNBTConverter; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.world.DataFixer; - -import java.util.Map; - -public class WorldEditWrapper18 extends WorldEditWrapper14 { - - @Override - @SuppressWarnings("removal") - public Map applyDataFixer(DataFixer fixer, int dataVersion, Map values) { - return ((CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, new CompoundTag(values).asBinaryTag(), dataVersion))).getValue(); - } -} diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java deleted file mode 100644 index 3033feac..00000000 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java +++ /dev/null @@ -1,152 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import de.steamwar.core.Core; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import net.minecraft.core.IRegistry; -import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; -import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.util.SimpleBitStorage; -import net.minecraft.world.level.block.entity.TileEntityTypes; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Set; -import java.util.function.BiFunction; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; - -public class ChunkHider18 implements ChunkHider { - @Override - public Class mapChunkPacket() { - return ClientboundLevelChunkWithLightPacket.class; - } - - private static final UnaryOperator chunkPacketCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); - private static final UnaryOperator chunkDataCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); - - private static final Reflection.Field chunkXField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 0); - private static final Reflection.Field chunkZField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 1); - private static final Reflection.Field chunkData = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkPacketData.class, 0); - - private static final Reflection.Field dataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0); - private static final Reflection.Field tileEntities = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0); - - @Override - public BiFunction chunkHiderGenerator(TechHider techHider) { - return (p, packet) -> { - int chunkX = chunkXField.get(packet); - int chunkZ = chunkZField.get(packet); - if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) - return packet; - - packet = chunkPacketCloner.apply(packet); - Object dataWrapper = chunkDataCloner.apply(chunkData.get(packet)); - - Set hiddenBlockEntities = techHider.getHiddenBlockEntities(); - tileEntities.set(dataWrapper, ((List)tileEntities.get(dataWrapper)).stream().filter(te -> tileEntityVisible(hiddenBlockEntities, te)).collect(Collectors.toList())); - - ByteBuf in = Unpooled.wrappedBuffer(dataField.get(dataWrapper)); - ByteBuf out = Unpooled.buffer(in.readableBytes() + 64); - for(int yOffset = p.getWorld().getMinHeight(); yOffset < p.getWorld().getMaxHeight(); yOffset += 16) { - SectionHider section = new SectionHider(p, techHider, in, out, chunkX, yOffset/16, chunkZ); - - section.copyBlockCount(); - blocks(section); - biomes(section); - } - out.writeBytes(in); // MC appends a 0 byte at the end if there is a full chunk, idk why - - byte[] data = new byte[out.readableBytes()]; - out.readBytes(data); - dataField.set(dataWrapper, data); - - chunkData.set(packet, dataWrapper); - return packet; - }; - } - - public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); - protected static final Reflection.Field entityType = Reflection.getField(tileEntity, TileEntityTypes.class, 0); - private static final IRegistry tileEntityTypes = Reflection.getField(Core.getVersion() > 18 ? Reflection.getClass("net.minecraft.core.registries.BuiltInRegistries") : IRegistry.class, IRegistry.class, 0, TileEntityTypes.class).get(null); - private static final Reflection.Method getKey = Reflection.getTypedMethod(IRegistry.class, null, MinecraftKey.class, Object.class); - private static final Reflection.Method getName = Reflection.getTypedMethod(MinecraftKey.class, null, String.class); - protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) { - return !hiddenBlockEntities.contains((String) getName.invoke(getKey.invoke(tileEntityTypes, entityType.get(tile)))); - } - - private void blocks(SectionHider section) { - section.copyBitsPerBlock(); - - boolean singletonPalette = section.getBitsPerBlock() == 0; - if(singletonPalette) { - int value = ProtocolUtils.readVarInt(section.getIn()); - ProtocolUtils.writeVarInt(section.getOut(), !section.isSkipSection() && section.getObfuscate().contains(value) ? section.getTarget() : value); - }else if(section.getBitsPerBlock() < 15) { - section.processPalette(); - } - - if(section.isSkipSection() || singletonPalette || (!section.blockPrecise() && section.isPaletted())) { - section.skipDataArray(); - return; - } - - SimpleBitStorage values = new SimpleBitStorage(section.getBitsPerBlock(), 4096, section.readDataArray()); - - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - for (int x = 0; x < 16; x++) { - int pos = (((y * 16) + z) * 16) + x; - - switch (section.test(x, y, z)) { - case SKIP: - break; - case CHECK: - if(!section.getObfuscate().contains(values.a(pos))) - break; - case HIDE: - values.b(pos, section.getTarget()); - break; - case HIDE_AIR: - default: - values.b(pos, section.getAir()); - } - } - } - } - - section.writeDataArray(values.a()); - } - - private void biomes(SectionHider section) { - section.copyBitsPerBlock(); - boolean singletonPalette = section.getBitsPerBlock() == 0; - if(singletonPalette) - section.copyVarInt(); - else if(section.getBitsPerBlock() < 6) - section.skipPalette(); - - section.skipDataArray(); - } -} diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java deleted file mode 100644 index 54f41d90..00000000 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java +++ /dev/null @@ -1,109 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import net.minecraft.core.SectionPosition; -import net.minecraft.network.protocol.game.PacketPlayOutBlockBreak; -import net.minecraft.world.level.block.entity.TileEntitySign; -import net.minecraft.world.level.block.entity.TileEntityTypes; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.function.BiFunction; - -public class ProtocolWrapper18 implements ProtocolWrapper { - - private static final Reflection.Field multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, SectionPosition.class, 0); - private static final Reflection.Field multiBlockChangePos = Reflection.getField(TechHider.multiBlockChangePacket, short[].class, 0); - private static final Reflection.Field multiBlockChangeBlocks = Reflection.getField(TechHider.multiBlockChangePacket, IBlockData[].class, 0); - @Override - public BiFunction multiBlockChangeGenerator(TechHider techHider) { - return (p, packet) -> { - TechHider.LocationEvaluator locationEvaluator = techHider.getLocationEvaluator(); - Object chunkCoords = multiBlockChangeChunk.get(packet); - int chunkX = TechHider.blockPositionX.get(chunkCoords); - int chunkY = TechHider.blockPositionY.get(chunkCoords); - int chunkZ = TechHider.blockPositionZ.get(chunkCoords); - if(locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ)) - return packet; - - packet = TechHider.multiBlockChangeCloner.apply(packet); - final short[] oldPos = multiBlockChangePos.get(packet); - final IBlockData[] oldBlocks = multiBlockChangeBlocks.get(packet); - ArrayList poss = new ArrayList<>(oldPos.length); - ArrayList blocks = new ArrayList<>(oldPos.length); - for(int i = 0; i < oldPos.length; i++) { - short pos = oldPos[i]; - IBlockData block = oldBlocks[i]; - switch(locationEvaluator.check(p, 16*chunkX + (pos >> 8 & 0xF), 16*chunkY + (pos & 0xF), 16*chunkZ + (pos >> 4 & 0xF))) { - case SKIP: - poss.add(pos); - blocks.add(block); - break; - case CHECK: - poss.add(pos); - blocks.add(techHider.iBlockDataHidden(block) ? (IBlockData) techHider.getObfuscationTarget() : block); - break; - default: - break; - } - } - - if(blocks.isEmpty()) - return null; - - short[] newPos = new short[poss.size()]; - for(int i = 0; i < newPos.length; i++) - newPos[i] = poss.get(i); - - multiBlockChangePos.set(packet, newPos); - multiBlockChangeBlocks.set(packet, blocks.toArray(new IBlockData[0])); - return packet; - }; - } - - private static final Reflection.Field tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, TileEntityTypes.class, 0); - private static final TileEntityTypes signType = Reflection.getField(TileEntityTypes.class, TileEntityTypes.class, 0, TileEntitySign.class).get(null); - @Override - public boolean unfilteredTileEntityDataAction(Object packet) { - return tileEntityType.get(packet) != signType; - } - - @Override - public BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider) { - return (p, packet) -> { - PacketPlayOutBlockBreak breakPacket = (PacketPlayOutBlockBreak) packet; - switch (techHider.getLocationEvaluator().checkBlockPos(p, breakPacket.b())) { - case SKIP: - return packet; - case CHECK: - if(!techHider.iBlockDataHidden(breakPacket.c())) - return packet; - case HIDE: - return new PacketPlayOutBlockBreak(breakPacket.b(), (IBlockData) techHider.getObfuscationTarget(), breakPacket.d(), breakPacket.a()); - case HIDE_AIR: - default: - return new PacketPlayOutBlockBreak(breakPacket.b(), (IBlockData) TechHider.AIR, breakPacket.d(), breakPacket.a()); - } - }; - } -} diff --git a/SpigotCore/SpigotCore_19/build.gradle.kts b/SpigotCore/SpigotCore_19/build.gradle.kts deleted file mode 100644 index 13a4ee47..00000000 --- a/SpigotCore/SpigotCore_19/build.gradle.kts +++ /dev/null @@ -1,37 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - compileOnly(project(":SpigotCore:SpigotCore_14", "default")) - compileOnly(project(":SpigotCore:SpigotCore_18", "default")) - - compileOnly(libs.worldedit15) - compileOnly(libs.nms19) - - compileOnly(libs.spigotapi) - compileOnly(libs.brigadier) - compileOnly(libs.datafixer) - compileOnly(libs.authlib) -} diff --git a/SpigotCore/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java b/SpigotCore/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java deleted file mode 100644 index 79c98420..00000000 --- a/SpigotCore/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java +++ /dev/null @@ -1,45 +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 . - */ - -package de.steamwar.core; - -import net.minecraft.network.chat.IChatMutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.syncher.DataWatcher; - -import java.util.ArrayList; - -public class ChatWrapper19 implements ChatWrapper { - - @Override - public Object stringToChatComponent(String text) { - return IChatMutableComponent.a(new LiteralContents(text)); - } - - @Override - public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) { - ArrayList> nativeWatchers = new ArrayList<>(1); - for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { - nativeWatchers.add(((DataWatcher.Item) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e()); - } - - return new PacketPlayOutEntityMetadata(entityId, nativeWatchers); - } -} diff --git a/SpigotCore/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java b/SpigotCore/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java deleted file mode 100644 index ac378188..00000000 --- a/SpigotCore/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java +++ /dev/null @@ -1,64 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.mojang.authlib.GameProfile; -import com.mojang.datafixers.util.Pair; -import net.minecraft.SystemUtils; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; -import net.minecraft.world.level.EnumGamemode; -import org.bukkit.GameMode; - -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; -import java.util.function.LongSupplier; - -public class ProtocolWrapper19 implements ProtocolWrapper { - - private static final Reflection.Field equipmentStack = Reflection.getField(equipmentPacket, List.class, 0); - @Override - public void setEquipmentPacketStack(Object packet, Object slot, Object stack) { - equipmentStack.set(packet, Collections.singletonList(new Pair<>(slot, stack))); - } - - private static final Reflection.Constructor removePacketConstructor = Reflection.getConstructor(ClientboundPlayerInfoRemovePacket.class, List.class); - private static final Reflection.Field updateActions = Reflection.getField(ClientboundPlayerInfoUpdatePacket.class, EnumSet.class, 0); - private static final Reflection.Field updatePlayers = Reflection.getField(ClientboundPlayerInfoUpdatePacket.class, List.class, 0); - - @Override - @SuppressWarnings("deprecation") - public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) { - if(action == PlayerInfoAction.REMOVE) - return removePacketConstructor.invoke(Collections.singletonList(profile.getId())); - - Object packet = Reflection.newInstance(ClientboundPlayerInfoUpdatePacket.class); - updateActions.set(packet, action == PlayerInfoAction.ADD ? EnumSet.of(ClientboundPlayerInfoUpdatePacket.a.a, ClientboundPlayerInfoUpdatePacket.a.c) : EnumSet.of(ClientboundPlayerInfoUpdatePacket.a.c)); - updatePlayers.set(packet, Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.b(profile.getId(), profile, false, 0, EnumGamemode.a(mode.getValue()), null, null))); - return packet; - } - - @Override - public void initTPSWarp(LongSupplier longSupplier) { - SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong(); - } -} diff --git a/SpigotCore/SpigotCore_19/src/de/steamwar/core/WorldIdentifier19.java b/SpigotCore/SpigotCore_19/src/de/steamwar/core/WorldIdentifier19.java deleted file mode 100644 index 74a2dc14..00000000 --- a/SpigotCore/SpigotCore_19/src/de/steamwar/core/WorldIdentifier19.java +++ /dev/null @@ -1,68 +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 . - */ - -package de.steamwar.core; - -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.PacketPlayOutLogin; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.World; - -public class WorldIdentifier19 implements WorldIdentifier.IWorldIdentifier { - - private static ResourceKey resourceKey = null; - - private static final Class resourceKeyClass = Reflection.getClass("net.minecraft.resources.ResourceKey"); - private static final Class minecraftKeyClass = Reflection.getClass("net.minecraft.resources.MinecraftKey"); - private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass); - private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class); - - @Override - public void setResourceKey(String name) { - resourceKey = (ResourceKey) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name)); - } - - public WorldIdentifier19() { - TinyProtocol.instance.addFilter(PacketPlayOutLogin.class, (player, o) -> { - if (resourceKey == null) return o; - PacketPlayOutLogin packet = (PacketPlayOutLogin) o; - - return new PacketPlayOutLogin( - packet.b(), - packet.c(), - packet.d(), - packet.e(), - packet.f(), - packet.g(), - packet.h(), - resourceKey, - packet.j(), - packet.k(), - packet.l(), - packet.m(), - packet.n(), - packet.o(), - packet.p(), - packet.q(), - packet.r() - ); - }); - } -} diff --git a/SpigotCore/SpigotCore_19/src/de/steamwar/core/authlib/SteamwarGameProfileRepository19.java b/SpigotCore/SpigotCore_19/src/de/steamwar/core/authlib/SteamwarGameProfileRepository19.java deleted file mode 100644 index c0d90efa..00000000 --- a/SpigotCore/SpigotCore_19/src/de/steamwar/core/authlib/SteamwarGameProfileRepository19.java +++ /dev/null @@ -1,68 +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 . - */ - -package de.steamwar.core.authlib; - -import com.mojang.authlib.Agent; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.GameProfileRepository; -import com.mojang.authlib.ProfileLookupCallback; -import de.steamwar.Reflection; -import de.steamwar.sql.SteamwarUser; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.Services; - -import java.util.ArrayList; -import java.util.List; - -public class SteamwarGameProfileRepository19 extends SteamwarGameProfileRepository { - private static final GameProfileRepository fallback; - private static final Reflection.Field field; - private static final Services current; - - static { - Class clazz = MinecraftServer.getServer().getClass(); - field = Reflection.getField(clazz, Services.class, 0); - current = field.get(MinecraftServer.getServer()); - fallback = current.c(); - } - - @Override - public void inject() { - Services newServices = new Services(current.a(), current.b(), this, current.d(), current.paperConfigurations()); - field.set(MinecraftServer.getServer(), newServices); - } - - @Override - public void findProfilesByNames(String[] strings, Agent agent, ProfileLookupCallback profileLookupCallback) { - List unknownNames = new ArrayList<>(); - for (String name:strings) { - SteamwarUser user = SteamwarUser.get(name); - if(user == null) { - unknownNames.add(name); - continue; - } - - profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName())); - } - if(!unknownNames.isEmpty()) { - fallback.findProfilesByNames(unknownNames.toArray(new String[0]), agent, profileLookupCallback); - } - } -} diff --git a/SpigotCore/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java b/SpigotCore/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java deleted file mode 100644 index 2aded961..00000000 --- a/SpigotCore/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java +++ /dev/null @@ -1,32 +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 . - */ - -package de.steamwar.techhider; - -import org.bukkit.entity.Player; - -import java.util.function.BiFunction; - -public class ProtocolWrapper19 extends ProtocolWrapper18 { - - @Override - public BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider) { - return null; - } -} diff --git a/SpigotCore/SpigotCore_20/build.gradle.kts b/SpigotCore/SpigotCore_20/build.gradle.kts deleted file mode 100644 index 357feb75..00000000 --- a/SpigotCore/SpigotCore_20/build.gradle.kts +++ /dev/null @@ -1,31 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - - compileOnly(libs.spigotapi) - - compileOnly(libs.fawe18) - compileOnly(libs.nms20) -} diff --git a/SpigotCore/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java b/SpigotCore/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java deleted file mode 100644 index ca2e059e..00000000 --- a/SpigotCore/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java +++ /dev/null @@ -1,41 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.lighting.LevelLightEngine; -import org.bukkit.entity.Player; - -public class CraftbukkitWrapper20 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle", ChunkStatus.class); - private static final Reflection.Method getLightEngine = Reflection.getTypedMethod(World.class, null, LevelLightEngine.class); - - @Override - public void sendChunk(Player p, int chunkX, int chunkZ) { - Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n); - TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true)); - } -} diff --git a/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldEditRendererWrapper20.java b/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldEditRendererWrapper20.java deleted file mode 100644 index 3403415a..00000000 --- a/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldEditRendererWrapper20.java +++ /dev/null @@ -1,117 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.entity.CWireframe; -import de.steamwar.entity.REntityServer; -import org.bukkit.Material; -import org.bukkit.block.data.BlockData; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.HashMap; -import java.util.Map; - -public class WorldEditRendererWrapper20 implements WorldEditRendererWrapper { - - private static final class BoxPair { - private CWireframe regionBox; - private CWireframe clipboardBox; - - public CWireframe get(boolean clipboard) { - if (clipboard) { - return clipboardBox; - } else { - return regionBox; - } - } - - public void set(boolean clipboard, CWireframe box) { - if (clipboard) { - this.clipboardBox = box; - } else { - this.regionBox = box; - } - } - - public void die() { - if (clipboardBox != null) { - clipboardBox.die(); - } - if (regionBox != null) { - regionBox.die(); - } - } - } - - private static final Map servers = new HashMap<>(); - private static final Map boxes = new HashMap<>(); - - @Override - public void draw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2) { - REntityServer server = servers.computeIfAbsent(player, __ -> { - REntityServer entityServer = new REntityServer(); - entityServer.addPlayer(player); - return entityServer; - }); - - WorldEditRendererCUIEditor.Type type = clipboard ? WorldEditRendererCUIEditor.Type.CLIPBOARD : WorldEditRendererCUIEditor.Type.SELECTION; - float width = type.getWidth(player).value; - Material material = type.getMaterial(player); - if (material == Material.BARRIER) { - hide(player, clipboard, true); - return; - } - BlockData block = material.createBlockData(); - - BoxPair boxPair = boxes.computeIfAbsent(player, __ -> new BoxPair()); - CWireframe box = boxPair.get(clipboard); - if (box == null) { - box = new CWireframe(server); - boxPair.set(clipboard, box); - } - box.setPos1And2(pos1.toLocation(player.getWorld()), pos2.toLocation(player.getWorld())); - box.setWidth(width); - box.setBlock(block); - } - - @Override - public void tick(Player player) { - REntityServer server = servers.get(player); - if (server != null) server.tick(); - } - - @Override - public void hide(Player player, boolean clipboard, boolean hide) { - BoxPair boxPair = boxes.get(player); - if (boxPair == null) return; - CWireframe box = boxPair.get(clipboard); - if (box == null) return; - box.hide(hide); - } - - @Override - public void remove(Player player) { - BoxPair boxPair = boxes.remove(player); - if (boxPair != null) boxPair.die(); - REntityServer server = servers.remove(player); - if (server != null) server.close(); - } -} diff --git a/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldIdentifier20.java b/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldIdentifier20.java deleted file mode 100644 index 354d8710..00000000 --- a/SpigotCore/SpigotCore_20/src/de/steamwar/core/WorldIdentifier20.java +++ /dev/null @@ -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 . - */ - -package de.steamwar.core; - -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.PacketPlayOutLogin; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.World; - -public class WorldIdentifier20 implements WorldIdentifier.IWorldIdentifier { - - private static ResourceKey resourceKey = null; - - private static final Reflection.Field playerId = Reflection.getField(PacketPlayOutLogin.class, int.class, 0); - private static final Class resourceKeyClass = Reflection.getClass("net.minecraft.resources.ResourceKey"); - private static final Class minecraftKeyClass = Reflection.getClass("net.minecraft.resources.MinecraftKey"); - private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass); - private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class); - - @Override - public void setResourceKey(String name) { - resourceKey = (ResourceKey) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name)); - } - - public WorldIdentifier20() { - TinyProtocol.instance.addFilter(PacketPlayOutLogin.class, (player, o) -> { - if (resourceKey == null) return o; - PacketPlayOutLogin packet = (PacketPlayOutLogin) o; - - return new PacketPlayOutLogin( - playerId.get(packet), - packet.c(), - packet.d(), - packet.e(), - packet.f(), - packet.g(), - packet.h(), - resourceKey, - packet.j(), - packet.k(), - packet.l(), - packet.m(), - packet.n(), - packet.o(), - packet.p(), - packet.q(), - packet.r(), - packet.s() - ); - }); - } -} diff --git a/SpigotCore/SpigotCore_21/build.gradle.kts b/SpigotCore/SpigotCore_21/build.gradle.kts deleted file mode 100644 index a05a08fa..00000000 --- a/SpigotCore/SpigotCore_21/build.gradle.kts +++ /dev/null @@ -1,44 +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 . - */ - -plugins { - steamwar.java -} - -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - compileOnly(project(":SpigotCore:SpigotCore_18", "default")) - compileOnly(project(":SpigotCore:SpigotCore_14", "default")) - compileOnly(project(":SpigotCore:SpigotCore_9", "default")) - - compileOnly(libs.fawe21) - - compileOnly(libs.paperapi21) - compileOnly(libs.nms21) - compileOnly(libs.authlib2) - compileOnly(libs.datafixer) - compileOnly(libs.netty) - compileOnly(libs.authlib) -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java deleted file mode 100644 index c8b4c8b0..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java +++ /dev/null @@ -1,42 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import net.minecraft.world.entity.PositionMoveRotation; -import net.minecraft.world.phys.Vec3; - -public class BountifulWrapper21 extends BountifulWrapper9 { - - @Override - public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { - try { - Reflection.Field field = Reflection.getField(packetClass, PositionMoveRotation.class, 0); - - return (packet, x, y, z, pitch, yaw) -> { - PositionMoveRotation pos = field.get(packet); - - field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), pos.deltaMovement(), yaw, pitch)); - }; - } catch (IllegalArgumentException e) { - return super.getPositionSetter(packetClass, fieldOffset); - } - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java deleted file mode 100644 index b3570146..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.core; - -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.contents.PlainTextContents; -import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; -import net.minecraft.network.syncher.SynchedEntityData; - -import java.util.ArrayList; - -public class ChatWrapper21 implements ChatWrapper { - @Override - public Object stringToChatComponent(String text) { - return MutableComponent.create(PlainTextContents.create(text)); - } - - @Override - public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) { - ArrayList> nativeWatchers = new ArrayList<>(1); - for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { - nativeWatchers.add(((SynchedEntityData.DataItem) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).value()); - } - - return new ClientboundSetEntityDataPacket(entityId, nativeWatchers); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java deleted file mode 100644 index 033ab273..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java +++ /dev/null @@ -1,39 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.status.ChunkStatus; -import org.bukkit.craftbukkit.CraftChunk; -import org.bukkit.entity.Player; - -public class CraftbukkitWrapper21 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle", ChunkStatus.class); - - @Override - public void sendChunk(Player p, int chunkX, int chunkZ) { - LevelChunk chunk = (LevelChunk) ((CraftChunk) p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(ChunkStatus.FULL); - TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null, true)); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java deleted file mode 100644 index 1d791a90..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java +++ /dev/null @@ -1,53 +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 . - */ - -package de.steamwar.core; - -import com.destroystokyo.paper.profile.PlayerProfile; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -public class FlatteningWrapper21 extends FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper { - - @Override - public ItemStack setSkullOwner(String player) { - ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); - head.editMeta(SkullMeta.class, skullMeta -> { - try { - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player); - PlayerProfile playerProfile = offlinePlayer.getPlayerProfile(); - playerProfile.complete(); - skullMeta.setPlayerProfile(playerProfile); - } catch (Exception e) { - // Ignore - } - }); - return head; - } - - protected static final Object shooting = entityPose.getEnumConstants()[16]; - @Override - public Object getPose(FlatteningWrapper.EntityPose pose) { - if (pose == FlatteningWrapper.EntityPose.SHOOTING) return shooting; - return super.getPose(pose); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/ProtocolWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/ProtocolWrapper21.java deleted file mode 100644 index 32cf4618..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/ProtocolWrapper21.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.core; - -import com.mojang.authlib.GameProfile; -import com.mojang.datafixers.util.Pair; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; -import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.GameType; -import org.bukkit.GameMode; - -import java.util.Collections; -import java.util.EnumSet; - -public class ProtocolWrapper21 implements ProtocolWrapper { - @Override - public void setEquipmentPacketStack(Object packet, Object slot, Object stack) { - ClientboundSetEquipmentPacket setEquipmentPacket = (ClientboundSetEquipmentPacket) packet; - setEquipmentPacket.getSlots().add(Pair.of((EquipmentSlot) slot, (ItemStack) stack)); - } - - @Override - public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) { - if(action == PlayerInfoAction.REMOVE) - return new ClientboundPlayerInfoRemovePacket(Collections.singletonList(profile.getId())); - - return new ClientboundPlayerInfoUpdatePacket(action == PlayerInfoAction.ADD ? - EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE) : EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE), - Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry(profile.getId(), profile, false, 0, GameType.byId(mode.getValue()), null, false, 0, null))); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java deleted file mode 100644 index 4f3ca8f0..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java +++ /dev/null @@ -1,29 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.Particle; - -public class TrickyParticleWrapper21 implements TrickyParticleWrapper { - @Override - public Particle getVillagerHappy() { - return Particle.HAPPY_VILLAGER; - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java deleted file mode 100644 index 562c7058..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ /dev/null @@ -1,49 +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 . - */ - -package de.steamwar.core; - -import com.mojang.authlib.properties.Property; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; - -public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { - @Override - public EntityType getTntEntityType() { - return EntityType.TNT; - } - - @Override - public Enchantment getUnbreakingEnchantment() { - return Enchantment.UNBREAKING; - } - - @Override - public Material getTurtleScute() { - return Material.TURTLE_SCUTE; - } - - @Override - public String getValue(Property property) { - return property.value(); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java deleted file mode 100644 index b1e97156..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ /dev/null @@ -1,182 +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 . - */ - -package de.steamwar.core; - -import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2; -import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV3; -import com.sk89q.jnbt.NBTInputStream; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.*; -import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; -import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV2Reader; -import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV3Reader; -import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.session.ClipboardHolder; -import de.steamwar.sql.NodeData; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; -import org.enginehub.linbus.stream.LinBinaryIO; - -import java.io.DataInputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; - -public class WorldEditWrapper21 implements WorldEditWrapper { - - @Override - public InputStream getPlayerClipboard(Player player) { - return WorldEditWrapper.getPlayerClipboard(player, (outputStream, clipboard, clipboardHolder) -> { - ClipboardWriter writer = BuiltInClipboardFormat.FAST_V3.getWriter(outputStream); - writer.write(clipboard); - writer.close(); - }); - } - - @Override - public void setPlayerClipboard(Player player, Clipboard clipboard) { - Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player); - WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard)); - } - - @Override - public Clipboard getClipboard(NodeData data) throws IOException { - ResetableInputStream is = new ResetableInputStream(data.schemData(false)); - for (ClipboardFormat clipboardFormat : ClipboardFormats.getAll()) { - FilterInputStream fis = new FilterInputStream(is) { - @Override - public void close() throws IOException { - // Ignore close call! - } - }; - boolean canBeRead = clipboardFormat.isFormat(fis); - is.reset(); - if (!canBeRead) continue; - return clipboardFormat.load(is); - } - throw new IOException("No clipboard found"); - } - - private static final Function FastV3 = FastSchematicReaderV3::new; - @SuppressWarnings("removal") - private static final Function FastV2 = inputStream -> new FastSchematicReaderV2(new NBTInputStream(inputStream)); - @SuppressWarnings("removal") - private static final Function McEdit = inputStream -> new MCEditSchematicReader(new NBTInputStream(inputStream)); - private static final Function SpongeV3 = inputStream -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(inputStream))); - private static final Function SpongeV2 = inputStream -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(inputStream))); - private static final Function SpongeV1 = inputStream -> new SpongeSchematicV1Reader(LinBinaryIO.read(new DataInputStream(inputStream))); - - private static final Function[] READERS = new Function[]{ - FastV3, - FastV2, - SpongeV3, - SpongeV2, - SpongeV1, - McEdit - }; - - @Override - public Clipboard getClipboard(InputStream inputStream) throws IOException { - ResetableInputStream is = new ResetableInputStream(inputStream); - for (Function reader : READERS) { - FilterInputStream fis = new FilterInputStream(is) { - @Override - public void close() throws IOException { - // Ignore close call! - } - }; - try { - return reader.apply(fis).read(); - } catch (Exception e) { - is.reset(); - } - } - is.close(); - throw new IOException("No clipboard found"); - } - - private static class ResetableInputStream extends InputStream { - - private InputStream inputStream; - private int pointer = 0; - private List list = new ArrayList<>(); - - public ResetableInputStream(InputStream in) { - this.inputStream = in; - } - - @Override - public int read() throws IOException { - if (pointer >= list.size()) { - int data = inputStream.read(); - list.add(data); - pointer++; - return data; - } - int data = list.get(pointer); - pointer++; - return data; - } - - @Override - public void reset() throws IOException { - pointer = 0; - } - - @Override - public void close() throws IOException { - list.clear(); - pointer = -1; - } - } - - @Override - public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { - return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z()); - } - - @Override - public Vector getMinimum(Region region) { - return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z()); - } - - @Override - public Vector getMaximum(Region region) { - return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z()); - } - - @Override - public Vector applyTransform(Vector vector, Transform transform) { - Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); - v = transform.apply(v); - return new org.bukkit.util.Vector(v.x(), v.y(), v.z()); - } - - @Override - public NodeData.SchematicFormat getNativeFormat() { - return NodeData.SchematicFormat.SPONGE_V3; - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldIdentifier21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldIdentifier21.java deleted file mode 100644 index 8553124c..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldIdentifier21.java +++ /dev/null @@ -1,73 +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 . - */ - -package de.steamwar.core; - -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; -import net.minecraft.network.protocol.game.ClientboundLoginPacket; -import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; - -public class WorldIdentifier21 implements WorldIdentifier.IWorldIdentifier { - - private static ResourceKey resourceKey = null; - - private static final Class resourceKeyClass = Reflection.getClass("net.minecraft.resources.ResourceKey"); - private static final Class minecraftKeyClass = Reflection.getClass("net.minecraft.resources.MinecraftKey"); - private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass); - private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class); - - @Override - public void setResourceKey(String name) { - resourceKey = (ResourceKey) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name)); - } - - public WorldIdentifier21() { - TinyProtocol.instance.addFilter(ClientboundLoginPacket.class, (player, o) -> { - if (resourceKey == null) return o; - ClientboundLoginPacket packet = (ClientboundLoginPacket) o; - - return new ClientboundLoginPacket(packet.playerId(), - packet.hardcore(), - packet.levels(), - packet.maxPlayers(), - packet.chunkRadius(), - packet.simulationDistance(), - packet.reducedDebugInfo(), - packet.showDeathScreen(), - packet.doLimitedCrafting(), - new CommonPlayerSpawnInfo( - packet.commonPlayerSpawnInfo().dimensionType(), - resourceKey, - packet.commonPlayerSpawnInfo().seed(), - packet.commonPlayerSpawnInfo().gameType(), - packet.commonPlayerSpawnInfo().previousGameType(), - packet.commonPlayerSpawnInfo().isDebug(), - packet.commonPlayerSpawnInfo().isFlat(), - packet.commonPlayerSpawnInfo().lastDeathLocation(), - packet.commonPlayerSpawnInfo().portalCooldown(), - packet.commonPlayerSpawnInfo().seaLevel() - ), - packet.enforcesSecureChat() - ); - }); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/authlib/SteamwarGameProfileRepository21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/authlib/SteamwarGameProfileRepository21.java deleted file mode 100644 index 21df7d4c..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/authlib/SteamwarGameProfileRepository21.java +++ /dev/null @@ -1,73 +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 . - */ - -package de.steamwar.core.authlib; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.GameProfileRepository; -import com.mojang.authlib.ProfileLookupCallback; -import de.steamwar.Reflection; -import de.steamwar.sql.SteamwarUser; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.Services; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class SteamwarGameProfileRepository21 extends SteamwarGameProfileRepository { - private static final GameProfileRepository fallback; - private static final Reflection.Field field; - private static final Services current; - - static { - Class clazz = MinecraftServer.getServer().getClass(); - field = Reflection.getField(clazz, Services.class, 0); - current = field.get(MinecraftServer.getServer()); - fallback = current.profileRepository(); - } - - @Override - public void findProfilesByNames(String[] strings, ProfileLookupCallback profileLookupCallback) { - List unknownNames = new ArrayList<>(); - for (String name:strings) { - SteamwarUser user = SteamwarUser.get(name); - if(user == null) { - unknownNames.add(name); - continue; - } - - profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName())); - } - if(!unknownNames.isEmpty()) { - fallback.findProfilesByNames(unknownNames.toArray(new String[0]), profileLookupCallback); - } - } - - @Override - public Optional findProfileByName(String s) { - return fallback.findProfileByName(s); - } - - @Override - public void inject() { - Services newServices = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations()); - field.set(MinecraftServer.getServer(), newServices); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/entity/PacketConstructor21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/entity/PacketConstructor21.java deleted file mode 100644 index 80ad1bc3..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/entity/PacketConstructor21.java +++ /dev/null @@ -1,53 +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 . - */ - -package de.steamwar.entity; - -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.PositionMoveRotation; -import net.minecraft.world.phys.Vec3; - -import java.util.Collections; - -public class PacketConstructor21 implements PacketConstructor{ - @Override - public Object teleportPacket(int entityId, double x, double y, double z, float yaw, float pitch) { - PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch, yaw); - return new ClientboundTeleportEntityPacket(entityId, rot, Collections.emptySet(), false); - } - - @Override - public Object createRPlayerSpawn(RPlayer player) { - return new ClientboundAddEntityPacket( - player.entityId, - player.uuid, - player.x, - player.y, - player.z, - player.yaw, - player.pitch, - EntityType.PLAYER, - 0, - Vec3.ZERO, - player.headYaw - ); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/scoreboard/SWScoreboard21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/scoreboard/SWScoreboard21.java deleted file mode 100644 index cfb64049..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/scoreboard/SWScoreboard21.java +++ /dev/null @@ -1,74 +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 . - */ - -package de.steamwar.scoreboard; - -import de.steamwar.core.Core; -import net.kyori.adventure.text.Component; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; - -import java.util.HashMap; -import java.util.Map; - -public class SWScoreboard21 implements SWScoreboard { - - private static final HashMap playerBoards = new HashMap<>(); - private static final String SIDEBAR = "sw-sidebar"; - - static { - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { - for(Map.Entry scoreboard : playerBoards.entrySet()) { - render(scoreboard.getKey(), scoreboard.getValue()); - } - }, 10, 5); - } - - private static void render(Player player, ScoreboardCallback callback) { - if (player.getScoreboard().getObjective(SIDEBAR) != null) { - player.getScoreboard().getObjective(SIDEBAR).unregister(); - } - - Objective objective = player.getScoreboard().registerNewObjective(SIDEBAR, "dummy", Component.text(callback.getTitle())); - objective.setAutoUpdateDisplay(true); - objective.setDisplaySlot(DisplaySlot.SIDEBAR); - - callback.getData().forEach((text, score) -> objective.getScore(text).setScore(score)); - } - - @Override - public boolean createScoreboard(Player player, ScoreboardCallback callback) { - Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - player.setScoreboard(scoreboard); - - render(player, callback); - - playerBoards.put(player, callback); - return true; - } - - @Override - public void removeScoreboard(Player player) { - player.getScoreboard().getObjective(SIDEBAR).unregister(); - playerBoards.remove(player); - } -} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/techhider/ChunkHider21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/techhider/ChunkHider21.java deleted file mode 100644 index 1cc6c29c..00000000 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/techhider/ChunkHider21.java +++ /dev/null @@ -1,161 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; -import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; -import net.minecraft.util.SimpleBitStorage; -import net.minecraft.world.level.block.entity.BlockEntityType; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Set; -import java.util.function.BiFunction; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; - -public class ChunkHider21 implements ChunkHider { - @Override - public Class mapChunkPacket() { - return ClientboundLevelChunkWithLightPacket.class; - } - - private static final UnaryOperator chunkPacketCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); - private static final UnaryOperator chunkDataCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); - - private static final Reflection.Field chunkXField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 0); - private static final Reflection.Field chunkZField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 1); - private static final Reflection.Field chunkData = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkPacketData.class, 0); - - private static final Reflection.Field dataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0); - private static final Reflection.Field tileEntities = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0); - - @Override - public BiFunction chunkHiderGenerator(TechHider techHider) { - return (p, packet) -> { - int chunkX = chunkXField.get(packet); - int chunkZ = chunkZField.get(packet); - if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) - return packet; - - packet = chunkPacketCloner.apply(packet); - Object dataWrapper = chunkDataCloner.apply(chunkData.get(packet)); - - Set hiddenBlockEntities = techHider.getHiddenBlockEntities(); - tileEntities.set(dataWrapper, ((List)tileEntities.get(dataWrapper)).stream().filter(te -> tileEntityVisible(hiddenBlockEntities, te)).collect(Collectors.toList())); - - ByteBuf in = Unpooled.wrappedBuffer(dataField.get(dataWrapper)); - ByteBuf out = Unpooled.buffer(in.readableBytes() + 64); - for(int yOffset = p.getWorld().getMinHeight(); yOffset < p.getWorld().getMaxHeight(); yOffset += 16) { - SectionHider section = new SectionHider(p, techHider, in, out, chunkX, yOffset/16, chunkZ); - section.copyBlockCount(); - - blocks(section); - biomes(section); - } - - if (in.readableBytes() != 0) { - throw new IllegalStateException("ChunkHider21: Incomplete chunk data, " + in.readableBytes() + " bytes left"); - } - - byte[] data = new byte[out.readableBytes()]; - out.readBytes(data); - dataField.set(dataWrapper, data); - - chunkData.set(packet, dataWrapper); - return packet; - }; - } - - public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); - protected static final Reflection.Field entityType = Reflection.getField(tileEntity, BlockEntityType.class, 0); - private static final Class builtInRegestries = Reflection.getClass("net.minecraft.core.registries.BuiltInRegistries"); - private static final Class registry = Reflection.getClass("net.minecraft.core.Registry"); - private static final Reflection.Field nameField = Reflection.getField(builtInRegestries, "BLOCK_ENTITY_TYPE", registry); - private static final Class resourceLocation = Reflection.getClass("net.minecraft.resources.ResourceLocation"); - private static final Reflection.Method getKey = Reflection.getTypedMethod(registry, "getKey", resourceLocation, Object.class); - private static final Reflection.Method getName = Reflection.getTypedMethod(resourceLocation, "getPath", String.class); - protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) { - return !hiddenBlockEntities.contains(getName.invoke(getKey.invoke(nameField.get(null), entityType.get(tile)))); - } - - private void blocks(SectionHider section) { - section.copyBitsPerBlock(); - - boolean singleValued = section.getBitsPerBlock() == 0; - if (singleValued) { - int value = ProtocolUtils.readVarInt(section.getIn()); - ProtocolUtils.writeVarInt(section.getOut(), !section.isSkipSection() && section.getObfuscate().contains(value) ? section.getTarget() : value); - return; - } else if (section.getBitsPerBlock() < 9) { - // Indirect (paletted) storage – only present when bitsPerBlock < 9 in 1.21+ - section.processPalette(); - } - - if (section.isSkipSection() || (!section.blockPrecise() && section.isPaletted())) { - section.skipNewDataArray(4096); - return; - } - - SimpleBitStorage values = new SimpleBitStorage(section.getBitsPerBlock(), 4096, section.readNewDataArray(4096)); - - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - for (int x = 0; x < 16; x++) { - int pos = (((y * 16) + z) * 16) + x; - - TechHider.State test = section.test(x, y, z); - - switch (test) { - case SKIP: - break; - case CHECK: - if (!section.getObfuscate().contains(values.get(pos))) - break; - case HIDE: - values.set(pos, section.getTarget()); - break; - case HIDE_AIR: - default: - values.set(pos, section.getAir()); - } - } - } - } - - section.writeDataArray(values.getRaw()); - } - - private void biomes(SectionHider section) { - section.copyBitsPerBlock(); - if(section.getBitsPerBlock() == 0) { - section.copyVarInt(); - } else if(section.getBitsPerBlock() < 6) { - section.skipPalette(); - section.skipNewDataArray(64); - } else { - // Direct (global) biome IDs – no palette present - section.skipNewDataArray(64); - } - } -} diff --git a/SpigotCore/SpigotCore_8/build.gradle.kts b/SpigotCore/SpigotCore_8/build.gradle.kts deleted file mode 100644 index cc99f61e..00000000 --- a/SpigotCore/SpigotCore_8/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":CommonCore", "default")) - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - - compileOnly(libs.nms8) - compileOnly(libs.worldedit12) -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java deleted file mode 100644 index eb3c8bc1..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java +++ /dev/null @@ -1,106 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; -import net.minecraft.server.v1_8_R3.ChatComponentText; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.Map; - -public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { - - @Override - public void playPling(Player player) { - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1); - } - - @Override - public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) { - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(msg)), (byte)type.ordinal())); - } - - @Override - public Object getDataWatcherObject(int index, Class type) { - return index; - } - - private static final Class watchableObject = Reflection.getClass("net.minecraft.DataWatcher$WatchableObject"); - private static final Reflection.Constructor watchableObjectConstructor = Reflection.getConstructor(watchableObject, int.class, int.class, Object.class); - private static final Map, Integer> watchableDatatypes = new HashMap<>(); - static { - watchableDatatypes.put(byte.class, 0); - watchableDatatypes.put(short.class, 1); - watchableDatatypes.put(int.class, 2); - watchableDatatypes.put(float.class, 3); - watchableDatatypes.put(String.class, 4); - } - - @Override - public Object getDataWatcherItem(Object dwo, Object value) { - return watchableObjectConstructor.invoke(watchableDatatypes.get(value.getClass()), dwo, value); - } - - @Override - public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { - Reflection.Field posX = Reflection.getField(packetClass, int.class, fieldOffset); - Reflection.Field posY = Reflection.getField(packetClass, int.class, fieldOffset +1); - Reflection.Field posZ = Reflection.getField(packetClass, int.class, fieldOffset +2); - Reflection.Field lookYaw = Reflection.getField(packetClass, byte.class, 0); - Reflection.Field lookPitch = Reflection.getField(packetClass, byte.class, 1); - - return (packet, x, y, z, pitch, yaw) -> { - posX.set(packet, MathHelper.floor(x * 32)); - posY.set(packet, MathHelper.floor(y * 32)); - posZ.set(packet, MathHelper.floor(z * 32)); - lookYaw.set(packet, (byte)(yaw * 256 / 360)); - lookPitch.set(packet, (byte)(pitch * 256 / 360)); - }; - } - - @Override - public BountifulWrapper.PositionSetter getRelMoveSetter(Class packetClass) { - Reflection.Field moveX = Reflection.getField(packetClass, "b", byte.class); - Reflection.Field moveY = Reflection.getField(packetClass, "c", byte.class); - Reflection.Field moveZ = Reflection.getField(packetClass, "d", byte.class); - Reflection.Field lookYaw = Reflection.getField(packetClass, "e", byte.class); - Reflection.Field lookPitch = Reflection.getField(packetClass, "f", byte.class); - - return (packet, x, y, z, pitch, yaw) -> { - moveX.set(packet, (byte)(x*32)); - moveY.set(packet, (byte)(y*32)); - moveZ.set(packet, (byte)(z*32)); - lookYaw.set(packet, (byte)(yaw*256/360)); - lookPitch.set(packet, (byte)(pitch*256/360)); - }; - } - - @Override - public BountifulWrapper.UUIDSetter getUUIDSetter(Class packetClass) { - return (packet, uuid) -> {}; - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java deleted file mode 100644 index 969e32ad..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java +++ /dev/null @@ -1,51 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; - -import java.util.ArrayList; -import java.util.List; - -public class ChatWrapper8 implements ChatWrapper { - - private static final Reflection.Constructor chatComponentConstructor = Reflection.getConstructor(Reflection.getClass("net.minecraft.network.chat.ChatComponentText"), String.class); - @Override - public Object stringToChatComponent(String text) { - return chatComponentConstructor.invoke(text); - } - - private static final Class metadataPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket"); - private static final Reflection.Field metadataEntity = Reflection.getField(metadataPacket, int.class, 0); - private static final Reflection.Field metadataMetadata = Reflection.getField(metadataPacket, List.class, 0); - @Override - public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) { - Object packet = Reflection.newInstance(metadataPacket); - metadataEntity.set(packet, entityId); - - ArrayList nativeWatchers = new ArrayList<>(1); - for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { - nativeWatchers.add(BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])); - } - metadataMetadata.set(packet, nativeWatchers); - - return packet; - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/CraftbukkitWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/CraftbukkitWrapper8.java deleted file mode 100644 index 9f04130f..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/CraftbukkitWrapper8.java +++ /dev/null @@ -1,33 +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 . - */ - -package de.steamwar.core; - -import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; -import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - @Override - public void sendChunk(Player p, int chunkX, int chunkZ) { - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), true, 65535)); - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java deleted file mode 100644 index 4c85eca0..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java +++ /dev/null @@ -1,121 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.HashMap; -import java.util.Map; - -public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper { - - private static final Reflection.Field scoreboardName = Reflection.getField(FlatteningWrapper.scoreboardObjective, String.class, 1); - private static final Class scoreActionEnum = Reflection.getClass("net.minecraft.PacketPlayOutScoreboardScore$EnumScoreboardAction"); - private static final Reflection.Field scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0); - private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0]; - - @Override - public void setScoreboardTitle(Object packet, String title) { - scoreboardName.set(packet, title); - } - - @Override - public void setScoreAction(Object packet) { - scoreAction.set(packet, scoreActionChange); - } - - @Override - public Material getMaterial(String material) { - try{ - return Material.valueOf(material); - }catch(IllegalArgumentException e){ - return Material.STONE; - } - } - - @Override - public Material getDye(int colorCode) { - return Material.INK_SACK; - } - - @Override - public ItemStack setSkullOwner(String player) { - ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); - SkullMeta headmeta = (SkullMeta) head.getItemMeta(); - headmeta.setOwner(player.startsWith(".") ? player.substring(1) : player); - headmeta.setDisplayName(player); - head.setItemMeta(headmeta); - return head; - } - - @Override - public Object getPose(FlatteningWrapper.EntityPose pose) { - return Byte.valueOf((byte)(pose == FlatteningWrapper.EntityPose.SNEAKING ? 2 : 0)); - } - - private static final Class dataWatcher = Reflection.getClass("net.minecraft.DataWatcher"); - private static final Class namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket"); - private static final Reflection.Field namedSpawnDataWatcher = Reflection.getField(namedSpawnPacket, dataWatcher, 0); - private static final Class entity = Reflection.getClass("net.minecraft.Entity"); - private static final Reflection.Constructor dataWatcherConstructor = Reflection.getConstructor(dataWatcher, entity); - @Override - public void setNamedSpawnPacketDataWatcher(Object packet) { - namedSpawnDataWatcher.set(packet, dataWatcherConstructor.invoke((Object) null)); - } - - @Override - public Object formatDisplayName(String displayName) { - return displayName != null ? displayName : ""; - } - - - private static final Reflection.Field spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9); - private static final Reflection.Field spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); - private static final Map types = new HashMap<>(); - static { - types.put(TrickyTrialsWrapper.impl.getTntEntityType(), 50); - types.put(EntityType.ARMOR_STAND, 30); - types.put(EntityType.ARROW, 60); - types.put(EntityType.FIREBALL, 63); - types.put(EntityType.ITEM_FRAME, 18); - types.put(EntityType.FALLING_BLOCK, 21); - } - @Override - public void setSpawnPacketType(Object packet, EntityType type) { - (type.isAlive() ? spawnLivingType : spawnType).set(packet, types.get(type)); - } - - @Override - public int getViewDistance(Player player) { - return 10; - } - - private static final Reflection.Method save = Reflection.getMethod("org.bukkit.craftbukkit.CraftWorld", "save", boolean.class); - @Override - public void syncSave(World world) { - save.invoke(world, true); - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/IDConverter8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/IDConverter8.java deleted file mode 100644 index e13ad74a..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/IDConverter8.java +++ /dev/null @@ -1,113 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.InputStreamReader; -import java.util.*; -import java.util.stream.Collectors; - -public class IDConverter8 { - - private final Map> availibleAttributes; - private final Map, BlockTypeID>> map; - - public IDConverter8() { - Map, BlockTypeID>> map = new HashMap<>(); - - YamlConfiguration legacy = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(IDConverter8.class.getClassLoader().getResourceAsStream("legacy.yml")))); - for(String blockString : legacy.getKeys(false)){ - String[] legacyBlockId = legacy.getString(blockString).split(":"); - - map.computeIfAbsent(getBlockId(blockString), bId -> { - Map, BlockTypeID> attributeMap = new HashMap<>(); - attributeMap.put(new HashSet<>(), new BlockTypeID(legacyBlockId[0], "0")); - return attributeMap; - }).put(getAttributes(blockString), new BlockTypeID(legacyBlockId[0], legacyBlockId[1])); - } - this.map = map; - - Map> availableAttributes = new HashMap<>(); - for (Map.Entry, BlockTypeID>> entry : map.entrySet()) { - availableAttributes.put(entry.getKey(), entry.getValue().keySet().stream().flatMap(Collection::stream).collect(Collectors.toSet())); - } - this.availibleAttributes = availableAttributes; - } - - public BlockTypeID getId(String blockString) { - String blockId = getBlockId(blockString); - Map, IDConverter8.BlockTypeID> attributeMap = map.get(blockId); - if(attributeMap == null) { // Block nonexistent pre-flattening - return new BlockTypeID("0", "0"); - } - - Set attributes = getAttributes(blockString); - Set knownAttributes = this.availibleAttributes.get(blockId); - attributes.removeIf(attribute -> !knownAttributes.contains(attribute)); - - long bestMatch = -1; - BlockTypeID blockID = null; - for(Map.Entry, BlockTypeID> entry : attributeMap.entrySet()) { - Set attrs = entry.getKey(); - if(attrs.size() <= bestMatch) - continue; - - long matching = attributes.stream().filter(attrs::contains).count(); - if(matching > bestMatch) { - blockID = entry.getValue(); - bestMatch = matching; - - if(bestMatch == attributes.size()) - break; - } - } - return blockID; - } - - private String getBlockId(String blockString) { - return blockString.split("\\[", 2)[0]; - } - - private Set getAttributes(String blockString) { - Set attributes = new HashSet<>(); - if(blockString.contains("[")) - Collections.addAll(attributes, blockString.split("\\[")[1].replace("]", "").split(",")); - return attributes; - } - - static class BlockTypeID{ - private final int blockId; - private final byte dataId; - - private BlockTypeID(String blockId, String dataId) { - this.blockId = Integer.parseInt(blockId); - this.dataId = Byte.parseByte(dataId); - } - - int getBlockId() { - return blockId; - } - - byte getDataId() { - return dataId; - } - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/LocaleChangeWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/LocaleChangeWrapper8.java deleted file mode 100644 index 76c565df..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/LocaleChangeWrapper8.java +++ /dev/null @@ -1,24 +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 . - */ - -package de.steamwar.core; - -public class LocaleChangeWrapper8 implements LocaleChangeWrapper { - // Event not available in 1.8-1.10 -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/ProtocolWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/ProtocolWrapper8.java deleted file mode 100644 index d897487b..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/ProtocolWrapper8.java +++ /dev/null @@ -1,71 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.mojang.authlib.GameProfile; -import org.bukkit.GameMode; - -import java.util.Collections; -import java.util.EnumMap; -import java.util.List; - -public class ProtocolWrapper8 implements ProtocolWrapper { - - private static final Reflection.Field equipmentSlot; - static { - if(Core.getVersion() == 8) { - equipmentSlot = Reflection.getField(equipmentPacket, int.class, 1); - } else { - Class enumItemSlot = Reflection.getClass("net.minecraft.world.entity.EnumItemSlot"); - equipmentSlot = Reflection.getField(equipmentPacket, enumItemSlot, 0); - } - } - - private static final Reflection.Field equipmentStack = Reflection.getField(equipmentPacket, itemStack, 0); - @Override - public void setEquipmentPacketStack(Object packet, Object slot, Object stack) { - equipmentSlot.set(packet, slot); - equipmentStack.set(packet, stack); - } - - private static final Class playerInfoPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo"); - private static final Class playerInfoActionClass = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo$EnumPlayerInfoAction"); - private static final Reflection.Field playerInfoAction = Reflection.getField(playerInfoPacket, playerInfoActionClass, 0); - private static final Reflection.Field playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0); - private static final EnumMap actions = new EnumMap<>(PlayerInfoAction.class); - static { - Object[] nativeActions = playerInfoActionClass.getEnumConstants(); - actions.put(PlayerInfoAction.ADD, nativeActions[0]); - actions.put(PlayerInfoAction.GAMEMODE, nativeActions[1]); - actions.put(PlayerInfoAction.REMOVE, nativeActions[4]); - } - private static final Class iChatBaseComponent = Reflection.getClass("net.minecraft.network.chat.Component"); - private static final Reflection.Constructor playerInfoDataConstructor = Reflection.getConstructor("net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo$PlayerInfoData", playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); - - @Override - @SuppressWarnings("deprecation") - public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) { - Object packet = Reflection.newInstance(playerInfoPacket); - playerInfoAction.set(packet, actions.get(action)); - playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(packet, profile, 0, ProtocolWrapper.getGameModeById.invoke(null, mode.getValue()), null))); - return packet; - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java deleted file mode 100644 index 841719cd..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/RecipeDiscoverWrapper8.java +++ /dev/null @@ -1,24 +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 . - */ - -package de.steamwar.core; - -public class RecipeDiscoverWrapper8 implements RecipeDiscoverWrapper { - // Event not available pre flattening -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java deleted file mode 100644 index 1d9abc37..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ /dev/null @@ -1,49 +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 . - */ - -package de.steamwar.core; - -import com.mojang.authlib.properties.Property; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; - -public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { - @Override - public EntityType getTntEntityType() { - return EntityType.PRIMED_TNT; - } - - @Override - public Enchantment getUnbreakingEnchantment() { - return Enchantment.DURABILITY; - } - - @Override - public Material getTurtleScute() { - return Material.STONE; - } - - @Override - public String getValue(Property property) { - return property.getValue(); - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditRendererWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditRendererWrapper8.java deleted file mode 100644 index 1994e42f..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditRendererWrapper8.java +++ /dev/null @@ -1,42 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WorldEditRendererWrapper8 implements WorldEditRendererWrapper { - - @Override - public void draw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2) { - } - - @Override - public void tick(Player player) { - } - - @Override - public void hide(Player player, boolean clipboard, boolean hide) { - } - - @Override - public void remove(Player player) { - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java deleted file mode 100644 index 4f45729d..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ /dev/null @@ -1,305 +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 . - */ - -package de.steamwar.core; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; -import com.sk89q.jnbt.*; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; -import com.sk89q.worldedit.extent.clipboard.io.SchematicReader; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.registry.WorldData; -import de.steamwar.sql.NodeData; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class WorldEditWrapper8 implements WorldEditWrapper { - - @Override - public InputStream getPlayerClipboard(Player player) { - return WorldEditWrapper.getPlayerClipboard(player, (outputStream, clipboard, clipboardHolder) -> - ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData())); - } - - @Override - public void setPlayerClipboard(Player player, Clipboard clipboard) { - WorldData world = new BukkitWorld(player.getWorld()).getWorldData(); - Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player); - WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, world)); - } - - @Override - public Clipboard getClipboard(NodeData data) throws IOException { - InputStream is = data.schemData(true); - return readClipboard(is, data.getNodeFormat()); - } - - @Override - public Clipboard getClipboard(InputStream inputStream) throws IOException { - return readClipboard(inputStream, getNativeFormat()); - } - - private Clipboard readClipboard(InputStream is, NodeData.SchematicFormat format) throws IOException { - switch (format) { - case MCEDIT: - return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData()); - case SPONGE_V2: - case SPONGE_V3: - return new SpongeSchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData()); - default: - throw new IllegalArgumentException("Unsupported schematic format"); - } - } - - @Override - public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { - return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ()); - } - - @Override - public org.bukkit.util.Vector getMinimum(Region region) { - return new org.bukkit.util.Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); - } - - @Override - public org.bukkit.util.Vector getMaximum(Region region) { - return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); - } - - @Override - public org.bukkit.util.Vector applyTransform(org.bukkit.util.Vector vector, Transform transform) { - Vector v = new Vector(vector.getX(), vector.getY(), vector.getZ()); - v = transform.apply(v); - return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ()); - } - - @Override - public NodeData.SchematicFormat getNativeFormat() { - return NodeData.SchematicFormat.MCEDIT; - } - - private static class SpongeSchematicReader implements ClipboardReader { - - private final NBTInputStream inputStream; - private int schematicVersion = -1; - - SpongeSchematicReader(NBTInputStream inputStream) { - Preconditions.checkNotNull(inputStream); - this.inputStream = inputStream; - } - - @Override - public Clipboard read(WorldData worldData) throws IOException { - CompoundTag schematicTag = this.getBaseTag(); - if (this.schematicVersion == 1) { - return this.readSchematic(schematicTag); - } else if (this.schematicVersion == 2) { - return this.readSchematic(schematicTag); - } else { - throw new IOException("This schematic version is currently not supported"); - } - } - - private CompoundTag getBaseTag() throws IOException { - NamedTag rootTag = this.inputStream.readNamedTag(); - if (!rootTag.getName().equals("Schematic")) { - throw new IOException("Tag 'Schematic' does not exist or is not first"); - } else { - CompoundTag schematicTag = (CompoundTag)rootTag.getTag(); - Map schematic = schematicTag.getValue(); - this.schematicVersion = (requireTag(schematic, "Version", IntTag.class)).getValue(); - return schematicTag; - } - } - - private BlockArrayClipboard readSchematic(CompoundTag schematicTag) throws IOException { - IDConverter8 ids = new IDConverter8(); - - Map schematic = schematicTag.getValue(); - boolean v3Mode = false; - - if (schematic.size() == 1) { - schematic = (requireTag(schematic, "Schematic", CompoundTag.class)).getValue(); - v3Mode = true; - } - - int width = (requireTag(schematic, "Width", ShortTag.class)).getValue(); - int height = (requireTag(schematic, "Height", ShortTag.class)).getValue(); - int length = (requireTag(schematic, "Length", ShortTag.class)).getValue(); - IntArrayTag offsetTag = getTag(schematic, "Offset", IntArrayTag.class); - int[] offsetParts; - if (offsetTag != null) { - offsetParts = offsetTag.getValue(); - if (offsetParts.length != 3) - throw new IOException("Invalid offset specified in schematic."); - } else { - offsetParts = new int[]{0, 0, 0}; - } - - BlockVector min = new BlockVector(offsetParts[0], offsetParts[1], offsetParts[2]); - CompoundTag metadataTag = getTag(schematic, "Metadata", CompoundTag.class); - Vector origin; - CuboidRegion region; - if (metadataTag != null && metadataTag.containsKey("WEOffsetX")) { - Map metadata = metadataTag.getValue(); - int offsetX = (requireTag(metadata, "WEOffsetX", IntTag.class)).getValue(); - int offsetY = (requireTag(metadata, "WEOffsetY", IntTag.class)).getValue(); - int offsetZ = (requireTag(metadata, "WEOffsetZ", IntTag.class)).getValue(); - BlockVector offset = new BlockVector(offsetX, offsetY, offsetZ); - origin = min.subtract(offset); - region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector.ONE)); - } else { - origin = min; - region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector.ONE)); - } - - Map blockContainer = null; - - if (v3Mode) { - blockContainer = getTag(schematic, "Blocks", CompoundTag.class).getValue(); - } - - Map paletteObject = requireTag(v3Mode ? blockContainer : schematic, "Palette", CompoundTag.class).getValue(); - - Map palette = new HashMap<>(); - ParserContext parserContext = new ParserContext(); - parserContext.setRestricted(false); - parserContext.setPreferringWildcard(false); - - for(String palettePart : paletteObject.keySet()) { - IDConverter8.BlockTypeID blockID = ids.getId(palettePart); - palette.put(requireTag(paletteObject, palettePart, IntTag.class).getValue(), new BaseBlock(blockID.getBlockId(), blockID.getDataId())); - } - - byte[] blocks = requireTag(v3Mode ? blockContainer : schematic, v3Mode ? "Data" : "BlockData", ByteArrayTag.class).getValue(); - Map> tileEntitiesMap = new HashMap<>(); - ListTag tileEntities = getTag(v3Mode ? blockContainer : schematic, "BlockEntities", ListTag.class); - if (tileEntities == null) { - tileEntities = getTag(v3Mode ? blockContainer : schematic, "TileEntities", ListTag.class); - } - - if (tileEntities != null) { - List> tileEntityTags = tileEntities.getValue().stream().map((tag) -> - (CompoundTag)tag - ).map(CompoundTag::getValue).collect(Collectors.toList()); - - BlockVector pt; - Map tileEntity; - for(Iterator> var20 = tileEntityTags.iterator(); var20.hasNext(); tileEntitiesMap.put(pt, tileEntity)) { - tileEntity = var20.next(); - int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); - pt = new BlockVector(pos[0], pos[1], pos[2]); - Map values = Maps.newHashMap(tileEntity); - values.put("x", new IntTag(pt.getBlockX())); - values.put("y", new IntTag(pt.getBlockY())); - values.put("z", new IntTag(pt.getBlockZ())); - values.put("id", values.get("Id")); - values.remove("Id"); - values.remove("Pos"); - tileEntity = values; - } - } - - BlockArrayClipboard clipboard = new BlockArrayClipboard(region); - clipboard.setOrigin(origin); - int index = 0; - - for(int i = 0; i < blocks.length; ++index) { - int value = 0; - int varintLength = 0; - - while(true) { - value |= (blocks[i] & 127) << varintLength++ * 7; - if (varintLength > 5) { - throw new IOException("VarInt too big (probably corrupted data)"); - } - - if ((blocks[i] & 128) != 128) { - ++i; - int y = index / (width * length); - int z = index % (width * length) / width; - int x = index % (width * length) % width; - BaseBlock block = palette.get(value); - BlockVector pt = new BlockVector(x, y, z); - - try { - if (tileEntitiesMap.containsKey(pt)) { - block.setNbtData(new CompoundTag(tileEntitiesMap.get(pt))); - clipboard.setBlock(clipboard.getMinimumPoint().add(pt), block); - } else { - clipboard.setBlock(clipboard.getMinimumPoint().add(pt), block); - } - break; - } catch (WorldEditException var30) { - throw new IOException("Failed to load a block in the schematic"); - } - } - - ++i; - } - } - - return clipboard; - } - - private static T requireTag(Map items, String key, Class expected) throws IOException { - if (!items.containsKey(key)) { - throw new IOException("Schematic file is missing a \"" + key + "\" tag"); - } else { - Tag tag = items.get(key); - if (!expected.isInstance(tag)) { - throw new IOException(key + " tag is not of tag type " + expected.getName()); - } else { - return expected.cast(tag); - } - } - } - - private static T getTag(Map items, String key, Class expected) { - if (!items.containsKey(key)) { - return null; - } else { - Tag test = items.get(key); - return !expected.isInstance(test) ? null : expected.cast(test); - } - } - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldIdentifier8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldIdentifier8.java deleted file mode 100644 index 632201bb..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldIdentifier8.java +++ /dev/null @@ -1,27 +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 . - */ - -package de.steamwar.core; - -public class WorldIdentifier8 implements WorldIdentifier.IWorldIdentifier { - - @Override - public void setResourceKey(String name) { - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/authlib/SteamwarGameProfileRepository8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/authlib/SteamwarGameProfileRepository8.java deleted file mode 100644 index be7ba13e..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/authlib/SteamwarGameProfileRepository8.java +++ /dev/null @@ -1,72 +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 . - */ - -package de.steamwar.core.authlib; - -import com.mojang.authlib.Agent; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.GameProfileRepository; -import com.mojang.authlib.ProfileLookupCallback; -import de.steamwar.Reflection; -import de.steamwar.sql.SteamwarUser; - -import java.util.ArrayList; -import java.util.List; - -public class SteamwarGameProfileRepository8 extends SteamwarGameProfileRepository { - - private static final GameProfileRepository fallback; - - private static final Object minecraftServer; - private static final Reflection.Field gameProfile; - - static { - Class minecraftServerClass = Reflection.getClass("net.minecraft.server.MinecraftServer"); - Class gpr = Reflection.getClass("com.mojang.authlib.GameProfileRepository"); - gameProfile = Reflection.getField(minecraftServerClass, gpr, 0); - minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null); - fallback = (GameProfileRepository) gameProfile.get(minecraftServer); - } - - @Override - public void inject() { - gameProfile.set(minecraftServer, this); - } - - @Override - public void findProfilesByNames(String[] strings, Agent agent, ProfileLookupCallback profileLookupCallback) { - if(agent == Agent.SCROLLS) { - fallback.findProfilesByNames(strings, agent, profileLookupCallback); - } else { - List unknownNames = new ArrayList<>(); - for (String name:strings) { - SteamwarUser user = SteamwarUser.get(name); - if(user == null) { - unknownNames.add(name); - continue; - } - - profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName())); - } - if(!unknownNames.isEmpty()) { - fallback.findProfilesByNames(unknownNames.toArray(new String[0]), agent, profileLookupCallback); - } - } - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/scoreboard/SWScoreboard8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/scoreboard/SWScoreboard8.java deleted file mode 100644 index 75b4da57..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/scoreboard/SWScoreboard8.java +++ /dev/null @@ -1,115 +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 . - */ - -package de.steamwar.scoreboard; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.core.Core; -import de.steamwar.core.FlatteningWrapper; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.Map; - -public class SWScoreboard8 implements SWScoreboard { - private static final Reflection.Field scoreboardName = Reflection.getField(FlatteningWrapper.scoreboardObjective, String.class, 0); - private static final Reflection.Field scoreboardAction = Reflection.getField(FlatteningWrapper.scoreboardObjective, int.class, Core.getVersion() > 15 ? 3 : 0); - private static final Class scoreboardDisplayEnum = Reflection.getClass("net.minecraft.world.scores.criteria.IScoreboardCriteria$EnumScoreboardHealthDisplay"); - private static final Reflection.Field scoreboardDisplayType = Reflection.getField(FlatteningWrapper.scoreboardObjective, scoreboardDisplayEnum, 0); - private static final Object displayTypeIntegers = scoreboardDisplayEnum.getEnumConstants()[0]; - - private static final Reflection.Field scoreName = Reflection.getField(FlatteningWrapper.scoreboardScore, String.class, 0); - private static final Reflection.Field scoreScoreboardName = Reflection.getField(FlatteningWrapper.scoreboardScore, String.class, 1); - private static final Reflection.Field scoreValue = Reflection.getField(FlatteningWrapper.scoreboardScore, int.class, 0); - - private static final HashMap playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map! - private static int toggle = 0; // Scoreboard 0 updates while scoreboard 1 is presenting. toggle marks the current active scoreboard - - private static final String SIDEBAR = "Sidebar"; - private static final Object[] DELETE_SCOREBOARD = new Object[2]; - private static final Object[] DISPLAY_SIDEBAR = new Object[2]; - - static { - Class scoreboardDisplayObjective = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutScoreboardDisplayObjective"); - Reflection.Field scoreboardDisplayName = Reflection.getField(scoreboardDisplayObjective, String.class, 0); - Reflection.Field scoreboardDisplaySlot = Reflection.getField(scoreboardDisplayObjective, int.class, 0); - for(int id = 0; id < 2; id++) { - DELETE_SCOREBOARD[id] = Reflection.newInstance(FlatteningWrapper.scoreboardObjective); - scoreboardName.set(DELETE_SCOREBOARD[id], SIDEBAR + id); - scoreboardAction.set(DELETE_SCOREBOARD[id], 1); //1 to remove - - DISPLAY_SIDEBAR[id] = Reflection.newInstance(scoreboardDisplayObjective); - scoreboardDisplayName.set(DISPLAY_SIDEBAR[id], SIDEBAR + id); - scoreboardDisplaySlot.set(DISPLAY_SIDEBAR[id], 1); // 1 = Sidebar - } - - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { - toggle ^= 1; // Toggle between 0 and 1 - - for(Map.Entry scoreboard : playerBoards.entrySet()) { - Player player = scoreboard.getKey(); - ScoreboardCallback callback = scoreboard.getValue(); - - TinyProtocol.instance.sendPacket(player, DELETE_SCOREBOARD[toggle]); - TinyProtocol.instance.sendPacket(player, createSidebarPacket(callback.getTitle())); - for(Map.Entry score : callback.getData().entrySet()){ - TinyProtocol.instance.sendPacket(player, createScorePacket(score.getKey(), score.getValue())); - } - - Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> { - if(!player.isOnline()) - return; - TinyProtocol.instance.sendPacket(player, DISPLAY_SIDEBAR[toggle]); - }, 2); - } - }, 10, 5); - } - - public boolean createScoreboard(Player player, ScoreboardCallback callback) { - playerBoards.put(player, callback); - return true; - } - - public void removeScoreboard(Player player) { - if(playerBoards.remove(player) == null || !player.isOnline()) - return; - - TinyProtocol.instance.sendPacket(player, DELETE_SCOREBOARD[toggle]); - } - - private static Object createSidebarPacket(String name){ - Object packet = Reflection.newInstance(FlatteningWrapper.scoreboardObjective); - scoreboardName.set(packet, SIDEBAR + toggle); - scoreboardAction.set(packet, 0); //0 to create - FlatteningWrapper.impl.setScoreboardTitle(packet, name); - scoreboardDisplayType.set(packet, displayTypeIntegers); - return packet; - } - - private static Object createScorePacket(String name, int value){ - Object packet = Reflection.newInstance(FlatteningWrapper.scoreboardScore); - scoreName.set(packet, name); - scoreScoreboardName.set(packet, SIDEBAR + toggle); - scoreValue.set(packet, value); - FlatteningWrapper.impl.setScoreAction(packet); - return packet; - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/BlockIds8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/BlockIds8.java deleted file mode 100644 index 25535af8..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/BlockIds8.java +++ /dev/null @@ -1,44 +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 . - */ - -package de.steamwar.techhider; - -import org.bukkit.Material; - -import java.util.Collections; -import java.util.Set; - -public class BlockIds8 implements BlockIds { - @Override - public int getCombinedId(Object iBlockData) { - int id = (int) getCombinedId.invoke(null, iBlockData); // blockState << 12 | blockId - return (id & 4095) | (id >> 12); - } - - @Override - @SuppressWarnings("deprecation") - public int materialToId(Material material) { - return material.getId() << 4; - } - - @Override - public Set materialToAllIds(Material material) { - return Collections.singleton(materialToId(material)); - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ChunkHider8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ChunkHider8.java deleted file mode 100644 index 6b7441a4..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ChunkHider8.java +++ /dev/null @@ -1,39 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import org.bukkit.entity.Player; - -import java.util.function.BiFunction; - -public class ChunkHider8 implements ChunkHider { - - protected static final Class mapChunkPacket = Reflection.getClass("net.minecraft.PacketPlayOutMapChunk"); - @Override - public Class mapChunkPacket() { - return mapChunkPacket; - } - - @Override - public BiFunction chunkHiderGenerator(TechHider techHider) { - return (player, packet) -> packet; - } -} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java deleted file mode 100644 index 28d6b8f6..00000000 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/techhider/ProtocolWrapper8.java +++ /dev/null @@ -1,85 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import org.bukkit.entity.Player; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.function.BiFunction; - -public class ProtocolWrapper8 implements ProtocolWrapper { - private static final Class chunkCoordinateIntPair = Reflection.getClass("net.minecraft.ChunkCoordIntPair"); - private static final Reflection.Field multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, chunkCoordinateIntPair, 0); - private static final Reflection.Field chunkCoordinateX = Reflection.getField(chunkCoordinateIntPair, int.class, 0); - private static final Reflection.Field chunkCoordinateZ = Reflection.getField(chunkCoordinateIntPair, int.class, 1); - private static final Class multiBlockChangeInfo = Reflection.getClass("net.minecraft.PacketPlayOutMultiBlockChange$MultiBlockChangeInfo"); - private static final Reflection.Constructor multiBlockChangeInfoConstructor = Reflection.getConstructor(multiBlockChangeInfo, TechHider.multiBlockChangePacket, short.class, TechHider.iBlockData); - private static final Reflection.Field multiBlockChangeInfoBlock = Reflection.getField(multiBlockChangeInfo, TechHider.iBlockData, 0); - private static final Reflection.Field multiBlockChangeInfoPos = Reflection.getField(multiBlockChangeInfo, short.class, 0); - private static final Class multiBlockChangeInfoArray = Reflection.getClass("[L" + Reflection.LEGACY_NET_MINECRAFT_SERVER + ".PacketPlayOutMultiBlockChange$MultiBlockChangeInfo;"); - private static final Reflection.Field multiBlockChangeInfos = Reflection.getField(TechHider.multiBlockChangePacket, multiBlockChangeInfoArray, 0); - @Override - public BiFunction multiBlockChangeGenerator(TechHider techHider) { - return (p, packet) -> { - TechHider.LocationEvaluator locationEvaluator = techHider.getLocationEvaluator(); - Object chunkCoords = multiBlockChangeChunk.get(packet); - int chunkX = chunkCoordinateX.get(chunkCoords); - int chunkZ = chunkCoordinateZ.get(chunkCoords); - if(locationEvaluator.skipChunk(p, chunkX, chunkZ)) - return packet; - - packet = TechHider.multiBlockChangeCloner.apply(packet); - Object[] mbcis = (Object[]) multiBlockChangeInfos.get(packet); - ArrayList blockChangeInfos = new ArrayList<>(mbcis.length); - for(Object mbci : mbcis) { - short pos = (short) multiBlockChangeInfoPos.get(mbci); - switch(locationEvaluator.check(p, 16*chunkX + (pos >> 12 & 0xF), pos & 0xFF, 16*chunkZ + (pos >> 8 & 0xF))) { - case SKIP: - blockChangeInfos.add(mbci); - break; - case CHECK: - blockChangeInfos.add(techHider.iBlockDataHidden(multiBlockChangeInfoBlock.get(mbci)) ? multiBlockChangeInfoConstructor.invoke(packet, pos, techHider.getObfuscationTarget()) : mbci); - break; - default: - break; - } - } - - if(blockChangeInfos.isEmpty()) - return null; - - multiBlockChangeInfos.set(packet, blockChangeInfos.toArray((Object[])Array.newInstance(multiBlockChangeInfo, 0))); - return packet; - }; - } - - private static final Reflection.Field tileEntityDataAction = Reflection.getField(TechHider.tileEntityDataPacket, int.class, 0); - @Override - public boolean unfilteredTileEntityDataAction(Object packet) { - return tileEntityDataAction.get(packet) != 9; - } - - @Override - public BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider) { - return null; - } -} diff --git a/SpigotCore/SpigotCore_8/src/legacy.yml b/SpigotCore/SpigotCore_8/src/legacy.yml deleted file mode 100644 index 51097cd6..00000000 --- a/SpigotCore/SpigotCore_8/src/legacy.yml +++ /dev/null @@ -1,1623 +0,0 @@ -"minecraft:air": "0:0" -"minecraft:stone": "1:0" -"minecraft:granite": "1:1" -"minecraft:polished_granite": "1:2" -"minecraft:diorite": "1:3" -"minecraft:polished_diorite": "1:4" -"minecraft:andesite": "1:5" -"minecraft:polished_andesite": "1:6" -"minecraft:grass_block[snowy=false]": "2:0" -"minecraft:dirt": "3:0" -"minecraft:coarse_dirt": "3:1" -"minecraft:podzol[snowy=false]": "3:2" -"minecraft:cobblestone": "4:0" -"minecraft:oak_planks": "5:0" -"minecraft:spruce_planks": "5:1" -"minecraft:birch_planks": "5:2" -"minecraft:jungle_planks": "5:3" -"minecraft:acacia_planks": "5:4" -"minecraft:dark_oak_planks": "5:5" -"minecraft:oak_sapling[stage=0]": "6:0" -"minecraft:spruce_sapling[stage=0]": "6:1" -"minecraft:birch_sapling[stage=0]": "6:2" -"minecraft:jungle_sapling[stage=0]": "6:3" -"minecraft:acacia_sapling[stage=0]": "6:4" -"minecraft:dark_oak_sapling[stage=0]": "6:5" -"minecraft:oak_sapling[stage=1]": "6:8" -"minecraft:spruce_sapling[stage=1]": "6:9" -"minecraft:birch_sapling[stage=1]": "6:10" -"minecraft:jungle_sapling[stage=1]": "6:11" -"minecraft:acacia_sapling[stage=1]": "6:12" -"minecraft:dark_oak_sapling[stage=1]": "6:13" -"minecraft:bedrock": "7:0" -"minecraft:water[level=0]": "8:0" -"minecraft:water[level=1]": "8:1" -"minecraft:water[level=2]": "8:2" -"minecraft:water[level=3]": "8:3" -"minecraft:water[level=4]": "8:4" -"minecraft:water[level=5]": "8:5" -"minecraft:water[level=6]": "8:6" -"minecraft:water[level=7]": "8:7" -"minecraft:water[level=8]": "8:8" -"minecraft:water[level=9]": "8:9" -"minecraft:water[level=10]": "8:10" -"minecraft:water[level=11]": "8:11" -"minecraft:water[level=12]": "8:12" -"minecraft:water[level=13]": "8:13" -"minecraft:water[level=14]": "8:14" -"minecraft:water[level=15]": "8:15" -"minecraft:lava[level=0]": "10:0" -"minecraft:lava[level=1]": "10:1" -"minecraft:lava[level=2]": "10:2" -"minecraft:lava[level=3]": "10:3" -"minecraft:lava[level=4]": "10:4" -"minecraft:lava[level=5]": "10:5" -"minecraft:lava[level=6]": "10:6" -"minecraft:lava[level=7]": "10:7" -"minecraft:lava[level=8]": "10:8" -"minecraft:lava[level=9]": "10:9" -"minecraft:lava[level=10]": "10:10" -"minecraft:lava[level=11]": "10:11" -"minecraft:lava[level=12]": "10:12" -"minecraft:lava[level=13]": "10:13" -"minecraft:lava[level=14]": "10:14" -"minecraft:lava[level=15]": "10:15" -"minecraft:sand": "12:0" -"minecraft:red_sand": "12:1" -"minecraft:gravel": "13:0" -"minecraft:gold_ore": "14:0" -"minecraft:iron_ore": "15:0" -"minecraft:coal_ore": "16:0" -"minecraft:oak_log[axis=y]": "17:0" -"minecraft:spruce_log[axis=y]": "17:1" -"minecraft:birch_log[axis=y]": "17:2" -"minecraft:jungle_log[axis=y]": "17:3" -"minecraft:oak_log[axis=x]": "17:4" -"minecraft:spruce_log[axis=x]": "17:5" -"minecraft:birch_log[axis=x]": "17:6" -"minecraft:jungle_log[axis=x]": "17:7" -"minecraft:oak_log[axis=z]": "17:8" -"minecraft:spruce_log[axis=z]": "17:9" -"minecraft:birch_log[axis=z]": "17:10" -"minecraft:jungle_log[axis=z]": "17:11" -"minecraft:oak_wood": "17:12" -"minecraft:spruce_wood": "17:13" -"minecraft:birch_wood": "17:14" -"minecraft:jungle_wood": "17:15" -"minecraft:oak_leaves[persistent=false,distance=1]": "18:0" -"minecraft:spruce_leaves[persistent=false,distance=1]": "18:1" -"minecraft:birch_leaves[persistent=false,distance=1]": "18:2" -"minecraft:jungle_leaves[persistent=false,distance=1]": "18:3" -"minecraft:oak_leaves[persistent=true,distance=1]": "18:4" -"minecraft:spruce_leaves[persistent=true,distance=1]": "18:5" -"minecraft:birch_leaves[persistent=true,distance=1]": "18:6" -"minecraft:jungle_leaves[persistent=true,distance=1]": "18:7" -"minecraft:sponge": "19:0" -"minecraft:wet_sponge": "19:1" -"minecraft:glass": "20:0" -"minecraft:lapis_ore": "21:0" -"minecraft:lapis_block": "22:0" -"minecraft:dispenser[triggered=false,facing=down]": "23:0" -"minecraft:dispenser[triggered=false,facing=up]": "23:1" -"minecraft:dispenser[triggered=false,facing=north]": "23:2" -"minecraft:dispenser[triggered=false,facing=south]": "23:3" -"minecraft:dispenser[triggered=false,facing=west]": "23:4" -"minecraft:dispenser[triggered=false,facing=east]": "23:5" -"minecraft:dispenser[triggered=true,facing=down]": "23:8" -"minecraft:dispenser[triggered=true,facing=up]": "23:9" -"minecraft:dispenser[triggered=true,facing=north]": "23:10" -"minecraft:dispenser[triggered=true,facing=south]": "23:11" -"minecraft:dispenser[triggered=true,facing=west]": "23:12" -"minecraft:dispenser[triggered=true,facing=east]": "23:13" -"minecraft:sandstone": "24:0" -"minecraft:chiseled_sandstone": "24:1" -"minecraft:cut_sandstone": "24:2" -"minecraft:note_block": "25:0" -"minecraft:red_bed[part=foot,facing=south,occupied=false]": "26:0" -"minecraft:red_bed[part=foot,facing=west,occupied=false]": "26:1" -"minecraft:red_bed[part=foot,facing=north,occupied=false]": "26:2" -"minecraft:red_bed[part=foot,facing=east,occupied=false]": "26:3" -"minecraft:red_bed[part=foot,facing=south,occupied=true]": "26:4" -"minecraft:red_bed[part=foot,facing=west,occupied=true]": "26:5" -"minecraft:red_bed[part=foot,facing=north,occupied=true]": "26:6" -"minecraft:red_bed[part=foot,facing=east,occupied=true]": "26:7" -"minecraft:red_bed[part=head,facing=south,occupied=false]": "26:8" -"minecraft:red_bed[part=head,facing=west,occupied=false]": "26:9" -"minecraft:red_bed[part=head,facing=north,occupied=false]": "26:10" -"minecraft:red_bed[part=head,facing=east,occupied=false]": "26:11" -"minecraft:red_bed[part=head,facing=south,occupied=true]": "26:12" -"minecraft:red_bed[part=head,facing=west,occupied=true]": "26:13" -"minecraft:red_bed[part=head,facing=north,occupied=true]": "26:14" -"minecraft:red_bed[part=head,facing=east,occupied=true]": "26:15" -"minecraft:powered_rail[shape=north_south,powered=false]": "27:0" -"minecraft:powered_rail[shape=east_west,powered=false]": "27:1" -"minecraft:powered_rail[shape=ascending_east,powered=false]": "27:2" -"minecraft:powered_rail[shape=ascending_west,powered=false]": "27:3" -"minecraft:powered_rail[shape=ascending_north,powered=false]": "27:4" -"minecraft:powered_rail[shape=ascending_south,powered=false]": "27:5" -"minecraft:powered_rail[shape=north_south,powered=true]": "27:8" -"minecraft:powered_rail[shape=east_west,powered=true]": "27:9" -"minecraft:powered_rail[shape=ascending_east,powered=true]": "27:10" -"minecraft:powered_rail[shape=ascending_west,powered=true]": "27:11" -"minecraft:powered_rail[shape=ascending_north,powered=true]": "27:12" -"minecraft:powered_rail[shape=ascending_south,powered=true]": "27:13" -"minecraft:detector_rail[shape=north_south,powered=false]": "28:0" -"minecraft:detector_rail[shape=east_west,powered=false]": "28:1" -"minecraft:detector_rail[shape=ascending_east,powered=false]": "28:2" -"minecraft:detector_rail[shape=ascending_west,powered=false]": "28:3" -"minecraft:detector_rail[shape=ascending_north,powered=false]": "28:4" -"minecraft:detector_rail[shape=ascending_south,powered=false]": "28:5" -"minecraft:detector_rail[shape=north_south,powered=true]": "28:8" -"minecraft:detector_rail[shape=east_west,powered=true]": "28:9" -"minecraft:detector_rail[shape=ascending_east,powered=true]": "28:10" -"minecraft:detector_rail[shape=ascending_west,powered=true]": "28:11" -"minecraft:detector_rail[shape=ascending_north,powered=true]": "28:12" -"minecraft:detector_rail[shape=ascending_south,powered=true]": "28:13" -"minecraft:sticky_piston[facing=down,extended=false]": "29:0" -"minecraft:sticky_piston[facing=up,extended=false]": "29:1" -"minecraft:sticky_piston[facing=north,extended=false]": "29:2" -"minecraft:sticky_piston[facing=south,extended=false]": "29:3" -"minecraft:sticky_piston[facing=west,extended=false]": "29:4" -"minecraft:sticky_piston[facing=east,extended=false]": "29:5" -"minecraft:sticky_piston[facing=down,extended=true]": "29:8" -"minecraft:sticky_piston[facing=up,extended=true]": "29:9" -"minecraft:sticky_piston[facing=north,extended=true]": "29:10" -"minecraft:sticky_piston[facing=south,extended=true]": "29:11" -"minecraft:sticky_piston[facing=west,extended=true]": "29:12" -"minecraft:sticky_piston[facing=east,extended=true]": "29:13" -"minecraft:cobweb": "30:0" -"minecraft:dead_bush": "31:0" -"minecraft:grass": "31:1" -"minecraft:fern": "31:2" -"minecraft:piston[facing=down,extended=false]": "33:0" -"minecraft:piston[facing=up,extended=false]": "33:1" -"minecraft:piston[facing=north,extended=false]": "33:2" -"minecraft:piston[facing=south,extended=false]": "33:3" -"minecraft:piston[facing=west,extended=false]": "33:4" -"minecraft:piston[facing=east,extended=false]": "33:5" -"minecraft:piston[facing=down,extended=true]": "33:8" -"minecraft:piston[facing=up,extended=true]": "33:9" -"minecraft:piston[facing=north,extended=true]": "33:10" -"minecraft:piston[facing=south,extended=true]": "33:11" -"minecraft:piston[facing=west,extended=true]": "33:12" -"minecraft:piston[facing=east,extended=true]": "33:13" -"minecraft:piston_head[short=false,facing=down,type=normal]": "34:0" -"minecraft:piston_head[short=false,facing=up,type=normal]": "34:1" -"minecraft:piston_head[short=false,facing=north,type=normal]": "34:2" -"minecraft:piston_head[short=false,facing=south,type=normal]": "34:3" -"minecraft:piston_head[short=false,facing=west,type=normal]": "34:4" -"minecraft:piston_head[short=false,facing=east,type=normal]": "34:5" -"minecraft:piston_head[short=false,facing=down,type=sticky]": "34:8" -"minecraft:piston_head[short=false,facing=up,type=sticky]": "34:9" -"minecraft:piston_head[short=false,facing=north,type=sticky]": "34:10" -"minecraft:piston_head[short=false,facing=south,type=sticky]": "34:11" -"minecraft:piston_head[short=false,facing=west,type=sticky]": "34:12" -"minecraft:piston_head[short=false,facing=east,type=sticky]": "34:13" -"minecraft:white_wool": "35:0" -"minecraft:orange_wool": "35:1" -"minecraft:magenta_wool": "35:2" -"minecraft:light_blue_wool": "35:3" -"minecraft:yellow_wool": "35:4" -"minecraft:lime_wool": "35:5" -"minecraft:pink_wool": "35:6" -"minecraft:gray_wool": "35:7" -"minecraft:light_gray_wool": "35:8" -"minecraft:cyan_wool": "35:9" -"minecraft:purple_wool": "35:10" -"minecraft:blue_wool": "35:11" -"minecraft:brown_wool": "35:12" -"minecraft:green_wool": "35:13" -"minecraft:red_wool": "35:14" -"minecraft:black_wool": "35:15" -"minecraft:moving_piston[facing=down,type=normal]": "36:0" -"minecraft:moving_piston[facing=up,type=normal]": "36:1" -"minecraft:moving_piston[facing=north,type=normal]": "36:2" -"minecraft:moving_piston[facing=south,type=normal]": "36:3" -"minecraft:moving_piston[facing=west,type=normal]": "36:4" -"minecraft:moving_piston[facing=east,type=normal]": "36:5" -"minecraft:moving_piston[facing=down,type=sticky]": "36:8" -"minecraft:moving_piston[facing=up,type=sticky]": "36:9" -"minecraft:moving_piston[facing=north,type=sticky]": "36:10" -"minecraft:moving_piston[facing=south,type=sticky]": "36:11" -"minecraft:moving_piston[facing=west,type=sticky]": "36:12" -"minecraft:moving_piston[facing=east,type=sticky]": "36:13" -"minecraft:dandelion": "37:0" -"minecraft:poppy": "38:0" -"minecraft:blue_orchid": "38:1" -"minecraft:allium": "38:2" -"minecraft:azure_bluet": "38:3" -"minecraft:red_tulip": "38:4" -"minecraft:orange_tulip": "38:5" -"minecraft:white_tulip": "38:6" -"minecraft:pink_tulip": "38:7" -"minecraft:oxeye_daisy": "38:8" -"minecraft:brown_mushroom": "39:0" -"minecraft:red_mushroom": "40:0" -"minecraft:gold_block": "41:0" -"minecraft:iron_block": "42:0" -"minecraft:stone_slab[type=double]": "43:0" -"minecraft:sandstone_slab[type=double]": "43:1" -"minecraft:petrified_oak_slab[type=double]": "43:2" -"minecraft:cobblestone_slab[type=double]": "43:3" -"minecraft:brick_slab[type=double]": "43:4" -"minecraft:stone_brick_slab[type=double]": "43:5" -"minecraft:nether_brick_slab[type=double]": "43:6" -"minecraft:quartz_slab[type=double]": "43:7" -"minecraft:smooth_stone": "43:8" -"minecraft:smooth_sandstone": "43:9" -"minecraft:smooth_quartz": "43:15" -"minecraft:stone_slab[type=bottom]": "44:0" -"minecraft:sandstone_slab[type=bottom]": "44:1" -"minecraft:petrified_oak_slab[type=bottom]": "44:2" -"minecraft:cobblestone_slab[type=bottom]": "44:3" -"minecraft:brick_slab[type=bottom]": "44:4" -"minecraft:stone_brick_slab[type=bottom]": "44:5" -"minecraft:nether_brick_slab[type=bottom]": "44:6" -"minecraft:quartz_slab[type=bottom]": "44:7" -"minecraft:stone_slab[type=top]": "44:8" -"minecraft:sandstone_slab[type=top]": "44:9" -"minecraft:petrified_oak_slab[type=top]": "44:10" -"minecraft:cobblestone_slab[type=top]": "44:11" -"minecraft:brick_slab[type=top]": "44:12" -"minecraft:stone_brick_slab[type=top]": "44:13" -"minecraft:nether_brick_slab[type=top]": "44:14" -"minecraft:quartz_slab[type=top]": "44:15" -"minecraft:bricks": "45:0" -"minecraft:tnt[unstable=false]": "46:0" -"minecraft:tnt[unstable=true]": "46:1" -"minecraft:bookshelf": "47:0" -"minecraft:mossy_cobblestone": "48:0" -"minecraft:obsidian": "49:0" -"minecraft:torch": "50:0" -"minecraft:wall_torch[facing=east]": "50:1" -"minecraft:wall_torch[facing=west]": "50:2" -"minecraft:wall_torch[facing=south]": "50:3" -"minecraft:wall_torch[facing=north]": "50:4" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=0]": "51:0" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=1]": "51:1" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=2]": "51:2" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=3]": "51:3" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=4]": "51:4" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=5]": "51:5" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=6]": "51:6" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=7]": "51:7" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=8]": "51:8" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=9]": "51:9" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=10]": "51:10" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=11]": "51:11" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=12]": "51:12" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=13]": "51:13" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=14]": "51:14" -"minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=15]": "51:15" -"minecraft:spawner": "52:0" -"minecraft:oak_stairs[half=bottom,shape=outer_right,facing=east]": "53:0" -"minecraft:oak_stairs[half=bottom,shape=outer_right,facing=west]": "53:1" -"minecraft:oak_stairs[half=bottom,shape=outer_right,facing=south]": "53:2" -"minecraft:oak_stairs[half=bottom,shape=outer_right,facing=north]": "53:3" -"minecraft:oak_stairs[half=top,shape=outer_right,facing=east]": "53:4" -"minecraft:oak_stairs[half=top,shape=outer_right,facing=west]": "53:5" -"minecraft:oak_stairs[half=top,shape=outer_right,facing=south]": "53:6" -"minecraft:oak_stairs[half=top,shape=outer_right,facing=north]": "53:7" -"minecraft:chest": "54:0" -"minecraft:chest[facing=north,type=single]": "54:2" -"minecraft:chest[facing=south,type=single]": "54:3" -"minecraft:chest[facing=west,type=single]": "54:4" -"minecraft:chest[facing=east,type=single]": "54:5" -"minecraft:chest[facing=north]": "54:10" -"minecraft:chest[facing=south]": "54:11" -"minecraft:chest[facing=west]": "54:12" -"minecraft:chest[facing=east]": "54:13" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=0]": "55:0" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=1]": "55:1" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=2]": "55:2" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=3]": "55:3" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=4]": "55:4" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=5]": "55:5" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=6]": "55:6" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=7]": "55:7" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=8]": "55:8" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=9]": "55:9" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=10]": "55:10" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=11]": "55:11" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=12]": "55:12" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=13]": "55:13" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=14]": "55:14" -"minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=15]": "55:15" -"minecraft:diamond_ore": "56:0" -"minecraft:diamond_block": "57:0" -"minecraft:crafting_table": "58:0" -"minecraft:wheat[age=0]": "59:0" -"minecraft:wheat[age=1]": "59:1" -"minecraft:wheat[age=2]": "59:2" -"minecraft:wheat[age=3]": "59:3" -"minecraft:wheat[age=4]": "59:4" -"minecraft:wheat[age=5]": "59:5" -"minecraft:wheat[age=6]": "59:6" -"minecraft:wheat[age=7]": "59:7" -"minecraft:farmland[moisture=0]": "60:0" -"minecraft:farmland[moisture=1]": "60:1" -"minecraft:farmland[moisture=2]": "60:2" -"minecraft:farmland[moisture=3]": "60:3" -"minecraft:farmland[moisture=4]": "60:4" -"minecraft:farmland[moisture=5]": "60:5" -"minecraft:farmland[moisture=6]": "60:6" -"minecraft:farmland[moisture=7]": "60:7" -"minecraft:furnace": "61:0" -"minecraft:furnace[facing=north,lit=false]": "61:2" -"minecraft:furnace[facing=south,lit=false]": "61:3" -"minecraft:furnace[facing=west,lit=false]": "61:4" -"minecraft:furnace[facing=east,lit=false]": "61:5" -"minecraft:furnace[lit=true]": "62:0" -"minecraft:furnace[facing=north,lit=true]": "62:2" -"minecraft:furnace[facing=south,lit=true]": "62:3" -"minecraft:furnace[facing=west,lit=true]": "62:4" -"minecraft:furnace[facing=east,lit=true]": "62:5" -"minecraft:oak_sign[rotation=0]": "63:0" -"minecraft:oak_sign[rotation=1]": "63:1" -"minecraft:oak_sign[rotation=2]": "63:2" -"minecraft:oak_sign[rotation=3]": "63:3" -"minecraft:oak_sign[rotation=4]": "63:4" -"minecraft:oak_sign[rotation=5]": "63:5" -"minecraft:oak_sign[rotation=6]": "63:6" -"minecraft:oak_sign[rotation=7]": "63:7" -"minecraft:oak_sign[rotation=8]": "63:8" -"minecraft:oak_sign[rotation=9]": "63:9" -"minecraft:oak_sign[rotation=10]": "63:10" -"minecraft:oak_sign[rotation=11]": "63:11" -"minecraft:oak_sign[rotation=12]": "63:12" -"minecraft:oak_sign[rotation=13]": "63:13" -"minecraft:oak_sign[rotation=14]": "63:14" -"minecraft:oak_sign[rotation=15]": "63:15" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "64:0" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "64:1" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "64:2" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "64:3" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "64:4" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "64:5" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "64:6" -"minecraft:oak_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "64:7" -"minecraft:oak_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "64:8" -"minecraft:oak_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "64:9" -"minecraft:oak_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "64:10" -"minecraft:oak_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "64:11" -"minecraft:ladder": "65:0" -"minecraft:ladder[facing=north]": "65:2" -"minecraft:ladder[facing=south]": "65:3" -"minecraft:ladder[facing=west]": "65:4" -"minecraft:ladder[facing=east]": "65:5" -"minecraft:rail[shape=north_south]": "66:0" -"minecraft:rail[shape=east_west]": "66:1" -"minecraft:rail[shape=ascending_east]": "66:2" -"minecraft:rail[shape=ascending_west]": "66:3" -"minecraft:rail[shape=ascending_north]": "66:4" -"minecraft:rail[shape=ascending_south]": "66:5" -"minecraft:rail[shape=south_east]": "66:6" -"minecraft:rail[shape=south_west]": "66:7" -"minecraft:rail[shape=north_west]": "66:8" -"minecraft:rail[shape=north_east]": "66:9" -"minecraft:cobblestone_stairs[half=bottom,shape=straight,facing=east]": "67:0" -"minecraft:cobblestone_stairs[half=bottom,shape=straight,facing=west]": "67:1" -"minecraft:cobblestone_stairs[half=bottom,shape=straight,facing=south]": "67:2" -"minecraft:cobblestone_stairs[half=bottom,shape=straight,facing=north]": "67:3" -"minecraft:cobblestone_stairs[half=top,shape=straight,facing=east]": "67:4" -"minecraft:cobblestone_stairs[half=top,shape=straight,facing=west]": "67:5" -"minecraft:cobblestone_stairs[half=top,shape=straight,facing=south]": "67:6" -"minecraft:cobblestone_stairs[half=top,shape=straight,facing=north]": "67:7" -"minecraft:oak_wall_sign": "68:0" -"minecraft:oak_wall_sign[facing=north]": "68:2" -"minecraft:oak_wall_sign[facing=south]": "68:3" -"minecraft:oak_wall_sign[facing=west]": "68:4" -"minecraft:oak_wall_sign[facing=east]": "68:5" -"minecraft:lever[powered=false,facing=north,face=ceiling]": "69:0" -"minecraft:lever[powered=false,facing=east,face=wall]": "69:1" -"minecraft:lever[powered=false,facing=west,face=wall]": "69:2" -"minecraft:lever[powered=false,facing=south,face=wall]": "69:3" -"minecraft:lever[powered=false,facing=north,face=wall]": "69:4" -"minecraft:lever[powered=false,facing=east,face=floor]": "69:5" -"minecraft:lever[powered=false,facing=north,face=floor]": "69:6" -"minecraft:lever[powered=false,facing=east,face=ceiling]": "69:7" -"minecraft:lever[powered=true,facing=north,face=ceiling]": "69:8" -"minecraft:lever[powered=true,facing=east,face=wall]": "69:9" -"minecraft:lever[powered=true,facing=west,face=wall]": "69:10" -"minecraft:lever[powered=true,facing=south,face=wall]": "69:11" -"minecraft:lever[powered=true,facing=north,face=wall]": "69:12" -"minecraft:lever[powered=true,facing=east,face=floor]": "69:13" -"minecraft:lever[powered=true,facing=north,face=floor]": "69:14" -"minecraft:lever[powered=true,facing=east,face=ceiling]": "69:15" -"minecraft:stone_pressure_plate[powered=false]": "70:0" -"minecraft:stone_pressure_plate[powered=true]": "70:1" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "71:0" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "71:1" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "71:2" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "71:3" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "71:4" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "71:5" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "71:6" -"minecraft:iron_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "71:7" -"minecraft:iron_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "71:8" -"minecraft:iron_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "71:9" -"minecraft:iron_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "71:10" -"minecraft:iron_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "71:11" -"minecraft:oak_pressure_plate[powered=false]": "72:0" -"minecraft:oak_pressure_plate[powered=true]": "72:1" -"minecraft:redstone_ore[lit=false]": "73:0" -"minecraft:redstone_ore[lit=true]": "74:0" -"minecraft:redstone_torch[lit=false]": "75:0" -"minecraft:redstone_wall_torch[facing=east,lit=false]": "75:1" -"minecraft:redstone_wall_torch[facing=west,lit=false]": "75:2" -"minecraft:redstone_wall_torch[facing=south,lit=false]": "75:3" -"minecraft:redstone_wall_torch[facing=north,lit=false]": "75:4" -"minecraft:redstone_wall_torch[lit=false]": "75:13" -"minecraft:redstone_torch[lit=true]": "76:0" -"minecraft:redstone_wall_torch[facing=east,lit=true]": "76:1" -"minecraft:redstone_wall_torch[facing=west,lit=true]": "76:2" -"minecraft:redstone_wall_torch[facing=south,lit=true]": "76:3" -"minecraft:redstone_wall_torch[facing=north,lit=true]": "76:4" -"minecraft:redstone_wall_torch[lit=true]": "76:5" -"minecraft:stone_button[powered=false,facing=east,face=ceiling]": "77:0" -"minecraft:stone_button[powered=false,facing=east,face=wall]": "77:1" -"minecraft:stone_button[powered=false,facing=west,face=wall]": "77:2" -"minecraft:stone_button[powered=false,facing=south,face=wall]": "77:3" -"minecraft:stone_button[powered=false,facing=north,face=wall]": "77:4" -"minecraft:stone_button[powered=false,facing=east,face=floor]": "77:5" -"minecraft:stone_button[powered=true,facing=south,face=ceiling]": "77:8" -"minecraft:stone_button[powered=true,facing=east,face=wall]": "77:9" -"minecraft:stone_button[powered=true,facing=west,face=wall]": "77:10" -"minecraft:stone_button[powered=true,facing=south,face=wall]": "77:11" -"minecraft:stone_button[powered=true,facing=north,face=wall]": "77:12" -"minecraft:stone_button[powered=true,facing=south,face=floor]": "77:13" -"minecraft:snow[layers=1]": "78:0" -"minecraft:snow[layers=2]": "78:1" -"minecraft:snow[layers=3]": "78:2" -"minecraft:snow[layers=4]": "78:3" -"minecraft:snow[layers=5]": "78:4" -"minecraft:snow[layers=6]": "78:5" -"minecraft:snow[layers=7]": "78:6" -"minecraft:snow[layers=8]": "78:7" -"minecraft:ice": "79:0" -"minecraft:snow_block": "80:0" -"minecraft:cactus[age=0]": "81:0" -"minecraft:cactus[age=1]": "81:1" -"minecraft:cactus[age=2]": "81:2" -"minecraft:cactus[age=3]": "81:3" -"minecraft:cactus[age=4]": "81:4" -"minecraft:cactus[age=5]": "81:5" -"minecraft:cactus[age=6]": "81:6" -"minecraft:cactus[age=7]": "81:7" -"minecraft:cactus[age=8]": "81:8" -"minecraft:cactus[age=9]": "81:9" -"minecraft:cactus[age=10]": "81:10" -"minecraft:cactus[age=11]": "81:11" -"minecraft:cactus[age=12]": "81:12" -"minecraft:cactus[age=13]": "81:13" -"minecraft:cactus[age=14]": "81:14" -"minecraft:cactus[age=15]": "81:15" -"minecraft:clay": "82:0" -"minecraft:sugar_cane[age=0]": "83:0" -"minecraft:sugar_cane[age=1]": "83:1" -"minecraft:sugar_cane[age=2]": "83:2" -"minecraft:sugar_cane[age=3]": "83:3" -"minecraft:sugar_cane[age=4]": "83:4" -"minecraft:sugar_cane[age=5]": "83:5" -"minecraft:sugar_cane[age=6]": "83:6" -"minecraft:sugar_cane[age=7]": "83:7" -"minecraft:sugar_cane[age=8]": "83:8" -"minecraft:sugar_cane[age=9]": "83:9" -"minecraft:sugar_cane[age=10]": "83:10" -"minecraft:sugar_cane[age=11]": "83:11" -"minecraft:sugar_cane[age=12]": "83:12" -"minecraft:sugar_cane[age=13]": "83:13" -"minecraft:sugar_cane[age=14]": "83:14" -"minecraft:sugar_cane[age=15]": "83:15" -"minecraft:jukebox[has_record=false]": "84:0" -"minecraft:jukebox[has_record=true]": "84:1" -"minecraft:oak_fence[east=false,south=false,north=false,west=false]": "85:0" -"minecraft:carved_pumpkin[facing=south]": "86:0" -"minecraft:carved_pumpkin[facing=west]": "86:1" -"minecraft:carved_pumpkin[facing=north]": "86:2" -"minecraft:carved_pumpkin[facing=east]": "86:3" -"minecraft:netherrack": "87:0" -"minecraft:soul_sand": "88:0" -"minecraft:glowstone": "89:0" -"minecraft:nether_portal": "90:0" -"minecraft:nether_portal[axis=x]": "90:1" -"minecraft:nether_portal[axis=z]": "90:2" -"minecraft:jack_o_lantern[facing=south]": "91:0" -"minecraft:jack_o_lantern[facing=west]": "91:1" -"minecraft:jack_o_lantern[facing=north]": "91:2" -"minecraft:jack_o_lantern[facing=east]": "91:3" -"minecraft:cake[bites=0]": "92:0" -"minecraft:cake[bites=1]": "92:1" -"minecraft:cake[bites=2]": "92:2" -"minecraft:cake[bites=3]": "92:3" -"minecraft:cake[bites=4]": "92:4" -"minecraft:cake[bites=5]": "92:5" -"minecraft:cake[bites=6]": "92:6" -"minecraft:repeater[delay=1,facing=south,locked=false,powered=false]": "93:0" -"minecraft:repeater[delay=1,facing=west,locked=false,powered=false]": "93:1" -"minecraft:repeater[delay=1,facing=north,locked=false,powered=false]": "93:2" -"minecraft:repeater[delay=1,facing=east,locked=false,powered=false]": "93:3" -"minecraft:repeater[delay=2,facing=south,locked=false,powered=false]": "93:4" -"minecraft:repeater[delay=2,facing=west,locked=false,powered=false]": "93:5" -"minecraft:repeater[delay=2,facing=north,locked=false,powered=false]": "93:6" -"minecraft:repeater[delay=2,facing=east,locked=false,powered=false]": "93:7" -"minecraft:repeater[delay=3,facing=south,locked=false,powered=false]": "93:8" -"minecraft:repeater[delay=3,facing=west,locked=false,powered=false]": "93:9" -"minecraft:repeater[delay=3,facing=north,locked=false,powered=false]": "93:10" -"minecraft:repeater[delay=3,facing=east,locked=false,powered=false]": "93:11" -"minecraft:repeater[delay=4,facing=south,locked=false,powered=false]": "93:12" -"minecraft:repeater[delay=4,facing=west,locked=false,powered=false]": "93:13" -"minecraft:repeater[delay=4,facing=north,locked=false,powered=false]": "93:14" -"minecraft:repeater[delay=4,facing=east,locked=false,powered=false]": "93:15" -"minecraft:repeater[delay=1,facing=south,locked=false,powered=true]": "94:0" -"minecraft:repeater[delay=1,facing=west,locked=false,powered=true]": "94:1" -"minecraft:repeater[delay=1,facing=north,locked=false,powered=true]": "94:2" -"minecraft:repeater[delay=1,facing=east,locked=false,powered=true]": "94:3" -"minecraft:repeater[delay=2,facing=south,locked=false,powered=true]": "94:4" -"minecraft:repeater[delay=2,facing=west,locked=false,powered=true]": "94:5" -"minecraft:repeater[delay=2,facing=north,locked=false,powered=true]": "94:6" -"minecraft:repeater[delay=2,facing=east,locked=false,powered=true]": "94:7" -"minecraft:repeater[delay=3,facing=south,locked=false,powered=true]": "94:8" -"minecraft:repeater[delay=3,facing=west,locked=false,powered=true]": "94:9" -"minecraft:repeater[delay=3,facing=north,locked=false,powered=true]": "94:10" -"minecraft:repeater[delay=3,facing=east,locked=false,powered=true]": "94:11" -"minecraft:repeater[delay=4,facing=south,locked=false,powered=true]": "94:12" -"minecraft:repeater[delay=4,facing=west,locked=false,powered=true]": "94:13" -"minecraft:repeater[delay=4,facing=north,locked=false,powered=true]": "94:14" -"minecraft:repeater[delay=4,facing=east,locked=false,powered=true]": "94:15" -"minecraft:white_stained_glass": "95:0" -"minecraft:orange_stained_glass": "95:1" -"minecraft:magenta_stained_glass": "95:2" -"minecraft:light_blue_stained_glass": "95:3" -"minecraft:yellow_stained_glass": "95:4" -"minecraft:lime_stained_glass": "95:5" -"minecraft:pink_stained_glass": "95:6" -"minecraft:gray_stained_glass": "95:7" -"minecraft:light_gray_stained_glass": "95:8" -"minecraft:cyan_stained_glass": "95:9" -"minecraft:purple_stained_glass": "95:10" -"minecraft:blue_stained_glass": "95:11" -"minecraft:brown_stained_glass": "95:12" -"minecraft:green_stained_glass": "95:13" -"minecraft:red_stained_glass": "95:14" -"minecraft:black_stained_glass": "95:15" -"minecraft:oak_trapdoor[half=bottom,facing=north,open=false,powered=false]": "96:0" -"minecraft:oak_trapdoor[half=bottom,facing=south,open=false,powered=false]": "96:1" -"minecraft:oak_trapdoor[half=bottom,facing=west,open=false,powered=false]": "96:2" -"minecraft:oak_trapdoor[half=bottom,facing=east,open=false,powered=false]": "96:3" -"minecraft:oak_trapdoor[half=bottom,facing=north,open=true,powered=true]": "96:4" -"minecraft:oak_trapdoor[half=bottom,facing=south,open=true,powered=true]": "96:5" -"minecraft:oak_trapdoor[half=bottom,facing=west,open=true,powered=true]": "96:6" -"minecraft:oak_trapdoor[half=bottom,facing=east,open=true,powered=true]": "96:7" -"minecraft:oak_trapdoor[half=top,facing=north,open=false,powered=false]": "96:8" -"minecraft:oak_trapdoor[half=top,facing=south,open=false,powered=false]": "96:9" -"minecraft:oak_trapdoor[half=top,facing=west,open=false,powered=false]": "96:10" -"minecraft:oak_trapdoor[half=top,facing=east,open=false,powered=false]": "96:11" -"minecraft:oak_trapdoor[half=top,facing=north,open=true,powered=true]": "96:12" -"minecraft:oak_trapdoor[half=top,facing=south,open=true,powered=true]": "96:13" -"minecraft:oak_trapdoor[half=top,facing=west,open=true,powered=true]": "96:14" -"minecraft:oak_trapdoor[half=top,facing=east,open=true,powered=true]": "96:15" -"minecraft:infested_stone": "97:0" -"minecraft:infested_cobblestone": "97:1" -"minecraft:infested_stone_bricks": "97:2" -"minecraft:infested_mossy_stone_bricks": "97:3" -"minecraft:infested_cracked_stone_bricks": "97:4" -"minecraft:infested_chiseled_stone_bricks": "97:5" -"minecraft:stone_bricks": "98:0" -"minecraft:mossy_stone_bricks": "98:1" -"minecraft:cracked_stone_bricks": "98:2" -"minecraft:chiseled_stone_bricks": "98:3" -"minecraft:brown_mushroom_block[north=false,east=false,south=false,west=false,up=false,down=false]": "99:0" -"minecraft:brown_mushroom_block[north=true,east=false,south=false,west=true,up=true,down=false]": "99:1" -"minecraft:brown_mushroom_block[north=true,east=false,south=false,west=false,up=true,down=false]": "99:2" -"minecraft:brown_mushroom_block[north=true,east=true,south=false,west=false,up=true,down=false]": "99:3" -"minecraft:brown_mushroom_block[north=false,east=false,south=false,west=true,up=true,down=false]": "99:4" -"minecraft:brown_mushroom_block[north=false,east=false,south=false,west=false,up=true,down=false]": "99:5" -"minecraft:brown_mushroom_block[north=false,east=true,south=false,west=false,up=true,down=false]": "99:6" -"minecraft:brown_mushroom_block[north=false,east=false,south=true,west=true,up=true,down=false]": "99:7" -"minecraft:brown_mushroom_block[north=false,east=false,south=true,west=false,up=true,down=false]": "99:8" -"minecraft:brown_mushroom_block[north=false,east=true,south=true,west=false,up=true,down=false]": "99:9" -"minecraft:mushroom_stem[north=true,east=true,south=true,west=true,up=false,down=false]": "99:10" -"minecraft:brown_mushroom_block[north=true,east=true,south=true,west=true,up=true,down=true]": "99:14" -"minecraft:mushroom_stem[north=true,east=true,south=true,west=true,up=true,down=true]": "99:15" -"minecraft:red_mushroom_block[north=false,east=false,south=false,west=false,up=false,down=false]": "100:0" -"minecraft:red_mushroom_block[north=true,east=false,south=false,west=true,up=true,down=false]": "100:1" -"minecraft:red_mushroom_block[north=true,east=false,south=false,west=false,up=true,down=false]": "100:2" -"minecraft:red_mushroom_block[north=true,east=true,south=false,west=false,up=true,down=false]": "100:3" -"minecraft:red_mushroom_block[north=false,east=false,south=false,west=true,up=true,down=false]": "100:4" -"minecraft:red_mushroom_block[north=false,east=false,south=false,west=false,up=true,down=false]": "100:5" -"minecraft:red_mushroom_block[north=false,east=true,south=false,west=false,up=true,down=false]": "100:6" -"minecraft:red_mushroom_block[north=false,east=false,south=true,west=true,up=true,down=false]": "100:7" -"minecraft:red_mushroom_block[north=false,east=false,south=true,west=false,up=true,down=false]": "100:8" -"minecraft:red_mushroom_block[north=false,east=true,south=true,west=false,up=true,down=false]": "100:9" -"minecraft:red_mushroom_block[north=true,east=true,south=true,west=true,up=true,down=true]": "100:14" -"minecraft:iron_bars[east=false,south=false,north=false,west=false]": "101:0" -"minecraft:glass_pane[east=false,south=false,north=false,west=false]": "102:0" -"minecraft:melon": "103:0" -"minecraft:pumpkin_stem[age=0]": "104:0" -"minecraft:pumpkin_stem[age=1]": "104:1" -"minecraft:pumpkin_stem[age=2]": "104:2" -"minecraft:pumpkin_stem[age=3]": "104:3" -"minecraft:pumpkin_stem[age=4]": "104:4" -"minecraft:pumpkin_stem[age=5]": "104:5" -"minecraft:pumpkin_stem[age=6]": "104:6" -"minecraft:pumpkin_stem[age=7]": "104:7" -"minecraft:melon_stem[age=0]": "105:0" -"minecraft:melon_stem[age=1]": "105:1" -"minecraft:melon_stem[age=2]": "105:2" -"minecraft:melon_stem[age=3]": "105:3" -"minecraft:melon_stem[age=4]": "105:4" -"minecraft:melon_stem[age=5]": "105:5" -"minecraft:melon_stem[age=6]": "105:6" -"minecraft:melon_stem[age=7]": "105:7" -"minecraft:vine[east=false,south=false,north=false,west=false,up=false]": "106:0" -"minecraft:vine[east=false,south=true,north=false,west=false,up=false]": "106:1" -"minecraft:vine[east=false,south=false,north=false,west=true,up=false]": "106:2" -"minecraft:vine[east=false,south=true,north=false,west=true,up=false]": "106:3" -"minecraft:vine[east=false,south=false,north=true,west=false,up=false]": "106:4" -"minecraft:vine[east=false,south=true,north=true,west=false,up=false]": "106:5" -"minecraft:vine[east=false,south=false,north=true,west=true,up=false]": "106:6" -"minecraft:vine[east=false,south=true,north=true,west=true,up=false]": "106:7" -"minecraft:vine[east=true,south=false,north=false,west=false,up=false]": "106:8" -"minecraft:vine[east=true,south=true,north=false,west=false,up=false]": "106:9" -"minecraft:vine[east=true,south=false,north=false,west=true,up=false]": "106:10" -"minecraft:vine[east=true,south=true,north=false,west=true,up=false]": "106:11" -"minecraft:vine[east=true,south=false,north=true,west=false,up=false]": "106:12" -"minecraft:vine[east=true,south=true,north=true,west=false,up=false]": "106:13" -"minecraft:vine[east=true,south=false,north=true,west=true,up=false]": "106:14" -"minecraft:vine[east=true,south=true,north=true,west=true,up=false]": "106:15" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "107:0" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "107:1" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "107:2" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "107:3" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "107:4" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "107:5" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "107:6" -"minecraft:oak_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "107:7" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "107:8" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "107:9" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "107:10" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "107:11" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "107:12" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "107:13" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "107:14" -"minecraft:oak_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "107:15" -"minecraft:brick_stairs[half=bottom,shape=straight,facing=east]": "108:0" -"minecraft:brick_stairs[half=bottom,shape=straight,facing=west]": "108:1" -"minecraft:brick_stairs[half=bottom,shape=straight,facing=south]": "108:2" -"minecraft:brick_stairs[half=bottom,shape=straight,facing=north]": "108:3" -"minecraft:brick_stairs[half=top,shape=straight,facing=east]": "108:4" -"minecraft:brick_stairs[half=top,shape=straight,facing=west]": "108:5" -"minecraft:brick_stairs[half=top,shape=straight,facing=south]": "108:6" -"minecraft:brick_stairs[half=top,shape=straight,facing=north]": "108:7" -"minecraft:stone_brick_stairs[half=bottom,shape=straight,facing=east]": "109:0" -"minecraft:stone_brick_stairs[half=bottom,shape=straight,facing=west]": "109:1" -"minecraft:stone_brick_stairs[half=bottom,shape=straight,facing=south]": "109:2" -"minecraft:stone_brick_stairs[half=bottom,shape=straight,facing=north]": "109:3" -"minecraft:stone_brick_stairs[half=top,shape=straight,facing=east]": "109:4" -"minecraft:stone_brick_stairs[half=top,shape=straight,facing=west]": "109:5" -"minecraft:stone_brick_stairs[half=top,shape=straight,facing=south]": "109:6" -"minecraft:stone_brick_stairs[half=top,shape=straight,facing=north]": "109:7" -"minecraft:mycelium[snowy=false]": "110:0" -"minecraft:lily_pad": "111:0" -"minecraft:nether_bricks": "112:0" -"minecraft:nether_brick_fence[east=false,south=false,north=false,west=false]": "113:0" -"minecraft:nether_brick_stairs[half=bottom,shape=straight,facing=east]": "114:0" -"minecraft:nether_brick_stairs[half=bottom,shape=straight,facing=west]": "114:1" -"minecraft:nether_brick_stairs[half=bottom,shape=straight,facing=south]": "114:2" -"minecraft:nether_brick_stairs[half=bottom,shape=straight,facing=north]": "114:3" -"minecraft:nether_brick_stairs[half=top,shape=straight,facing=east]": "114:4" -"minecraft:nether_brick_stairs[half=top,shape=straight,facing=west]": "114:5" -"minecraft:nether_brick_stairs[half=top,shape=straight,facing=south]": "114:6" -"minecraft:nether_brick_stairs[half=top,shape=straight,facing=north]": "114:7" -"minecraft:nether_wart[age=0]": "115:0" -"minecraft:nether_wart[age=1]": "115:1" -"minecraft:nether_wart[age=2]": "115:2" -"minecraft:nether_wart[age=3]": "115:3" -"minecraft:enchanting_table": "116:0" -"minecraft:brewing_stand[has_bottle_0=false,has_bottle_1=false,has_bottle_2=false]": "117:0" -"minecraft:brewing_stand[has_bottle_0=true,has_bottle_1=false,has_bottle_2=false]": "117:1" -"minecraft:brewing_stand[has_bottle_0=false,has_bottle_1=true,has_bottle_2=false]": "117:2" -"minecraft:brewing_stand[has_bottle_0=true,has_bottle_1=true,has_bottle_2=false]": "117:3" -"minecraft:brewing_stand[has_bottle_0=false,has_bottle_1=false,has_bottle_2=true]": "117:4" -"minecraft:brewing_stand[has_bottle_0=true,has_bottle_1=false,has_bottle_2=true]": "117:5" -"minecraft:brewing_stand[has_bottle_0=false,has_bottle_1=true,has_bottle_2=true]": "117:6" -"minecraft:brewing_stand[has_bottle_0=true,has_bottle_1=true,has_bottle_2=true]": "117:7" -"minecraft:cauldron[level=0]": "118:0" -"minecraft:cauldron[level=1]": "118:1" -"minecraft:cauldron[level=2]": "118:2" -"minecraft:cauldron[level=3]": "118:3" -"minecraft:end_portal": "119:0" -"minecraft:end_portal_frame[eye=false,facing=south]": "120:0" -"minecraft:end_portal_frame[eye=false,facing=west]": "120:1" -"minecraft:end_portal_frame[eye=false,facing=north]": "120:2" -"minecraft:end_portal_frame[eye=false,facing=east]": "120:3" -"minecraft:end_portal_frame[eye=true,facing=south]": "120:4" -"minecraft:end_portal_frame[eye=true,facing=west]": "120:5" -"minecraft:end_portal_frame[eye=true,facing=north]": "120:6" -"minecraft:end_portal_frame[eye=true,facing=east]": "120:7" -"minecraft:end_stone": "121:0" -"minecraft:dragon_egg": "122:0" -"minecraft:redstone_lamp[lit=false]": "123:0" -"minecraft:redstone_lamp[lit=true]": "124:0" -"minecraft:oak_slab[type=double]": "125:0" -"minecraft:spruce_slab[type=double]": "125:1" -"minecraft:birch_slab[type=double]": "125:2" -"minecraft:jungle_slab[type=double]": "125:3" -"minecraft:acacia_slab[type=double]": "125:4" -"minecraft:dark_oak_slab[type=double]": "125:5" -"minecraft:oak_slab[type=bottom]": "126:0" -"minecraft:spruce_slab[type=bottom]": "126:1" -"minecraft:birch_slab[type=bottom]": "126:2" -"minecraft:jungle_slab[type=bottom]": "126:3" -"minecraft:acacia_slab[type=bottom]": "126:4" -"minecraft:dark_oak_slab[type=bottom]": "126:5" -"minecraft:oak_slab[type=top]": "126:8" -"minecraft:spruce_slab[type=top]": "126:9" -"minecraft:birch_slab[type=top]": "126:10" -"minecraft:jungle_slab[type=top]": "126:11" -"minecraft:acacia_slab[type=top]": "126:12" -"minecraft:dark_oak_slab[type=top]": "126:13" -"minecraft:cocoa[facing=south,age=0]": "127:0" -"minecraft:cocoa[facing=west,age=0]": "127:1" -"minecraft:cocoa[facing=north,age=0]": "127:2" -"minecraft:cocoa[facing=east,age=0]": "127:3" -"minecraft:cocoa[facing=south,age=1]": "127:4" -"minecraft:cocoa[facing=west,age=1]": "127:5" -"minecraft:cocoa[facing=north,age=1]": "127:6" -"minecraft:cocoa[facing=east,age=1]": "127:7" -"minecraft:cocoa[facing=south,age=2]": "127:8" -"minecraft:cocoa[facing=west,age=2]": "127:9" -"minecraft:cocoa[facing=north,age=2]": "127:10" -"minecraft:cocoa[facing=east,age=2]": "127:11" -"minecraft:sandstone_stairs[half=bottom,shape=straight,facing=east]": "128:0" -"minecraft:sandstone_stairs[half=bottom,shape=straight,facing=west]": "128:1" -"minecraft:sandstone_stairs[half=bottom,shape=straight,facing=south]": "128:2" -"minecraft:sandstone_stairs[half=bottom,shape=straight,facing=north]": "128:3" -"minecraft:sandstone_stairs[half=top,shape=straight,facing=east]": "128:4" -"minecraft:sandstone_stairs[half=top,shape=straight,facing=west]": "128:5" -"minecraft:sandstone_stairs[half=top,shape=straight,facing=south]": "128:6" -"minecraft:sandstone_stairs[half=top,shape=straight,facing=north]": "128:7" -"minecraft:emerald_ore": "129:0" -"minecraft:ender_chest": "130:0" -"minecraft:ender_chest[facing=north]": "130:2" -"minecraft:ender_chest[facing=south]": "130:3" -"minecraft:ender_chest[facing=west]": "130:4" -"minecraft:ender_chest[facing=east]": "130:5" -"minecraft:tripwire_hook[powered=false,attached=false,facing=south]": "131:0" -"minecraft:tripwire_hook[powered=false,attached=false,facing=west]": "131:1" -"minecraft:tripwire_hook[powered=false,attached=false,facing=north]": "131:2" -"minecraft:tripwire_hook[powered=false,attached=false,facing=east]": "131:3" -"minecraft:tripwire_hook[powered=false,attached=true,facing=south]": "131:4" -"minecraft:tripwire_hook[powered=false,attached=true,facing=west]": "131:5" -"minecraft:tripwire_hook[powered=false,attached=true,facing=north]": "131:6" -"minecraft:tripwire_hook[powered=false,attached=true,facing=east]": "131:7" -"minecraft:tripwire_hook[powered=true,attached=false,facing=south]": "131:8" -"minecraft:tripwire_hook[powered=true,attached=false,facing=west]": "131:9" -"minecraft:tripwire_hook[powered=true,attached=false,facing=north]": "131:10" -"minecraft:tripwire_hook[powered=true,attached=false,facing=east]": "131:11" -"minecraft:tripwire_hook[powered=true,attached=true,facing=south]": "131:12" -"minecraft:tripwire_hook[powered=true,attached=true,facing=west]": "131:13" -"minecraft:tripwire_hook[powered=true,attached=true,facing=north]": "131:14" -"minecraft:tripwire_hook[powered=true,attached=true,facing=east]": "131:15" -"minecraft:tripwire[disarmed=false,east=false,powered=false,south=false,north=false,west=false,attached=false]": "132:0" -"minecraft:tripwire[disarmed=false,east=false,powered=true,south=false,north=false,west=false,attached=false]": "132:1" -"minecraft:tripwire[disarmed=false,east=false,powered=false,south=false,north=false,west=false,attached=true]": "132:4" -"minecraft:tripwire[disarmed=false,east=false,powered=true,south=false,north=false,west=false,attached=true]": "132:5" -"minecraft:tripwire[disarmed=true,east=false,powered=false,south=false,north=false,west=false,attached=false]": "132:8" -"minecraft:tripwire[disarmed=true,east=false,powered=true,south=false,north=false,west=false,attached=false]": "132:9" -"minecraft:tripwire[disarmed=true,east=false,powered=false,south=false,north=false,west=false,attached=true]": "132:12" -"minecraft:tripwire[disarmed=true,east=false,powered=true,south=false,north=false,west=false,attached=true]": "132:13" -"minecraft:emerald_block": "133:0" -"minecraft:spruce_stairs[half=bottom,shape=straight,facing=east]": "134:0" -"minecraft:spruce_stairs[half=bottom,shape=straight,facing=west]": "134:1" -"minecraft:spruce_stairs[half=bottom,shape=straight,facing=south]": "134:2" -"minecraft:spruce_stairs[half=bottom,shape=straight,facing=north]": "134:3" -"minecraft:spruce_stairs[half=top,shape=straight,facing=east]": "134:4" -"minecraft:spruce_stairs[half=top,shape=straight,facing=west]": "134:5" -"minecraft:spruce_stairs[half=top,shape=straight,facing=south]": "134:6" -"minecraft:spruce_stairs[half=top,shape=straight,facing=north]": "134:7" -"minecraft:birch_stairs[half=bottom,shape=straight,facing=east]": "135:0" -"minecraft:birch_stairs[half=bottom,shape=straight,facing=west]": "135:1" -"minecraft:birch_stairs[half=bottom,shape=straight,facing=south]": "135:2" -"minecraft:birch_stairs[half=bottom,shape=straight,facing=north]": "135:3" -"minecraft:birch_stairs[half=top,shape=straight,facing=east]": "135:4" -"minecraft:birch_stairs[half=top,shape=straight,facing=west]": "135:5" -"minecraft:birch_stairs[half=top,shape=straight,facing=south]": "135:6" -"minecraft:birch_stairs[half=top,shape=straight,facing=north]": "135:7" -"minecraft:jungle_stairs[half=bottom,shape=straight,facing=east]": "136:0" -"minecraft:jungle_stairs[half=bottom,shape=straight,facing=west]": "136:1" -"minecraft:jungle_stairs[half=bottom,shape=straight,facing=south]": "136:2" -"minecraft:jungle_stairs[half=bottom,shape=straight,facing=north]": "136:3" -"minecraft:jungle_stairs[half=top,shape=straight,facing=east]": "136:4" -"minecraft:jungle_stairs[half=top,shape=straight,facing=west]": "136:5" -"minecraft:jungle_stairs[half=top,shape=straight,facing=south]": "136:6" -"minecraft:jungle_stairs[half=top,shape=straight,facing=north]": "136:7" -"minecraft:command_block[conditional=false,facing=down]": "137:0" -"minecraft:command_block[conditional=false,facing=up]": "137:1" -"minecraft:command_block[conditional=false,facing=north]": "137:2" -"minecraft:command_block[conditional=false,facing=south]": "137:3" -"minecraft:command_block[conditional=false,facing=west]": "137:4" -"minecraft:command_block[conditional=false,facing=east]": "137:5" -"minecraft:command_block[conditional=true,facing=down]": "137:8" -"minecraft:command_block[conditional=true,facing=up]": "137:9" -"minecraft:command_block[conditional=true,facing=north]": "137:10" -"minecraft:command_block[conditional=true,facing=south]": "137:11" -"minecraft:command_block[conditional=true,facing=west]": "137:12" -"minecraft:command_block[conditional=true,facing=east]": "137:13" -"minecraft:beacon": "138:0" -"minecraft:cobblestone_wall[east=false,south=false,north=false,west=false,up=false]": "139:0" -"minecraft:mossy_cobblestone_wall[east=false,south=false,north=false,west=false,up=false]": "139:1" -"minecraft:flower_pot": "140:0" -"minecraft:potted_poppy": "140:1" -"minecraft:potted_dandelion": "140:2" -"minecraft:potted_oak_sapling": "140:3" -"minecraft:potted_spruce_sapling": "140:4" -"minecraft:potted_birch_sapling": "140:5" -"minecraft:potted_jungle_sapling": "140:6" -"minecraft:potted_red_mushroom": "140:7" -"minecraft:potted_brown_mushroom": "140:8" -"minecraft:potted_cactus": "140:9" -"minecraft:potted_dead_bush": "140:10" -"minecraft:potted_fern": "140:11" -"minecraft:potted_acacia_sapling": "140:12" -"minecraft:potted_dark_oak_sapling": "140:13" -"minecraft:potted_blue_orchid": "140:14" -"minecraft:potted_allium": "140:15" -"minecraft:carrots[age=0]": "141:0" -"minecraft:carrots[age=1]": "141:1" -"minecraft:carrots[age=2]": "141:2" -"minecraft:carrots[age=3]": "141:3" -"minecraft:carrots[age=4]": "141:4" -"minecraft:carrots[age=5]": "141:5" -"minecraft:carrots[age=6]": "141:6" -"minecraft:carrots[age=7]": "141:7" -"minecraft:potatoes[age=0]": "142:0" -"minecraft:potatoes[age=1]": "142:1" -"minecraft:potatoes[age=2]": "142:2" -"minecraft:potatoes[age=3]": "142:3" -"minecraft:potatoes[age=4]": "142:4" -"minecraft:potatoes[age=5]": "142:5" -"minecraft:potatoes[age=6]": "142:6" -"minecraft:potatoes[age=7]": "142:7" -"minecraft:oak_button[powered=false,facing=east,face=ceiling]": "143:0" -"minecraft:oak_button[powered=false,facing=east,face=wall]": "143:1" -"minecraft:oak_button[powered=false,facing=west,face=wall]": "143:2" -"minecraft:oak_button[powered=false,facing=south,face=wall]": "143:3" -"minecraft:oak_button[powered=false,facing=north,face=wall]": "143:4" -"minecraft:oak_button[powered=false,facing=east,face=floor]": "143:5" -"minecraft:oak_button[powered=true,facing=south,face=ceiling]": "143:8" -"minecraft:oak_button[powered=true,facing=east,face=wall]": "143:9" -"minecraft:oak_button[powered=true,facing=west,face=wall]": "143:10" -"minecraft:oak_button[powered=true,facing=south,face=wall]": "143:11" -"minecraft:oak_button[powered=true,facing=north,face=wall]": "143:12" -"minecraft:oak_button[powered=true,facing=south,face=floor]": "143:13" -"minecraft:skeleton_skull[rotation=0]": "144:0" -"minecraft:skeleton_skull[rotation=4]": "144:1" -"minecraft:skeleton_wall_skull[facing=north]": "144:2" -"minecraft:skeleton_wall_skull[facing=south]": "144:3" -"minecraft:skeleton_wall_skull[facing=west]": "144:4" -"minecraft:skeleton_wall_skull[facing=east]": "144:5" -"minecraft:skeleton_skull[rotation=8]": "144:8" -"minecraft:skeleton_skull[rotation=12]": "144:9" -"minecraft:anvil[facing=south]": "145:0" -"minecraft:anvil[facing=west]": "145:1" -"minecraft:anvil[facing=north]": "145:2" -"minecraft:anvil[facing=east]": "145:3" -"minecraft:chipped_anvil[facing=south]": "145:4" -"minecraft:chipped_anvil[facing=west]": "145:5" -"minecraft:chipped_anvil[facing=north]": "145:6" -"minecraft:chipped_anvil[facing=east]": "145:7" -"minecraft:damaged_anvil[facing=south]": "145:8" -"minecraft:damaged_anvil[facing=west]": "145:9" -"minecraft:damaged_anvil[facing=north]": "145:10" -"minecraft:damaged_anvil[facing=east]": "145:11" -"minecraft:trapped_chest": "146:0" -"minecraft:trapped_chest[facing=north,type=single]": "146:2" -"minecraft:trapped_chest[facing=south,type=single]": "146:3" -"minecraft:trapped_chest[facing=west,type=single]": "146:4" -"minecraft:trapped_chest[facing=east,type=single]": "146:5" -"minecraft:light_weighted_pressure_plate[power=0]": "147:0" -"minecraft:light_weighted_pressure_plate[power=1]": "147:1" -"minecraft:light_weighted_pressure_plate[power=2]": "147:2" -"minecraft:light_weighted_pressure_plate[power=3]": "147:3" -"minecraft:light_weighted_pressure_plate[power=4]": "147:4" -"minecraft:light_weighted_pressure_plate[power=5]": "147:5" -"minecraft:light_weighted_pressure_plate[power=6]": "147:6" -"minecraft:light_weighted_pressure_plate[power=7]": "147:7" -"minecraft:light_weighted_pressure_plate[power=8]": "147:8" -"minecraft:light_weighted_pressure_plate[power=9]": "147:9" -"minecraft:light_weighted_pressure_plate[power=10]": "147:10" -"minecraft:light_weighted_pressure_plate[power=11]": "147:11" -"minecraft:light_weighted_pressure_plate[power=12]": "147:12" -"minecraft:light_weighted_pressure_plate[power=13]": "147:13" -"minecraft:light_weighted_pressure_plate[power=14]": "147:14" -"minecraft:light_weighted_pressure_plate[power=15]": "147:15" -"minecraft:heavy_weighted_pressure_plate[power=0]": "148:0" -"minecraft:heavy_weighted_pressure_plate[power=1]": "148:1" -"minecraft:heavy_weighted_pressure_plate[power=2]": "148:2" -"minecraft:heavy_weighted_pressure_plate[power=3]": "148:3" -"minecraft:heavy_weighted_pressure_plate[power=4]": "148:4" -"minecraft:heavy_weighted_pressure_plate[power=5]": "148:5" -"minecraft:heavy_weighted_pressure_plate[power=6]": "148:6" -"minecraft:heavy_weighted_pressure_plate[power=7]": "148:7" -"minecraft:heavy_weighted_pressure_plate[power=8]": "148:8" -"minecraft:heavy_weighted_pressure_plate[power=9]": "148:9" -"minecraft:heavy_weighted_pressure_plate[power=10]": "148:10" -"minecraft:heavy_weighted_pressure_plate[power=11]": "148:11" -"minecraft:heavy_weighted_pressure_plate[power=12]": "148:12" -"minecraft:heavy_weighted_pressure_plate[power=13]": "148:13" -"minecraft:heavy_weighted_pressure_plate[power=14]": "148:14" -"minecraft:heavy_weighted_pressure_plate[power=15]": "148:15" -"minecraft:comparator[mode=compare,powered=false,facing=south]": "149:0" -"minecraft:comparator[mode=compare,powered=false,facing=west]": "149:1" -"minecraft:comparator[mode=compare,powered=false,facing=north]": "149:2" -"minecraft:comparator[mode=compare,powered=false,facing=east]": "149:3" -"minecraft:comparator[mode=subtract,powered=false,facing=south]": "149:4" -"minecraft:comparator[mode=subtract,powered=false,facing=west]": "149:5" -"minecraft:comparator[mode=subtract,powered=false,facing=north]": "149:6" -"minecraft:comparator[mode=subtract,powered=false,facing=east]": "149:7" -"minecraft:comparator[mode=compare,powered=true,facing=south]": "150:0" -"minecraft:comparator[mode=compare,powered=true,facing=west]": "150:1" -"minecraft:comparator[mode=compare,powered=true,facing=north]": "150:2" -"minecraft:comparator[mode=compare,powered=true,facing=east]": "150:3" -"minecraft:comparator[mode=subtract,powered=true,facing=south]": "150:4" -"minecraft:comparator[mode=subtract,powered=true,facing=west]": "150:5" -"minecraft:comparator[mode=subtract,powered=true,facing=north]": "150:6" -"minecraft:comparator[mode=subtract,powered=true,facing=east]": "150:7" -"minecraft:daylight_detector[inverted=false,power=0]": "151:0" -"minecraft:daylight_detector[inverted=false,power=1]": "151:1" -"minecraft:daylight_detector[inverted=false,power=2]": "151:2" -"minecraft:daylight_detector[inverted=false,power=3]": "151:3" -"minecraft:daylight_detector[inverted=false,power=4]": "151:4" -"minecraft:daylight_detector[inverted=false,power=5]": "151:5" -"minecraft:daylight_detector[inverted=false,power=6]": "151:6" -"minecraft:daylight_detector[inverted=false,power=7]": "151:7" -"minecraft:daylight_detector[inverted=false,power=8]": "151:8" -"minecraft:daylight_detector[inverted=false,power=9]": "151:9" -"minecraft:daylight_detector[inverted=false,power=10]": "151:10" -"minecraft:daylight_detector[inverted=false,power=11]": "151:11" -"minecraft:daylight_detector[inverted=false,power=12]": "151:12" -"minecraft:daylight_detector[inverted=false,power=13]": "151:13" -"minecraft:daylight_detector[inverted=false,power=14]": "151:14" -"minecraft:daylight_detector[inverted=false,power=15]": "151:15" -"minecraft:redstone_block": "152:0" -"minecraft:nether_quartz_ore": "153:0" -"minecraft:hopper[facing=down,enabled=true]": "154:0" -"minecraft:hopper[facing=north,enabled=true]": "154:2" -"minecraft:hopper[facing=south,enabled=true]": "154:3" -"minecraft:hopper[facing=west,enabled=true]": "154:4" -"minecraft:hopper[facing=east,enabled=true]": "154:5" -"minecraft:hopper[facing=down,enabled=false]": "154:8" -"minecraft:hopper[facing=north,enabled=false]": "154:10" -"minecraft:hopper[facing=south,enabled=false]": "154:11" -"minecraft:hopper[facing=west,enabled=false]": "154:12" -"minecraft:hopper[facing=east,enabled=false]": "154:13" -"minecraft:quartz_block": "155:0" -"minecraft:chiseled_quartz_block": "155:1" -"minecraft:quartz_pillar[axis=y]": "155:2" -"minecraft:quartz_pillar[axis=x]": "155:3" -"minecraft:quartz_pillar[axis=z]": "155:4" -"minecraft:quartz_stairs[half=bottom,shape=straight,facing=east]": "156:0" -"minecraft:quartz_stairs[half=bottom,shape=straight,facing=west]": "156:1" -"minecraft:quartz_stairs[half=bottom,shape=straight,facing=south]": "156:2" -"minecraft:quartz_stairs[half=bottom,shape=straight,facing=north]": "156:3" -"minecraft:quartz_stairs[half=top,shape=straight,facing=east]": "156:4" -"minecraft:quartz_stairs[half=top,shape=straight,facing=west]": "156:5" -"minecraft:quartz_stairs[half=top,shape=straight,facing=south]": "156:6" -"minecraft:quartz_stairs[half=top,shape=straight,facing=north]": "156:7" -"minecraft:activator_rail[shape=north_south,powered=false]": "157:0" -"minecraft:activator_rail[shape=east_west,powered=false]": "157:1" -"minecraft:activator_rail[shape=ascending_east,powered=false]": "157:2" -"minecraft:activator_rail[shape=ascending_west,powered=false]": "157:3" -"minecraft:activator_rail[shape=ascending_north,powered=false]": "157:4" -"minecraft:activator_rail[shape=ascending_south,powered=false]": "157:5" -"minecraft:activator_rail[shape=north_south,powered=true]": "157:8" -"minecraft:activator_rail[shape=east_west,powered=true]": "157:9" -"minecraft:activator_rail[shape=ascending_east,powered=true]": "157:10" -"minecraft:activator_rail[shape=ascending_west,powered=true]": "157:11" -"minecraft:activator_rail[shape=ascending_north,powered=true]": "157:12" -"minecraft:activator_rail[shape=ascending_south,powered=true]": "157:13" -"minecraft:dropper[triggered=false,facing=down]": "158:0" -"minecraft:dropper[triggered=false,facing=up]": "158:1" -"minecraft:dropper[triggered=false,facing=north]": "158:2" -"minecraft:dropper[triggered=false,facing=south]": "158:3" -"minecraft:dropper[triggered=false,facing=west]": "158:4" -"minecraft:dropper[triggered=false,facing=east]": "158:5" -"minecraft:dropper[triggered=true,facing=down]": "158:8" -"minecraft:dropper[triggered=true,facing=up]": "158:9" -"minecraft:dropper[triggered=true,facing=north]": "158:10" -"minecraft:dropper[triggered=true,facing=south]": "158:11" -"minecraft:dropper[triggered=true,facing=west]": "158:12" -"minecraft:dropper[triggered=true,facing=east]": "158:13" -"minecraft:white_terracotta": "159:0" -"minecraft:orange_terracotta": "159:1" -"minecraft:magenta_terracotta": "159:2" -"minecraft:light_blue_terracotta": "159:3" -"minecraft:yellow_terracotta": "159:4" -"minecraft:lime_terracotta": "159:5" -"minecraft:pink_terracotta": "159:6" -"minecraft:gray_terracotta": "159:7" -"minecraft:light_gray_terracotta": "159:8" -"minecraft:cyan_terracotta": "159:9" -"minecraft:purple_terracotta": "159:10" -"minecraft:blue_terracotta": "159:11" -"minecraft:brown_terracotta": "159:12" -"minecraft:green_terracotta": "159:13" -"minecraft:red_terracotta": "159:14" -"minecraft:black_terracotta": "159:15" -"minecraft:white_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:0" -"minecraft:orange_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:1" -"minecraft:magenta_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:2" -"minecraft:light_blue_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:3" -"minecraft:yellow_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:4" -"minecraft:lime_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:5" -"minecraft:pink_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:6" -"minecraft:gray_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:7" -"minecraft:light_gray_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:8" -"minecraft:cyan_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:9" -"minecraft:purple_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:10" -"minecraft:blue_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:11" -"minecraft:brown_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:12" -"minecraft:green_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:13" -"minecraft:red_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:14" -"minecraft:black_stained_glass_pane[east=false,south=false,north=false,west=false]": "160:15" -"minecraft:acacia_leaves[persistent=false,distance=1]": "161:0" -"minecraft:dark_oak_leaves[persistent=false,distance=1]": "161:1" -"minecraft:acacia_leaves[persistent=true,distance=1]": "161:4" -"minecraft:dark_oak_leaves[persistent=true,distance=1]": "161:5" -"minecraft:acacia_log[axis=y]": "162:0" -"minecraft:dark_oak_log[axis=y]": "162:1" -"minecraft:acacia_log[axis=x]": "162:4" -"minecraft:dark_oak_log[axis=x]": "162:5" -"minecraft:acacia_log[axis=z]": "162:8" -"minecraft:dark_oak_log[axis=z]": "162:9" -"minecraft:acacia_wood": "162:12" -"minecraft:dark_oak_wood": "162:13" -"minecraft:acacia_stairs[half=bottom,shape=straight,facing=east]": "163:0" -"minecraft:acacia_stairs[half=bottom,shape=straight,facing=west]": "163:1" -"minecraft:acacia_stairs[half=bottom,shape=straight,facing=south]": "163:2" -"minecraft:acacia_stairs[half=bottom,shape=straight,facing=north]": "163:3" -"minecraft:acacia_stairs[half=top,shape=straight,facing=east]": "163:4" -"minecraft:acacia_stairs[half=top,shape=straight,facing=west]": "163:5" -"minecraft:acacia_stairs[half=top,shape=straight,facing=south]": "163:6" -"minecraft:acacia_stairs[half=top,shape=straight,facing=north]": "163:7" -"minecraft:dark_oak_stairs[half=bottom,shape=straight,facing=east]": "164:0" -"minecraft:dark_oak_stairs[half=bottom,shape=straight,facing=west]": "164:1" -"minecraft:dark_oak_stairs[half=bottom,shape=straight,facing=south]": "164:2" -"minecraft:dark_oak_stairs[half=bottom,shape=straight,facing=north]": "164:3" -"minecraft:dark_oak_stairs[half=top,shape=straight,facing=east]": "164:4" -"minecraft:dark_oak_stairs[half=top,shape=straight,facing=west]": "164:5" -"minecraft:dark_oak_stairs[half=top,shape=straight,facing=south]": "164:6" -"minecraft:dark_oak_stairs[half=top,shape=straight,facing=north]": "164:7" -"minecraft:slime_block": "165:0" -"minecraft:barrier": "166:0" -"minecraft:iron_trapdoor[half=bottom,facing=north,open=false]": "167:0" -"minecraft:iron_trapdoor[half=bottom,facing=south,open=false]": "167:1" -"minecraft:iron_trapdoor[half=bottom,facing=west,open=false]": "167:2" -"minecraft:iron_trapdoor[half=bottom,facing=east,open=false]": "167:3" -"minecraft:iron_trapdoor[half=bottom,facing=north,open=true]": "167:4" -"minecraft:iron_trapdoor[half=bottom,facing=south,open=true]": "167:5" -"minecraft:iron_trapdoor[half=bottom,facing=west,open=true]": "167:6" -"minecraft:iron_trapdoor[half=bottom,facing=east,open=true]": "167:7" -"minecraft:iron_trapdoor[half=top,facing=north,open=false]": "167:8" -"minecraft:iron_trapdoor[half=top,facing=south,open=false]": "167:9" -"minecraft:iron_trapdoor[half=top,facing=west,open=false]": "167:10" -"minecraft:iron_trapdoor[half=top,facing=east,open=false]": "167:11" -"minecraft:iron_trapdoor[half=top,facing=north,open=true]": "167:12" -"minecraft:iron_trapdoor[half=top,facing=south,open=true]": "167:13" -"minecraft:iron_trapdoor[half=top,facing=west,open=true]": "167:14" -"minecraft:iron_trapdoor[half=top,facing=east,open=true]": "167:15" -"minecraft:prismarine": "168:0" -"minecraft:prismarine_bricks": "168:1" -"minecraft:dark_prismarine": "168:2" -"minecraft:sea_lantern": "169:0" -"minecraft:hay_block[axis=y]": "170:0" -"minecraft:hay_block[axis=x]": "170:4" -"minecraft:hay_block[axis=z]": "170:8" -"minecraft:white_carpet": "171:0" -"minecraft:orange_carpet": "171:1" -"minecraft:magenta_carpet": "171:2" -"minecraft:light_blue_carpet": "171:3" -"minecraft:yellow_carpet": "171:4" -"minecraft:lime_carpet": "171:5" -"minecraft:pink_carpet": "171:6" -"minecraft:gray_carpet": "171:7" -"minecraft:light_gray_carpet": "171:8" -"minecraft:cyan_carpet": "171:9" -"minecraft:purple_carpet": "171:10" -"minecraft:blue_carpet": "171:11" -"minecraft:brown_carpet": "171:12" -"minecraft:green_carpet": "171:13" -"minecraft:red_carpet": "171:14" -"minecraft:black_carpet": "171:15" -"minecraft:terracotta": "172:0" -"minecraft:coal_block": "173:0" -"minecraft:packed_ice": "174:0" -"minecraft:sunflower[half=lower]": "175:0" -"minecraft:lilac[half=lower]": "175:1" -"minecraft:tall_grass[half=lower]": "175:2" -"minecraft:large_fern[half=lower]": "175:3" -"minecraft:rose_bush[half=lower]": "175:4" -"minecraft:peony[half=lower]": "175:5" -"minecraft:sunflower[half=upper]": "175:8" -"minecraft:lilac[half=upper]": "175:9" -"minecraft:tall_grass[half=upper]": "175:10" -"minecraft:large_fern[half=upper]": "175:11" -"minecraft:rose_bush[half=upper]": "175:12" -"minecraft:peony[half=upper]": "175:13" -"minecraft:white_banner[rotation=0]": "176:0" -"minecraft:white_banner[rotation=1]": "176:1" -"minecraft:white_banner[rotation=2]": "176:2" -"minecraft:white_banner[rotation=3]": "176:3" -"minecraft:white_banner[rotation=4]": "176:4" -"minecraft:white_banner[rotation=5]": "176:5" -"minecraft:white_banner[rotation=6]": "176:6" -"minecraft:white_banner[rotation=7]": "176:7" -"minecraft:white_banner[rotation=8]": "176:8" -"minecraft:white_banner[rotation=9]": "176:9" -"minecraft:white_banner[rotation=10]": "176:10" -"minecraft:white_banner[rotation=11]": "176:11" -"minecraft:white_banner[rotation=12]": "176:12" -"minecraft:white_banner[rotation=13]": "176:13" -"minecraft:white_banner[rotation=14]": "176:14" -"minecraft:white_banner[rotation=15]": "176:15" -"minecraft:white_wall_banner": "177:0" -"minecraft:white_wall_banner[facing=north]": "177:2" -"minecraft:white_wall_banner[facing=south]": "177:3" -"minecraft:white_wall_banner[facing=west]": "177:4" -"minecraft:white_wall_banner[facing=east]": "177:5" -"minecraft:daylight_detector[inverted=true,power=0]": "178:0" -"minecraft:daylight_detector[inverted=true,power=1]": "178:1" -"minecraft:daylight_detector[inverted=true,power=2]": "178:2" -"minecraft:daylight_detector[inverted=true,power=3]": "178:3" -"minecraft:daylight_detector[inverted=true,power=4]": "178:4" -"minecraft:daylight_detector[inverted=true,power=5]": "178:5" -"minecraft:daylight_detector[inverted=true,power=6]": "178:6" -"minecraft:daylight_detector[inverted=true,power=7]": "178:7" -"minecraft:daylight_detector[inverted=true,power=8]": "178:8" -"minecraft:daylight_detector[inverted=true,power=9]": "178:9" -"minecraft:daylight_detector[inverted=true,power=10]": "178:10" -"minecraft:daylight_detector[inverted=true,power=11]": "178:11" -"minecraft:daylight_detector[inverted=true,power=12]": "178:12" -"minecraft:daylight_detector[inverted=true,power=13]": "178:13" -"minecraft:daylight_detector[inverted=true,power=14]": "178:14" -"minecraft:daylight_detector[inverted=true,power=15]": "178:15" -"minecraft:red_sandstone": "179:0" -"minecraft:chiseled_red_sandstone": "179:1" -"minecraft:cut_red_sandstone": "179:2" -"minecraft:red_sandstone_stairs[half=bottom,shape=straight,facing=east]": "180:0" -"minecraft:red_sandstone_stairs[half=bottom,shape=straight,facing=west]": "180:1" -"minecraft:red_sandstone_stairs[half=bottom,shape=straight,facing=south]": "180:2" -"minecraft:red_sandstone_stairs[half=bottom,shape=straight,facing=north]": "180:3" -"minecraft:red_sandstone_stairs[half=top,shape=straight,facing=east]": "180:4" -"minecraft:red_sandstone_stairs[half=top,shape=straight,facing=west]": "180:5" -"minecraft:red_sandstone_stairs[half=top,shape=straight,facing=south]": "180:6" -"minecraft:red_sandstone_stairs[half=top,shape=straight,facing=north]": "180:7" -"minecraft:red_sandstone_slab[type=double]": "181:0" -"minecraft:smooth_red_sandstone": "181:8" -"minecraft:red_sandstone_slab[type=bottom]": "182:0" -"minecraft:red_sandstone_slab[type=top]": "182:8" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "183:0" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "183:1" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "183:2" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "183:3" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "183:4" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "183:5" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "183:6" -"minecraft:spruce_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "183:7" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "183:8" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "183:9" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "183:10" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "183:11" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "183:12" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "183:13" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "183:14" -"minecraft:spruce_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "183:15" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "184:0" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "184:1" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "184:2" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "184:3" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "184:4" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "184:5" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "184:6" -"minecraft:birch_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "184:7" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "184:8" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "184:9" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "184:10" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "184:11" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "184:12" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "184:13" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "184:14" -"minecraft:birch_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "184:15" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "185:0" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "185:1" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "185:2" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "185:3" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "185:4" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "185:5" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "185:6" -"minecraft:jungle_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "185:7" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "185:8" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "185:9" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "185:10" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "185:11" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "185:12" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "185:13" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "185:14" -"minecraft:jungle_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "185:15" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "186:0" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "186:1" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "186:2" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "186:3" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "186:4" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "186:5" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "186:6" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "186:7" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "186:8" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "186:9" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "186:10" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "186:11" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "186:12" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "186:13" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "186:14" -"minecraft:dark_oak_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "186:15" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=south,open=false]": "187:0" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=west,open=false]": "187:1" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=north,open=false]": "187:2" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=east,open=false]": "187:3" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=south,open=true]": "187:4" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=west,open=true]": "187:5" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=north,open=true]": "187:6" -"minecraft:acacia_fence_gate[in_wall=false,powered=false,facing=east,open=true]": "187:7" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=south,open=false]": "187:8" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=west,open=false]": "187:9" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=north,open=false]": "187:10" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=east,open=false]": "187:11" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=south,open=true]": "187:12" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=west,open=true]": "187:13" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=north,open=true]": "187:14" -"minecraft:acacia_fence_gate[in_wall=false,powered=true,facing=east,open=true]": "187:15" -"minecraft:spruce_fence[east=false,south=false,north=false,west=false]": "188:0" -"minecraft:birch_fence[east=false,south=false,north=false,west=false]": "189:0" -"minecraft:jungle_fence[east=false,south=false,north=false,west=false]": "190:0" -"minecraft:dark_oak_fence[east=false,south=false,north=false,west=false]": "191:0" -"minecraft:acacia_fence[east=false,south=false,north=false,west=false]": "192:0" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "193:0" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "193:1" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "193:2" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "193:3" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "193:4" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "193:5" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "193:6" -"minecraft:spruce_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "193:7" -"minecraft:spruce_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "193:8" -"minecraft:spruce_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "193:9" -"minecraft:spruce_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "193:10" -"minecraft:spruce_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "193:11" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "194:0" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "194:1" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "194:2" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "194:3" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "194:4" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "194:5" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "194:6" -"minecraft:birch_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "194:7" -"minecraft:birch_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "194:8" -"minecraft:birch_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "194:9" -"minecraft:birch_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "194:10" -"minecraft:birch_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "194:11" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "195:0" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "195:1" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "195:2" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "195:3" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "195:4" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "195:5" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "195:6" -"minecraft:jungle_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "195:7" -"minecraft:jungle_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "195:8" -"minecraft:jungle_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "195:9" -"minecraft:jungle_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "195:10" -"minecraft:jungle_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "195:11" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "196:0" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "196:1" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "196:2" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "196:3" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "196:4" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "196:5" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "196:6" -"minecraft:acacia_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "196:7" -"minecraft:acacia_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "196:8" -"minecraft:acacia_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "196:9" -"minecraft:acacia_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "196:10" -"minecraft:acacia_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "196:11" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=east,open=false]": "197:0" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=south,open=false]": "197:1" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=west,open=false]": "197:2" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=north,open=false]": "197:3" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=east,open=true]": "197:4" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=south,open=true]": "197:5" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=west,open=true]": "197:6" -"minecraft:dark_oak_door[hinge=right,half=lower,powered=false,facing=north,open=true]": "197:7" -"minecraft:dark_oak_door[hinge=left,half=upper,powered=false,facing=east,open=false]": "197:8" -"minecraft:dark_oak_door[hinge=right,half=upper,powered=false,facing=east,open=false]": "197:9" -"minecraft:dark_oak_door[hinge=left,half=upper,powered=true,facing=east,open=false]": "197:10" -"minecraft:dark_oak_door[hinge=right,half=upper,powered=true,facing=east,open=false]": "197:11" -"minecraft:end_rod[facing=down]": "198:0" -"minecraft:end_rod[facing=up]": "198:1" -"minecraft:end_rod[facing=north]": "198:2" -"minecraft:end_rod[facing=south]": "198:3" -"minecraft:end_rod[facing=west]": "198:4" -"minecraft:end_rod[facing=east]": "198:5" -"minecraft:chorus_plant[east=false,south=false,north=false,west=false,up=false,down=false]": "199:0" -"minecraft:chorus_flower[age=0]": "200:0" -"minecraft:chorus_flower[age=1]": "200:1" -"minecraft:chorus_flower[age=2]": "200:2" -"minecraft:chorus_flower[age=3]": "200:3" -"minecraft:chorus_flower[age=4]": "200:4" -"minecraft:chorus_flower[age=5]": "200:5" -"minecraft:purpur_block": "201:0" -"minecraft:purpur_pillar[axis=y]": "202:0" -"minecraft:purpur_pillar[axis=x]": "202:4" -"minecraft:purpur_pillar[axis=z]": "202:8" -"minecraft:purpur_stairs[half=bottom,shape=straight,facing=east]": "203:0" -"minecraft:purpur_stairs[half=bottom,shape=straight,facing=west]": "203:1" -"minecraft:purpur_stairs[half=bottom,shape=straight,facing=south]": "203:2" -"minecraft:purpur_stairs[half=bottom,shape=straight,facing=north]": "203:3" -"minecraft:purpur_stairs[half=top,shape=straight,facing=east]": "203:4" -"minecraft:purpur_stairs[half=top,shape=straight,facing=west]": "203:5" -"minecraft:purpur_stairs[half=top,shape=straight,facing=south]": "203:6" -"minecraft:purpur_stairs[half=top,shape=straight,facing=north]": "203:7" -"minecraft:purpur_slab[type=double]": "204:0" -"minecraft:purpur_slab[type=bottom]": "205:0" -"minecraft:purpur_slab[type=top]": "205:8" -"minecraft:end_stone_bricks": "206:0" -"minecraft:beetroots[age=0]": "207:0" -"minecraft:beetroots[age=1]": "207:1" -"minecraft:beetroots[age=2]": "207:2" -"minecraft:beetroots[age=3]": "207:3" -"minecraft:grass_path": "208:0" -"minecraft:end_gateway": "209:0" -"minecraft:repeating_command_block[conditional=false,facing=down]": "210:0" -"minecraft:repeating_command_block[conditional=false,facing=up]": "210:1" -"minecraft:repeating_command_block[conditional=false,facing=north]": "210:2" -"minecraft:repeating_command_block[conditional=false,facing=south]": "210:3" -"minecraft:repeating_command_block[conditional=false,facing=west]": "210:4" -"minecraft:repeating_command_block[conditional=false,facing=east]": "210:5" -"minecraft:repeating_command_block[conditional=true,facing=down]": "210:8" -"minecraft:repeating_command_block[conditional=true,facing=up]": "210:9" -"minecraft:repeating_command_block[conditional=true,facing=north]": "210:10" -"minecraft:repeating_command_block[conditional=true,facing=south]": "210:11" -"minecraft:repeating_command_block[conditional=true,facing=west]": "210:12" -"minecraft:repeating_command_block[conditional=true,facing=east]": "210:13" -"minecraft:chain_command_block[conditional=false,facing=down]": "211:0" -"minecraft:chain_command_block[conditional=false,facing=up]": "211:1" -"minecraft:chain_command_block[conditional=false,facing=north]": "211:2" -"minecraft:chain_command_block[conditional=false,facing=south]": "211:3" -"minecraft:chain_command_block[conditional=false,facing=west]": "211:4" -"minecraft:chain_command_block[conditional=false,facing=east]": "211:5" -"minecraft:chain_command_block[conditional=true,facing=down]": "211:8" -"minecraft:chain_command_block[conditional=true,facing=up]": "211:9" -"minecraft:chain_command_block[conditional=true,facing=north]": "211:10" -"minecraft:chain_command_block[conditional=true,facing=south]": "211:11" -"minecraft:chain_command_block[conditional=true,facing=west]": "211:12" -"minecraft:chain_command_block[conditional=true,facing=east]": "211:13" -"minecraft:frosted_ice[age=0]": "212:0" -"minecraft:frosted_ice[age=1]": "212:1" -"minecraft:frosted_ice[age=2]": "212:2" -"minecraft:frosted_ice[age=3]": "212:3" -"minecraft:magma_block": "213:0" -"minecraft:nether_wart_block": "214:0" -"minecraft:red_nether_bricks": "215:0" -"minecraft:bone_block[axis=y]": "216:0" -"minecraft:bone_block[axis=x]": "216:4" -"minecraft:bone_block[axis=z]": "216:8" -"minecraft:structure_void": "217:0" -"minecraft:observer[powered=false,facing=down]": "218:0" -"minecraft:observer[powered=false,facing=up]": "218:1" -"minecraft:observer[powered=false,facing=north]": "218:2" -"minecraft:observer[powered=false,facing=south]": "218:3" -"minecraft:observer[powered=false,facing=west]": "218:4" -"minecraft:observer[powered=false,facing=east]": "218:5" -"minecraft:observer[powered=true,facing=down]": "218:8" -"minecraft:observer[powered=true,facing=up]": "218:9" -"minecraft:observer[powered=true,facing=north]": "218:10" -"minecraft:observer[powered=true,facing=south]": "218:11" -"minecraft:observer[powered=true,facing=west]": "218:12" -"minecraft:observer[powered=true,facing=east]": "218:13" -"minecraft:white_shulker_box[facing=down]": "219:0" -"minecraft:white_shulker_box[facing=up]": "219:1" -"minecraft:white_shulker_box[facing=north]": "219:2" -"minecraft:white_shulker_box[facing=south]": "219:3" -"minecraft:white_shulker_box[facing=west]": "219:4" -"minecraft:white_shulker_box[facing=east]": "219:5" -"minecraft:orange_shulker_box[facing=down]": "220:0" -"minecraft:orange_shulker_box[facing=up]": "220:1" -"minecraft:orange_shulker_box[facing=north]": "220:2" -"minecraft:orange_shulker_box[facing=south]": "220:3" -"minecraft:orange_shulker_box[facing=west]": "220:4" -"minecraft:orange_shulker_box[facing=east]": "220:5" -"minecraft:magenta_shulker_box[facing=down]": "221:0" -"minecraft:magenta_shulker_box[facing=up]": "221:1" -"minecraft:magenta_shulker_box[facing=north]": "221:2" -"minecraft:magenta_shulker_box[facing=south]": "221:3" -"minecraft:magenta_shulker_box[facing=west]": "221:4" -"minecraft:magenta_shulker_box[facing=east]": "221:5" -"minecraft:light_blue_shulker_box[facing=down]": "222:0" -"minecraft:light_blue_shulker_box[facing=up]": "222:1" -"minecraft:light_blue_shulker_box[facing=north]": "222:2" -"minecraft:light_blue_shulker_box[facing=south]": "222:3" -"minecraft:light_blue_shulker_box[facing=west]": "222:4" -"minecraft:light_blue_shulker_box[facing=east]": "222:5" -"minecraft:yellow_shulker_box[facing=down]": "223:0" -"minecraft:yellow_shulker_box[facing=up]": "223:1" -"minecraft:yellow_shulker_box[facing=north]": "223:2" -"minecraft:yellow_shulker_box[facing=south]": "223:3" -"minecraft:yellow_shulker_box[facing=west]": "223:4" -"minecraft:yellow_shulker_box[facing=east]": "223:5" -"minecraft:lime_shulker_box[facing=down]": "224:0" -"minecraft:lime_shulker_box[facing=up]": "224:1" -"minecraft:lime_shulker_box[facing=north]": "224:2" -"minecraft:lime_shulker_box[facing=south]": "224:3" -"minecraft:lime_shulker_box[facing=west]": "224:4" -"minecraft:lime_shulker_box[facing=east]": "224:5" -"minecraft:pink_shulker_box[facing=down]": "225:0" -"minecraft:pink_shulker_box[facing=up]": "225:1" -"minecraft:pink_shulker_box[facing=north]": "225:2" -"minecraft:pink_shulker_box[facing=south]": "225:3" -"minecraft:pink_shulker_box[facing=west]": "225:4" -"minecraft:pink_shulker_box[facing=east]": "225:5" -"minecraft:gray_shulker_box[facing=down]": "226:0" -"minecraft:gray_shulker_box[facing=up]": "226:1" -"minecraft:gray_shulker_box[facing=north]": "226:2" -"minecraft:gray_shulker_box[facing=south]": "226:3" -"minecraft:gray_shulker_box[facing=west]": "226:4" -"minecraft:gray_shulker_box[facing=east]": "226:5" -"minecraft:light_gray_shulker_box[facing=down]": "227:0" -"minecraft:light_gray_shulker_box[facing=up]": "227:1" -"minecraft:light_gray_shulker_box[facing=north]": "227:2" -"minecraft:light_gray_shulker_box[facing=south]": "227:3" -"minecraft:light_gray_shulker_box[facing=west]": "227:4" -"minecraft:light_gray_shulker_box[facing=east]": "227:5" -"minecraft:cyan_shulker_box[facing=down]": "228:0" -"minecraft:cyan_shulker_box[facing=up]": "228:1" -"minecraft:cyan_shulker_box[facing=north]": "228:2" -"minecraft:cyan_shulker_box[facing=south]": "228:3" -"minecraft:cyan_shulker_box[facing=west]": "228:4" -"minecraft:cyan_shulker_box[facing=east]": "228:5" -"minecraft:purple_shulker_box[facing=down]": "229:0" -"minecraft:purple_shulker_box[facing=up]": "229:1" -"minecraft:purple_shulker_box[facing=north]": "229:2" -"minecraft:purple_shulker_box[facing=south]": "229:3" -"minecraft:purple_shulker_box[facing=west]": "229:4" -"minecraft:purple_shulker_box[facing=east]": "229:5" -"minecraft:blue_shulker_box[facing=down]": "230:0" -"minecraft:blue_shulker_box[facing=up]": "230:1" -"minecraft:blue_shulker_box[facing=north]": "230:2" -"minecraft:blue_shulker_box[facing=south]": "230:3" -"minecraft:blue_shulker_box[facing=west]": "230:4" -"minecraft:blue_shulker_box[facing=east]": "230:5" -"minecraft:brown_shulker_box[facing=down]": "231:0" -"minecraft:brown_shulker_box[facing=up]": "231:1" -"minecraft:brown_shulker_box[facing=north]": "231:2" -"minecraft:brown_shulker_box[facing=south]": "231:3" -"minecraft:brown_shulker_box[facing=west]": "231:4" -"minecraft:brown_shulker_box[facing=east]": "231:5" -"minecraft:green_shulker_box[facing=down]": "232:0" -"minecraft:green_shulker_box[facing=up]": "232:1" -"minecraft:green_shulker_box[facing=north]": "232:2" -"minecraft:green_shulker_box[facing=south]": "232:3" -"minecraft:green_shulker_box[facing=west]": "232:4" -"minecraft:green_shulker_box[facing=east]": "232:5" -"minecraft:red_shulker_box[facing=down]": "233:0" -"minecraft:red_shulker_box[facing=up]": "233:1" -"minecraft:red_shulker_box[facing=north]": "233:2" -"minecraft:red_shulker_box[facing=south]": "233:3" -"minecraft:red_shulker_box[facing=west]": "233:4" -"minecraft:red_shulker_box[facing=east]": "233:5" -"minecraft:black_shulker_box[facing=down]": "234:0" -"minecraft:black_shulker_box[facing=up]": "234:1" -"minecraft:black_shulker_box[facing=north]": "234:2" -"minecraft:black_shulker_box[facing=south]": "234:3" -"minecraft:black_shulker_box[facing=west]": "234:4" -"minecraft:black_shulker_box[facing=east]": "234:5" -"minecraft:white_glazed_terracotta[facing=south]": "235:0" -"minecraft:white_glazed_terracotta[facing=west]": "235:1" -"minecraft:white_glazed_terracotta[facing=north]": "235:2" -"minecraft:white_glazed_terracotta[facing=east]": "235:3" -"minecraft:orange_glazed_terracotta[facing=south]": "236:0" -"minecraft:orange_glazed_terracotta[facing=west]": "236:1" -"minecraft:orange_glazed_terracotta[facing=north]": "236:2" -"minecraft:orange_glazed_terracotta[facing=east]": "236:3" -"minecraft:magenta_glazed_terracotta[facing=south]": "237:0" -"minecraft:magenta_glazed_terracotta[facing=west]": "237:1" -"minecraft:magenta_glazed_terracotta[facing=north]": "237:2" -"minecraft:magenta_glazed_terracotta[facing=east]": "237:3" -"minecraft:light_blue_glazed_terracotta[facing=south]": "238:0" -"minecraft:light_blue_glazed_terracotta[facing=west]": "238:1" -"minecraft:light_blue_glazed_terracotta[facing=north]": "238:2" -"minecraft:light_blue_glazed_terracotta[facing=east]": "238:3" -"minecraft:yellow_glazed_terracotta[facing=south]": "239:0" -"minecraft:yellow_glazed_terracotta[facing=west]": "239:1" -"minecraft:yellow_glazed_terracotta[facing=north]": "239:2" -"minecraft:yellow_glazed_terracotta[facing=east]": "239:3" -"minecraft:lime_glazed_terracotta[facing=south]": "240:0" -"minecraft:lime_glazed_terracotta[facing=west]": "240:1" -"minecraft:lime_glazed_terracotta[facing=north]": "240:2" -"minecraft:lime_glazed_terracotta[facing=east]": "240:3" -"minecraft:pink_glazed_terracotta[facing=south]": "241:0" -"minecraft:pink_glazed_terracotta[facing=west]": "241:1" -"minecraft:pink_glazed_terracotta[facing=north]": "241:2" -"minecraft:pink_glazed_terracotta[facing=east]": "241:3" -"minecraft:gray_glazed_terracotta[facing=south]": "242:0" -"minecraft:gray_glazed_terracotta[facing=west]": "242:1" -"minecraft:gray_glazed_terracotta[facing=north]": "242:2" -"minecraft:gray_glazed_terracotta[facing=east]": "242:3" -"minecraft:light_gray_glazed_terracotta[facing=south]": "243:0" -"minecraft:light_gray_glazed_terracotta[facing=west]": "243:1" -"minecraft:light_gray_glazed_terracotta[facing=north]": "243:2" -"minecraft:light_gray_glazed_terracotta[facing=east]": "243:3" -"minecraft:cyan_glazed_terracotta[facing=south]": "244:0" -"minecraft:cyan_glazed_terracotta[facing=west]": "244:1" -"minecraft:cyan_glazed_terracotta[facing=north]": "244:2" -"minecraft:cyan_glazed_terracotta[facing=east]": "244:3" -"minecraft:purple_glazed_terracotta[facing=south]": "245:0" -"minecraft:purple_glazed_terracotta[facing=west]": "245:1" -"minecraft:purple_glazed_terracotta[facing=north]": "245:2" -"minecraft:purple_glazed_terracotta[facing=east]": "245:3" -"minecraft:blue_glazed_terracotta[facing=south]": "246:0" -"minecraft:blue_glazed_terracotta[facing=west]": "246:1" -"minecraft:blue_glazed_terracotta[facing=north]": "246:2" -"minecraft:blue_glazed_terracotta[facing=east]": "246:3" -"minecraft:brown_glazed_terracotta[facing=south]": "247:0" -"minecraft:brown_glazed_terracotta[facing=west]": "247:1" -"minecraft:brown_glazed_terracotta[facing=north]": "247:2" -"minecraft:brown_glazed_terracotta[facing=east]": "247:3" -"minecraft:green_glazed_terracotta[facing=south]": "248:0" -"minecraft:green_glazed_terracotta[facing=west]": "248:1" -"minecraft:green_glazed_terracotta[facing=north]": "248:2" -"minecraft:green_glazed_terracotta[facing=east]": "248:3" -"minecraft:red_glazed_terracotta[facing=south]": "249:0" -"minecraft:red_glazed_terracotta[facing=west]": "249:1" -"minecraft:red_glazed_terracotta[facing=north]": "249:2" -"minecraft:red_glazed_terracotta[facing=east]": "249:3" -"minecraft:black_glazed_terracotta[facing=south]": "250:0" -"minecraft:black_glazed_terracotta[facing=west]": "250:1" -"minecraft:black_glazed_terracotta[facing=north]": "250:2" -"minecraft:black_glazed_terracotta[facing=east]": "250:3" -"minecraft:white_concrete": "251:0" -"minecraft:orange_concrete": "251:1" -"minecraft:magenta_concrete": "251:2" -"minecraft:light_blue_concrete": "251:3" -"minecraft:yellow_concrete": "251:4" -"minecraft:lime_concrete": "251:5" -"minecraft:pink_concrete": "251:6" -"minecraft:gray_concrete": "251:7" -"minecraft:light_gray_concrete": "251:8" -"minecraft:cyan_concrete": "251:9" -"minecraft:purple_concrete": "251:10" -"minecraft:blue_concrete": "251:11" -"minecraft:brown_concrete": "251:12" -"minecraft:green_concrete": "251:13" -"minecraft:red_concrete": "251:14" -"minecraft:black_concrete": "251:15" -"minecraft:white_concrete_powder": "252:0" -"minecraft:orange_concrete_powder": "252:1" -"minecraft:magenta_concrete_powder": "252:2" -"minecraft:light_blue_concrete_powder": "252:3" -"minecraft:yellow_concrete_powder": "252:4" -"minecraft:lime_concrete_powder": "252:5" -"minecraft:pink_concrete_powder": "252:6" -"minecraft:gray_concrete_powder": "252:7" -"minecraft:light_gray_concrete_powder": "252:8" -"minecraft:cyan_concrete_powder": "252:9" -"minecraft:purple_concrete_powder": "252:10" -"minecraft:blue_concrete_powder": "252:11" -"minecraft:brown_concrete_powder": "252:12" -"minecraft:green_concrete_powder": "252:13" -"minecraft:red_concrete_powder": "252:14" -"minecraft:black_concrete_powder": "252:15" -"minecraft:structure_block[mode=save]": "255:0" -"minecraft:structure_block[mode=load]": "255:1" -"minecraft:structure_block[mode=corner]": "255:2" -"minecraft:structure_block[mode=data]": "255:3" \ No newline at end of file diff --git a/SpigotCore/SpigotCore_9/build.gradle.kts b/SpigotCore/SpigotCore_9/build.gradle.kts deleted file mode 100644 index 1abca6d1..00000000 --- a/SpigotCore/SpigotCore_9/build.gradle.kts +++ /dev/null @@ -1,30 +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 . - */ - -plugins { - steamwar.java -} - -dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) - compileOnly(project(":SpigotCore:SpigotCore_8", "default")) - - compileOnly(libs.nms9) - compileOnly(libs.worldedit12) -} diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java deleted file mode 100644 index a77a0abe..00000000 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ /dev/null @@ -1,110 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.Sound; -import org.bukkit.entity.Player; - -import java.util.UUID; - -public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { - - @Override - public void playPling(Player player) { - player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - } - - @Override - public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) { - if(type == ChatMessageType.CHAT) - type = ChatMessageType.SYSTEM; - - player.spigot().sendMessage(type, msg); - } - - private static final Class dataWatcherObject = Reflection.getClass("net.minecraft.network.syncher.EntityDataAccessor"); - private static final Class dataWatcherRegistry = Reflection.getClass("net.minecraft.network.syncher.EntityDataSerializers"); - private static final Class dataWatcherSerializer = Reflection.getClass("net.minecraft.network.syncher.EntityDataSerializer"); - private static final Reflection.Constructor dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer); - @Override - public Object getDataWatcherObject(int index, Class type) { - return dataWatcherObjectConstructor.invoke(index, Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null)); - } - - private static final Class item = Reflection.getClass("net.minecraft.network.syncher.SynchedEntityData$DataItem"); - private static final Reflection.Constructor itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class); - @Override - public Object getDataWatcherItem(Object dwo, Object value) { - return itemConstructor.invoke(dwo, value); - } - - @Override - public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { - Reflection.Field posX = Reflection.getField(packetClass, double.class, fieldOffset); - Reflection.Field posY = Reflection.getField(packetClass, double.class, fieldOffset+1); - Reflection.Field posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); - boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn"); - Class pitchYawType = isByteClass ? byte.class : int.class; - Reflection.Field lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); - Reflection.Field lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); - - return (packet, x, y, z, pitch, yaw) -> { - posX.set(packet, x); - posY.set(packet, y); - posZ.set(packet, z); - if (isByteClass) { - lookYaw.set(packet, (byte) (yaw*256/360)); - lookPitch.set(packet, (byte) (pitch*256/360)); - } else { - lookYaw.set(packet, (int) (yaw*256/360)); - lookPitch.set(packet, (int) (pitch*256/360)); - } - }; - } - - @Override - public BountifulWrapper.PositionSetter getRelMoveSetter(Class packetClass) { - Class type = Core.getVersion() > 12 ? short.class : int.class; - int fieldOffset = Core.getVersion() > 12 ? 0 : 1; - Reflection.Field moveX = Reflection.getField(packetClass, type, 0 + fieldOffset); - Reflection.Field moveY = Reflection.getField(packetClass, type, 1 + fieldOffset); - Reflection.Field moveZ = Reflection.getField(packetClass, type, 2 + fieldOffset); - Reflection.Field moveYaw = Reflection.getField(packetClass, byte.class, 0); - Reflection.Field movePitch = Reflection.getField(packetClass, byte.class, 1); - - return (packet, x, y, z, pitch, yaw) -> { - moveX.set(packet, (short)(x*4096)); - moveY.set(packet, (short)(y*4096)); - moveZ.set(packet, (short)(z*4096)); - moveYaw.set(packet, (byte)(yaw*256/360)); - movePitch.set(packet, (byte)(pitch*256/360)); - }; - } - - @Override - public BountifulWrapper.UUIDSetter getUUIDSetter(Class packetClass) { - Reflection.Field uuidField = Reflection.getField(packetClass, UUID.class, 0); - - return uuidField::set; - } -} diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/CraftbukkitWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/CraftbukkitWrapper9.java deleted file mode 100644 index 847036cc..00000000 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/CraftbukkitWrapper9.java +++ /dev/null @@ -1,37 +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 . - */ - -package de.steamwar.core; - -import de.steamwar.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; -import org.bukkit.entity.Player; - -public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper { - - private static final Class chunk = Reflection.getClass("net.minecraft.world.level.chunk.LevelChunk"); - private static final Class packetPlayOutMapChunk = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutMapChunk"); - private static final Reflection.Constructor newPacketPlayOutMapChunk = Reflection.getConstructor(packetPlayOutMapChunk, chunk, int.class); - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle"); - - @Override - public void sendChunk(Player p, int chunkX, int chunkZ) { - TinyProtocol.instance.sendPacket(p, newPacketPlayOutMapChunk.invoke(getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ)), 65535)); - } -} diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java deleted file mode 100644 index 2304ee3c..00000000 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java +++ /dev/null @@ -1,29 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.Particle; - -public class TrickyParticleWrapper9 implements TrickyParticleWrapper { - @Override - public Particle getVillagerHappy() { - return Particle.VILLAGER_HAPPY; - } -} diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java deleted file mode 100644 index 71b47743..00000000 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/techhider/ChunkHider9.java +++ /dev/null @@ -1,158 +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 . - */ - -package de.steamwar.techhider; - -import de.steamwar.Reflection; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Set; -import java.util.function.BiFunction; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; - -public class ChunkHider9 extends ChunkHider8 { - - private static final UnaryOperator mapChunkCloner = ProtocolUtils.shallowCloneGenerator(mapChunkPacket); - - private static final Reflection.Field mapChunkX = Reflection.getField(mapChunkPacket, int.class, 0); - private static final Reflection.Field mapChunkZ = Reflection.getField(mapChunkPacket, int.class, 1); - private static final Reflection.Field mapChunkBitMask = Reflection.getField(mapChunkPacket, int.class, 2); - private static final Reflection.Field mapChunkBlockEntities = Reflection.getField(mapChunkPacket, List.class, 0); - private static final Reflection.Field mapChunkData = Reflection.getField(mapChunkPacket, byte[].class, 0); - - private static final Class nbtTagCompound = Reflection.getClass("net.minecraft.nbt.CompoundTag"); - private static final Reflection.Method nbtTagGetString = Reflection.getTypedMethod(nbtTagCompound, null, String.class, String.class); - - @Override - public BiFunction chunkHiderGenerator(TechHider techHider) { - return (p, packet) -> { - int chunkX = mapChunkX.get(packet); - int chunkZ = mapChunkZ.get(packet); - if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) - return packet; - - packet = mapChunkCloner.apply(packet); - Set hiddenBlockEntities = techHider.getHiddenBlockEntities(); - mapChunkBlockEntities.set(packet, ((List)mapChunkBlockEntities.get(packet)).stream().filter( - nbttag -> !hiddenBlockEntities.contains((String) nbtTagGetString.invoke(nbttag, "id")) - ).collect(Collectors.toList())); - - int primaryBitMask = mapChunkBitMask.get(packet); - ByteBuf in = Unpooled.wrappedBuffer(mapChunkData.get(packet)); - ByteBuf out = Unpooled.buffer(in.readableBytes() + 64); - for(int chunkY = 0; chunkY < p.getWorld().getMaxHeight()/16; chunkY++) { - if(((1 << chunkY) & primaryBitMask) == 0) - continue; - - SectionHider section = new SectionHider(p, techHider, in, out, chunkX, chunkY, chunkZ); - dataHider(section); - } - byte[] data = new byte[out.readableBytes()]; - out.readBytes(data); - mapChunkData.set(packet, data); - - return packet; - }; - } - - protected void dataHider(SectionHider section) { - section.copyBitsPerBlock(); - section.processPalette(); - - if(section.isSkipSection() || (!section.blockPrecise() && section.isPaletted())) { //section.getBitsPerBlock() < 9 - section.skipDataArray(); - } else { - processDataArray(section); - } - - section.getOut().writeBytes(section.getIn(), 4096); //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048 - } - - protected void processDataArray(SectionHider section) { - VariableValueArray values = new VariableValueArray(section.getBitsPerBlock(), section.readDataArray()); - - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - for (int x = 0; x < 16; x++) { - int pos = (((y * 16) + z) * 16) + x; - - switch (section.test(x, y, z)) { - case SKIP: - break; - case CHECK: - if(!section.getObfuscate().contains(values.get(pos))) - break; - case HIDE: - values.set(pos, section.getTarget()); - break; - case HIDE_AIR: - default: - values.set(pos, section.getAir()); - } - } - } - } - - section.writeDataArray(values.backing); - } - - private static class VariableValueArray { - private final long[] backing; - private final int bitsPerValue; - private final long valueMask; - - public VariableValueArray(int bitsPerEntry, long[] dataArray) { - this.bitsPerValue = bitsPerEntry; - this.valueMask = (1L << this.bitsPerValue) - 1; - this.backing = dataArray; - } - - public int get(int index) { - index *= bitsPerValue; - int i0 = index >> 6; - int i1 = index & 0x3f; - - long value = backing[i0] >>> i1; - - // The value is divided over two long values - if (i1 + bitsPerValue > 64) - value |= backing[++i0] << 64 - i1; - - return (int) (value & valueMask); - } - - public void set(int index, int value) { - index *= bitsPerValue; - int i0 = index >> 6; - int i1 = index & 0x3f; - - backing[i0] = backing[i0] & ~(valueMask << i1) | (value & valueMask) << i1; - int i2 = i1 + bitsPerValue; - // The value is divided over two long values - if (i2 > 64) { - i0++; - backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1; - } - } - } -} diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index 85ff16cc..4ab7771e 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -25,6 +25,21 @@ tasks.compileJava { options.isWarnings = false } +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +tasks.withType().configureEach { + options.compilerArgs.addAll(listOf( + "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED" + )) +} + +tasks.withType().configureEach { + jvmArgs("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED") +} + dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) @@ -32,11 +47,14 @@ dependencies { compileOnly(project(":CommandFramework", "default")) compileOnly(project(":SpigotCore:CRIUDummy", "default")) - compileOnly(libs.worldedit12) + compileOnly(libs.fawe) - compileOnly(libs.spigotapi) - compileOnly(libs.netty) + compileOnly(libs.paperapi) + compileOnly(libs.nms) compileOnly(libs.authlib) + compileOnly(libs.datafixer) + compileOnly(libs.netty) + compileOnly(libs.brigadier) compileOnly(libs.fastutil) implementation(libs.anvilgui) diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index cb4aca06..5f8c02c3 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -19,100 +19,235 @@ package com.comphenix.tinyprotocol; +import com.google.common.collect.MapMaker; import de.steamwar.Reflection; -import de.steamwar.Reflection.Field; import de.steamwar.core.Core; import io.netty.channel.*; -import lombok.Getter; -import org.bukkit.Bukkit; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.login.ServerboundHelloPacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.ServerConnectionListener; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitRunnable; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.BiFunction; import java.util.logging.Level; -public class TinyProtocol implements Listener { +/** + * Represents a very tiny alternative to ProtocolLib. + *

+ * It now supports intercepting packets during login and status ping (such as OUT_SERVER_PING)! + * + * @author Kristian + */ +public class TinyProtocol { + // Speedup channel lookup + private Map channelLookup = new MapMaker().weakValues().makeMap(); + private Listener listener; - private static final Class craftServer = Reflection.getClass("org.bukkit.craftbukkit.CraftServer"); - private static final Class dedicatedPlayerList = Reflection.getClass("net.minecraft.server.dedicated.DedicatedPlayerList"); - private static final Field getPlayerList = Reflection.getField(craftServer, dedicatedPlayerList, 0); - private static final Class playerList = Reflection.getClass("net.minecraft.server.players.PlayerList"); - private static final Class minecraftServer = Reflection.getClass("net.minecraft.server.MinecraftServer"); - private static final Field getMinecraftServer = Reflection.getField(playerList, minecraftServer, 0); - public static final Class serverConnection = Reflection.getClass("net.minecraft.server.network.ServerConnectionListener"); - private static final Field getServerConnection = Reflection.getField(minecraftServer, serverConnection, 0); - public static Object getServerConnection(Plugin plugin) { - return getServerConnection.get(getMinecraftServer.get(getPlayerList.get(plugin.getServer()))); - } - private static final Class networkManager = Reflection.getClass("net.minecraft.network.NetworkManager"); - public static final Field networkManagers = Reflection.getField(serverConnection, List.class, 0, networkManager); + // Channels that have already been removed + private Set uninjectedChannels = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap()); + // List of network markers + public List networkManagers; + + // Injected channel handlers + private List serverChannels = new ArrayList<>(); + private ChannelInboundHandlerAdapter serverChannelHandler; + private ChannelInitializer beginInitProtocol; + private ChannelInitializer endInitProtocol; + + // Current handler name private static final String HANDLER_NAME = "tiny-steamwar"; + + protected volatile boolean closed; + protected Plugin plugin; + public static final TinyProtocol instance = new TinyProtocol(Core.getInstance()); + private final Map, List>> packetFilters = new HashMap<>(); public static void init() { - //enforce init - } - - private final Plugin plugin; - private final List connections; - private boolean closed; - - private final Map, List>> packetFilters = new HashMap<>(); - @Getter - private final Map playerInterceptors = new HashMap<>(); - - @Override - public String toString() { - return "TinyProtocol{" + - "plugin=" + plugin + - ", connections=" + connections + - ", closed=" + closed + - ", packetFilters=" + packetFilters + - ", playerInterceptors=" + playerInterceptors + - '}'; + // enforce init } + /** + * Construct a new instance of TinyProtocol, and start intercepting packets for all connected clients and future clients. + *

+ * You can construct multiple instances per plugin. + * + * @param plugin - the plugin. + */ private TinyProtocol(final Plugin plugin) { this.plugin = plugin; - this.connections = networkManagers.get(getServerConnection(plugin)); - plugin.getServer().getPluginManager().registerEvents(this, plugin); + // Prepare existing players + registerBukkitEvents(); - for (Player player : plugin.getServer().getOnlinePlayers()) { - new PacketInterceptor(player); + try { + registerChannelHandler(); + registerPlayers(plugin); + } catch (IllegalArgumentException ex) { + // Damn you, late bind + plugin.getLogger().info("[TinyProtocol] Delaying server channel injection due to late bind."); + + new BukkitRunnable() { + @Override + public void run() { + registerChannelHandler(); + registerPlayers(plugin); + plugin.getLogger().info("[TinyProtocol] Late bind injection successful."); + } + }.runTask(plugin); } } - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerLogin(PlayerLoginEvent e) { - plugin.getLogger().info("Creating PacketInterceptor for: " + e.getPlayer().getName() + " (" + closed + ")"); - if(closed) + private void createServerChannelHandler() { + // Handle connected channels + endInitProtocol = new ChannelInitializer() { + + @Override + protected void initChannel(Channel channel) throws Exception { + try { + // This can take a while, so we need to stop the main thread from interfering + synchronized (networkManagers) { + // Stop injecting channels + if (!closed) { + channel.eventLoop().submit(() -> injectChannelInternal(channel)); + } + } + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "Cannot inject incomming channel " + channel, e); + } + } + + }; + + // This is executed before Minecraft's channel handler + beginInitProtocol = new ChannelInitializer() { + + @Override + protected void initChannel(Channel channel) throws Exception { + channel.pipeline().addLast(endInitProtocol); + } + + }; + + serverChannelHandler = new ChannelInboundHandlerAdapter() { + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Channel channel = (Channel) msg; + + // Prepare to initialize ths channel + channel.pipeline().addFirst(beginInitProtocol); + ctx.fireChannelRead(msg); + } + + }; + } + + /** + * Register bukkit events. + */ + private void registerBukkitEvents() { + listener = new Listener() { + + @EventHandler(priority = EventPriority.LOWEST) + public final void onPlayerLogin(PlayerLoginEvent e) { + if (closed) + return; + + Channel channel = getChannel(e.getPlayer()); + + // Don't inject players that have been explicitly uninjected + if (!uninjectedChannels.contains(channel)) { + injectPlayer(e.getPlayer()); + } + } + + @EventHandler + public final void onPluginDisable(PluginDisableEvent e) { + if (e.getPlugin().equals(plugin)) { + close(); + } + } + + }; + + plugin.getServer().getPluginManager().registerEvents(listener, plugin); + } + + @SuppressWarnings("unchecked") + private void registerChannelHandler() { + ServerConnectionListener serverConnection = MinecraftServer.getServer().getConnection(); + networkManagers = serverConnection.getConnections(); + // We need to synchronize against this list + createServerChannelHandler(); + + // Find the correct list, or implicitly throw an exception + boolean looking = true; + for (int i = 0; looking; i++) { + List list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection); + + for (Object item : list) { + if (!(item instanceof ChannelFuture)) + break; + + // Channel future that contains the server connection + Channel serverChannel = ((ChannelFuture) item).channel(); + + serverChannels.add(serverChannel); + serverChannel.pipeline().addFirst(serverChannelHandler); + looking = false; + } + } + } + + private void unregisterChannelHandler() { + if (serverChannelHandler == null) return; - new PacketInterceptor(e.getPlayer()); - } - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerDisconnect(PlayerQuitEvent e) { - getInterceptor(e.getPlayer()).ifPresent(PacketInterceptor::close); - } + for (Channel serverChannel : serverChannels) { + final ChannelPipeline pipeline = serverChannel.pipeline(); - @EventHandler - public void onPluginDisable(PluginDisableEvent e) { - if (e.getPlugin().equals(plugin)) { - close(); + // Remove channel handler + serverChannel.eventLoop().execute(new Runnable() { + + @Override + public void run() { + try { + pipeline.remove(serverChannelHandler); + } catch (NoSuchElementException e) { + // That's fine + } + } + + }); } } + private void registerPlayers(Plugin plugin) { + for (Player player : plugin.getServer().getOnlinePlayers()) { + injectPlayer(player); + } + } + + public void addTypedFilter(Class packetType, BiFunction filter) { + packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add((BiFunction) filter); + } + + @Deprecated public void addFilter(Class packetType, BiFunction filter) { packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add(filter); } @@ -121,96 +256,206 @@ public class TinyProtocol implements Listener { packetFilters.getOrDefault(packetType, Collections.emptyList()).remove(filter); } - public void sendPacket(Player player, Object packet) { - getInterceptor(player).ifPresent(i -> i.sendPacket(packet)); + /** + * Send a packet to a particular player. + * + * @param player - the destination player. + * @param packet - the packet to send. + */ + public void sendPacket(Player player, Packet packet) { + sendPacket(getChannel(player), packet); } - public void receivePacket(Player player, Object packet) { - getInterceptor(player).ifPresent(i -> i.receivePacket(packet)); + @Deprecated + public void sendPacket(Player player, Object object) { + if (object instanceof Packet packet) { + sendPacket(getChannel(player), packet); + } } + /** + * Send a packet to a particular client. + * + * @param channel - client identified by a channel. + * @param packet - the packet to send. + */ + public void sendPacket(Channel channel, Packet packet) { + channel.pipeline().writeAndFlush(packet); + } + + /** + * Pretend that a given packet has been received from a player. + * + * @param player - the player that sent the packet. + * @param packet - the packet that will be received by the server. + */ + public void receivePacket(Player player, Packet packet) { + receivePacket(getChannel(player), packet); + } + + /** + * Pretend that a given packet has been received from a given client. + * + * @param channel - client identified by a channel. + * @param packet - the packet that will be received by the server. + */ + public void receivePacket(Channel channel, Packet packet) { + channel.pipeline().context("encoder").fireChannelRead(packet); + } + + /** + * Add a custom channel handler to the given player's channel pipeline, allowing us to intercept sent and received packets. + *

+ * This will automatically be called when a player has logged in. + * + * @param player - the player to inject. + */ + public void injectPlayer(Player player) { + injectChannelInternal(getChannel(player)).player = player; + } + + /** + * Add a custom channel handler to the given channel. + * + * @param channel - the channel to inject. + * @return The intercepted channel, or NULL if it has already been injected. + */ + public void injectChannel(Channel channel) { + injectChannelInternal(channel); + } + + /** + * Add a custom channel handler to the given channel. + * + * @param channel - the channel to inject. + * @return The packet interceptor. + */ + private PacketInterceptor injectChannelInternal(Channel channel) { + try { + PacketInterceptor interceptor = (PacketInterceptor) channel.pipeline().get(HANDLER_NAME); + + // Inject our packet interceptor + if (interceptor == null) { + interceptor = new PacketInterceptor(); + channel.pipeline().addBefore("packet_handler", HANDLER_NAME, interceptor); + uninjectedChannels.remove(channel); + } + + return interceptor; + } catch (IllegalArgumentException e) { + // Try again + return (PacketInterceptor) channel.pipeline().get(HANDLER_NAME); + } + } + + /** + * Retrieve the Netty channel associated with a player. This is cached. + * + * @param player - the player. + * @return The Netty channel. + */ + public Channel getChannel(Player player) { + Channel channel = channelLookup.get(player.getName()); + + // Lookup channel again + if (channel == null) { + Channel playerChannel = ((CraftPlayer) player).getHandle().connection.connection.channel; + channelLookup.put(player.getName(), channel = playerChannel); + } + + return channel; + } + + /** + * Uninject a specific player. + * + * @param player - the injected player. + */ + public void uninjectPlayer(Player player) { + uninjectChannel(getChannel(player)); + } + + /** + * Uninject a specific channel. + *

+ * This will also disable the automatic channel injection that occurs when a player has properly logged in. + * + * @param channel - the injected channel. + */ + public void uninjectChannel(final Channel channel) { + // No need to guard against this if we're closing + if (!closed) { + uninjectedChannels.add(channel); + } + + // See ChannelInjector in ProtocolLib, line 590 + channel.eventLoop().execute(new Runnable() { + + @Override + public void run() { + channel.pipeline().remove(HANDLER_NAME); + } + + }); + } + + /** + * Determine if the given player has been injected by TinyProtocol. + * + * @param player - the player. + * @return TRUE if it is, FALSE otherwise. + */ + public boolean hasInjected(Player player) { + return hasInjected(getChannel(player)); + } + + /** + * Determine if the given channel has been injected by TinyProtocol. + * + * @param channel - the channel. + * @return TRUE if it is, FALSE otherwise. + */ + public boolean hasInjected(Channel channel) { + return channel.pipeline().get(HANDLER_NAME) != null; + } + + /** + * Cease listening for packets. This is called automatically when your plugin is disabled. + */ public final void close() { - plugin.getLogger().log(Level.INFO, "Closing PacketInterceptor", new Exception("Stacktrace")); + if (!closed) { + closed = true; - if(closed) - return; - closed = true; + // Remove our handlers + for (Player player : plugin.getServer().getOnlinePlayers()) { + uninjectPlayer(player); + } - HandlerList.unregisterAll(this); - - for (Player player : plugin.getServer().getOnlinePlayers()) { - getInterceptor(player).ifPresent(PacketInterceptor::close); + // Clean up Bukkit + HandlerList.unregisterAll(listener); + unregisterChannelHandler(); } } - private Optional getInterceptor(Player player) { - synchronized (playerInterceptors) { - return Optional.ofNullable(playerInterceptors.get(player)); - } - } - - private static final Field getChannel = Reflection.getField(networkManager, Channel.class, 0); - private static final Field getUUID = Reflection.getField(networkManager, UUID.class, 0); - - public final class PacketInterceptor extends ChannelDuplexHandler { - private final Player player; - @Getter - private final Channel channel; - - private PacketInterceptor(Player player) { - this.player = player; - - channel = connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).map(getChannel::get).filter(Channel::isActive).findAny().orElseThrow(() -> { - Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure.")); - return new SecurityException("Could not find channel for player " + player.getName()); - }); - - if(!channel.isActive()) - return; - - synchronized (playerInterceptors) { - playerInterceptors.put(player, this); - } - plugin.getLogger().info("Adding Techhider for: " + player.getName()); - - try { - channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this); - } catch (IllegalArgumentException | NoSuchElementException e) { - Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure.")); - throw new SecurityException(e); - } - } - - private void sendPacket(Object packet) { - channel.pipeline().writeAndFlush(packet); - } - - private void receivePacket(Object packet) { - channel.pipeline().context("encoder").fireChannelRead(packet); - } - - private void close() { - if(channel.isActive()) { - channel.eventLoop().execute(() -> { - try { - channel.pipeline().remove(HANDLER_NAME); - } catch (NoSuchElementException e) { - // ignore - } - }); - } - - synchronized (playerInterceptors) { - playerInterceptors.remove(player, this); - } - } + /** + * Channel handler that is inserted into the player's channel pipeline, allowing us to intercept sent and received packets. + * + * @author Kristian + */ + private final class PacketInterceptor extends ChannelDuplexHandler { + // Updated by the login event + public volatile Player player; @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + // Intercept channel + final Channel channel = ctx.channel(); + handleLoginStart(channel, msg); + try { msg = filterPacket(player, msg); } catch (Exception e) { - plugin.getLogger().log(Level.SEVERE, "Error during incoming packet processing", e); + plugin.getLogger().log(Level.SEVERE, "Error in onPacketInAsync().", e); } if (msg != null) { @@ -223,7 +468,7 @@ public class TinyProtocol implements Listener { try { msg = filterPacket(player, msg); } catch (Exception e) { - plugin.getLogger().log(Level.SEVERE, "Error during outgoing packet processing", e); + plugin.getLogger().log(Level.SEVERE, "Error in onPacketOutAsync().", e); } if (msg != null) { @@ -231,17 +476,21 @@ public class TinyProtocol implements Listener { } } + private void handleLoginStart(Channel channel, Object packet) { + if (packet instanceof ServerboundHelloPacket(String name, UUID packetId)) { + channelLookup.put(name, channel); + } + } + private Object filterPacket(Player player, Object packet) { List> filters = packetFilters.getOrDefault(packet.getClass(), Collections.emptyList()); for(BiFunction filter : filters) { packet = filter.apply(player, packet); - - if(packet == null) - break; + if(packet == null) break; } return packet; } } -} +} \ No newline at end of file diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java index 5b5d88d2..3230e84e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java @@ -206,18 +206,10 @@ public final class Reflection { return getField(target, name, fieldType, 0); } - public static Field getField(String className, String name, Class fieldType) { - return getField(getClass(className), name, fieldType, 0); - } - public static Field getField(Class target, Class fieldType, int index) { return getField(target, null, fieldType, index); } - public static Field getField(String className, Class fieldType, int index) { - return getField(getClass(className), fieldType, index); - } - public static Field getField(Class target, Class fieldType, int index, Class... parameters) { return getField(target, null, fieldType, index, parameters); } @@ -268,14 +260,6 @@ public final class Reflection { } } - public static Method getMethod(String className, String methodName, Class... params) { - return getTypedMethod(getClass(className), methodName, null, params); - } - - public static Method getMethod(Class clazz, String methodName, Class... params) { - return getTypedMethod(clazz, methodName, null, params); - } - public static Method getTypedMethod(Class clazz, String methodName, Class returnType, Class... params) { for (final java.lang.reflect.Method method : clazz.getDeclaredMethods()) { if ((methodName == null || method.getName().equals(methodName)) @@ -306,10 +290,6 @@ public final class Reflection { } } - public static Constructor getConstructor(String className, Class... params) { - return getConstructor(getClass(className), params); - } - public static Constructor getConstructor(Class clazz, Class... params) { for (final java.lang.reflect.Constructor constructor : clazz.getDeclaredConstructors()) { if (Arrays.equals(constructor.getParameterTypes(), params)) { @@ -323,12 +303,8 @@ public final class Reflection { public static Object newInstance(Class clazz) { try { - if (Core.getVersion() > 15) { - return Unsafe.getUnsafe().allocateInstance(clazz); - } else { - return clazz.newInstance(); - } - } catch (InstantiationException | IllegalAccessException e) { + return Unsafe.getUnsafe().allocateInstance(clazz); + } catch (InstantiationException e) { throw new SecurityException("Could not create object", e); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/TypeMapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/TypeMapper.java index 8beaa2f0..8d44f9ec 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/TypeMapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/TypeMapper.java @@ -21,8 +21,6 @@ package de.steamwar.command; import org.bukkit.command.CommandSender; -import java.util.List; - public interface TypeMapper extends AbstractTypeMapper { /** * The CommandSender can be null! diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java index 4cf64ac7..33f85cdb 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java @@ -19,28 +19,99 @@ package de.steamwar.core; +import de.steamwar.Reflection; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializer; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Sound; import org.bukkit.entity.Player; import java.util.UUID; public class BountifulWrapper { - private BountifulWrapper() {} + public static final BountifulWrapper impl = new BountifulWrapper(); - public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + public void playPling(Player player) { + player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + } - public interface IBountifulWrapper { - void playPling(Player player); + public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) { + if(type == ChatMessageType.CHAT) + type = ChatMessageType.SYSTEM; - void sendMessage(Player player, ChatMessageType type, BaseComponent... msg); + player.spigot().sendMessage(type, msg); + } - Object getDataWatcherObject(int index, Class type); - Object getDataWatcherItem(Object dataWatcherObject, Object value); + private static final Class dataWatcherRegistry = EntityDataSerializers.class; + private static final Class dataWatcherSerializer = EntityDataSerializer.class; + public Object getDataWatcherObject(int index, Class type) { + return new EntityDataAccessor<>(index, (EntityDataSerializer) Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null)); + } - PositionSetter getPositionSetter(Class packetClass, int fieldOffset); - PositionSetter getRelMoveSetter(Class packetClass); - UUIDSetter getUUIDSetter(Class packetClass); + public Object getDataWatcherItem(Object dwo, Object value) { + return new SynchedEntityData.DataItem<>((EntityDataAccessor) dwo, value); + } + + public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { + try { + Reflection.Field field = Reflection.getField(packetClass, PositionMoveRotation.class, 0); + + return (packet, x, y, z, pitch, yaw) -> { + PositionMoveRotation pos = field.get(packet); + + field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), pos.deltaMovement(), yaw, pitch)); + }; + } catch (IllegalArgumentException e) { + Reflection.Field posX = Reflection.getField(packetClass, double.class, fieldOffset); + Reflection.Field posY = Reflection.getField(packetClass, double.class, fieldOffset+1); + Reflection.Field posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); + boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn"); + Class pitchYawType = isByteClass ? byte.class : int.class; + Reflection.Field lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); + Reflection.Field lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); + + return (packet, x, y, z, pitch, yaw) -> { + posX.set(packet, x); + posY.set(packet, y); + posZ.set(packet, z); + if (isByteClass) { + lookYaw.set(packet, (byte) (yaw*256/360)); + lookPitch.set(packet, (byte) (pitch*256/360)); + } else { + lookYaw.set(packet, (int) (yaw*256/360)); + lookPitch.set(packet, (int) (pitch*256/360)); + } + }; + } + } + + + public BountifulWrapper.PositionSetter getRelMoveSetter(Class packetClass) { + Class type = short.class; + Reflection.Field moveX = Reflection.getField(packetClass, type, 0); + Reflection.Field moveY = Reflection.getField(packetClass, type, 1); + Reflection.Field moveZ = Reflection.getField(packetClass, type, 2); + Reflection.Field moveYaw = Reflection.getField(packetClass, byte.class, 0); + Reflection.Field movePitch = Reflection.getField(packetClass, byte.class, 1); + + return (packet, x, y, z, pitch, yaw) -> { + moveX.set(packet, (short)(x*4096)); + moveY.set(packet, (short)(y*4096)); + moveZ.set(packet, (short)(z*4096)); + moveYaw.set(packet, (byte)(yaw*256/360)); + movePitch.set(packet, (byte)(pitch*256/360)); + }; + } + + public BountifulWrapper.UUIDSetter getUUIDSetter(Class packetClass) { + Reflection.Field uuidField = Reflection.getField(packetClass, UUID.class, 0); + + return uuidField::set; } public interface PositionSetter { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java index 668a47a7..57e90970 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java @@ -19,11 +19,26 @@ package de.steamwar.core; -public interface ChatWrapper { - ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.contents.PlainTextContents; +import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; +import net.minecraft.network.syncher.SynchedEntityData; +import java.util.ArrayList; - Object stringToChatComponent(String text); +public class ChatWrapper { + public static final ChatWrapper impl = new ChatWrapper(); - Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues); + public Object stringToChatComponent(String text) { + return MutableComponent.create(PlainTextContents.create(text)); + } + + public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) { + ArrayList> nativeWatchers = new ArrayList<>(1); + for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { + nativeWatchers.add(((SynchedEntityData.DataItem) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).value()); + } + + return new ClientboundSetEntityDataPacket(entityId, nativeWatchers); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java index 8f34ae6a..0099d6cf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java @@ -23,6 +23,8 @@ import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; import de.steamwar.sql.internal.Statement; import io.netty.channel.ChannelFuture; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.ServerConnectionListener; import org.bukkit.Bukkit; import org.eclipse.openj9.criu.CRIUSupport; import org.eclipse.openj9.criu.JVMCRIUException; @@ -56,7 +58,7 @@ class CheckpointUtilsJ9 { Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(null)); - List networkManagers = TinyProtocol.networkManagers.get(TinyProtocol.getServerConnection(Core.getInstance())); + List networkManagers = TinyProtocol.instance.networkManagers; if(!Bukkit.getOnlinePlayers().isEmpty() || !networkManagers.isEmpty()) { Core.getInstance().getLogger().log(Level.INFO, "Waiting for players to disconnect for checkpointing"); Bukkit.getScheduler().runTaskLater(Core.getInstance(), CheckpointUtils::freeze, 1); @@ -90,8 +92,7 @@ class CheckpointUtilsJ9 { } - private static final Reflection.Field channelFutures = Reflection.getField(TinyProtocol.serverConnection, List.class, 0, ChannelFuture.class); - private static final Reflection.Method bind = Reflection.getMethod(TinyProtocol.serverConnection, null, InetAddress.class, int.class); + private static final Reflection.Field channelFutures = Reflection.getField(ServerConnectionListener.class, List.class, 0, ChannelFuture.class); private static void freezeInternal(Path path) throws Exception { Bukkit.getPluginManager().callEvent(new CRIUSleepEvent()); @@ -99,7 +100,7 @@ class CheckpointUtilsJ9 { Statement.closeAll(); // Close socket - Object serverConnection = TinyProtocol.getServerConnection(Core.getInstance()); + ServerConnectionListener serverConnection = MinecraftServer.getServer().getConnection(); List channels = channelFutures.get(serverConnection); for(Object future : channels) { ((ChannelFuture) future).channel().close().syncUninterruptibly(); @@ -135,11 +136,9 @@ class CheckpointUtilsJ9 { } // Reopen socket - bind.invoke(serverConnection, InetAddress.getLoopbackAddress(), port); - if(Core.getVersion() > 12) { - for(Object future : channels) { - ((ChannelFuture) future).channel().config().setAutoRead(true); - } + serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port); + for(Object future : channels) { + ((ChannelFuture) future).channel().config().setAutoRead(true); } Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent()); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CommandRemover.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CommandRemover.java index 8b6aa992..b2da8b75 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CommandRemover.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CommandRemover.java @@ -19,22 +19,20 @@ package de.steamwar.core; -import de.steamwar.Reflection; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; +import org.bukkit.craftbukkit.CraftServer; import java.util.Map; @UtilityClass public class CommandRemover { - private static final Reflection.Field commandMap = Reflection.getField("org.bukkit.craftbukkit.CraftServer", "commandMap", SimpleCommandMap.class); - private static final Reflection.Field knownCommands = Reflection.getField(SimpleCommandMap.class, "knownCommands", Map.class); + private static final Map knownCommands = ((CraftServer) Bukkit.getServer()).getCommandMap().getKnownCommands(); + public static void removeAll(String... cmds) { - Map knownCmds = knownCommands.get(commandMap.get(Bukkit.getServer())); for (String cmd : cmds) { - knownCmds.remove(cmd.toLowerCase()); + knownCommands.remove(cmd.toLowerCase()); } } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java index e632ca45..02dd64bf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -21,16 +21,11 @@ package de.steamwar.core; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; -import de.steamwar.command.*; -import de.steamwar.core.authlib.SteamwarGameProfileRepository; -import de.steamwar.core.events.AntiNocom; -import de.steamwar.core.events.ChattingEvent; -import de.steamwar.core.events.PlayerJoinedEvent; -import de.steamwar.core.events.WorldLoadEvent; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.SWTypeMapperCreator; import de.steamwar.command.TabCompletionCache; import de.steamwar.command.TypeMapper; +import de.steamwar.core.authlib.SteamwarGameProfileRepository; import de.steamwar.linkage.AbstractLinker; import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; @@ -54,6 +49,7 @@ public class Core extends JavaPlugin { public static final Message MESSAGE = new Message("SpigotCore", Core.class.getClassLoader()); + @Deprecated public static int getVersion(){ return Reflection.MAJOR_VERSION; } @@ -108,16 +104,14 @@ public class Core extends JavaPlugin { return; } - Bukkit.getServer().getPluginManager().registerEvents(RecipeDiscoverWrapper.impl, this); if(!Statement.productionDatabase()) { - getServer().getPluginManager().registerEvents(LocaleChangeWrapper.impl, this); + getServer().getPluginManager().registerEvents(new LocaleChangeWrapper(), this); } getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); - if (Core.getVersion() != 20) - SteamwarGameProfileRepository.impl.inject(); + SteamwarGameProfileRepository.impl.inject(); TinyProtocol.init(); CheckpointUtils.signalHandler(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java index dfeed83c..17efee53 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java @@ -19,14 +19,18 @@ package de.steamwar.core; +import com.comphenix.tinyprotocol.TinyProtocol; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.entity.Player; public class CraftbukkitWrapper { - private CraftbukkitWrapper() {} + public static final CraftbukkitWrapper impl = new CraftbukkitWrapper(); - public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); - - public interface ICraftbukkitWrapper { - void sendChunk(Player p, int chunkX, int chunkZ); + public void sendChunk(Player p, int chunkX, int chunkZ) { + LevelChunk chunk = (LevelChunk) ((CraftChunk) p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(ChunkStatus.FULL); + TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null, true)); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index 640d7ac0..969a65d8 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -21,6 +21,7 @@ package de.steamwar.core; import de.steamwar.Reflection; import de.steamwar.sql.SWException; +import org.spigotmc.WatchdogThread; import java.io.ByteArrayOutputStream; import java.io.PrintStream; @@ -39,10 +40,8 @@ public class ErrorHandler extends Handler { public ErrorHandler(){ Logger.getLogger("").addHandler(this); - Class watchdogThread = Reflection.getClass("org.spigotmc.WatchdogThread"); - Reflection.Field getInstance = Reflection.getField(watchdogThread, watchdogThread, 0); - Thread watchdog = (Thread) getInstance.get(null); - watchdogThreadId = watchdog.getId(); + Reflection.Field getInstance = Reflection.getField(WatchdogThread.class, WatchdogThread.class, 0); + watchdogThreadId = getInstance.get(null).getId(); } void unregister() { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java index f98646f5..e08b9a9e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java @@ -19,38 +19,332 @@ package de.steamwar.core; +import com.destroystokyo.paper.profile.PlayerProfile; import de.steamwar.Reflection; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetObjectivePacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Pose; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; public class FlatteningWrapper { private FlatteningWrapper() {} - public static final Class scoreboardObjective = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetObjectivePacket"); - public static final Class scoreboardScore = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetScorePacket"); + public static final FlatteningWrapper impl = new FlatteningWrapper(); - public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + private static final Map renamedLegacy = new HashMap<>(); - public interface IFlatteningWrapper { - void setScoreboardTitle(Object packet, String title); - void setScoreAction(Object packet); + static{ + renamedLegacy.put("WOOD", Material.OAK_WOOD); + renamedLegacy.put("SAPLING", Material.OAK_SAPLING); + renamedLegacy.put("STATIONARY_WATER", Material.WATER); + renamedLegacy.put("STATIONARY_LAVA", Material.LAVA); + renamedLegacy.put("LOG", Material.OAK_LOG); + renamedLegacy.put("LEAVES", Material.OAK_LEAVES); + renamedLegacy.put("BED_BLOCK", Material.RED_BED); + renamedLegacy.put("BED", Material.RED_BED); + renamedLegacy.put("PISTON_STICKY_BASE", Material.STICKY_PISTON); + renamedLegacy.put("WEB", Material.COBWEB); + renamedLegacy.put("LONG_GRASS", Material.TALL_GRASS); + renamedLegacy.put("PISTON_BASE", Material.PISTON); + renamedLegacy.put("PISTON_EXTENSION", Material.PISTON_HEAD); + renamedLegacy.put("WOOL", Material.WHITE_WOOL); + renamedLegacy.put("PISTON_MOVING_PIECE", Material.MOVING_PISTON); + renamedLegacy.put("YELLOW_FLOWER", Material.DANDELION); + renamedLegacy.put("RED_ROSE", Material.POPPY); + renamedLegacy.put("DOUBLE_STEP", Material.SMOOTH_STONE); + renamedLegacy.put("STEP", Material.SMOOTH_STONE_SLAB); + renamedLegacy.put("MOB_SPAWNER", Material.SPAWNER); + renamedLegacy.put("WOOD_STAIRS", Material.OAK_STAIRS); + renamedLegacy.put("WORKBENCH", Material.CRAFTING_TABLE); + renamedLegacy.put("CROPS", Material.WHEAT_SEEDS); + renamedLegacy.put("SEEDS", Material.WHEAT_SEEDS); + renamedLegacy.put("SOIL", Material.FARMLAND); + renamedLegacy.put("BURNING_FURNACE", Material.FURNACE); + renamedLegacy.put("SIGN_POST", Material.OAK_SIGN); + renamedLegacy.put("SIGN", Material.OAK_SIGN); + renamedLegacy.put("WOODEN_DOOR", Material.OAK_DOOR); + renamedLegacy.put("WOOD_DOOR", Material.OAK_DOOR); + renamedLegacy.put("RAILS", Material.RAIL); + renamedLegacy.put("WALL_SIGN", Material.OAK_WALL_SIGN); + renamedLegacy.put("STONE_PLATE", Material.STONE_PRESSURE_PLATE); + renamedLegacy.put("WOOD_PLATE", Material.OAK_PRESSURE_PLATE); + renamedLegacy.put("GLOWING_REDSTONE_ORE", Material.REDSTONE_ORE); + renamedLegacy.put("REDSTONE_TORCH_OFF", Material.REDSTONE_TORCH); + renamedLegacy.put("REDSTONE_TORCH_ON", Material.REDSTONE_TORCH); + renamedLegacy.put("IRON_DOOR_BLOCK", Material.IRON_DOOR); + renamedLegacy.put("SUGAR_CANE_BLOCK", Material.SUGAR_CANE); + renamedLegacy.put("CAKE_BLOCK", Material.CAKE); + renamedLegacy.put("MELON_BLOCK", Material.MELON); + renamedLegacy.put("BEETROOT_BLOCK", Material.BEETROOT); + renamedLegacy.put("FENCE", Material.OAK_FENCE); + renamedLegacy.put("PORTAL", Material.NETHER_PORTAL); + renamedLegacy.put("DIODE_BLOCK_OFF", Material.REPEATER); + renamedLegacy.put("DIODE_BLOCK_ON", Material.REPEATER); + renamedLegacy.put("DIODE", Material.REPEATER); + renamedLegacy.put("STAINED_GLASS", Material.WHITE_STAINED_GLASS); + renamedLegacy.put("TRAP_DOOR", Material.OAK_TRAPDOOR); + renamedLegacy.put("MONSTER_EGGS", Material.SKELETON_SPAWN_EGG); + renamedLegacy.put("MONSTER_EGG", Material.SKELETON_SPAWN_EGG); + renamedLegacy.put("SMOOTH_BRICK", Material.STONE_BRICKS); + renamedLegacy.put("HUGE_MUSHROOM_1", Material.MUSHROOM_STEM); + renamedLegacy.put("HUGE_MUSHROOM_2", Material.RED_MUSHROOM); + renamedLegacy.put("IRON_FENCE", Material.IRON_BARS); + renamedLegacy.put("THIN_GLASS", Material.GLASS_PANE); + renamedLegacy.put("FENCE_GATE", Material.OAK_FENCE_GATE); + renamedLegacy.put("SMOOTH_STAIRS", Material.STONE_BRICK_STAIRS); + renamedLegacy.put("MYCEL", Material.MYCELIUM); + renamedLegacy.put("WATER_LILY", Material.LILY_PAD); + renamedLegacy.put("NETHER_FENCE", Material.NETHER_BRICK_FENCE); + renamedLegacy.put("NETHER_WARTS", Material.NETHER_WART); + renamedLegacy.put("NETHER_STALK", Material.NETHER_WART); + renamedLegacy.put("ENCHANTMENT_TABLE", Material.ENCHANTING_TABLE); + renamedLegacy.put("ENDER_PORTAL", Material.END_PORTAL); + renamedLegacy.put("ENDER_PORTAL_FRAME", Material.END_PORTAL_FRAME); + renamedLegacy.put("ENDER_STONE", Material.END_STONE); + renamedLegacy.put("REDSTONE_LAMP_OFF", Material.REDSTONE_LAMP); + renamedLegacy.put("REDSTONE_LAMP_ON", Material.REDSTONE_LAMP); + renamedLegacy.put("WOOD_DOUBLE_STEP", Material.OAK_SLAB); + renamedLegacy.put("WOOD_STEP", Material.OAK_SLAB); + renamedLegacy.put("SPRUCE_WOOD_STAIRS", Material.SPRUCE_STAIRS); + renamedLegacy.put("BIRCH_WOOD_STAIRS", Material.BIRCH_STAIRS); + renamedLegacy.put("JUNGLE_WOOD_STAIRS", Material.JUNGLE_STAIRS); + renamedLegacy.put("COMMAND", Material.COMMAND_BLOCK); + renamedLegacy.put("COBBLE_WALL", Material.COBBLESTONE_WALL); + renamedLegacy.put("WOOD_BUTTON", Material.OAK_BUTTON); + renamedLegacy.put("SKULL", Material.SKELETON_SKULL); + renamedLegacy.put("SKULL_ITEM", Material.SKELETON_SKULL); + renamedLegacy.put("GOLD_PLATE", Material.LIGHT_WEIGHTED_PRESSURE_PLATE); + renamedLegacy.put("IRON_PLATE", Material.HEAVY_WEIGHTED_PRESSURE_PLATE); + renamedLegacy.put("REDSTONE_COMPARATOR_OFF", Material.COMPARATOR); + renamedLegacy.put("REDSTONE_COMPARATOR_ON", Material.COMPARATOR); + renamedLegacy.put("REDSTONE_COMPARATOR", Material.COMPARATOR); + renamedLegacy.put("QUARTZ_ORE", Material.QUARTZ); + renamedLegacy.put("STAINED_CLAY", Material.WHITE_TERRACOTTA); + renamedLegacy.put("STAINED_GLASS_PANE", Material.WHITE_STAINED_GLASS_PANE); + renamedLegacy.put("LEAVES_2", Material.ACACIA_LEAVES); + renamedLegacy.put("LOG_2", Material.ACACIA_LOG); + renamedLegacy.put("CARPET", Material.WHITE_CARPET); + renamedLegacy.put("HARD_CLAY", Material.TERRACOTTA); + renamedLegacy.put("DOUBLE_PLANT", Material.SUNFLOWER); + renamedLegacy.put("STANDING_BANNER", Material.WHITE_BANNER); + renamedLegacy.put("BANNER", Material.WHITE_BANNER); + renamedLegacy.put("WALL_BANNER", Material.WHITE_WALL_BANNER); + renamedLegacy.put("DAYLIGHT_DETECTOR_INVERTED", Material.DAYLIGHT_DETECTOR); + renamedLegacy.put("DOUBLE_STONE_SLAB2", Material.RED_SANDSTONE_SLAB); + renamedLegacy.put("STONE_SLAB2", Material.RED_SANDSTONE_SLAB); + renamedLegacy.put("PURPUR_DOUBLE_SLAB", Material.PURPUR_SLAB); + renamedLegacy.put("END_BRICKS", Material.END_STONE_BRICKS); + renamedLegacy.put("COMMAND_REPEATING", Material.REPEATING_COMMAND_BLOCK); + renamedLegacy.put("COMMAND_CHAIN", Material.CHAIN_COMMAND_BLOCK); + renamedLegacy.put("MAGMA", Material.MAGMA_BLOCK); + renamedLegacy.put("RED_NETHER_BRICK", Material.RED_NETHER_BRICKS); + renamedLegacy.put("SILVER_SHULKER_BOX", Material.LIGHT_GRAY_SHULKER_BOX); + renamedLegacy.put("SILVER_GLAZED_TERRACOTTA", Material.LIGHT_GRAY_TERRACOTTA); + renamedLegacy.put("CONCRETE", Material.WHITE_CONCRETE); + renamedLegacy.put("CONCRETE_POWDER", Material.WHITE_CONCRETE_POWDER); + renamedLegacy.put("IRON_SPADE", Material.IRON_SHOVEL); + renamedLegacy.put("WOOD_SWORD", Material.WOODEN_SWORD); + renamedLegacy.put("WOOD_SPADE", Material.WOODEN_SHOVEL); + renamedLegacy.put("WOOD_PICKAXE", Material.WOODEN_PICKAXE); + renamedLegacy.put("WOOD_AXE", Material.WOODEN_AXE); + renamedLegacy.put("STONE_SPADE", Material.STONE_SHOVEL); + renamedLegacy.put("DIAMOND_SPADE", Material.DIAMOND_SHOVEL); + renamedLegacy.put("MUSHROOM_SOUP", Material.MUSHROOM_STEW); + renamedLegacy.put("GOLD_SWORD", Material.GOLDEN_SWORD); + renamedLegacy.put("GOLD_SPADE", Material.GOLDEN_SHOVEL); + renamedLegacy.put("GOLD_PICKAXE", Material.GOLDEN_PICKAXE); + renamedLegacy.put("GOLD_AXE", Material.GOLDEN_AXE); + renamedLegacy.put("SULPHUR", Material.GUNPOWDER); + renamedLegacy.put("WOOD_HOE", Material.WOODEN_HOE); + renamedLegacy.put("GOLD_HOE", Material.GOLDEN_HOE); + renamedLegacy.put("GOLD_HELMET", Material.GOLDEN_HELMET); + renamedLegacy.put("GOLD_CHESTPLATE", Material.GOLDEN_CHESTPLATE); + renamedLegacy.put("GOLD_LEGGINGS", Material.GOLDEN_LEGGINGS); + renamedLegacy.put("GOLD_BOOTS", Material.GOLDEN_BOOTS); + renamedLegacy.put("PORK", Material.PORKCHOP); + renamedLegacy.put("GRILLED_PORK", Material.COOKED_PORKCHOP); + renamedLegacy.put("SNOW_BALL", Material.SNOWBALL); + renamedLegacy.put("BOAT", Material.OAK_BOAT); + renamedLegacy.put("CLAY_BRICK", Material.BRICKS); + renamedLegacy.put("STORAGE_MINECART", Material.CHEST_MINECART); + renamedLegacy.put("POWERED_MINECART", Material.FURNACE_MINECART); + renamedLegacy.put("WATCH", Material.CLOCK); + renamedLegacy.put("RAW_FISH", Material.SALMON); + renamedLegacy.put("COOKED_FISH", Material.COOKED_SALMON); + renamedLegacy.put("INK_SACK", Material.INK_SAC); + renamedLegacy.put("RAW_BEEF", Material.BEEF); + renamedLegacy.put("RAW_CHICKEN", Material.CHICKEN); + renamedLegacy.put("EYE_OF_ENDER", Material.ENDER_EYE); + renamedLegacy.put("SPECKLED_MELON", Material.GLISTERING_MELON_SLICE); + renamedLegacy.put("EXP_BOTTLE", Material.EXPERIENCE_BOTTLE); + renamedLegacy.put("FIREBALL", Material.FIRE_CHARGE); + renamedLegacy.put("BOOK_AND_QUILL", Material.WRITABLE_BOOK); + renamedLegacy.put("FLOWER_POT_ITEM", Material.FLOWER_POT); + renamedLegacy.put("EMPTY_MAP", Material.MAP); + renamedLegacy.put("BREWING_STAND_ITEM", Material.BREWING_STAND); + renamedLegacy.put("CAULDRON_ITEM", Material.CAULDRON); + renamedLegacy.put("CARROT_ITEM", Material.CARROT); + renamedLegacy.put("POTATO_ITEM", Material.POTATO); + renamedLegacy.put("SPRUCE_DOOR_ITEM", Material.SPRUCE_DOOR); + renamedLegacy.put("BIRCH_DOOR_ITEM", Material.BIRCH_DOOR); + renamedLegacy.put("JUNGLE_DOOR_ITEM", Material.JUNGLE_DOOR); + renamedLegacy.put("ACACIA_DOOR_ITEM", Material.ACACIA_DOOR); + renamedLegacy.put("DARK_OAK_DOOR_ITEM", Material.DARK_OAK_DOOR); + renamedLegacy.put("CARROT_STICK", Material.CARROT_ON_A_STICK); + renamedLegacy.put("FIREWORK", Material.FIREWORK_ROCKET); + renamedLegacy.put("FIREWORK_CHARGE", Material.FIREWORK_STAR); + renamedLegacy.put("NETHER_BRICK_ITEM", Material.NETHER_BRICKS); + renamedLegacy.put("EXPLOSIVE_MINECART", Material.TNT_MINECART); + renamedLegacy.put("IRON_BARDING", Material.IRON_HORSE_ARMOR); + renamedLegacy.put("GOLD_BARDING", Material.GOLDEN_HORSE_ARMOR); + renamedLegacy.put("DIAMOND_BARDING", Material.DIAMOND_HORSE_ARMOR); + renamedLegacy.put("LEASH", Material.LEAD); + renamedLegacy.put("COMMAND_MINECART", Material.COMMAND_BLOCK_MINECART); + renamedLegacy.put("CHORUS_FRUIT_POPPED", Material.POPPED_CHORUS_FRUIT); + renamedLegacy.put("DRAGONS_BREATH", Material.DRAGON_BREATH); + renamedLegacy.put("BOAT_SPRUCE", Material.SPRUCE_BOAT); + renamedLegacy.put("BOAT_BIRCH", Material.BIRCH_BOAT); + renamedLegacy.put("BOAT_JUNGLE", Material.JUNGLE_BOAT); + renamedLegacy.put("BOAT_ACACIA", Material.ACACIA_BOAT); + renamedLegacy.put("BOAT_DARK_OAK", Material.DARK_OAK_BOAT); + renamedLegacy.put("TOTEM", Material.TOTEM_OF_UNDYING); + renamedLegacy.put("GOLD_RECORD", Material.MUSIC_DISC_13); + renamedLegacy.put("GREEN_RECORD", Material.MUSIC_DISC_CAT); + renamedLegacy.put("RECORD_3", Material.MUSIC_DISC_BLOCKS); + renamedLegacy.put("RECORD_4", Material.MUSIC_DISC_CHIRP); + renamedLegacy.put("RECORD_5", Material.MUSIC_DISC_FAR); + renamedLegacy.put("RECORD_6", Material.MUSIC_DISC_MALL); + renamedLegacy.put("RECORD_7", Material.MUSIC_DISC_MELLOHI); + renamedLegacy.put("RECORD_8", Material.MUSIC_DISC_STAL); + renamedLegacy.put("RECORD_9", Material.MUSIC_DISC_STRAD); + renamedLegacy.put("RECORD_10", Material.MUSIC_DISC_WARD); + renamedLegacy.put("RECORD_11", Material.MUSIC_DISC_11); + renamedLegacy.put("RECORD_12", Material.MUSIC_DISC_WAIT); + } - Material getMaterial(String material); - Material getDye(int colorCode); - ItemStack setSkullOwner(String player); + private static final Reflection.Field scoreboardName = Reflection.getField(ClientboundSetObjectivePacket.class, Component.class, 0); + public void setScoreboardTitle(Object packet, String title) { + scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); + } - Object getPose(EntityPose pose); - void setNamedSpawnPacketDataWatcher(Object packet); - Object formatDisplayName(String displayName); + private static final Class scoreActionEnum = null; + private static final Reflection.Field scoreAction = null; + private static final Object scoreActionChange = null; - void setSpawnPacketType(Object packet, EntityType type); + public void setScoreAction(Object packet) { + scoreAction.set(packet, scoreActionChange); + } - int getViewDistance(Player player); + public Material getMaterial(String material) { + try{ + return Material.valueOf(material); + }catch(IllegalArgumentException e){ + return renamedLegacy.get(material); + } + } - void syncSave(World world); + public Material getDye(int colorCode) { + switch(colorCode){ + case 1: + return Material.RED_DYE; + case 2: + return Material.GREEN_DYE; + case 3: + return Material.BROWN_DYE; + case 4: + return Material.LAPIS_LAZULI; + case 5: + return Material.PURPLE_DYE; + case 6: + return Material.CYAN_DYE; + case 7: + return Material.LIGHT_GRAY_DYE; + case 8: + return Material.GRAY_DYE; + case 9: + return Material.PINK_DYE; + case 10: + return Material.LIME_DYE; + case 11: + return Material.YELLOW_DYE; + case 12: + return Material.LIGHT_BLUE_DYE; + case 13: + return Material.MAGENTA_DYE; + case 14: + return Material.ORANGE_DYE; + case 15: + return Material.WHITE_DYE; + default: + return Material.BLACK_DYE; + } + } + + public ItemStack setSkullOwner(String player) { + ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); + head.editMeta(SkullMeta.class, skullMeta -> { + try { + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player); + PlayerProfile playerProfile = offlinePlayer.getPlayerProfile(); + playerProfile.complete(); + skullMeta.setPlayerProfile(playerProfile); + } catch (Exception e) { + // Ignore + } + }); + return head; + } + + protected static final Class entityPose = Pose.class; + protected static final Object shooting = entityPose.getEnumConstants()[16]; + protected static final Object standing = entityPose.getEnumConstants()[0]; + protected static final Object swimming = entityPose.getEnumConstants()[3]; + protected static final Object sneaking = entityPose.getEnumConstants()[5]; + public Object getPose(FlatteningWrapper.EntityPose pose) { + switch (pose) { + case SHOOTING: + return shooting; + case SNEAKING: + return sneaking; + case SWIMMING: + return swimming; + case NORMAL: + default: + return standing; + } + } + + public Object formatDisplayName(String displayName) { + return displayName != null ? Optional.of(ChatWrapper.impl.stringToChatComponent(displayName)) : Optional.empty(); + } + + private static final Reflection.Field spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, net.minecraft.world.entity.EntityType.class, 0); + public void setSpawnPacketType(Object packet, EntityType type) { + ResourceLocation key = CraftNamespacedKey.toMinecraft(type.getKey()); + spawnType.set(packet, BuiltInRegistries.ENTITY_TYPE.get(key).get().value()); + } + + public int getViewDistance(Player player) { + return player.getClientViewDistance(); + } + + public void syncSave(World world) { + ((CraftWorld) world).getHandle().save(null, true, false); } public enum EntityPose { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/LocaleChangeWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/LocaleChangeWrapper.java index 0726dfb2..79e49cd1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/LocaleChangeWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/LocaleChangeWrapper.java @@ -19,8 +19,17 @@ package de.steamwar.core; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLocaleChangeEvent; -public interface LocaleChangeWrapper extends Listener { - LocaleChangeWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +import java.util.Locale; + +public class LocaleChangeWrapper implements Listener { + + @EventHandler + private void onLocale(PlayerLocaleChangeEvent event) { + SteamwarUser.get(event.getPlayer().getUniqueId()).setLocale(Locale.forLanguageTag(event.getLocale()), false); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java index dcdb1791..d6fdd3f2 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java @@ -19,37 +19,47 @@ package de.steamwar.core; -import de.steamwar.Reflection; import com.mojang.authlib.GameProfile; +import com.mojang.datafixers.util.Pair; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import org.bukkit.GameMode; -import java.util.function.LongSupplier; +import java.util.Collections; +import java.util.EnumSet; -public interface ProtocolWrapper { +public class ProtocolWrapper { - Class itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack"); - Class spawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddEntityPacket"); - Class spawnLivingPacket = Core.getVersion() > 18 ? ProtocolWrapper.spawnPacket : Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving"); - Class equipmentPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket"); - - Class enumGamemode = Reflection.getClass(Core.getVersion() > 9 ? "net.minecraft.world.level.GameType" : "net.minecraft.WorldSettings$EnumGamemode"); - Reflection.Method getGameModeById = Reflection.getTypedMethod(enumGamemode, null, enumGamemode, int.class); + public static final Class itemStack = ItemStack.class; + public static final Class spawnPacket = ClientboundAddEntityPacket.class; + public static final Class spawnLivingPacket = ProtocolWrapper.spawnPacket; + public static final Class equipmentPacket = ClientboundSetEquipmentPacket.class; // 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head - Object[] itemSlots = Core.getVersion() > 8 ? Reflection.getClass("net.minecraft.world.entity.EnumItemSlot").getEnumConstants() : new Integer[]{0, 0, 1, 2, 3, 4}; + public static final EquipmentSlot[] itemSlots = EquipmentSlot.values(); - ProtocolWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + public static final ProtocolWrapper impl = new ProtocolWrapper(); - void setEquipmentPacketStack(Object packet, Object slot, Object stack); - - Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode); - - default void initTPSWarp(LongSupplier longSupplier) { - Class systemUtils = Reflection.getClass("net.minecraft.Util"); - Reflection.getField(systemUtils, LongSupplier.class, 0).set(systemUtils, (LongSupplier) () -> System.nanoTime() + longSupplier.getAsLong()); + public void setEquipmentPacketStack(Object packet, Object slot, Object stack) { + ClientboundSetEquipmentPacket setEquipmentPacket = (ClientboundSetEquipmentPacket) packet; + setEquipmentPacket.getSlots().add(Pair.of((EquipmentSlot) slot, (ItemStack) stack)); } - enum PlayerInfoAction { + public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) { + if(action == PlayerInfoAction.REMOVE) + return new ClientboundPlayerInfoRemovePacket(Collections.singletonList(profile.getId())); + + return new ClientboundPlayerInfoUpdatePacket(action == PlayerInfoAction.ADD ? + EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE) : EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE), + Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry(profile.getId(), profile, false, 0, GameType.byId(mode.getValue()), null, false, 0, null))); + } + + public enum PlayerInfoAction { ADD, GAMEMODE, REMOVE diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java index 53b27d65..53cfaa79 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/RecipeDiscoverWrapper.java @@ -19,8 +19,15 @@ package de.steamwar.core; +import de.steamwar.linkage.Linked; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerRecipeDiscoverEvent; -public interface RecipeDiscoverWrapper extends Listener { - RecipeDiscoverWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +@Linked +public class RecipeDiscoverWrapper implements Listener { + @EventHandler + public void onRecipeDiscover(PlayerRecipeDiscoverEvent e) { + e.setCancelled(true); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/SWPlayer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/SWPlayer.java index de44f565..330e5a06 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/SWPlayer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/SWPlayer.java @@ -25,7 +25,6 @@ import lombok.NonNull; import lombok.experimental.Delegate; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.ClickEvent; -import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java deleted file mode 100644 index c5979bcf..00000000 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java +++ /dev/null @@ -1,52 +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 . - */ - -package de.steamwar.core; - -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitTask; - -@UtilityClass -public class TPSWarpUtils { - - private static long nanoOffset = 0; - private static long nanoDOffset = 0; - private static BukkitTask bukkitTask = null; - - static { - ProtocolWrapper.impl.initTPSWarp(() -> nanoOffset); - } - - public static void warp(double tps) { - double d = 50 - (50 / (tps / 20.0)); - nanoDOffset = Math.max(0, (long) (d * 1000000)); - if (nanoDOffset == 0) { - if (bukkitTask == null) return; - bukkitTask.cancel(); - bukkitTask = null; - } else if (bukkitTask == null) { - bukkitTask = Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> nanoOffset += nanoDOffset, 1, 1); - } - } - - public static boolean isWarping() { - return nanoDOffset > 0; - } -} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index e88b1e82..63aed6a1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -19,7 +19,7 @@ package de.steamwar.core; -import de.steamwar.Reflection; +import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; public class TPSWatcher { @@ -79,11 +79,8 @@ public class TPSWatcher { } } - private static final Class minecraftServer = Reflection.getClass("net.minecraft.server.MinecraftServer"); - private static final Reflection.Method getServer = Reflection.getTypedMethod(minecraftServer, "getServer", minecraftServer); - private static final Reflection.Field recentTps = Reflection.getField(minecraftServer, "recentTps", double[].class); private static double[] getSpigotTPS() { - return recentTps.get(getServer.invoke(null)); + return MinecraftServer.getServer().recentTps; } private static double round(double d) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java index 7b86bacf..6ada7e0f 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java @@ -21,8 +21,10 @@ package de.steamwar.core; import org.bukkit.Particle; -public interface TrickyParticleWrapper { - public TrickyParticleWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class TrickyParticleWrapper { + public static final TrickyParticleWrapper impl = new TrickyParticleWrapper(); - Particle getVillagerHappy(); + public Particle getVillagerHappy() { + return Particle.HAPPY_VILLAGER; + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index 98900f4a..f529fe9e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -24,14 +24,22 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; -public interface TrickyTrialsWrapper { - TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class TrickyTrialsWrapper { + public static final TrickyTrialsWrapper impl = new TrickyTrialsWrapper(); - EntityType getTntEntityType(); + public EntityType getTntEntityType() { + return EntityType.TNT; + } - Enchantment getUnbreakingEnchantment(); + public Enchantment getUnbreakingEnchantment() { + return Enchantment.UNBREAKING; + } - Material getTurtleScute(); + public Material getTurtleScute() { + return Material.TURTLE_SCUTE; + } - String getValue(Property property); + public String getValue(Property property) { + return property.value(); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/VersionDependent.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/VersionDependent.java deleted file mode 100644 index d31e9a24..00000000 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/VersionDependent.java +++ /dev/null @@ -1,54 +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 . - */ - -package de.steamwar.core; - -import org.bukkit.plugin.Plugin; - -import java.lang.reflect.InvocationTargetException; - -public class VersionDependent { - private VersionDependent() {} - - public static T getVersionImpl(Plugin plugin) { - return getVersionImpl(plugin, (new Exception()).getStackTrace()[1].getClassName()); - } - - public static T getVersionImpl(Plugin plugin, String className){ - return getVersionImpl(plugin, Core.getVersion(), className); - } - - public static T getVersionImpl(Plugin plugin, int fromVersion){ - return getVersionImpl(plugin, fromVersion, (new Exception()).getStackTrace()[1].getClassName()); - } - - public static T getVersionImpl(Plugin plugin, int fromVersion, String className){ - ClassLoader loader = plugin.getClass().getClassLoader(); - for(int version = fromVersion; version >= 8; version--) { - try { - return ((Class) Class.forName(className + version, true, loader)).getDeclaredConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new SecurityException("Could not load version dependent class", e); - } catch (ClassNotFoundException e) { - // try next version - } - } - throw new SecurityException("Unable to find version dependent implementation for " + className); - } -} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 3e84f30e..af3fbb08 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -40,7 +40,7 @@ import org.bukkit.event.player.*; import org.bukkit.util.Vector; @Linked -@PluginCheck("WorldEdit") +@PluginCheck("FastAsyncWorldEdit") public class WorldEditRenderer implements Listener { private static WorldEditRenderer INSTANCE; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java index 0060d29a..00a6d344 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java @@ -116,9 +116,7 @@ public class WorldEditRendererCUIEditor implements Listener { public WorldEditRendererCUIEditor() { Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); - if (Core.getVersion() >= 20) { - new Command(); - } + new Command(); } private static class Command extends SWCommand { diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/WorldEditRendererWrapper9.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererFallback.java similarity index 91% rename from SpigotCore/SpigotCore_9/src/de/steamwar/core/WorldEditRendererWrapper9.java rename to SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererFallback.java index 7c39b7ff..4f2579c6 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/WorldEditRendererWrapper9.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererFallback.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 @@ -24,7 +24,7 @@ import org.bukkit.Particle; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -public class WorldEditRendererWrapper9 implements WorldEditRendererWrapper { +public class WorldEditRendererFallback { private static final int VIEW_DISTANCE = 64; private static final int SQ_VIEW_DISTANCE = VIEW_DISTANCE * VIEW_DISTANCE; @@ -33,7 +33,6 @@ public class WorldEditRendererWrapper9 implements WorldEditRendererWrapper { private static final Vector ONES = new Vector(1, 1, 1); private static final Vector STEPS = new Vector(STEP_SIZE, STEP_SIZE, STEP_SIZE); - @Override public void draw(Player player, boolean scheduled, boolean clipboard, Vector min, Vector max) { if (!scheduled) return; @@ -77,16 +76,4 @@ public class WorldEditRendererWrapper9 implements WorldEditRendererWrapper { min.add(stepSize); } } - - @Override - public void tick(Player player) { - } - - @Override - public void hide(Player player, boolean clipboard, boolean hide) { - } - - @Override - public void remove(Player player) { - } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererWrapper.java index 4651cb06..6d93d0b1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererWrapper.java @@ -19,12 +19,19 @@ package de.steamwar.core; +import de.steamwar.entity.CWireframe; +import de.steamwar.entity.REntityServer; +import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -public interface WorldEditRendererWrapper { - WorldEditRendererWrapper fallback = VersionDependent.getVersionImpl(Core.getInstance(), 9); - WorldEditRendererWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +import java.util.HashMap; +import java.util.Map; + +public class WorldEditRendererWrapper { + public static final WorldEditRendererFallback fallback = new WorldEditRendererFallback(); + public static final WorldEditRendererWrapper impl = new WorldEditRendererWrapper(); static void safeDraw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2) { if (PlayerVersion.isBedrock(player) || PlayerVersion.getVersion(player) < 20) { @@ -34,11 +41,83 @@ public interface WorldEditRendererWrapper { } } - void draw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2); + private static final class BoxPair { + private CWireframe regionBox; + private CWireframe clipboardBox; - void tick(Player player); + public CWireframe get(boolean clipboard) { + if (clipboard) { + return clipboardBox; + } else { + return regionBox; + } + } - void hide(Player player, boolean clipboard, boolean hide); + public void set(boolean clipboard, CWireframe box) { + if (clipboard) { + this.clipboardBox = box; + } else { + this.regionBox = box; + } + } - void remove(Player player); + public void die() { + if (clipboardBox != null) { + clipboardBox.die(); + } + if (regionBox != null) { + regionBox.die(); + } + } + } + + private static final Map servers = new HashMap<>(); + private static final Map boxes = new HashMap<>(); + + public void draw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2) { + REntityServer server = servers.computeIfAbsent(player, __ -> { + REntityServer entityServer = new REntityServer(); + entityServer.addPlayer(player); + return entityServer; + }); + + WorldEditRendererCUIEditor.Type type = clipboard ? WorldEditRendererCUIEditor.Type.CLIPBOARD : WorldEditRendererCUIEditor.Type.SELECTION; + float width = type.getWidth(player).value; + Material material = type.getMaterial(player); + if (material == Material.BARRIER) { + hide(player, clipboard, true); + return; + } + BlockData block = material.createBlockData(); + + BoxPair boxPair = boxes.computeIfAbsent(player, __ -> new BoxPair()); + CWireframe box = boxPair.get(clipboard); + if (box == null) { + box = new CWireframe(server); + boxPair.set(clipboard, box); + } + box.setPos1And2(pos1.toLocation(player.getWorld()), pos2.toLocation(player.getWorld())); + box.setWidth(width); + box.setBlock(block); + } + + public void tick(Player player) { + REntityServer server = servers.get(player); + if (server != null) server.tick(); + } + + public void hide(Player player, boolean clipboard, boolean hide) { + BoxPair boxPair = boxes.get(player); + if (boxPair == null) return; + CWireframe box = boxPair.get(clipboard); + if (box == null) return; + box.hide(hide); + } + + public void remove(Player player) { + BoxPair boxPair = boxes.remove(player); + if (boxPair != null) boxPair.die(); + REntityServer server = servers.remove(player); + if (server != null) server.close(); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java index 724f8184..f637d5dc 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java @@ -19,9 +19,18 @@ package de.steamwar.core; +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2; +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV3; +import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.*; +import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; +import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV2Reader; +import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV3Reader; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; @@ -30,25 +39,140 @@ import de.steamwar.sql.NodeData; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import org.enginehub.linbus.stream.LinBinaryIO; import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; import java.util.logging.Level; -public interface WorldEditWrapper { - WorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class WorldEditWrapper { + public static final WorldEditWrapper impl = new WorldEditWrapper(); - InputStream getPlayerClipboard(Player player); + public InputStream getPlayerClipboard(Player player) { + return WorldEditWrapper.getPlayerClipboard(player, (outputStream, clipboard, clipboardHolder) -> { + ClipboardWriter writer = BuiltInClipboardFormat.FAST_V3.getWriter(outputStream); + writer.write(clipboard); + writer.close(); + }); + } - void setPlayerClipboard(Player player, Clipboard clipboard); - Clipboard getClipboard(NodeData data) throws IOException; - Clipboard getClipboard(InputStream inputStream) throws IOException; + public void setPlayerClipboard(Player player, Clipboard clipboard) { + Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player); + WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard)); + } - Vector getOrigin(Clipboard clipboard); - Vector getMinimum(Region region); - Vector getMaximum(Region region); - Vector applyTransform(Vector vector, Transform transform); + public Clipboard getClipboard(NodeData data) throws IOException { + ResetableInputStream is = new ResetableInputStream(data.schemData(false)); + for (ClipboardFormat clipboardFormat : ClipboardFormats.getAll()) { + FilterInputStream fis = new FilterInputStream(is) { + @Override + public void close() throws IOException { + // Ignore close call! + } + }; + boolean canBeRead = clipboardFormat.isFormat(fis); + is.reset(); + if (!canBeRead) continue; + return clipboardFormat.load(is); + } + throw new IOException("No clipboard found"); + } - NodeData.SchematicFormat getNativeFormat(); + private static final Function FastV3 = FastSchematicReaderV3::new; + @SuppressWarnings("removal") + private static final Function FastV2 = inputStream -> new FastSchematicReaderV2(new NBTInputStream(inputStream)); + @SuppressWarnings("removal") + private static final Function McEdit = inputStream -> new MCEditSchematicReader(new NBTInputStream(inputStream)); + private static final Function SpongeV3 = inputStream -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(inputStream))); + private static final Function SpongeV2 = inputStream -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(inputStream))); + private static final Function SpongeV1 = inputStream -> new SpongeSchematicV1Reader(LinBinaryIO.read(new DataInputStream(inputStream))); + + private static final Function[] READERS = new Function[]{ + FastV3, + FastV2, + SpongeV3, + SpongeV2, + SpongeV1, + McEdit + }; + + public Clipboard getClipboard(InputStream inputStream) throws IOException { + ResetableInputStream is = new ResetableInputStream(inputStream); + for (Function reader : READERS) { + FilterInputStream fis = new FilterInputStream(is) { + @Override + public void close() throws IOException { + // Ignore close call! + } + }; + try { + return reader.apply(fis).read(); + } catch (Exception e) { + is.reset(); + } + } + is.close(); + throw new IOException("No clipboard found"); + } + + private static class ResetableInputStream extends InputStream { + + private InputStream inputStream; + private int pointer = 0; + private List list = new ArrayList<>(); + + public ResetableInputStream(InputStream in) { + this.inputStream = in; + } + + @Override + public int read() throws IOException { + if (pointer >= list.size()) { + int data = inputStream.read(); + list.add(data); + pointer++; + return data; + } + int data = list.get(pointer); + pointer++; + return data; + } + + @Override + public void reset() throws IOException { + pointer = 0; + } + + @Override + public void close() throws IOException { + list.clear(); + pointer = -1; + } + } + + public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { + return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z()); + } + + public Vector getMinimum(Region region) { + return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z()); + } + + public Vector getMaximum(Region region) { + return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z()); + } + + public Vector applyTransform(Vector vector, Transform transform) { + Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + v = transform.apply(v); + return new org.bukkit.util.Vector(v.x(), v.y(), v.z()); + } + + public NodeData.SchematicFormat getNativeFormat() { + return NodeData.SchematicFormat.SPONGE_V3; + } static WorldEditPlugin getWorldEditPlugin() { return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java index 14e3db31..d9edd2c7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java @@ -19,15 +19,57 @@ package de.steamwar.core; +import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; +import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ClientboundLoginPacket; +import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; + +@Linked public class WorldIdentifier { - private static final IWorldIdentifier impl = VersionDependent.getVersionImpl(Core.getInstance()); + private static ResourceKey resourceKey = null; + + private static final Class resourceKeyClass = ResourceKey.class; + private static final Class minecraftKeyClass = ResourceLocation.class; + private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass); + private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class); public static void set(String name) { - impl.setResourceKey(name); + resourceKey = (ResourceKey) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name)); } - protected interface IWorldIdentifier { - void setResourceKey(String name); + public WorldIdentifier() { + TinyProtocol.instance.addFilter(ClientboundLoginPacket.class, (player, o) -> { + if (resourceKey == null) return o; + ClientboundLoginPacket packet = (ClientboundLoginPacket) o; + + return new ClientboundLoginPacket(packet.playerId(), + packet.hardcore(), + packet.levels(), + packet.maxPlayers(), + packet.chunkRadius(), + packet.simulationDistance(), + packet.reducedDebugInfo(), + packet.showDeathScreen(), + packet.doLimitedCrafting(), + new CommonPlayerSpawnInfo( + packet.commonPlayerSpawnInfo().dimensionType(), + resourceKey, + packet.commonPlayerSpawnInfo().seed(), + packet.commonPlayerSpawnInfo().gameType(), + packet.commonPlayerSpawnInfo().previousGameType(), + packet.commonPlayerSpawnInfo().isDebug(), + packet.commonPlayerSpawnInfo().isFlat(), + packet.commonPlayerSpawnInfo().lastDeathLocation(), + packet.commonPlayerSpawnInfo().portalCooldown(), + packet.commonPlayerSpawnInfo().seaLevel() + ), + packet.enforcesSecureChat() + ); + }); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java index 85a2ca26..f5f8c8fa 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java @@ -19,12 +19,56 @@ package de.steamwar.core.authlib; +import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfileRepository; -import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import com.mojang.authlib.ProfileLookupCallback; +import de.steamwar.Reflection; +import de.steamwar.sql.SteamwarUser; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.Services; -public abstract class SteamwarGameProfileRepository implements GameProfileRepository { - public static final SteamwarGameProfileRepository impl = VersionDependent.getVersionImpl(Core.getInstance()); +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; - public abstract void inject(); +public class SteamwarGameProfileRepository implements GameProfileRepository { + public static final SteamwarGameProfileRepository impl = new SteamwarGameProfileRepository(); + + private static final GameProfileRepository fallback; + private static final Reflection.Field field; + private static final Services current; + + static { + Class clazz = MinecraftServer.getServer().getClass(); + field = Reflection.getField(clazz, Services.class, 0); + current = field.get(MinecraftServer.getServer()); + fallback = current.profileRepository(); + } + + @Override + public void findProfilesByNames(String[] strings, ProfileLookupCallback profileLookupCallback) { + List unknownNames = new ArrayList<>(); + for (String name:strings) { + SteamwarUser user = SteamwarUser.get(name); + if(user == null) { + unknownNames.add(name); + continue; + } + + profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName())); + } + if(!unknownNames.isEmpty()) { + fallback.findProfilesByNames(unknownNames.toArray(new String[0]), profileLookupCallback); + } + } + + @Override + public Optional findProfileByName(String s) { + return fallback.findProfileByName(s); + } + + public void inject() { + Services newServices = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations()); + field.set(MinecraftServer.getServer(), newServices); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java index 40cdb955..0f4e016d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java @@ -26,6 +26,9 @@ import de.steamwar.linkage.Linked; import de.steamwar.sql.SWException; import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.TechHider; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; +import net.minecraft.world.phys.BlockHitResult; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,9 +46,7 @@ public class AntiNocom implements Listener { public AntiNocom() { TinyProtocol.instance.addFilter(blockDig, this::onDig); - if(Core.getVersion() > 8) { - registerUseItem(); - } + registerUseItem(); } @EventHandler @@ -54,18 +55,13 @@ public class AntiNocom implements Listener { } private void registerUseItem() { - Class useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"); + Class useItem = ServerboundUseItemOnPacket.class; - Function getPosition; - if(Core.getVersion() > 12) { - Class movingObjectPositionBlock = Reflection.getClass("net.minecraft.world.phys.BlockHitResult"); - Reflection.Field useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); - Reflection.Field movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); + Class movingObjectPositionBlock = BlockHitResult.class; + Reflection.Field useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); + Reflection.Field movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); - getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); - } else { - getPosition = Reflection.getField(useItem, TechHider.blockPosition, 0)::get; - } + Function getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); TinyProtocol.instance.addFilter(useItem, (player, packet) -> { Object pos = getPosition.apply(packet); @@ -73,7 +69,7 @@ public class AntiNocom implements Listener { }); } - private static final Class blockDig = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket"); + private static final Class blockDig = ServerboundPlayerActionPacket.class; private static final Reflection.Field digPosition = Reflection.getField(blockDig, TechHider.blockPosition, 0); private Object onDig(Player player, Object packet) { Object pos = digPosition.get(packet); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/PacketConstructor.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/PacketConstructor.java index 070b975e..da4944a6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/PacketConstructor.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/PacketConstructor.java @@ -19,12 +19,35 @@ package de.steamwar.entity; -import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.phys.Vec3; -public interface PacketConstructor { - PacketConstructor impl = VersionDependent.getVersionImpl(Core.getInstance()); +import java.util.Collections; - Object teleportPacket(int entityId, double x, double y, double z, float yaw, float pitch); - Object createRPlayerSpawn(RPlayer player); +public class PacketConstructor { + public static final PacketConstructor impl = new PacketConstructor(); + + public Object teleportPacket(int entityId, double x, double y, double z, float yaw, float pitch) { + PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch, yaw); + return new ClientboundTeleportEntityPacket(entityId, rot, Collections.emptySet(), false); + } + + public Object createRPlayerSpawn(RPlayer player) { + return new ClientboundAddEntityPacket( + player.entityId, + player.uuid, + player.x, + player.y, + player.z, + player.yaw, + player.pitch, + EntityType.PLAYER, + 0, + Vec3.ZERO, + player.headYaw + ); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java index 249d2cda..3fdafe4a 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java @@ -20,7 +20,6 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.Location; import org.bukkit.entity.EntityType; @@ -29,26 +28,7 @@ import java.util.function.Consumer; public class RArmorStand extends REntity { - private static int sizeIndex() { - switch(Core.getVersion()) { - case 8: - case 9: - return 10; - case 10: - case 12: - return 11; - case 14: - return 13; - case 15: - return 14; - case 18: - case 19: - default: - return 15; - } - } - - private static final Object sizeWatcher = BountifulWrapper.impl.getDataWatcherObject(sizeIndex(), Byte.class); + private static final Object sizeWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class); @Getter private final Size size; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java index 0058617a..8f87f63c 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java @@ -19,13 +19,13 @@ package de.steamwar.entity; -import de.steamwar.Reflection; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.entity.EntityType; import java.util.function.BiConsumer; @@ -58,12 +58,10 @@ public class RBlockDisplay extends RDisplay { sendPacket(updatePacketSink, this::getBlock); } - private static final Class iBlockDataClass = Reflection.getClass("net.minecraft.world.level.block.state.BlockState"); - private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", iBlockDataClass); - private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, iBlockDataClass); + private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(23, BlockState.class); private void getBlock(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !block.getAsString(true).equals(DEFAULT_BLOCK.getAsString(true))) { - packetSink.accept(blockWatcher, getState.invoke(block)); + packetSink.accept(blockWatcher, ((CraftBlockData) block).getState()); } } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java index 34c3a2eb..727e7b2a 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java @@ -20,7 +20,6 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; import lombok.NonNull; import org.bukkit.Color; @@ -111,10 +110,10 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getTransformData); } - private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 11 : 10, Vector3f.class); - private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 13 : 12, Quaternionf.class); - private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 12 : 11, Vector3f.class); - private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 14 : 13, Quaternionf.class); + private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(11, Vector3f.class); + private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(13, Quaternionf.class); + private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(12, Vector3f.class); + private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(14, Quaternionf.class); private void getTransformData(boolean ignoreDefault, BiConsumer dataSink) { if (ignoreDefault || !transform.equals(DEFAULT_TRANSFORM)) { @@ -130,8 +129,8 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getInterpolationDuration); } - private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 9 : 8, Integer.class); - private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 10 : 9, Integer.class); + private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(9, Integer.class); + private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(10, Integer.class); private void getInterpolationDuration(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || interpolationDelay != 0) { @@ -145,7 +144,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getViewRange); } - private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 17 : 16, Float.class); + private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Float.class); private void getViewRange(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || viewRange != 1.0F) { @@ -158,7 +157,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getShadowRadius); } - private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 18 : 17, Float.class); + private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(18, Float.class); private void getShadowRadius(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || shadowRadius != 0.0F) { @@ -171,7 +170,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getShadowStrength); } - private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 19 : 18, Float.class); + private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(19, Float.class); private void getShadowStrength(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || shadowStrength != 1.0F) { @@ -184,7 +183,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getDisplayWidth); } - private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 20 : 19, Float.class); + private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(20, Float.class); private void getDisplayWidth(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || displayWidth != 0.0F) { @@ -197,7 +196,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getDisplayHeight); } - private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 21 : 20, Float.class); + private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(21, Float.class); private void getDisplayHeight(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || displayHeight != 0.0F) { @@ -210,7 +209,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getInterpolationDelay); } - private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 8 : 7, Integer.class); + private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class); private void getInterpolationDelay(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || interpolationDelay != 0) { @@ -223,7 +222,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getBillboard); } - private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 15 : 14, Byte.class); + private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class); private void getBillboard(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || billboard != Display.Billboard.FIXED) { @@ -236,7 +235,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getGlowColorOverride); } - private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 22 : 21, Integer.class); + private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(22, Integer.class); private void getGlowColorOverride(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || glowColorOverride != null) { @@ -249,7 +248,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getBrightness); } - private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 16 : 15, Integer.class); + private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(16, Integer.class); private void getBrightness(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || brightness != null) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 9962878e..95ce73b0 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -20,11 +20,16 @@ package de.steamwar.entity; import de.steamwar.Reflection; -import de.steamwar.core.*; +import de.steamwar.core.BountifulWrapper; +import de.steamwar.core.ChatWrapper; +import de.steamwar.core.FlatteningWrapper; +import de.steamwar.core.ProtocolWrapper; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import lombok.Getter; +import net.minecraft.network.protocol.game.*; import org.bukkit.Location; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; @@ -35,9 +40,9 @@ import java.util.function.Function; public class REntity { private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class); - private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); - private static final Object bowDrawnWatcher = Core.getVersion() >= 21 ? BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()) : BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class); - private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional + private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); + private static final Object bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); + private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Optional.class); // Optional private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class); private static final Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5,Boolean.class); @@ -126,7 +131,7 @@ public class REntity { move(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), rotToByte(location.getYaw())); } - private static final double MAX_REL_MOVE = Core.getVersion() > 8 ? 8.0 : 4.0; + private static final double MAX_REL_MOVE = 8.0; public void move(double locX, double locY, double locZ, float pitch, float yaw, byte headYaw) { server.preEntityMove(this, locX, locZ); @@ -160,9 +165,9 @@ public class REntity { server.postEntityMove(this, fromX, fromZ); } - private static final Class animationPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAnimatePacket"); - private static final Reflection.Field animationEntity = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 5 : 6) : 0); - private static final Reflection.Field animationAnimation = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 6 : 7) : 1); + private static final Class animationPacket = ClientboundAnimatePacket.class; + private static final Reflection.Field animationEntity = Reflection.getField(animationPacket, int.class, 5); + private static final Reflection.Field animationAnimation = Reflection.getField(animationPacket, int.class, 6); public void showAnimation(byte animation) { Object packet = Reflection.newInstance(animationPacket); animationEntity.set(packet, entityId); @@ -170,7 +175,7 @@ public class REntity { server.updateEntity(this, packet); } - private static final Class velocityPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket"); + private static final Class velocityPacket = ClientboundSetEntityMotionPacket.class; private static final Reflection.Field velocityEntity = Reflection.getField(velocityPacket, int.class, 0); private static final Reflection.Field velocityX = Reflection.getField(velocityPacket, int.class, 1); private static final Reflection.Field velocityY = Reflection.getField(velocityPacket, int.class, 2); @@ -184,7 +189,7 @@ public class REntity { server.updateEntity(this, packet); } - private static final Class statusPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundEntityEventPacket"); + private static final Class statusPacket = ClientboundEntityEventPacket.class; private static final Reflection.Field statusEntity = Reflection.getField(statusPacket, int.class, 0); private static final Reflection.Field statusStatus = Reflection.getField(statusPacket, byte.class, 0); public void showDamage() { @@ -196,11 +201,7 @@ public class REntity { public void setPose(FlatteningWrapper.EntityPose pose) { this.pose = pose; - if(Core.getVersion() > 12) { - server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); - } else { - server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus())); - } + server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); } public void setOnFire(boolean perma) { @@ -219,13 +220,7 @@ public class REntity { public void setBowDrawn(boolean drawn, boolean offHand) { bowDrawn = drawn; - if (Core.getVersion() >= 21) { - server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); - } else if(Core.getVersion() > 8){ - server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)))); - }else{ - server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus())); - } + server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); } public void setDisplayName(String displayName) { @@ -247,55 +242,22 @@ public class REntity { public void setNoGravity(boolean noGravity) { this.noGravity = noGravity; - if(Core.getVersion() > 8) - server.updateEntity(this,getDataWatcherPacket(noGravityDataWatcher,noGravity)); + server.updateEntity(this,getDataWatcherPacket(noGravityDataWatcher,noGravity)); } public void setGlowing(boolean glowing) { this.isGlowing = glowing; - if(Core.getVersion() > 8) { - server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus())); - } + server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus())); } public boolean isGlowing() { return isGlowing; } - private static int spawnPacketOffset() { - switch (Core.getVersion()) { - case 8: - case 18: - return 1; - case 9: - case 10: - case 12: - case 14: - case 15: - return 0; - case 19: - default: - return 2; - } - } - private static final Function spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, spawnPacketOffset()); - private static int objectDataOffset() { - switch (Core.getVersion()) { - case 8: - return 9; - case 9: - case 14: - case 12: - case 10: - case 15: - case 18: - return 6; - case 19: - default: - return 4; - } - } - private static final Reflection.Field additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, objectDataOffset()); + private static final Function spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, 2); + + private static final Reflection.Field additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 4); + private Object spawnPacketGenerator() { Object packet = spawnPacketGenerator.apply(this); additionalData.set(packet, objectData); @@ -306,7 +268,7 @@ public class REntity { // empty for regular entity } - private static final Function livingSpawnPacketGenerator = Core.getVersion() >= 19 ? REntity::spawnPacketGenerator : entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, Core.getVersion() == 8 ? 2 : 0); + private static final Function livingSpawnPacketGenerator = REntity::spawnPacketGenerator; void spawn(Consumer packetSink) { if(entityType.isAlive()) { packetSink.accept(livingSpawnPacketGenerator.apply(this)); @@ -322,7 +284,7 @@ public class REntity { packetSink.accept(getHeadRotationPacket()); } - if(Core.getVersion() > 12 && pose != FlatteningWrapper.EntityPose.NORMAL) { + if(pose != FlatteningWrapper.EntityPose.NORMAL) { packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); } @@ -335,8 +297,9 @@ public class REntity { packetSink.accept(getDataWatcherPacket(nameWatcher, FlatteningWrapper.impl.formatDisplayName(displayName), nameVisibleWatcher, true)); } - if(Core.getVersion() > 8 && noGravity) + if(noGravity) { packetSink.accept(getDataWatcherPacket(noGravityDataWatcher, true)); + } } void tick() { @@ -348,17 +311,11 @@ public class REntity { } } - private static final Class destroyPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket"); - private static final Reflection.Field destroyEntities; - static { - if(Core.getVersion() > 15) - destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0); - else - destroyEntities = Reflection.getField(destroyPacket, int[].class, 0); - } + private static final Class destroyPacket = ClientboundRemoveEntitiesPacket.class; + private static final Reflection.Field destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0); void despawn(Consumer packetSink){ Object packet = Reflection.newInstance(destroyPacket); - destroyEntities.set(packet, Core.getVersion() > 15 ? new IntArrayList(new int[]{entityId}) : new int[]{entityId}); + destroyEntities.set(packet, new IntArrayList(new int[]{entityId})); packetSink.accept(packet); } @@ -381,11 +338,9 @@ public class REntity { status |= 1; if(pose == FlatteningWrapper.EntityPose.SNEAKING) status |= 2; - if(Core.getVersion() == 8 && bowDrawn) - status |= 0x10; if(invisible) status |= 0x20; - if(Core.getVersion() > 8 && isGlowing) + if(isGlowing) status |= 0x40; return status; @@ -395,26 +350,19 @@ public class REntity { return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues); } - public static final Class teleportPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket"); + public static final Class teleportPacket = ClientboundTeleportEntityPacket.class; public static final Reflection.Field teleportEntity = Reflection.getField(teleportPacket, int.class, 0); - public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); + public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, 0); private Object getTeleportPacket(){ - if (Core.getVersion() >= 21) { - return PacketConstructor.impl.teleportPacket(entityId, x, y, z, pitch, yaw); - } - - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, entityId); - teleportPosition.set(packet, x, y, z, pitch, yaw); - return packet; + return PacketConstructor.impl.teleportPacket(entityId, x, y, z, pitch, yaw); } - private static final Class entityPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket"); + private static final Class entityPacket = ClientboundMoveEntityPacket.class; private static final Reflection.Field moveEntityId = Reflection.getField(entityPacket, int.class, 0); private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket); - private static final Class lookPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot"); - private static final Class movePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Pos"); - private static final Class moveLookPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$PosRot"); + private static final Class lookPacket = ClientboundMoveEntityPacket.Rot.class; + private static final Class movePacket = ClientboundMoveEntityPacket.Pos.class; + private static final Class moveLookPacket = ClientboundMoveEntityPacket.PosRot.class; private Object getMoveLookPacket(double diffX, double diffY, double diffZ, boolean rotEq) { Class clazz; if(diffX == 0 && diffY == 0 && diffZ == 0) { @@ -434,7 +382,7 @@ public class REntity { return packet; } - private static final Class headRotationPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundRotateHeadPacket"); + private static final Class headRotationPacket = ClientboundRotateHeadPacket.class; private static final Reflection.Field headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0); private static final Reflection.Field headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0); private Object getHeadRotationPacket(){ @@ -447,13 +395,11 @@ public class REntity { private static final Reflection.Field equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0); private static final Reflection.Field equipmentSlots = Reflection.getField(ProtocolWrapper.equipmentPacket, List.class, 0); - private static final Class craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack"); - protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class); protected Object getEquipmentPacket(Object slot, ItemStack stack){ Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket); equipmentEntity.set(packet, entityId); equipmentSlots.set(packet, new ArrayList<>()); - ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack)); + ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, CraftItemStack.asNMSCopy(stack)); return packet; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java index 3ba28d38..33d36170 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java @@ -19,10 +19,11 @@ package de.steamwar.entity; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; +import net.minecraft.network.protocol.game.ServerboundInteractPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -47,19 +48,15 @@ public class REntityServer implements Listener { private static final HashSet emptyEntities = new HashSet<>(0); private static final HashSet emptyPlayers = new HashSet<>(0); - private static final Class useEntity = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"); + private static final Class useEntity = ServerboundInteractPacket.class; private static final Reflection.Field useEntityTarget = Reflection.getField(useEntity, int.class, 0); private static final Class useEntityEnumAction = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$Action"); private static final Reflection.Field useEntityAction = Reflection.getField(useEntity, useEntityEnumAction, 0); private static final Function getEntityAction; static { - if(Core.getVersion() > 15) { - Class useEntityEnumActionType = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType"); - Reflection.Method useEntityGetAction = Reflection.getTypedMethod(useEntityEnumAction, null, useEntityEnumActionType); - getEntityAction = value -> ((Enum) useEntityGetAction.invoke(value)).ordinal(); - } else { - getEntityAction = value -> ((Enum) value).ordinal(); - } + Class useEntityEnumActionType = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType"); + Reflection.Method useEntityGetAction = Reflection.getTypedMethod(useEntityEnumAction, null, useEntityEnumActionType); + getEntityAction = value -> ((Enum) useEntityGetAction.invoke(value)).ordinal(); } private final ConcurrentHashMap entityMap = new ConcurrentHashMap<>(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java index 92d19f90..293ce520 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java @@ -19,7 +19,6 @@ package de.steamwar.entity; -import de.steamwar.core.Core; import de.steamwar.techhider.BlockIds; import lombok.Getter; import org.bukkit.Location; @@ -32,7 +31,7 @@ public class RFallingBlockEntity extends REntity{ private final Material material; public RFallingBlockEntity(REntityServer server, Location location, Material material) { - super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(material) >> (Core.getVersion() <= 12 ? 4 : 0)); + super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(material)); this.material = material; server.addEntity(this); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java index 894ba21c..1d78cb8d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java @@ -20,11 +20,11 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import de.steamwar.core.ProtocolWrapper; import lombok.Getter; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemDisplay; import org.bukkit.inventory.ItemStack; @@ -61,14 +61,14 @@ public class RItemDisplay extends RDisplay { sendPacket(updatePacketSink, this::getItemStack); } - private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, ProtocolWrapper.itemStack); + private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(23, ProtocolWrapper.itemStack); private void getItemStack(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !itemStack.equals(DEFAULT_ITEM_STACK)) { - packetSink.accept(itemStackWatcher, asNMSCopy.invoke(null, itemStack)); + packetSink.accept(itemStackWatcher, CraftItemStack.asNMSCopy(itemStack)); } } - private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 24 : 23, Byte.class); + private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Byte.class); public void setItemDisplayTransform(ItemDisplay.ItemDisplayTransform itemDisplayTransform) { this.itemDisplayTransform = itemDisplayTransform; sendPacket(updatePacketSink, this::getItemDisplayTransform); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java index 9883cdde..6f7ce6b5 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java @@ -21,8 +21,9 @@ package de.steamwar.entity; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; -import de.steamwar.Reflection; -import de.steamwar.core.*; +import de.steamwar.core.BountifulWrapper; +import de.steamwar.core.ProtocolWrapper; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.network.CoreNetworkHandler; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.common.PlayerSkinRequestPacket; @@ -36,31 +37,10 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; import java.util.function.Consumer; -import java.util.function.Function; public class RPlayer extends REntity { - private static int skinPartsIndex() { - switch(Core.getVersion()) { - case 8: - return 10; - case 9: - return 12; - case 10: - case 12: - return 13; - case 14: - return 15; - case 15: - return 16; - case 18: - case 19: - default: - return 17; - } - } - - private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(skinPartsIndex(), Byte.class); + private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Byte.class); @Getter private final UUID actualUUID; @@ -114,24 +94,7 @@ public class RPlayer extends REntity { packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE)); } - private static Class namedSpawnPacket = null; - private static Function namedSpawnPacketGenerator = null; - private static Reflection.Field namedSpawnUUID = null; - - static { - try { - namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket"); - namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0); - namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0); - } catch (IllegalArgumentException e) { } - } - private Object getNamedSpawnPacket() { - if (Core.getVersion() >= 21) return PacketConstructor.impl.createRPlayerSpawn(this); - - Object packet = namedSpawnPacketGenerator.apply(this); - namedSpawnUUID.set(packet, uuid); - FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet); - return packet; + return PacketConstructor.impl.createRPlayerSpawn(this); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java index 29cb8a21..7deb82f8 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java @@ -19,11 +19,10 @@ package de.steamwar.entity; -import de.steamwar.Reflection; import de.steamwar.core.BountifulWrapper; import de.steamwar.core.ChatWrapper; -import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.network.chat.Component; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.TextDisplay; @@ -74,8 +73,8 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getText); } - private static final Class iChatBaseComponent = Reflection.getClass("net.minecraft.network.chat.Component"); - private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, iChatBaseComponent); + private static final Class iChatBaseComponent = Component.class; + private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(23, iChatBaseComponent); private void getText(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !text.isEmpty()) { packetSink.accept(textWatcher, ChatWrapper.impl.stringToChatComponent(text)); @@ -87,7 +86,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getLineWidth); } - private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 24 : 23, Integer.class); + private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Integer.class); private void getLineWidth(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || lineWidth != 200) { packetSink.accept(lineWidthWatcher, lineWidth); @@ -99,7 +98,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextOpacity); } - private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 26 : 25, Byte.class); + private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(26, Byte.class); private void getTextOpacity(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || textOpacity != (byte) -1) { packetSink.accept(textOpacityWatcher, textOpacity); @@ -121,7 +120,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextStatus, this::getBackgroundColor); } - private static final Object backgroundColorWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 25 : 24, Integer.class); + private static final Object backgroundColorWatcher = BountifulWrapper.impl.getDataWatcherObject(25, Integer.class); private void getBackgroundColor(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || backgroundColor != null) { packetSink.accept(backgroundColorWatcher, backgroundColor); @@ -140,7 +139,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextStatus); } - private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 27 : 26, Byte.class); + private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(27, Byte.class); private void getTextStatus(boolean ignoreDefault, BiConsumer packetSink) { byte status = 0; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index 1b230121..50039b8e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -21,7 +21,6 @@ package de.steamwar.inventory; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; import de.steamwar.core.TrickyTrialsWrapper; import org.bukkit.Material; @@ -217,10 +216,8 @@ public class SWItem { } public SWItem setCustomModelData(int customModelData) { - if (Core.getVersion() > 12) { - itemMeta.setCustomModelData(customModelData); - itemStack.setItemMeta(itemMeta); - } + itemMeta.setCustomModelData(customModelData); + itemStack.setItemMeta(itemMeta); return this; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/UtilGui.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/UtilGui.java index 6bdb8bfd..9456d5d7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/UtilGui.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/UtilGui.java @@ -20,8 +20,6 @@ package de.steamwar.inventory; import de.steamwar.core.Core; -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; import lombok.experimental.UtilityClass; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java index c157aa85..37ccaae3 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java @@ -20,7 +20,6 @@ package de.steamwar.linkage; import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; import de.steamwar.message.Message; import de.steamwar.network.packets.PacketHandler; import lombok.NonNull; @@ -38,17 +37,6 @@ public class SpigotLinker extends AbstractLinker { this.message = message; } - @Override - protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { - if (minVersion != null && Core.getVersion() < minVersion.value()) { - return false; - } - if (maxVersion != null && Core.getVersion() > maxVersion.value()) { - return false; - } - return true; - } - @Override protected boolean pluginCheck(@NonNull Class clazz, PluginCheck pluginCheck) { if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java index f24b84e6..89920d2b 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java @@ -20,7 +20,6 @@ package de.steamwar.message; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.ClickEvent; @@ -30,7 +29,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; @@ -82,10 +80,7 @@ public class Message { } private String fromRB(ResourceBundle bundle, String key) { - String result = bundle.getString(key); - if(Core.getVersion() < 12) - result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - return result; + return bundle.getString(key); } private Locale getLocale(Player player){ diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java index eec211b2..e4f27397 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java @@ -19,17 +19,16 @@ package de.steamwar.network.handlers; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; +import net.minecraft.network.protocol.game.ClientboundServerDataPacket; +import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket; @Linked -@MinVersion(19) public class ServerDataHandler { public ServerDataHandler() { - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ClientboundServerDataPacket"), (p, o) -> null); - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket"), (player, packet) -> null); + TinyProtocol.instance.addFilter(ClientboundServerDataPacket.class, (p, o) -> null); + TinyProtocol.instance.addFilter(ServerboundChatSessionUpdatePacket.class, (player, packet) -> null); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java index 06ea4346..702a726c 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java @@ -20,12 +20,54 @@ package de.steamwar.scoreboard; import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import net.kyori.adventure.text.Component; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; -public interface SWScoreboard { - public static final SWScoreboard impl = VersionDependent.getVersionImpl(Core.getInstance()); +import java.util.HashMap; +import java.util.Map; - boolean createScoreboard(Player player, ScoreboardCallback callback); - void removeScoreboard(Player player); +public class SWScoreboard { + public static final SWScoreboard impl = new SWScoreboard(); + + private static final HashMap playerBoards = new HashMap<>(); + private static final String SIDEBAR = "sw-sidebar"; + + static { + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { + for(Map.Entry scoreboard : playerBoards.entrySet()) { + render(scoreboard.getKey(), scoreboard.getValue()); + } + }, 10, 5); + } + + private static void render(Player player, ScoreboardCallback callback) { + if (player.getScoreboard().getObjective(SIDEBAR) != null) { + player.getScoreboard().getObjective(SIDEBAR).unregister(); + } + + Objective objective = player.getScoreboard().registerNewObjective(SIDEBAR, "dummy", Component.text(callback.getTitle())); + objective.setAutoUpdateDisplay(true); + objective.setDisplaySlot(DisplaySlot.SIDEBAR); + + callback.getData().forEach((text, score) -> objective.getScore(text).setScore(score)); + } + + public boolean createScoreboard(Player player, ScoreboardCallback callback) { + Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + player.setScoreboard(scoreboard); + + render(player, callback); + + playerBoards.put(player, callback); + return true; + } + + public void removeScoreboard(Player player) { + player.getScoreboard().getObjective(SIDEBAR).unregister(); + playerBoards.remove(player); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java index 4fd2bebe..69896ae1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java @@ -28,7 +28,6 @@ import org.bukkit.entity.Player; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -46,9 +45,6 @@ public class SQLWrapperImpl implements SQLWrapper { @Override public List getMaterialWithGreaterBlastResistance(double maxBlastResistance) { - if (Core.getVersion() <= 12) { - return Collections.emptyList(); - } return Arrays.stream(Material.values()) .filter(material -> !material.isLegacy()) .filter(Material::isBlock) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SchematicData.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SchematicData.java index f83e5a78..2c6a54ce 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SchematicData.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SchematicData.java @@ -25,7 +25,6 @@ import org.bukkit.entity.Player; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; public class SchematicData { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java index 168b87da..fb5a0ecf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java @@ -20,18 +20,48 @@ package de.steamwar.techhider; import de.steamwar.Reflection; -import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import net.minecraft.core.IdMapper; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import java.util.HashSet; import java.util.Set; -public interface BlockIds { - BlockIds impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class BlockIds { + public static final BlockIds impl = new BlockIds(); - Reflection.Method getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData); + public int materialToId(Material material) { + return getCombinedId(getBlock(material).defaultBlockState()); + } - int getCombinedId(Object iBlockData); - int materialToId(Material material); - Set materialToAllIds(Material material); + private static final FluidState water = Fluids.WATER.getSource(false); + private static final Iterable registryBlockId = (Iterable) Reflection.getField(TechHider.block, IdMapper.class, 0).get(null); + public Set materialToAllIds(Material material) { + Set ids = new HashSet<>(); + for(BlockState data : getBlock(material).getStateDefinition().getPossibleStates()) { + ids.add(getCombinedId(data)); + } + + if(material == Material.WATER) { + for(BlockState data : registryBlockId) { + if (data.getFluidState() == water) { + ids.add(getCombinedId(data)); + } + } + } + + return ids; + } + + private Block getBlock(Material material) { + return CraftMagicNumbers.getBlock(material); + } + + public int getCombinedId(BlockState blockData) { + return Block.getId(blockData); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java index bdc8cdd3..65143215 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java @@ -19,21 +19,148 @@ package de.steamwar.techhider; -import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import de.steamwar.Reflection; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import lombok.Getter; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.SimpleBitStorage; +import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.entity.Player; import java.util.Collections; +import java.util.List; import java.util.Set; import java.util.function.BiFunction; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; -public interface ChunkHider { - ChunkHider impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class ChunkHider { + public static final ChunkHider impl = new ChunkHider(); - Class mapChunkPacket(); - BiFunction chunkHiderGenerator(TechHider techHider); + public Class mapChunkPacket() { + return ClientboundLevelChunkWithLightPacket.class; + } + + private static final UnaryOperator chunkPacketCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); + private static final UnaryOperator chunkDataCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); + + private static final Reflection.Field chunkXField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 0); + private static final Reflection.Field chunkZField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 1); + private static final Reflection.Field chunkData = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkPacketData.class, 0); + + private static final Reflection.Field dataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0); + private static final Reflection.Field tileEntities = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0); + + public BiFunction chunkHiderGenerator(TechHider techHider) { + return (p, packet) -> { + int chunkX = chunkXField.get(packet); + int chunkZ = chunkZField.get(packet); + if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) + return packet; + + packet = chunkPacketCloner.apply(packet); + Object dataWrapper = chunkDataCloner.apply(chunkData.get(packet)); + + Set hiddenBlockEntities = techHider.getHiddenBlockEntities(); + tileEntities.set(dataWrapper, ((List)tileEntities.get(dataWrapper)).stream().filter(te -> tileEntityVisible(hiddenBlockEntities, te)).collect(Collectors.toList())); + + ByteBuf in = Unpooled.wrappedBuffer(dataField.get(dataWrapper)); + ByteBuf out = Unpooled.buffer(in.readableBytes() + 64); + for(int yOffset = p.getWorld().getMinHeight(); yOffset < p.getWorld().getMaxHeight(); yOffset += 16) { + SectionHider section = new SectionHider(p, techHider, in, out, chunkX, yOffset/16, chunkZ); + section.copyBlockCount(); + + blocks(section); + biomes(section); + } + + if (in.readableBytes() != 0) { + throw new IllegalStateException("ChunkHider21: Incomplete chunk data, " + in.readableBytes() + " bytes left"); + } + + byte[] data = new byte[out.readableBytes()]; + out.readBytes(data); + dataField.set(dataWrapper, data); + + chunkData.set(packet, dataWrapper); + return packet; + }; + } + + private static final Registry> registry = Reflection.getField(BuiltInRegistries.class, "BLOCK_ENTITY_TYPE", Registry.class).get(null); + private static final Reflection.Method getKey = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.core.Registry"), "getKey", ResourceLocation.class, Object.class); + public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); + protected static final Reflection.Field entityType = Reflection.getField(tileEntity, BlockEntityType.class, 0); + protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) { + BlockEntityType type = entityType.get(tile); + String path = ((ResourceLocation) getKey.invoke(registry, type)).getPath(); + return !hiddenBlockEntities.contains(path); + } + + private void blocks(SectionHider section) { + section.copyBitsPerBlock(); + + boolean singleValued = section.getBitsPerBlock() == 0; + if (singleValued) { + int value = ProtocolUtils.readVarInt(section.getIn()); + ProtocolUtils.writeVarInt(section.getOut(), !section.isSkipSection() && section.getObfuscate().contains(value) ? section.getTarget() : value); + return; + } else if (section.getBitsPerBlock() < 9) { + // Indirect (paletted) storage – only present when bitsPerBlock < 9 in 1.21+ + section.processPalette(); + } + + if (section.isSkipSection() || (!section.blockPrecise() && section.isPaletted())) { + section.skipNewDataArray(4096); + return; + } + + SimpleBitStorage values = new SimpleBitStorage(section.getBitsPerBlock(), 4096, section.readNewDataArray(4096)); + + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { + int pos = (((y * 16) + z) * 16) + x; + + TechHider.State test = section.test(x, y, z); + + switch (test) { + case SKIP: + break; + case CHECK: + if (!section.getObfuscate().contains(values.get(pos))) + break; + case HIDE: + values.set(pos, section.getTarget()); + break; + case HIDE_AIR: + default: + values.set(pos, section.getAir()); + } + } + } + } + + section.writeDataArray(values.getRaw()); + } + + private void biomes(SectionHider section) { + section.copyBitsPerBlock(); + if(section.getBitsPerBlock() == 0) { + section.copyVarInt(); + } else if(section.getBitsPerBlock() < 6) { + section.skipPalette(); + section.skipNewDataArray(64); + } else { + // Direct (global) biome IDs – no palette present + section.skipNewDataArray(64); + } + } @Getter class SectionHider { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java index a9677407..44d342ef 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java @@ -19,8 +19,8 @@ package de.steamwar.techhider; -import de.steamwar.Reflection; import com.google.common.primitives.Bytes; +import de.steamwar.Reflection; import io.netty.buffer.ByteBuf; import java.lang.reflect.Array; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolWrapper.java index aec71941..2c17dbb7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolWrapper.java @@ -19,19 +19,74 @@ package de.steamwar.techhider; -import de.steamwar.core.Core; -import de.steamwar.core.VersionDependent; +import de.steamwar.Reflection; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.SignBlockEntity; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.entity.Player; +import java.util.ArrayList; import java.util.function.BiFunction; -public interface ProtocolWrapper { - ProtocolWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); +public class ProtocolWrapper { + public static final ProtocolWrapper impl = new ProtocolWrapper(); + private static final Reflection.Field multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, SectionPos.class, 0); + private static final Reflection.Field multiBlockChangePos = Reflection.getField(TechHider.multiBlockChangePacket, short[].class, 0); + private static final Reflection.Field multiBlockChangeBlocks = Reflection.getField(TechHider.multiBlockChangePacket, BlockState[].class, 0); + public BiFunction multiBlockChangeGenerator(TechHider techHider) { + return (p, packet) -> { + TechHider.LocationEvaluator locationEvaluator = techHider.getLocationEvaluator(); + Object chunkCoords = multiBlockChangeChunk.get(packet); + int chunkX = TechHider.blockPositionX.get(chunkCoords); + int chunkY = TechHider.blockPositionY.get(chunkCoords); + int chunkZ = TechHider.blockPositionZ.get(chunkCoords); + if(locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ)) + return packet; - boolean unfilteredTileEntityDataAction(Object packet); + packet = TechHider.multiBlockChangeCloner.apply(packet); + final short[] oldPos = multiBlockChangePos.get(packet); + final BlockState[] oldBlocks = multiBlockChangeBlocks.get(packet); + ArrayList poss = new ArrayList<>(oldPos.length); + ArrayList blocks = new ArrayList<>(oldPos.length); + for(int i = 0; i < oldPos.length; i++) { + short pos = oldPos[i]; + BlockState block = oldBlocks[i]; + switch(locationEvaluator.check(p, 16*chunkX + (pos >> 8 & 0xF), 16*chunkY + (pos & 0xF), 16*chunkZ + (pos >> 4 & 0xF))) { + case SKIP: + poss.add(pos); + blocks.add(block); + break; + case CHECK: + poss.add(pos); + blocks.add(techHider.iBlockDataHidden(block) ? (BlockState) techHider.getObfuscationTarget() : block); + break; + default: + break; + } + } - BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider); + if(blocks.isEmpty()) + return null; - BiFunction multiBlockChangeGenerator(TechHider techHider); + short[] newPos = new short[poss.size()]; + for(int i = 0; i < newPos.length; i++) + newPos[i] = poss.get(i); + + multiBlockChangePos.set(packet, newPos); + multiBlockChangeBlocks.set(packet, blocks.toArray(new BlockState[0])); + return packet; + }; + } + + private static final Reflection.Field tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, BlockEntityType.class, 0); + private static final BlockEntityType signType = Reflection.getField(BlockEntityType.class, BlockEntityType.class, 0, SignBlockEntity.class).get(null); + public boolean unfilteredTileEntityDataAction(Object packet) { + return tileEntityType.get(packet) != signType; + } + + public BiFunction blockBreakHiderGenerator(Class blockBreakPacket, TechHider techHider) { + return null; + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java index 46e53bcf..9eff141e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java @@ -21,9 +21,14 @@ package de.steamwar.techhider; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; -import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.network.protocol.game.*; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Player; import java.util.HashMap; @@ -36,24 +41,20 @@ import java.util.stream.Collectors; public class TechHider { - public static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - private static final Class baseBlockPosition = Reflection.getClass("net.minecraft.core.Vec3i"); + public static final Class blockPosition = BlockPos.class; + private static final Class baseBlockPosition = Vec3i.class; public static final Reflection.Field blockPositionX = Reflection.getField(baseBlockPosition, int.class, 0); public static final Reflection.Field blockPositionY = Reflection.getField(baseBlockPosition, int.class, 1); public static final Reflection.Field blockPositionZ = Reflection.getField(baseBlockPosition, int.class, 2); - public static final Class iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.BlockState"); - public static final Class block = Reflection.getClass("net.minecraft.world.level.block.Block"); - private static final Reflection.Method getBlockDataByBlock = Reflection.getTypedMethod(block, null, iBlockData); + public static final Class iBlockData = BlockState.class; + public static final Class block = Block.class; - public static final Class craftMagicNumbers = Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers"); - private static final Reflection.Method getBlockByMaterial = Reflection.getTypedMethod(craftMagicNumbers, "getBlock", block, Material.class); - - public boolean iBlockDataHidden(Object iBlockData) { + public boolean iBlockDataHidden(BlockState iBlockData) { return obfuscateIds.contains(BlockIds.impl.getCombinedId(iBlockData)); } - public static final Object AIR = getBlockDataByBlock.invoke(getBlockByMaterial.invoke(null, Material.AIR)); + public static final Object AIR = CraftMagicNumbers.getBlock(Material.AIR).defaultBlockState(); public static final int AIR_ID = BlockIds.impl.materialToId(Material.AIR); private final Map, BiFunction> techhiders = new HashMap<>(); @@ -72,7 +73,7 @@ public class TechHider { this.locationEvaluator = locationEvaluator; this.obfuscateIds = obfuscate.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet()); this.hiddenBlockEntities = hiddenBlockEntities; - this.obfuscationTarget = getBlockDataByBlock.invoke(getBlockByMaterial.invoke(null, obfuscationTarget)); + this.obfuscationTarget = CraftMagicNumbers.getBlock(obfuscationTarget).defaultBlockState(); this.obfuscationTargetId = BlockIds.impl.materialToId(obfuscationTarget); techhiders.put(blockActionPacket, this::blockActionHider); @@ -80,16 +81,8 @@ public class TechHider { techhiders.put(tileEntityDataPacket, this::tileEntityDataHider); techhiders.put(multiBlockChangePacket, ProtocolWrapper.impl.multiBlockChangeGenerator(this)); techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this)); - - if(Core.getVersion() > 12 && Core.getVersion() < 19) { - Class blockBreakClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket"); - techhiders.put(blockBreakClass, ProtocolWrapper.impl.blockBreakHiderGenerator(blockBreakClass, this)); - } - - if(Core.getVersion() > 8){ - techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); - } - techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); + techhiders.put(ServerboundUseItemOnPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); + techhiders.put(ServerboundInteractPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); } @@ -101,10 +94,10 @@ public class TechHider { techhiders.forEach(TinyProtocol.instance::removeFilter); } - public static final Class multiBlockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket"); + public static final Class multiBlockChangePacket = ClientboundSectionBlocksUpdatePacket.class; public static final UnaryOperator multiBlockChangeCloner = ProtocolUtils.shallowCloneGenerator(TechHider.multiBlockChangePacket); - private static final Class blockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket"); + private static final Class blockChangePacket = ClientboundBlockUpdatePacket.class; private static final Function blockChangeCloner = ProtocolUtils.shallowCloneGenerator(blockChangePacket); private static final Reflection.Field blockChangePosition = Reflection.getField(blockChangePacket, blockPosition, 0); private static final Reflection.Field blockChangeBlockData = Reflection.getField(blockChangePacket, iBlockData, 0); @@ -113,7 +106,7 @@ public class TechHider { case SKIP: return packet; case CHECK: - if(!iBlockDataHidden(blockChangeBlockData.get(packet))) + if(!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet))) return packet; case HIDE: packet = blockChangeCloner.apply(packet); @@ -127,7 +120,7 @@ public class TechHider { } } - private static final Class blockActionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockEventPacket"); + private static final Class blockActionPacket = ClientboundBlockEventPacket.class; private static final Reflection.Field blockActionPosition = Reflection.getField(blockActionPacket, blockPosition, 0); private Object blockActionHider(Player p, Object packet) { if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP) @@ -135,7 +128,7 @@ public class TechHider { return null; } - public static final Class tileEntityDataPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket"); + public static final Class tileEntityDataPacket = ClientboundBlockEntityDataPacket.class; private static final Reflection.Field tileEntityDataPosition = Reflection.getField(tileEntityDataPacket, blockPosition, 0); private Object tileEntityDataHider(Player p, Object packet) { switch (locationEvaluator.checkBlockPos(p, tileEntityDataPosition.get(packet))) { diff --git a/SpigotCore/build.gradle.kts b/SpigotCore/build.gradle.kts index 22e65b20..88c99684 100644 --- a/SpigotCore/build.gradle.kts +++ b/SpigotCore/build.gradle.kts @@ -30,20 +30,4 @@ dependencies { api(project(":CommonCore")) api(project(":CommandFramework")) api(project(":SpigotCore:SpigotCore_Main")) - - implementation(project(":SpigotCore:SpigotCore_8")) - implementation(project(":SpigotCore:SpigotCore_9")) - implementation(project(":SpigotCore:SpigotCore_10")) - implementation(project(":SpigotCore:SpigotCore_12")) - implementation(project(":SpigotCore:SpigotCore_14")) - implementation(project(":SpigotCore:SpigotCore_15")) - implementation(project(":SpigotCore:SpigotCore_18")) - implementation(project(":SpigotCore:SpigotCore_19")) - implementation(project(":SpigotCore:SpigotCore_20")) - implementation(project(":SpigotCore:SpigotCore_21")) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } } diff --git a/TNTLeague/build.gradle.kts b/TNTLeague/build.gradle.kts index 79a08492..f3b78d69 100644 --- a/TNTLeague/build.gradle.kts +++ b/TNTLeague/build.gradle.kts @@ -25,13 +25,8 @@ kotlin { jvmToolchain(21) } -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} - dependencies { - compileOnly(libs.paperapi21) + compileOnly(libs.paperapi) compileOnly(project(":SpigotCore", "default")) compileOnly(project(":KotlinCore", "default")) } \ No newline at end of file diff --git a/Teamserver/build.gradle.kts b/Teamserver/build.gradle.kts index d4b47bbe..2f563c7e 100644 --- a/Teamserver/build.gradle.kts +++ b/Teamserver/build.gradle.kts @@ -26,8 +26,8 @@ dependencies { annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) - compileOnly(libs.worldedit15) + compileOnly(libs.fawe) compileOnly(libs.axiom) } diff --git a/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java b/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java index df32735e..fc9a4999 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java @@ -60,12 +60,12 @@ public class ArenaconfigCommand extends SWCommand { YamlConfiguration config = YamlConfiguration.loadConfiguration(file); config.set("UnderBorder", lowerPlayerBorder); - config.set("BlueCorner.x", pos1.getX()); - config.set("BlueCorner.y", pos1.getY()); - config.set("BlueCorner.z", pos1.getZ()); - config.set("BlueToRed.x", pos2.getX() - pos1.getX()); - config.set("BlueToRed.y", pos2.getY() - pos1.getY()); - config.set("BlueToRed.z", pos2.getZ() - pos1.getZ()); + config.set("BlueCorner.x", pos1.x()); + config.set("BlueCorner.y", pos1.y()); + config.set("BlueCorner.z", pos1.z()); + config.set("BlueToRed.x", pos2.x() - pos1.x()); + config.set("BlueToRed.y", pos2.y() - pos1.y()); + config.set("BlueToRed.z", pos2.z() - pos1.z()); config.save(file); } diff --git a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java index d4d0f9f3..403a1af4 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java @@ -135,7 +135,6 @@ public class FreezeListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onBlockBreak(BlockBreakEvent e) { - if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (freeze) { if (e.isCancelled()) return; diff --git a/TowerRun/build.gradle.kts b/TowerRun/build.gradle.kts index b8828ede..e1b3b5fb 100644 --- a/TowerRun/build.gradle.kts +++ b/TowerRun/build.gradle.kts @@ -21,21 +21,14 @@ plugins { steamwar.java } -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - dependencies { - annotationProcessor(libs.spigotannotations) - compileOnly(libs.spigotannotations) compileOnly(libs.classindex) annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.nms19) - compileOnly(libs.worldedit15) + compileOnly(libs.nms) + compileOnly(libs.fawe) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi) } diff --git a/TowerRun/src/de/steamwar/towerrun/TowerRun.java b/TowerRun/src/de/steamwar/towerrun/TowerRun.java index 357e8689..10298547 100644 --- a/TowerRun/src/de/steamwar/towerrun/TowerRun.java +++ b/TowerRun/src/de/steamwar/towerrun/TowerRun.java @@ -30,18 +30,7 @@ import de.steamwar.towerrun.generator.TowerGenerator; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.plugin.java.annotation.dependency.Dependency; -import org.bukkit.plugin.java.annotation.plugin.ApiVersion; -import org.bukkit.plugin.java.annotation.plugin.Description; -import org.bukkit.plugin.java.annotation.plugin.Plugin; -import org.bukkit.plugin.java.annotation.plugin.author.Author; -@Plugin(name = "TowerRun", version = "1.0.0") -@Dependency("SpigotCore") -@Author("YoyoNow") -@Author("Chaoscaot") -@Description("SteamWar TowerRun Plugin") -@ApiVersion(ApiVersion.Target.v1_19) public class TowerRun extends JavaPlugin { @Getter diff --git a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java index ba218ef0..db2e09f9 100644 --- a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java +++ b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java @@ -27,9 +27,9 @@ import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.state.GameState; import de.steamwar.towerrun.state.GameStates; import lombok.experimental.UtilityClass; -import net.minecraft.world.level.chunk.Chunk; +import net.minecraft.world.level.chunk.LevelChunk; import org.bukkit.*; -import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -187,10 +187,10 @@ public class TowerRunGame { } private static void resetChunk(World backup, int x, int z) { - Chunk chunk = ((CraftWorld) world).getHandle().d(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z); + LevelChunk chunk = ((CraftWorld) world).getHandle().getChunk(x, z); + LevelChunk backupChunk = ((CraftWorld) backup).getHandle().getChunk(x, z); - System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length); + System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); for (Player p : Bukkit.getOnlinePlayers()) CraftbukkitWrapper.impl.sendChunk(p, x, z); diff --git a/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java b/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java index 0e1c8781..2a4296db 100644 --- a/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java +++ b/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java @@ -118,12 +118,12 @@ public class TowerGenerator { ClipboardHolder ch = new ClipboardHolder(clipboard); Operations.completeBlindly(ch.createPaste(e).to(BlockVector3.at(config.x, y, config.z)).build()); } - width = clipboard.getDimensions().getX(); - depth = clipboard.getDimensions().getZ(); + width = clipboard.getDimensions().x(); + depth = clipboard.getDimensions().z(); currentY = y; - y += clipboard.getDimensions().getY(); - height -= clipboard.getDimensions().getY(); - TowerGenerator.this.height += clipboard.getDimensions().getY(); + y += clipboard.getDimensions().y(); + height -= clipboard.getDimensions().y(); + TowerGenerator.this.height += clipboard.getDimensions().y(); } catch (IOException e) { allSchematics.remove(schematicNode); return; diff --git a/TowerRun/src/plugin.yml b/TowerRun/src/plugin.yml new file mode 100644 index 00000000..91774e63 --- /dev/null +++ b/TowerRun/src/plugin.yml @@ -0,0 +1,5 @@ +name: TowerRun +version: 1.0.0 +main: de.steamwar.towerrun.TowerRun +api-version: 1.21 +depend: [SpigotCore] diff --git a/VelocityCore/build.gradle.kts b/VelocityCore/build.gradle.kts index 718b53f0..aa25af17 100644 --- a/VelocityCore/build.gradle.kts +++ b/VelocityCore/build.gradle.kts @@ -26,11 +26,6 @@ tasks.build { finalizedBy(tasks.shadowJar) } -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 3b95a338..8ee5a54c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -316,8 +316,18 @@ public class CheckCommand extends SWCommand { SchematicNode node = SchematicNode.createSchematic(-1, name, teamFolder.getNodeId()); NodeData.saveFromStream(node, data.schemData(false), data.getNodeFormat()); - // Accept the team folder schematic and set other to Normal + // Accept the team folder schematic and set other to Normal as well as adding the original owner on the schematic 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 concludeCheckSession("freigegeben", SchematicType.Normal, () -> { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java index 4d096b3f..d6a81f61 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java @@ -50,7 +50,7 @@ public class WhoisCommand extends SWCommand { @Register(description = "WHOIS_USAGE") public void whois(Chatter sender, long id, WhoisParameterTypes... parameters) { - if(!sender.user().hasPerm(UserPerm.ADMINISTRATION)) { + if(!sender.user().hasPerm(UserPerm.ADMINISTRATION) && !sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) { sender.system("UNKNOWN_PLAYER"); return; } diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java index 11944ff2..3113d834 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java @@ -28,7 +28,7 @@ import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; public enum DiscordTicketType { REPORT("U+1F46E", "Spieler melden", ButtonStyle.DANGER, null), IDEA("U+1F4A1", "Feature vorschlagen", ButtonStyle.SUCCESS, null), - BUG("U+1F41B", "Bug melden", ButtonStyle.LINK, "https://git.steamwar.de/SteamWar/SteamWar/issues/new"), + BUG("U+1F41B", "Bug melden", ButtonStyle.LINK, "https://git.steamwar.de/SteamWar/SteamWar/issues/new/choose"), QUESTION("U+2753", "Fragen", ButtonStyle.PRIMARY, null), APPEAL("U+1F528", "Entbannungsantrag", ButtonStyle.SECONDARY, null), SCHEMATIC("U+1F4BE", "Schematic melden", ButtonStyle.DANGER, null); diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/DiscordChannel.java b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/DiscordChannel.java index 4922d69b..799b3638 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/DiscordChannel.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/DiscordChannel.java @@ -26,6 +26,7 @@ import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.listeners.ChannelListener; import lombok.AllArgsConstructor; import lombok.Getter; +import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.Webhook; import net.dv8tion.jda.api.entities.WebhookClient; @@ -104,10 +105,16 @@ public class DiscordChannel extends Chatter.PlayerlessChatter { return; } - String avatarUrl; + String avatarUrl = null; if (user.getDiscordId() != null) { - avatarUrl = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()).complete().getEffectiveAvatarUrl(); - } else { + Member member = DiscordBot.getGuild().retrieveMemberById(user.getDiscordId()) + .onErrorMap(throwable -> null) + .complete(); + if (member != null) { + avatarUrl = member.getEffectiveAvatarUrl(); + } + } + if (avatarUrl == null) { avatarUrl = DiscordBot.getInstance().getJda().getSelfUser().getAvatarUrl(); } diff --git a/buildSrc/src/steamwar.java.gradle b/buildSrc/src/steamwar.java.gradle index 338a496c..c6bb0a35 100644 --- a/buildSrc/src/steamwar.java.gradle +++ b/buildSrc/src/steamwar.java.gradle @@ -22,8 +22,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.compileJava { diff --git a/buildSrc/src/steamwar.kotlin.gradle b/buildSrc/src/steamwar.kotlin.gradle index 791ae677..f672713d 100644 --- a/buildSrc/src/steamwar.kotlin.gradle +++ b/buildSrc/src/steamwar.kotlin.gradle @@ -23,12 +23,12 @@ plugins { } kotlin { - jvmToolchain(8) + jvmToolchain(21) } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.compileJava { diff --git a/settings.gradle.kts b/settings.gradle.kts index ea47eac1..c9103d0a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,7 @@ import org.apache.tools.ant.taskdefs.condition.Os import java.net.URI -import java.util.Properties +import java.util.* rootProject.name = "SteamWar" @@ -34,6 +34,14 @@ dependencyResolutionManagement { } } + maven { + url = URI("https://maven.enginehub.org/repo") + content { + includeGroup("com.sk89q.worldedit") + includeGroup("com.sk89q.worldedit.worldedit-libs") + } + } + maven { if (isInCi) { url = URI("file:///var/www/maven/") @@ -101,33 +109,17 @@ dependencyResolutionManagement { library("hamcrest", "org.hamcrest:hamcrest:2.2") library("classindex", "org.atteo.classindex:classindex:3.13") - - library("spigotapi", "org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") - library("spigotannotations", "org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT") - library("paperapi", "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") - library("paperapi21", "io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT") - library("authlib", "com.mojang:authlib:1.5.25") - library("authlib2", "com.mojang:authlib:6.0.58") + library("paperapi", "io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT") + library("authlib", "com.mojang:authlib:6.0.58") library("datafixer", "com.mojang:datafixerupper:4.0.26") library("brigadier", "com.mojang:brigadier:1.0.18") library("anvilgui", "net.wesjd:anvilgui:1.10.6-SNAPSHOT") - library("nms8", "de.steamwar:spigot:1.8") - library("nms9", "de.steamwar:spigot:1.9") - library("nms10", "de.steamwar:spigot:1.10") - library("nms12", "de.steamwar:spigot:1.12") - library("nms14", "de.steamwar:spigot:1.14") - library("nms15", "de.steamwar:spigot:1.15") - library("nms18", "de.steamwar:spigot:1.18") - library("nms19", "de.steamwar:spigot:1.19") - library("nms20", "de.steamwar:spigot:1.20") - library("nms21", "de.steamwar:spigot:1.21.6") + library("nms", "de.steamwar:spigot:1.21.6") library("axiom", "de.steamwar:axiompaper:RELEASE") - library("worldedit12", "de.steamwar:worldedit:1.12") - library("worldedit15", "de.steamwar:worldedit:1.15") - library("fawe18", "de.steamwar:fastasyncworldedit:1.18") - library("fawe21", "de.steamwar:fastasyncworldedit:1.21") + library("worldedit", "com.sk89q.worldedit:worldedit-bukkit:7.3.16") + library("fawe", "de.steamwar:fastasyncworldedit:1.21") library("velocity", "de.steamwar:velocity:RELEASE") library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") @@ -161,7 +153,7 @@ dependencyResolutionManagement { library("nbt", "dev.dewy:nbt:1.5.1") - val exposedVersion = "1.0.0-rc-2" + val exposedVersion = "1.3.0" library("exposedCore", "org.jetbrains.exposed:exposed-core:$exposedVersion") library("exposedDao", "org.jetbrains.exposed:exposed-dao:$exposedVersion") library("exposedJdbc", "org.jetbrains.exposed:exposed-jdbc:$exposedVersion") @@ -172,17 +164,14 @@ dependencyResolutionManagement { include( "BauSystem", - "BauSystem:BauSystem_15", - "BauSystem:BauSystem_18", - "BauSystem:BauSystem_19", - "BauSystem:BauSystem_20", - "BauSystem:BauSystem_21", "BauSystem:BauSystem_Main", "BauSystem:BauSystem_RegionFixed" ) include("CommandFramework") +include("CLI") + include( "CommonCore", "CommonCore:Data", @@ -193,53 +182,23 @@ include( include( "FightSystem", - "FightSystem:FightSystem_8", - "FightSystem:FightSystem_9", - "FightSystem:FightSystem_10", - "FightSystem:FightSystem_12", - "FightSystem:FightSystem_14", - "FightSystem:FightSystem_15", - "FightSystem:FightSystem_18", - "FightSystem:FightSystem_19", - "FightSystem:FightSystem_20", - "FightSystem:FightSystem_21", "FightSystem:FightSystem_Core", "FightSystem:FightSystem_Standalone" ) include("KotlinCore") -include("LegacyBauSystem") - include("LobbySystem") include("MissileWars") include("Realtime") -include( - "SchematicSystem", - "SchematicSystem:SchematicSystem_8", - "SchematicSystem:SchematicSystem_15", - "SchematicSystem:SchematicSystem_19", - "SchematicSystem:SchematicSystem_20", - "SchematicSystem:SchematicSystem_21", - "SchematicSystem:SchematicSystem_Core" -) +include("SchematicSystem") include( "SpigotCore", "SpigotCore:CRIUDummy", - "SpigotCore:SpigotCore_8", - "SpigotCore:SpigotCore_9", - "SpigotCore:SpigotCore_10", - "SpigotCore:SpigotCore_12", - "SpigotCore:SpigotCore_14", - "SpigotCore:SpigotCore_15", - "SpigotCore:SpigotCore_18", - "SpigotCore:SpigotCore_19", - "SpigotCore:SpigotCore_20", - "SpigotCore:SpigotCore_21", "SpigotCore:SpigotCore_Main" ) diff --git a/steamwarci.yml b/steamwarci.yml index 758d179e..b971c05c 100644 --- a/steamwarci.yml +++ b/steamwarci.yml @@ -33,4 +33,6 @@ artifacts: "/jars/website-api.jar": "WebsiteBackend/build/libs/WebsiteBackend-all.jar" release: + - "rm -rf /jars/sw" + - "unzip -o CLI/build/distributions/sw.zip -d /jars" - "sudo systemctl restart api.service"