From 9606c6bc0d87b2baf10de1b92ecad7332f58bb87 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Fri, 12 Jun 2026 16:50:26 +0200 Subject: [PATCH] . --- BauSystem/BauSystem_Main/build.gradle.kts | 12 ++------ .../src/de/steamwar/bausystem/BauSystem.java | 3 ++ .../features/cannonCore/CannonCoreCommand.kt | 1 - .../features/cannonCore/CannonCoreEntity.kt | 2 +- .../cannonCore/CannonCoreRegistration.kt | 29 +++++++++++++++++++ .../features/cannonCore/CannonCoreWand.kt | 10 ++----- .../features/cannonCore/CannonCoresDisplay.kt | 13 +++++---- .../cannonCore/EmptyCannonCoreWandDisplay.kt | 10 ++++--- .../steamwar/bausystem/utils/ItemUtils.java | 17 ++++++----- settings.gradle.kts | 4 --- 10 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreRegistration.kt diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index e29ce456..5fb90333 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -18,8 +18,7 @@ */ plugins { - steamwar.java - kotlin("jvm") version "2.4.0" + steamwar.kotlin } tasks.compileJava { @@ -27,6 +26,8 @@ tasks.compileJava { } java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } dependencies { @@ -45,11 +46,4 @@ dependencies { implementation(libs.luaj) implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar")) - implementation(kotlin("stdlib-jdk8")) } -repositories { - mavenCentral() -} -kotlin { - jvmToolchain(21) -} \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index e1f7b11a..c12dd164 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.ConfigConverter; +import de.steamwar.bausystem.features.cannonCore.CannonCoreRegistrationKt; import de.steamwar.bausystem.features.gui.BauGUI; import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin; import de.steamwar.bausystem.features.script.lua.libs.LuaLib; @@ -135,6 +136,8 @@ public class BauSystem extends JavaPlugin implements Listener { String identifier = BauServerInfo.getOwnerUser().getUUID().toString().replace("-", ""); WorldIdentifier.set("bau/" + Core.getVersion() + "/" + identifier); + + CannonCoreRegistrationKt.register(this); } @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreCommand.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreCommand.kt index e03bc7d2..c38c6d63 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreCommand.kt +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreCommand.kt @@ -24,7 +24,6 @@ import de.steamwar.command.SWCommand import de.steamwar.linkage.Linked import org.bukkit.entity.Player -@Linked object CannonCoreCommand : SWCommand("cannoncore") { @Register diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreEntity.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreEntity.kt index 80238791..619659ae 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreEntity.kt +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreEntity.kt @@ -40,7 +40,7 @@ class CannonCoreEntity: RBlockDisplay { } override fun die() { - this.die() + super.die() hitbox.die() } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreRegistration.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreRegistration.kt new file mode 100644 index 00000000..fd73e92f --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreRegistration.kt @@ -0,0 +1,29 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.cannonCore + +import org.bukkit.plugin.Plugin + +fun register(plugin: Plugin) { + CannonCoreCommand.register() + + val pluginManager = plugin.server.pluginManager + pluginManager.registerEvents(CannonCoreWand, plugin) +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreWand.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreWand.kt index c59a6c13..fcea285e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreWand.kt +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoreWand.kt @@ -22,21 +22,19 @@ package de.steamwar.bausystem.features.cannonCore import de.steamwar.bausystem.utils.ItemUtils import de.steamwar.core.SWPlayer import de.steamwar.inventory.SWItem -import de.steamwar.linkage.Linked import org.bukkit.Material import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.player.PlayerItemHeldEvent import org.bukkit.inventory.ItemStack -@Linked object CannonCoreWand: Listener { val wandId = "CANNON_CORE_WAND" val wandMaterial = Material.BREEZE_ROD fun getWandItem(): ItemStack { - val title = "Cannon Core Wand" + val title = "§eCannon Core Wand" val lore = listOf( "§eRight Click §8- §7Create a new cannon core" ) @@ -60,9 +58,7 @@ object CannonCoreWand: Listener { swPlayer.removeComponent(EmptyCannonCoreWandDisplay::class.java) } else { - // TODO add handling for bound wand - val newCursor = EmptyCannonCoreWandDisplay(player) - swPlayer.setComponent(newCursor) + EmptyCannonCoreWandDisplay(player) } } -} \ No newline at end of file +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoresDisplay.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoresDisplay.kt index aeae49c8..e2d7d0ab 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoresDisplay.kt +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/CannonCoresDisplay.kt @@ -28,15 +28,18 @@ class CannonCoresDisplay: SWPlayer.Component { val unlisten: () -> Unit constructor(owner: Player) { - displayServer.addPlayer(owner) unlisten = CannonCore.activeCores.observe( { cores -> displayServer.entities.forEach { it.die() } cores.forEach { CannonCoreEntity(displayServer, it.location) { _, _ -> println("Handler clicked at ${it.location}") } } }) } - override fun onUnmount(player: SWPlayer?) { - super.onUnmount(player) - unlisten() + override fun onMount(player: SWPlayer) { + displayServer.addPlayer(player.player) } -} \ No newline at end of file + + override fun onUnmount(player: SWPlayer?) { + unlisten() + displayServer.close() + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/EmptyCannonCoreWandDisplay.kt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/EmptyCannonCoreWandDisplay.kt index 6f5c745e..1a3a8740 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/EmptyCannonCoreWandDisplay.kt +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannonCore/EmptyCannonCoreWandDisplay.kt @@ -21,12 +21,8 @@ package de.steamwar.bausystem.features.cannonCore import de.steamwar.core.SWPlayer import de.steamwar.cursor.Cursor -import de.steamwar.entity.REntity -import org.bukkit.Location import org.bukkit.Material import org.bukkit.entity.Player -import org.bukkit.event.block.Action -import java.util.Optional class EmptyCannonCoreWandDisplay : SWPlayer.Component { val coresDisplay: CannonCoresDisplay @@ -43,5 +39,11 @@ class EmptyCannonCoreWandDisplay : SWPlayer.Component { ) { location, hitEntity, action -> print("Hello") } + + SWPlayer.of(owner).setComponent(this) + } + + override fun onUnmount(player: SWPlayer) { + player.removeComponent(cursor::class.java) } } \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/ItemUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/ItemUtils.java index f4958db0..1e273b35 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/ItemUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/ItemUtils.java @@ -20,29 +20,30 @@ package de.steamwar.bausystem.utils; import de.steamwar.bausystem.SWUtils; -import lombok.experimental.UtilityClass; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; -@UtilityClass -public class ItemUtils { +public final class ItemUtils { - private final NamespacedKey ITEM_KEY = SWUtils.getNamespaceKey("bau_item"); + private static final NamespacedKey ITEM_KEY = SWUtils.getNamespaceKey("bau_item"); - public boolean isItem(ItemStack itemStack, String tag) { + private ItemUtils() { + } + + public static boolean isItem(ItemStack itemStack, String tag) { String value = getTag(itemStack, ITEM_KEY); return value != null && value.equals(tag); } - public ItemStack setItem(ItemStack itemStack, String tag) { + public static ItemStack setItem(ItemStack itemStack, String tag) { setTag(itemStack, ITEM_KEY, tag); return itemStack; } - public String getTag(ItemStack itemStack, NamespacedKey key) { + public static String getTag(ItemStack itemStack, NamespacedKey key) { if (itemStack == null) { return null; } @@ -57,7 +58,7 @@ public class ItemUtils { return container.get(key, PersistentDataType.STRING); } - public void setTag(ItemStack itemStack, NamespacedKey key, String value) { + public static void setTag(ItemStack itemStack, NamespacedKey key, String value) { if (itemStack == null) { return; } diff --git a/settings.gradle.kts b/settings.gradle.kts index 5644decf..b84535d4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,10 +21,6 @@ import org.apache.tools.ant.taskdefs.condition.Os import java.net.URI import java.util.* -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.10.0" -} - rootProject.name = "SteamWar" private val isInCi by lazy { Os.isFamily(Os.FAMILY_UNIX) && ProcessBuilder("hostname").start().inputStream.bufferedReader().readText().startsWith("steamwar.de") }