From 03c3d496590ca88d426070467c0efef194d44f5b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 9 Jun 2026 16:38:22 +0200 Subject: [PATCH] Add BlastResistanceCommand --- .../BauSystem_Main/src/BauSystem.properties | 4 + .../src/BauSystem_de.properties | 4 + .../BlastResistanceCommand.java | 73 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/blastresistance/BlastResistanceCommand.java diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index a045edf4..c5adfb70 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -834,6 +834,10 @@ SKIN_NO_REGION = §7You are not in a region with a changealbe skin SKIN_ALREADY_EXISTS = §cThis skin already exists like this SKIN_MESSAGE = §7Skin created SKIN_MESSAGE_HOVER = §eClick to copy for YoyoNow and send +# Blast Resistance +BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Calculate min/max and average blast resistance of current clipboard +BLASTRESISTANCE_NO_CLIPBOARD = §cYou currently do not have a clipboard to be used. +BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2} # Panzern PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Armor your WorldEdit selection PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor. diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index dedc0599..9bee037c 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -772,6 +772,10 @@ SKIN_NO_REGION = §7Du steht in keiner Region, welche mit einem Skin versehen we SKIN_ALREADY_EXISTS = §cDieser Skin existiert in der Form bereits SKIN_MESSAGE = §7Skin erstellt SKIN_MESSAGE_HOVER = §eKlicken zum kopieren für YoyoNow und an diesen senden +# Blast Resistance +BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Minimal-, Maximal- und durchschnittliche Sprengfestigkeit des aktuellen Inhalts der Zwischenablage berechnen +BLASTRESISTANCE_NO_CLIPBOARD = §cDerzeit steht Ihnen keine Zwischenablage zur Verfügung. +BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2} # Panzern PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen. diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/blastresistance/BlastResistanceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/blastresistance/BlastResistanceCommand.java new file mode 100644 index 00000000..f296f1eb --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/blastresistance/BlastResistanceCommand.java @@ -0,0 +1,73 @@ +/* + * 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.slaves.blastresistance; + +import com.google.common.util.concurrent.AtomicDouble; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.world.block.BlockState; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +@Linked +public class BlastResistanceCommand extends SWCommand { + + public BlastResistanceCommand() { + super("blastresistance"); + } + + @Register(description = "BLASTRESISTANCE_HELP") + public void command(Player player) { + LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player)); + Clipboard clipboard; + try { + clipboard = localSession.getClipboard().getClipboards().getFirst(); + } catch (WorldEditException e) { + BauSystem.MESSAGE.send("BLASTRESISTANCE_NO_CLIPBOARD", player); + return; + } + + AtomicDouble min = new AtomicDouble(0); + AtomicDouble max = new AtomicDouble(0); + AtomicDouble sum = new AtomicDouble(0); + AtomicInteger count = new AtomicInteger(0); + clipboard.forEach(blockVector3 -> { + BlockState blockState = clipboard.getBlock(blockVector3); + Material material = BukkitAdapter.adapt(blockState).getMaterial(); + if (material == Material.WATER || material == Material.LAVA) return; + double blastResistance = BukkitAdapter.adapt(blockState).getMaterial().getBlastResistance(); + min.set(Math.min(min.get(), blastResistance)); + max.set(Math.max(max.get(), blastResistance)); + sum.addAndGet(blastResistance); + count.getAndIncrement(); + }); + + BauSystem.MESSAGE.send("BLASTRESISTANCE_RESULT", player, min.get(), max.get(), sum.get() / count.get()); + } +}