Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e07298e748 | |||
| d7ba19049a | |||
| 47909b6f07 |
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
steamwar.kotlin
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ 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;
|
||||
@@ -136,8 +135,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
String identifier = BauServerInfo.getOwnerUser().getUUID().toString().replace("-", "");
|
||||
WorldIdentifier.set("bau/" + Core.getVersion() + "/" + identifier);
|
||||
|
||||
CannonCoreRegistrationKt.register(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import org.bukkit.Location
|
||||
|
||||
class CannonCore(val location: Location) {
|
||||
|
||||
companion object Manager {
|
||||
var activeCores: Observable<List<CannonCore>> = Observable(ArrayList())
|
||||
}
|
||||
}
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import de.steamwar.bausystem.SWUtils
|
||||
import de.steamwar.command.SWCommand
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
object CannonCoreCommand : SWCommand("cannoncore") {
|
||||
|
||||
@Register
|
||||
fun giveCannonCoreWand(player: Player) {
|
||||
val wandItem = CannonCoreWand.getWandItem()
|
||||
|
||||
SWUtils.giveItemToPlayer(player, wandItem)
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import de.steamwar.entity.RBlockDisplay
|
||||
import de.steamwar.entity.REntityAction
|
||||
import de.steamwar.entity.REntityServer
|
||||
import de.steamwar.entity.RInteraction
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CannonCoreEntity: RBlockDisplay {
|
||||
val entityMaterial = Material.COMMAND_BLOCK
|
||||
|
||||
val hitbox: RInteraction
|
||||
|
||||
constructor(server: REntityServer, location: Location, onClick: (player: Player, clickAction: REntityAction) -> Unit) : super(server, location) {
|
||||
setBlock(entityMaterial.createBlockData())
|
||||
|
||||
hitbox = RInteraction(server, location)
|
||||
hitbox.setCallback(onClick)
|
||||
}
|
||||
|
||||
override fun die() {
|
||||
super.die()
|
||||
hitbox.die()
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
fun register(plugin: Plugin) {
|
||||
CannonCoreCommand.register()
|
||||
|
||||
val pluginManager = plugin.server.pluginManager
|
||||
pluginManager.registerEvents(CannonCoreWand, plugin)
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import de.steamwar.bausystem.BauSystem
|
||||
import de.steamwar.bausystem.utils.ItemUtils
|
||||
import de.steamwar.core.SWPlayer
|
||||
import de.steamwar.inventory.SWItem
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
object CannonCoreWand : Listener {
|
||||
val wandId = "CANNON_CORE_WAND"
|
||||
val wandMaterial = Material.BREEZE_ROD
|
||||
|
||||
|
||||
fun getWandItem(): ItemStack {
|
||||
val title = "§eCannon Core Wand"
|
||||
val lore = listOf(
|
||||
"§eRight Click §8- §7Create a new cannon core"
|
||||
)
|
||||
|
||||
val wand = SWItem(wandMaterial, title, lore, false, null)
|
||||
val item = wand.itemStack
|
||||
return ItemUtils.setItem(item, wandId)
|
||||
}
|
||||
|
||||
fun isWandItem(itemStack: ItemStack?): Boolean {
|
||||
return ItemUtils.isItem(itemStack, wandId)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onPlayerEquip(event: PlayerItemHeldEvent) {
|
||||
val player = event.player
|
||||
val swPlayer = SWPlayer.of(event.player)
|
||||
val item = player.inventory.getItem(event.newSlot)
|
||||
|
||||
if (isWandItem(item)) {
|
||||
scheduleDisplayUpdate(player)
|
||||
} else {
|
||||
swPlayer.removeComponent(EmptyCannonCoreWandDisplay::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
private fun scheduleDisplayUpdate(player: Player) {
|
||||
BauSystem.runTaskLater(JavaPlugin.getPlugin(BauSystem::class.java), Runnable { updateDisplay(player) }, 2)
|
||||
}
|
||||
|
||||
private fun updateDisplay(player: Player) {
|
||||
if (isWandItem(player.inventory.itemInMainHand)) {
|
||||
EmptyCannonCoreWandDisplay(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import de.steamwar.core.SWPlayer
|
||||
import de.steamwar.entity.REntityServer
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CannonCoresDisplay: SWPlayer.Component {
|
||||
val displayServer = REntityServer()
|
||||
val unlisten: () -> Unit
|
||||
|
||||
constructor(owner: Player) {
|
||||
unlisten = CannonCore.activeCores.observe( { cores ->
|
||||
displayServer.entities.forEach { it.die() }
|
||||
cores.forEach { CannonCoreEntity(displayServer, it.location) { _, _ -> println("Handler clicked at ${it.location}") } }
|
||||
})
|
||||
}
|
||||
|
||||
override fun onMount(player: SWPlayer) {
|
||||
displayServer.addPlayer(player.player)
|
||||
}
|
||||
|
||||
override fun onUnmount(player: SWPlayer?) {
|
||||
unlisten()
|
||||
displayServer.close()
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
import de.steamwar.core.SWPlayer
|
||||
import de.steamwar.cursor.Cursor
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class EmptyCannonCoreWandDisplay : SWPlayer.Component {
|
||||
val coresDisplay: CannonCoresDisplay
|
||||
var cursor: Cursor
|
||||
|
||||
constructor(owner: Player) {
|
||||
coresDisplay = CannonCoresDisplay(owner)
|
||||
SWPlayer.of(owner).setComponent(this)
|
||||
|
||||
cursor = Cursor(
|
||||
coresDisplay.displayServer, owner, Material.GLASS, Material.COMMAND_BLOCK,
|
||||
listOf(
|
||||
Cursor.CursorMode.BLOCK_ALIGNED
|
||||
),
|
||||
) { location, hitEntity, action ->
|
||||
print("Hello")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMount(player: SWPlayer) {
|
||||
coresDisplay.onMount(player)
|
||||
}
|
||||
|
||||
override fun onUnmount(player: SWPlayer) {
|
||||
|
||||
player.getComponent(Cursor::class.java)
|
||||
.filter { it === cursor }
|
||||
.ifPresent { player.removeComponent(Cursor::class.java) }
|
||||
|
||||
coresDisplay.onUnmount(player)
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannonCore
|
||||
|
||||
typealias Observer<T> = (currentValue: T) -> Unit
|
||||
|
||||
class Observable<T>(var value: T) {
|
||||
private val observers = ArrayList<Observer<T>>()
|
||||
|
||||
fun set(value: T) {
|
||||
val oldValue = this.value
|
||||
this.value = value
|
||||
|
||||
observers.forEach { it.invoke(value) }
|
||||
}
|
||||
|
||||
fun get(): T {
|
||||
return value
|
||||
}
|
||||
|
||||
fun observe(observer: Observer<T>): () -> Unit {
|
||||
observers.add(observer)
|
||||
observer(value)
|
||||
return {removeObserver(observer)}
|
||||
}
|
||||
|
||||
fun removeObserver(observer: Observer<T>) {
|
||||
observers.remove(observer)
|
||||
}
|
||||
}
|
||||
@@ -20,30 +20,28 @@
|
||||
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;
|
||||
|
||||
public final class ItemUtils {
|
||||
@UtilityClass
|
||||
public class ItemUtils {
|
||||
|
||||
private static final NamespacedKey ITEM_KEY = SWUtils.getNamespaceKey("bau_item");
|
||||
private final NamespacedKey ITEM_KEY = SWUtils.getNamespaceKey("bau_item");
|
||||
|
||||
private ItemUtils() {
|
||||
}
|
||||
|
||||
public static boolean isItem(ItemStack itemStack, String tag) {
|
||||
public boolean isItem(ItemStack itemStack, String tag) {
|
||||
String value = getTag(itemStack, ITEM_KEY);
|
||||
return value != null && value.equals(tag);
|
||||
}
|
||||
|
||||
public static ItemStack setItem(ItemStack itemStack, String tag) {
|
||||
public void setItem(ItemStack itemStack, String tag) {
|
||||
setTag(itemStack, ITEM_KEY, tag);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static String getTag(ItemStack itemStack, NamespacedKey key) {
|
||||
public String getTag(ItemStack itemStack, NamespacedKey key) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -58,7 +56,7 @@ public final class ItemUtils {
|
||||
return container.get(key, PersistentDataType.STRING);
|
||||
}
|
||||
|
||||
public static void setTag(ItemStack itemStack, NamespacedKey key, String value) {
|
||||
public void setTag(ItemStack itemStack, NamespacedKey key, String value) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,5 +38,4 @@ tasks.register<DevServer>("DevBau21") {
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau21"
|
||||
debug = true
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -31,17 +31,16 @@ import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.block.data.type.DriedGhast;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
@@ -258,4 +257,16 @@ public class Permanent implements Listener {
|
||||
event.setCancelled(true);
|
||||
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents Dried Ghast from spawning and plants from growing
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent event) {
|
||||
var type = event.getBlock().getType();
|
||||
|
||||
if (event.getBlock().getBlockData() instanceof DriedGhast || Tag.CROPS.isTagged(type) || Tag.SAPLINGS.isTagged(type)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user