From 7d45680fcbd9a1db50537dc868c1a4d3f38b655f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 23 Apr 2025 21:52:27 +0200 Subject: [PATCH 01/49] Enable a Dirt Block (Schem owner -1 and Name like GameMode) to be selected for any ServerTeam member --- .../fightsystem/FightSystem.properties | 1 + .../fightsystem/FightSystem_de.properties | 1 + .../de/steamwar/fightsystem/commands/GUI.java | 41 ++++++++++++++----- .../steamwar/fightsystem/fight/FightTeam.java | 7 +++- .../winconditions/WinconditionBlocks.java | 2 +- .../WinconditionCaptainDead.java | 2 + .../winconditions/WinconditionPercent.java | 2 + 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index dde4e266..455e0444 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -76,6 +76,7 @@ KITSEARCH_TITLE=Search for kit SCHEM_NO_ENEMY=§cNo schematic selection without an opponent SCHEM_TITLE={0} selection +SCHEM_DIRT=§eDirt Block SCHEM_PUBLIC=§ePublic {0} SCHEM_UNCHECKED=§eUnchecked {0} SCHEM_PRIVATE=§ePrivate {0} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties index 470226a8..cd294425 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -70,6 +70,7 @@ KITSEARCH_TITLE=Nach Kit suchen SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner SCHEM_TITLE={0}-Auswahl +SCHEM_DIRT=§eErdblock SCHEM_PUBLIC=§eÖffentliches {0} SCHEM_UNCHECKED=§eUngeprüftes {0} SCHEM_PRIVATE=§ePrivates {0} 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 2ca6849c..87e72c08 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -24,15 +24,14 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.ai.AIManager; import de.steamwar.fightsystem.fight.*; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.utils.ColorConverter; import de.steamwar.inventory.*; import de.steamwar.message.Message; -import de.steamwar.sql.PersonalKit; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.*; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -40,7 +39,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import java.util.*; +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 { @@ -206,6 +208,16 @@ public class GUI { for (int i = 0; i < Config.SubTypes.size(); i++) { setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1); } + if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) { + SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null); + if (node != null) { + inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> { + schemSelect(p, node, fightTeam -> { + fightTeam.setIgnoreWinconditions(true); + }); + })); + } + } inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } @@ -241,14 +253,21 @@ public class GUI { private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){ SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> { - FightTeam fightTeam = Fight.getPlayerTeam(p); - if(fightTeam == null) - return; - if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) - fightTeam.pasteSchem(node); - p.closeInventory(); + schemSelect(p, node, fightTeam -> { + fightTeam.setIgnoreWinconditions(false); + }); }); selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY); selector.open(); } + + private static void schemSelect(Player p, SchematicNode node, Consumer fightTeamConsumer) { + FightTeam fightTeam = Fight.getPlayerTeam(p); + if(fightTeam == null) + return; + fightTeamConsumer.accept(fightTeam); + if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) + fightTeam.pasteSchem(node); + p.closeInventory(); + } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 0cb68f71..19d45690 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -42,6 +42,7 @@ import de.steamwar.inventory.SWItem; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import lombok.Getter; +import lombok.Setter; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.*; import org.bukkit.entity.LivingEntity; @@ -100,6 +101,10 @@ public class FightTeam { @Getter private boolean publicsOnly; + @Getter + @Setter + private boolean ignoreWinconditions; + private final Map players = new HashMap<>(); @Getter @@ -385,7 +390,7 @@ public class FightTeam { } public void pasteSchem(SchematicNode schematic){ - if(schematic.getSchemtype().check()) { + if(schematic.getSchemtype().check() || schematic.getSchemtype().writeable()) { FightStatistics.unrank(); FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName()); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java index b9b0c9f7..4bbaa241 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java @@ -85,7 +85,7 @@ public class WinconditionBlocks extends Wincondition implements PrintableWincond private void check() { blocks.removeIf(block -> !isOfType.test(block)); - if(blocks.isEmpty()) + if(blocks.isEmpty() && !team.isIgnoreWinconditions()) win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName()); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java index de0205ab..df7651ee 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java @@ -42,6 +42,8 @@ public class WinconditionCaptainDead extends Wincondition implements Listener { return; FightTeam team = leader.getTeam(); + if (team.isIgnoreWinconditions()) + return; win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName()); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java index 37d3fafa..5a2cbe4f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java @@ -40,6 +40,8 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon private final Map teamMap = new HashMap<>(); protected Consumer checkWin = team -> { + if (team.isIgnoreWinconditions()) + return; if (getPercent(team) >= Config.PercentWin) { win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName()); } From f89c4e88f91b5eefa0f7af6ec67a696e02b304f2 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 25 Apr 2025 18:07:14 +0200 Subject: [PATCH 02/49] Fix HotbarKit Fix steamwar.devserver.gradle Add WarGear20 to build.gradle.kts --- .../src/de/steamwar/fightsystem/fight/HotbarKit.java | 4 +--- FightSystem/build.gradle.kts | 10 ++++++++++ buildSrc/src/steamwar.devserver.gradle | 12 ++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java index ec4d5439..6b3df110 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java @@ -37,6 +37,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; @@ -120,9 +121,6 @@ public class HotbarKit extends Kit { Player player = (Player) event.getWhoClicked(); click(player, slot, event); - Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { - player.setItemOnCursor(null); - }, 1); } private void click(Player player, int slot, Cancellable event) { diff --git a/FightSystem/build.gradle.kts b/FightSystem/build.gradle.kts index 0cd412bc..87849826 100644 --- a/FightSystem/build.gradle.kts +++ b/FightSystem/build.gradle.kts @@ -39,3 +39,13 @@ dependencies { implementation(project(":FightSystem:FightSystem_20")) implementation(project(":FightSystem:FightSystem_21")) } + +tasks.register("WarGear20") { + group = "run" + description = "Run a WarGear 1.20 Fight Server" + dependsOn(":SpigotCore:shadowJar") + dependsOn(":FightSystem:shadowJar") + template = "WarGear20" + worldName = "arenas/Pentraki" + config = "WarGear20.yml" +} diff --git a/buildSrc/src/steamwar.devserver.gradle b/buildSrc/src/steamwar.devserver.gradle index 1879bf87..53f8be3d 100644 --- a/buildSrc/src/steamwar.devserver.gradle +++ b/buildSrc/src/steamwar.devserver.gradle @@ -135,10 +135,10 @@ class DevServer extends DefaultTask { if (plugins != null) devPy.append(" -p $plugins") if (jar != null) devPy.append(" --jar $jar") for (Map.Entry dParam : dParams.entrySet()) { - devPy.append("-D${dParam.key}=${dParam.value}") + devPy.append(" -D${dParam.key}=${dParam.value}") } - println("Starting $template with command ${devPy.toString()}") devPy.append(" $template") + println("Starting $template with command ${devPy.toString()}") def process = new ProcessBuilder("ssh", host, "-T", devPy.toString()).start() def processOutput = new BufferedReader(new InputStreamReader(process.inputStream)) @@ -172,15 +172,15 @@ class FightServer extends DevServer { @Input @Optional - int checkSchemID = 0 + Integer checkSchemID = 0 @Input @Optional - int prepareSchemID = 0 + Integer prepareSchemID = 0 @Input @Optional - int replay = 0 + Integer replay = 0 @Input @Optional @@ -189,7 +189,7 @@ class FightServer extends DevServer { @Input @Optional // Property: fightID - int eventKampfID = 0 + Integer eventKampfID = 0 @Input @Optional From 84cc292df4fd8c821d3ef82dc3aabf01207c7411 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 26 Apr 2025 13:08:13 +0200 Subject: [PATCH 03/49] Fixed meterstock --- .../de/steamwar/bausystem/features/region/FreezeListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a78ff18a..673867e7 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 @@ -226,7 +226,7 @@ public class FreezeListener implements Listener, ScoreboardElement { } } - @EventHandler(priority = EventPriority.MONITOR) + @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; From e72ae3cf9477238200161e2b315ec5bd10b6e14c Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Apr 2025 22:13:31 +0200 Subject: [PATCH 04/49] LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java aktualisiert --- LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index f8ce3338..324a7901 100644 --- a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -107,7 +107,7 @@ public class JumpAndRun extends BasicListener { if (location.getY() < point.getY()) { return; } - if (location.toVector().distanceSquared(point) >= 12.25) { + if (location.toVector().distanceSquared(point) >= 17) { return; } CURRENT_POS.put(event.getPlayer(), index); From 713275ba11826874a00a6b87c4063d67608e3fe1 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Apr 2025 22:17:43 +0200 Subject: [PATCH 05/49] Add ErrorLogging for Bugged Schematics --- .../src/de/steamwar/routes/Schematic.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt index 1beb0f29..b220db08 100644 --- a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt +++ b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt @@ -149,6 +149,22 @@ fun Route.configureSchematic() { return@let SchematicFormat.SPONGE_V2 } + if (version == SchematicFormat.SPONGE_V3) { + try { + val fawe = schem.getCompound("Metadata") + .getCompound("WorldEdit") + .getString("Version") + + if (fawe.equals("2.12.3-SNAPSHOT")) { + SWException.log("Schematic with Bugged Version Uploaded", """ + Schematic=$schemName + User=${user.userName} + Id=${user.id} + """.trimIndent()) + } + } catch (_: Exception) {} + } + val data = NodeData(node.id, version) data.saveFromStream(content.inputStream(), version) From b1bef4ced5ed8d3222ed95ada4841b536abb9b50 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Apr 2025 22:27:53 +0200 Subject: [PATCH 06/49] Add ErrorLogging for Bugged Schematics --- WebsiteBackend/src/de/steamwar/routes/Schematic.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt index b220db08..ec3b54fb 100644 --- a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt +++ b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt @@ -154,6 +154,7 @@ fun Route.configureSchematic() { val fawe = schem.getCompound("Metadata") .getCompound("WorldEdit") .getString("Version") + .value if (fawe.equals("2.12.3-SNAPSHOT")) { SWException.log("Schematic with Bugged Version Uploaded", """ From f93362a02344b83bd29515700b99c551d0ac76f3 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Apr 2025 23:48:33 +0200 Subject: [PATCH 07/49] LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java aktualisiert --- LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index 324a7901..a783b05e 100644 --- a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -67,7 +67,7 @@ public class JumpAndRun extends BasicListener { int count = CLICKED_COUNT.getOrDefault(player, -1); if (count >= 0) { - if (count > 60) { + if (count > 20) { toReset.add(player); return; } From b5a95648088c07492ffe4feed54442b61c3d18e8 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 26 Apr 2025 23:56:59 +0200 Subject: [PATCH 08/49] Allow next next location in JumpAndRun --- .../de/steamwar/lobby/jumpandrun/JumpAndRun.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index 324a7901..3b8a3ab4 100644 --- a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -104,12 +104,18 @@ public class JumpAndRun extends BasicListener { return; } Vector point = points.get(index); - if (location.getY() < point.getY()) { - return; - } - if (location.toVector().distanceSquared(point) >= 17) { + if (location.getY() < point.getY()) index = -2; + if (location.toVector().distanceSquared(point) >= 17) index = -2; + if (index > 0 && index < points.size() - 1) { + Vector nextPoint = points.get(index + 1); + if (location.getY() >= nextPoint.getY() && location.toVector().distanceSquared(nextPoint) < 17) { + index = index + 1; + } + } + if (index == -2) { return; } + CURRENT_POS.put(event.getPlayer(), index); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.4F, 1); if (index < points.size() - 1) { From 5cdad8c2f4adc909eec1f62c3b1966ff23d1d752 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 27 Apr 2025 02:28:39 +0200 Subject: [PATCH 09/49] Add Dev 1.21.5 --- VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java index a5e08b55..d8952118 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java @@ -44,6 +44,7 @@ public enum ServerVersion { PAPER_18("paper-1.18.2.jar", 15, ProtocolVersion.MINECRAFT_1_18_2), PAPER_19("paper-1.19.3.jar", 19, ProtocolVersion.MINECRAFT_1_19_3), PAPER_20("paper-1.20.1.jar", 20, ProtocolVersion.MINECRAFT_1_20), + DEVEL_21("paper-1.21.5.jar", 21, ProtocolVersion.MINECRAFT_1_21_5), PAPER_21("paper-1.21.3.jar", 21, ProtocolVersion.MINECRAFT_1_21_2); private static final Map chatMap = new HashMap<>(); @@ -94,6 +95,10 @@ public enum ServerVersion { } public static ServerVersion get(int version) { + if (version == 21) { + return DEVEL_21; + } + return versionMap.get(version); } From 66d18e316b229fae615e0688f0d6da0908e881d7 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Apr 2025 16:47:43 +0200 Subject: [PATCH 10/49] =?UTF-8?q?Hotfix:=20Schematic=20Download=20geht=20f?= =?UTF-8?q?=C3=BCr=20nicht=20Supervisor=20Player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bausystem/features/world/SpectatorListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 3b3ea664..f1aed39f 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 @@ -179,7 +179,12 @@ public class SpectatorListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) { + if (event.getMessage().startsWith("/schem save") || + event.getMessage().startsWith("//schem save") || + event.getMessage().startsWith("/schematic save") || + event.getMessage().startsWith("//schematic save") || + event.getMessage().startsWith("/download") || + event.getMessage().startsWith("//download")) { if (!Permission.SUPERVISOR.hasPermission(event.getPlayer())) { event.setCancelled(true); event.setMessage("/"); From d6a5caf95d48499776b40bcdd148e96cb2d0933f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 29 Apr 2025 17:59:22 +0200 Subject: [PATCH 11/49] Add error handling and logging to Techhider and TinyProtocol --- .../commands/TechhiderbugCommand.java | 42 ++++++++++++------- .../comphenix/tinyprotocol/TinyProtocol.java | 15 +++++++ 2 files changed, 42 insertions(+), 15 deletions(-) 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 4a3bf47f..eb0c82f5 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -34,6 +34,7 @@ import org.bukkit.command.CommandSender; import java.io.StringWriter; import java.util.Arrays; +import java.util.logging.Level; public class TechhiderbugCommand implements CommandExecutor { @@ -45,25 +46,36 @@ public class TechhiderbugCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) { StringWriter writer = new StringWriter(); - writer.append("ArenaMode: ").append(Config.mode.name()).append('\n'); - writer.append("FightState: ").append(FightState.getFightState().name()).append('\n'); - writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n'); + try { + writer.append("ArenaMode: ").append(Config.mode.name()).append('\n'); + writer.append("FightState: ").append(FightState.getFightState().name()).append('\n'); + writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n'); - writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n'); - writer.append("Team regions: "); - Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' ')); - writer.append('\n'); + writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n'); + writer.append("Team regions: "); + Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' ')); + writer.append('\n'); - writer.append("HullHider regions: "); - FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' ')); - writer.append('\n'); + writer.append("HullHider regions: "); + FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' ')); + writer.append('\n'); - writer.append("Hidden regions: "); - FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' ')); - writer.append('\n'); + writer.append("Hidden regions: "); + FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' ')); + writer.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')); + writer.append("TinyProtocol: "); + 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')); + } catch (Exception e) { + writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n'); + writer.flush(); + Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e); + } finally { + writer.flush(); + } SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString()); return false; diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index af318d83..6a77e082 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -71,6 +71,17 @@ public class TinyProtocol implements Listener { @Getter private final Map playerInterceptors = new HashMap<>(); + @Override + public String toString() { + return "TinyProtocol{" + + "plugin=" + plugin + + ", connections=" + connections + + ", closed=" + closed + + ", packetFilters=" + packetFilters + + ", playerInterceptors=" + playerInterceptors + + '}'; + } + private TinyProtocol(final Plugin plugin) { this.plugin = plugin; this.connections = networkManagers.get(getServerConnection(plugin)); @@ -84,6 +95,7 @@ public class TinyProtocol implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerLogin(PlayerLoginEvent e) { + plugin.getLogger().info("Creating Techhider for: " + e.getPlayer().getName() + " (" + closed + ")"); if(closed) return; new PacketInterceptor(e.getPlayer()); @@ -118,6 +130,8 @@ public class TinyProtocol implements Listener { } public final void close() { + plugin.getLogger().log(Level.INFO, "Closing Techhider", new Exception("Stacktrace")); + if(closed) return; closed = true; @@ -155,6 +169,7 @@ public class TinyProtocol implements Listener { return; synchronized (playerInterceptors) { + plugin.getLogger().info("Adding Techhider for: " + player.getName()); playerInterceptors.put(player, this); } From 15bb92fbbac90601ebdc4d2819c7e338789753d8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 29 Apr 2025 18:04:58 +0200 Subject: [PATCH 12/49] Improve error handling and logging in Techhider and TinyProtocol Refined logging messages for clarity by replacing "Techhider" with "PacketInterceptor" where appropriate. Adjusted error handling in `TechhiderbugCommand` by removing redundant `flush` calls and properly logging exceptions during bug report generation. These changes aim to enhance maintainability and debugging. --- .../steamwar/fightsystem/commands/TechhiderbugCommand.java | 3 --- .../src/com/comphenix/tinyprotocol/TinyProtocol.java | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) 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 eb0c82f5..3080c13e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -71,10 +71,7 @@ public class TechhiderbugCommand implements CommandExecutor { Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n')); } catch (Exception e) { writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n'); - writer.flush(); Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e); - } finally { - writer.flush(); } SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString()); diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index 6a77e082..c8070e46 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -95,7 +95,7 @@ public class TinyProtocol implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerLogin(PlayerLoginEvent e) { - plugin.getLogger().info("Creating Techhider for: " + e.getPlayer().getName() + " (" + closed + ")"); + plugin.getLogger().info("Creating PacketInterceptor for: " + e.getPlayer().getName() + " (" + closed + ")"); if(closed) return; new PacketInterceptor(e.getPlayer()); @@ -130,7 +130,7 @@ public class TinyProtocol implements Listener { } public final void close() { - plugin.getLogger().log(Level.INFO, "Closing Techhider", new Exception("Stacktrace")); + plugin.getLogger().log(Level.INFO, "Closing PacketInterceptor", new Exception("Stacktrace")); if(closed) return; @@ -169,9 +169,9 @@ public class TinyProtocol implements Listener { return; synchronized (playerInterceptors) { - plugin.getLogger().info("Adding Techhider for: " + player.getName()); playerInterceptors.put(player, this); } + plugin.getLogger().info("Adding Techhider for: " + player.getName()); try { channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this); From 5015aca15905ac4f920f6d9291b7502d87cb4c8d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 2 May 2025 10:13:47 +0200 Subject: [PATCH 13/49] =?UTF-8?q?Maybe=E2=84=A2=EF=B8=8F=20fix=20Techhider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/comphenix/tinyprotocol/TinyProtocol.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index c8070e46..6f1dbf1a 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -160,10 +160,10 @@ public class TinyProtocol implements Listener { private PacketInterceptor(Player player) { this.player = player; - channel = getChannel.get(connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).findAny().orElseThrow(() -> { + 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; @@ -175,11 +175,11 @@ public class TinyProtocol implements Listener { try { channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this); - } catch (IllegalArgumentException e) { + } 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); From 6940c32b02945d4594f4cca24f7fd9a09f89886f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 2 May 2025 14:13:33 +0200 Subject: [PATCH 14/49] Adjust OpenJ9 JVM arguments to include hprof option in dumps. --- VelocityCore/src/de/steamwar/velocitycore/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/Node.java b/VelocityCore/src/de/steamwar/velocitycore/Node.java index 9c717886..f83d042f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/Node.java +++ b/VelocityCore/src/de/steamwar/velocitycore/Node.java @@ -35,7 +35,7 @@ public abstract class Node { private static final List OPENJ9_ARGS = Arrays.asList( "-XX:+EnableCRIUSupport", "-XX:-CRIURestoreNonPortableMode", "-Xgc:excessiveGCratio=80", "-Xdisableexplicitgc", "-Xnoclassgc", "-Xmos128M", "-Xmns48M", "-XX:+ExitOnOutOfMemoryError", // initial heap half values of memory observed by 1.19 spectate server - "-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none", + "-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none,opts=hprof", "-XX:+EnableDynamicAgentLoading", "-Dlog4j.configurationFile=log4j2.xml" ); private static final Set JAVA_8 = new HashSet<>(); From 7f0fa09c5674dd5b9799a13c09220f9d12c14235 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 2 May 2025 14:14:27 +0200 Subject: [PATCH 15/49] Update OpenJ9 dump configuration to enable heap hprof. --- VelocityCore/src/de/steamwar/velocitycore/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/Node.java b/VelocityCore/src/de/steamwar/velocitycore/Node.java index f83d042f..308d9938 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/Node.java +++ b/VelocityCore/src/de/steamwar/velocitycore/Node.java @@ -35,7 +35,7 @@ public abstract class Node { private static final List OPENJ9_ARGS = Arrays.asList( "-XX:+EnableCRIUSupport", "-XX:-CRIURestoreNonPortableMode", "-Xgc:excessiveGCratio=80", "-Xdisableexplicitgc", "-Xnoclassgc", "-Xmos128M", "-Xmns48M", "-XX:+ExitOnOutOfMemoryError", // initial heap half values of memory observed by 1.19 spectate server - "-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none,opts=hprof", + "-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none", "-Xdump:heap:opts=hprof", "-XX:+EnableDynamicAgentLoading", "-Dlog4j.configurationFile=log4j2.xml" ); private static final Set JAVA_8 = new HashSet<>(); From a4eea298d21b2c270fe16231f0b9f94527f77aae Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 7 May 2025 14:37:00 +0200 Subject: [PATCH 16/49] Hotfix PrepareSchem not copying allowReplay and replaceColor while creating a prepared schem --- .../src/de/steamwar/fightsystem/listener/PrepareSchem.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java index 288eda76..29ccc434 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java @@ -86,7 +86,10 @@ public class PrepareSchem implements Listener { if(schemExists(schem)) return; + SchematicNode old = schem; schem = SchematicNode.createSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent(), Config.SchematicType.checkType().toDB(), schem.getItem()); + schem.setReplaceColor(old.replaceColor()); + schem.setAllowReplay(old.allowReplay()); try{ WorldeditWrapper.impl.saveSchem(schem, region, minY); From ac00245b0481fb52b6c421a76a93a63e4431290c Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 11 May 2025 18:50:21 +0200 Subject: [PATCH 17/49] Fix lag of IngameListener --- .../de/steamwar/towerrun/listener/IngameListener.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index bbb332bf..26b8b045 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -67,11 +67,15 @@ public class IngameListener extends GameStateBukkitListener { if (blocks == null) { return; } - blocks.forEach(block -> { - if (block.getType() == Material.AIR || block.getType() == Material.LAVA) return; + int maxBlocks = 1_000; + while (maxBlocks > 0 && !blocks.isEmpty()) { + Block block = blocks.removeFirst(); + if (block.getType() == Material.AIR || block.getType() == Material.LAVA) continue; block.setType(Material.AIR); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1); - }); + maxBlocks--; + } + blocksToMelt.computeIfAbsent(time, __ -> new ArrayList<>()).addAll(0, blocks); } }; blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1); From b229b0d0ae3d64d1dc03d94ecd75b02b719f357b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 11 May 2025 19:02:02 +0200 Subject: [PATCH 18/49] Fix many simple things --- .../towerrun/generator/TowerGenerator.java | 6 +- .../towerrun/listener/IngameListener.java | 69 +++++++++++++++---- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java b/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java index 4f379547..63cd94ee 100644 --- a/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java +++ b/TowerRun/src/de/steamwar/towerrun/generator/TowerGenerator.java @@ -140,8 +140,10 @@ public class TowerGenerator { noKeyFloors--; if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) { noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors; - Container container = chestBlocks.get(random.nextInt(chestBlocks.size())); - keys.add(container.getLocation()); + for (int i = 0; i < 2; i++) { + Container container = chestBlocks.get(random.nextInt(chestBlocks.size())); + keys.add(container.getLocation()); + } for (WorldConfig.TowerGeneratorDoorBlock doorBlock : config.doorBlocks) { int x = doorBlock.getX(); diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index 26b8b045..eb7c3c1c 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -20,6 +20,7 @@ package de.steamwar.towerrun.listener; import de.steamwar.inventory.SWItem; +import de.steamwar.network.packets.server.BaumemberUpdatePacket; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.config.WorldConfig; @@ -84,16 +85,16 @@ public class IngameListener extends GameStateBukkitListener { @Override public void run() { double minY = TowerRunGame.PLAYERS_ALIVE.stream() - .map(p -> p.player().getLocation().getY()) - .min(Comparator.comparing(Function.identity())) + .mapToDouble(p -> p.player().getLocation().getY()) + .average() .orElse(0.0); List toDamage = new ArrayList<>(); TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> { - if (towerRunPlayer.player().getLocation().getY() - minY > 20) { - towerRunPlayer.player().sendTitle("§a", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5); - } if (towerRunPlayer.player().getLocation().getY() - minY > 30) { + towerRunPlayer.player().sendTitle("", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5); + } + if (towerRunPlayer.player().getLocation().getY() - minY > 50) { toDamage.add(towerRunPlayer.player()); } }); @@ -119,12 +120,12 @@ public class IngameListener extends GameStateBukkitListener { public void onPlayerDeath(PlayerDeathEvent event) { event.setDeathMessage(null); Bukkit.getScheduler().runTaskLater(TowerRun.getInstance(), () -> { - if (TowerRun.getTowerGenerator() != null) { - event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn()); - } else { - event.getEntity().teleport(WorldConfig.SPAWN); - } - }, 5 + if (TowerRun.getTowerGenerator() != null) { + event.getEntity().teleport(TowerRun.getTowerGenerator().getSpawn()); + } else { + event.getEntity().teleport(WorldConfig.SPAWN); + } + }, 5 ); event.getEntity().setGameMode(GameMode.SPECTATOR); Bukkit.getOnlinePlayers().forEach(player -> { @@ -185,10 +186,12 @@ public class IngameListener extends GameStateBukkitListener { } event.getPlayer().getInventory().addItem(new SWItem(Material.LEVER, TowerRun.getMessage().parse("KEY_NAME", event.getPlayer())).getItemStack()); - event.getClickedBlock().setType(Material.ENDER_CHEST); - event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1); - TowerRun.getMessage().broadcast("KEY_FOUND", event.getPlayer().getName()); + + Bukkit.getOnlinePlayers().forEach(player -> { + player.playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1); + player.sendTitle("", TowerRun.getMessage().parse("KEY_FOUND", player, event.getPlayer().getName()), 10, 70, 20); + }); } @EventHandler @@ -211,6 +214,44 @@ public class IngameListener extends GameStateBukkitListener { private void shouldMelt(Block block) { if (block.getType().isBurnable()) return; int meltingTime = (int) (block.getType().getHardness() * 48 * 20); + switch (block.getType()) { + case TINTED_GLASS: + case WHITE_STAINED_GLASS: + case ORANGE_STAINED_GLASS: + case MAGENTA_STAINED_GLASS: + case LIGHT_BLUE_STAINED_GLASS: + case YELLOW_STAINED_GLASS: + case LIME_STAINED_GLASS: + case PINK_STAINED_GLASS: + case GRAY_STAINED_GLASS: + case LIGHT_GRAY_STAINED_GLASS: + case CYAN_STAINED_GLASS: + case PURPLE_STAINED_GLASS: + case BLUE_STAINED_GLASS: + case BROWN_STAINED_GLASS: + case GREEN_STAINED_GLASS: + case RED_STAINED_GLASS: + case BLACK_STAINED_GLASS: + case WHITE_STAINED_GLASS_PANE: + case ORANGE_STAINED_GLASS_PANE: + case MAGENTA_STAINED_GLASS_PANE: + case LIGHT_BLUE_STAINED_GLASS_PANE: + case YELLOW_STAINED_GLASS_PANE: + case LIME_STAINED_GLASS_PANE: + case PINK_STAINED_GLASS_PANE: + case GRAY_STAINED_GLASS_PANE: + case LIGHT_GRAY_STAINED_GLASS_PANE: + case CYAN_STAINED_GLASS_PANE: + case PURPLE_STAINED_GLASS_PANE: + case BLUE_STAINED_GLASS_PANE: + case BROWN_STAINED_GLASS_PANE: + case GREEN_STAINED_GLASS_PANE: + case RED_STAINED_GLASS_PANE: + case BLACK_STAINED_GLASS_PANE: + meltingTime = meltingTime * 10; + default: + break; + } blocksToMelt.computeIfAbsent(time + meltingTime, integer -> new ArrayList<>()).add(block); } From d6fba9b0afbfad27cfe50175a97c212a8083e95e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 11 May 2025 19:02:46 +0200 Subject: [PATCH 19/49] Fix many simple things --- TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index eb7c3c1c..a4e2bec6 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -216,6 +216,8 @@ public class IngameListener extends GameStateBukkitListener { int meltingTime = (int) (block.getType().getHardness() * 48 * 20); switch (block.getType()) { case TINTED_GLASS: + meltingTime = meltingTime * 2; + break; case WHITE_STAINED_GLASS: case ORANGE_STAINED_GLASS: case MAGENTA_STAINED_GLASS: From d0665932f44396b2d6f3accbfa9103e8090533a2 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 11 May 2025 20:19:23 +0200 Subject: [PATCH 20/49] Fix TowerRunGame.reset --- TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java | 1 + 1 file changed, 1 insertion(+) diff --git a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java index 3c846247..c1514db4 100644 --- a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java +++ b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java @@ -147,6 +147,7 @@ public class TowerRunGame { player.setGameMode(GameMode.SURVIVAL); } player.teleport(WorldConfig.SPAWN); + PLAYERS_ALIVE.add(TowerRunPlayer.get(player)); }); } From e893d7934aa121cc618125175a6f2fd2e28cbff7 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 14 May 2025 19:11:05 +0200 Subject: [PATCH 21/49] Fix TowerRun for events --- TowerRun/src/de/steamwar/towerrun/TowerRun.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/TowerRun.java b/TowerRun/src/de/steamwar/towerrun/TowerRun.java index 7e6df112..4503c5da 100644 --- a/TowerRun/src/de/steamwar/towerrun/TowerRun.java +++ b/TowerRun/src/de/steamwar/towerrun/TowerRun.java @@ -80,7 +80,5 @@ public class TowerRun extends JavaPlugin { gameCountdown = new GameCountdown(); Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20); - - TowerRunGame.reset(); } } From 260656ad357748e4fcd2bc40cbea00beaf0dab04 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 14 May 2025 19:28:27 +0200 Subject: [PATCH 22/49] Fix for events --- .../de/steamwar/misslewars/countdowns/EndCountdown.java | 2 +- .../src/de/steamwar/towerrun/countdowns/EndCountdown.java | 7 ++++++- .../src/de/steamwar/towerrun/listener/LobbyListener.java | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java b/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java index 292071a6..f2d3183b 100644 --- a/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java +++ b/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java @@ -37,7 +37,7 @@ public class EndCountdown extends StateDependent { @Override public void enable() { if (Config.isEvent()) { - task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 1200); + task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 200); } else { task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime); } diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java index 0162ba53..6d631e02 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java @@ -20,6 +20,7 @@ package de.steamwar.towerrun.countdowns; import de.steamwar.towerrun.TowerRun; +import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.state.GameStates; import org.bukkit.Bukkit; @@ -48,7 +49,11 @@ public class EndCountdown extends Countdown { void timerEnd() { Bukkit.getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1)); if (RESETS) { - TowerRunGame.reset(); + if (Config.event()) { + Bukkit.shutdown(); + } else { + TowerRunGame.reset(); + } lobbyCountdown.setTime(lobbyCountdown.defaultTime()); } else { Bukkit.shutdown(); diff --git a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java index c93bc4bb..78fe59c5 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java @@ -62,12 +62,13 @@ public class LobbyListener extends GameStateBukkitListener { int team = user.getTeam(); if (team != Config.EVENT_TEAM_BLUE_ID && team != Config.EVENT_TEAM_RED_ID) { - player.setGameMode(GameMode.SPECTATOR); return; } if (TowerRunGame.PLAYERS_ALIVE.stream().map(towerRunPlayer -> SteamwarUser.get(towerRunPlayer.player().getUniqueId()).getTeam()).filter(integer -> integer == team).count() < Config.EVENT_MAXIMUM_TEAM_MEMBERS) { TowerRunGame.PLAYERS_ALIVE.add(TowerRunPlayer.get(player)); + } else { + player.setGameMode(GameMode.SPECTATOR); } } else { TowerRunGame.PLAYERS_ALIVE.add(TowerRunPlayer.get(player)); From 717cfa8baf6483122bbb64dc6d60f30fe46c4187 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 16 May 2025 18:00:23 +0200 Subject: [PATCH 23/49] Prevent usage of Flashback channels for restricted players Added new channel handlers to block Flashback mod channels for users without appropriate permissions. Ensures restricted players using these channels are disconnected with a specific warning message. This enhances control over mod usage and maintains server integrity. --- .../velocitycore/listeners/PluginMessage.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java index 7ef0be27..33e431fb 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java @@ -33,6 +33,8 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.proxy.protocol.ProtocolUtils; import de.steamwar.messages.Chatter; import de.steamwar.network.packets.NetworkPacket; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.commands.TeamCommand; import de.steamwar.velocitycore.mods.*; @@ -360,6 +362,23 @@ public class PluginMessage extends BasicListener { )) channelRegisterHandlers.put(channel, player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "minimap")); + for(String channel : Arrays.asList( + "flashback:remote_food_data", + "flashback:remote_set_slot", + "flashback:force_client_tick", + "flashback:accurate_entity_position", + "flashback:instantly_lerp", + "flashback:remote_experience", + "flashback:clear_particles", + "flashback:remote_select_hotbar_slot", // https://github.com/Moulberry/Flashback/tree/master/src/main/java/com/moulberry/flashback/packet + "flashback:clear_entities" // https://github.com/Moulberry/Flashback + )) + channelRegisterHandlers.put(channel, player -> { + if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.RESTRICTED_MODS)) { + Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "flashback"); + } + }); + for(String channel : Arrays.asList("bedrockify:cauldron_particles", "bedrockify:eat-particles")) //https://github.com/juancarloscp52/BedrockIfy (Bedrock features on Java, banned for reach-around block placement) channelRegisterHandlers.put(channel, player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "bedrockify")); From 69251f42a6e540d57d50d8bf6a8424f6dce593ef Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 17 May 2025 23:40:48 +0200 Subject: [PATCH 24/49] Add music disks to autochecker --- .../SchematicSystem_19/build.gradle.kts | 32 +++ .../autocheck/AutoChecker19.java | 213 ++++++++++++++++++ .../schematiccommand/SchematicCommand19.java | 147 ++++++++++++ SchematicSystem/build.gradle.kts | 1 + settings.gradle.kts | 1 + 5 files changed, 394 insertions(+) create mode 100644 SchematicSystem/SchematicSystem_19/build.gradle.kts create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts new file mode 100644 index 00000000..d1baf622 --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -0,0 +1,32 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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.spigotapi) + + compileOnly(libs.nms19) + compileOnly(libs.fawe18) +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java new file mode 100644 index 00000000..92b06c0d --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java @@ -0,0 +1,213 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2023 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public 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.schematicsystem.CheckSchemType; +import org.bukkit.Material; + +import java.util.*; +import java.util.stream.Collectors; + +public class AutoChecker19 implements AutoChecker.IAutoChecker { + 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( + // 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, + // 16-stackable Items + Material.HONEY_BOTTLE, + // Non-stackable items + Material.DIAMOND_HORSE_ARMOR, + Material.IRON_HORSE_ARMOR, + Material.GOLDEN_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 + ); + + 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(INVENTORY.contains(material)) { + checkInventory(result, block, material, 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)); + } + } + } + } + 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)); + FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); + } + + 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 += 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, CheckSchemType 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, CheckSchemType type) { + return AutoCheckerResult.builder() + .type(type) + .height(clipboard.getDimensions().getBlockY()) + .width(clipboard.getDimensions().getBlockX()) + .depth(clipboard.getDimensions().getBlockZ()) + .build(); + } +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java new file mode 100644 index 00000000..2fecb87d --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java @@ -0,0 +1,147 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2023 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public 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.jnbt.CompoundTag; +import com.sk89q.jnbt.CompoundTagBuilder; +import com.sk89q.jnbt.ListTag; +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 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.schematicsystem.CheckSchemType; +import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; +import de.steamwar.schematicsystem.autocheck.BlockPos; +import org.bukkit.Material; + +import java.util.*; +import java.util.stream.Collectors; + +public class SchematicCommand19 implements SchematicCommand.ISchematicCommand { + @Override + public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType 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()))); + } + + Map> toBeCheckedInvs = new HashMap<>(); + + toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems()); + toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt()); + + for (Map.Entry> entry: toBeCheckedInvs.entrySet()) { + BlockPos pos = entry.getKey(); + Set materials = entry.getValue(); + BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); + BaseBlock block = clipboard.getFullBlock(vector); + CompoundTag tag = block.getNbtData(); + CompoundTagBuilder builder = CompoundTagBuilder.create(); + List list = new ArrayList<>(); + for (CompoundTag items : tag.getList("Items", CompoundTag.class)) { + if(materials.contains(Material.matchMaterial(items.getString("id")))) { + continue; + } + + if(items.containsKey("tag")) { + continue; + } + + list.add(items); + } + builder.put("Items", new ListTag(CompoundTag.class, list)); + clipboard.setBlock(vector, block.toBaseBlock(builder.build())); + } + + if(type.getMaxDispenserItems() > 0 ) { + for (Map.Entry entry : result.getBlockScanResult().getDispenserItems().entrySet()) { + if(entry.getValue() <= type.getMaxDispenserItems()) { + continue; + } + + BlockPos pos = entry.getKey(); + BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); + BaseBlock block = clipboard.getFullBlock(vector); + CompoundTag tag = block.getNbtData(); + CompoundTagBuilder builder = tag.createBuilder(); + List items = tag.getList("Items", CompoundTag.class); + Collections.reverse(items); // To let the first item be in the Dispenser + List list = new ArrayList<>(); + int diff = entry.getValue() - type.getMaxDispenserItems(); + for (CompoundTag item : items) { + if(item == null) { + continue; + } + + if(diff == 0) { + list.add(item); + continue; + } + + if(diff > item.getByte("Count")) { + diff -= item.getByte("Count"); + continue; + } + + item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); + diff = 0; + list.add(item); + } + + builder.put("Items", new ListTag(CompoundTag.class, list)); + clipboard.setBlock(vector, block.toBaseBlock(builder.build())); + } + } + + if(!result.isLimitedBlocksOK()) { + Set toReplace = type.getLimits().entrySet().stream() + .filter(setIntegerEntry -> setIntegerEntry.getValue() == 0) + .flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream()) + .map(Material::matchMaterial) + .collect(Collectors.toSet()); + BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState(); + BlockVector3 min = clipboard.getMinimumPoint(); + BlockVector3 max = clipboard.getMaximumPoint(); + for (int i = min.getBlockX(); i <= max.getBlockX(); i++) { + for (int j = min.getBlockY(); j <= max.getBlockY(); j++) { + for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) { + BlockVector3 vector = BlockVector3.at(i, j, k); + BaseBlock block = clipboard.getFullBlock(vector); + if(toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) { + clipboard.setBlock(vector, replaceType.toBaseBlock()); + } + } + } + } + } + + return clipboard; + } + + @Override + public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { + Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); + } +} diff --git a/SchematicSystem/build.gradle.kts b/SchematicSystem/build.gradle.kts index f9871adc..813550b2 100644 --- a/SchematicSystem/build.gradle.kts +++ b/SchematicSystem/build.gradle.kts @@ -30,4 +30,5 @@ dependencies { implementation(project(":SchematicSystem:SchematicSystem_Core")) implementation(project(":SchematicSystem:SchematicSystem_8")) implementation(project(":SchematicSystem:SchematicSystem_15")) + implementation(project(":SchematicSystem:SchematicSystem_19")) } diff --git a/settings.gradle.kts b/settings.gradle.kts index dc94bc0c..cd2550dd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -218,6 +218,7 @@ include( "SchematicSystem", "SchematicSystem:SchematicSystem_8", "SchematicSystem:SchematicSystem_15", + "SchematicSystem:SchematicSystem_19", "SchematicSystem:SchematicSystem_Core" ) From bf5eef2ebd7bcb936ac5eea5268cedb5b1447050 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 10:28:32 +0200 Subject: [PATCH 25/49] Fix copyright nit Remove SchematicCommand19 --- .../SchematicSystem_19/build.gradle.kts | 2 +- .../autocheck/AutoChecker19.java | 2 +- .../schematiccommand/SchematicCommand19.java | 147 ------------------ 3 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts index d1baf622..99b982c8 100644 --- a/SchematicSystem/SchematicSystem_19/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2024 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 diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java index 92b06c0d..0f456ee2 100644 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2023 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 diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java deleted file mode 100644 index 2fecb87d..00000000 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand19.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2023 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public 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.jnbt.CompoundTag; -import com.sk89q.jnbt.CompoundTagBuilder; -import com.sk89q.jnbt.ListTag; -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 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.schematicsystem.CheckSchemType; -import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; -import de.steamwar.schematicsystem.autocheck.BlockPos; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -public class SchematicCommand19 implements SchematicCommand.ISchematicCommand { - @Override - public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType 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()))); - } - - Map> toBeCheckedInvs = new HashMap<>(); - - toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems()); - toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt()); - - for (Map.Entry> entry: toBeCheckedInvs.entrySet()) { - BlockPos pos = entry.getKey(); - Set materials = entry.getValue(); - BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); - BaseBlock block = clipboard.getFullBlock(vector); - CompoundTag tag = block.getNbtData(); - CompoundTagBuilder builder = CompoundTagBuilder.create(); - List list = new ArrayList<>(); - for (CompoundTag items : tag.getList("Items", CompoundTag.class)) { - if(materials.contains(Material.matchMaterial(items.getString("id")))) { - continue; - } - - if(items.containsKey("tag")) { - continue; - } - - list.add(items); - } - builder.put("Items", new ListTag(CompoundTag.class, list)); - clipboard.setBlock(vector, block.toBaseBlock(builder.build())); - } - - if(type.getMaxDispenserItems() > 0 ) { - for (Map.Entry entry : result.getBlockScanResult().getDispenserItems().entrySet()) { - if(entry.getValue() <= type.getMaxDispenserItems()) { - continue; - } - - BlockPos pos = entry.getKey(); - BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ()); - BaseBlock block = clipboard.getFullBlock(vector); - CompoundTag tag = block.getNbtData(); - CompoundTagBuilder builder = tag.createBuilder(); - List items = tag.getList("Items", CompoundTag.class); - Collections.reverse(items); // To let the first item be in the Dispenser - List list = new ArrayList<>(); - int diff = entry.getValue() - type.getMaxDispenserItems(); - for (CompoundTag item : items) { - if(item == null) { - continue; - } - - if(diff == 0) { - list.add(item); - continue; - } - - if(diff > item.getByte("Count")) { - diff -= item.getByte("Count"); - continue; - } - - item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); - diff = 0; - list.add(item); - } - - builder.put("Items", new ListTag(CompoundTag.class, list)); - clipboard.setBlock(vector, block.toBaseBlock(builder.build())); - } - } - - if(!result.isLimitedBlocksOK()) { - Set toReplace = type.getLimits().entrySet().stream() - .filter(setIntegerEntry -> setIntegerEntry.getValue() == 0) - .flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream()) - .map(Material::matchMaterial) - .collect(Collectors.toSet()); - BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState(); - BlockVector3 min = clipboard.getMinimumPoint(); - BlockVector3 max = clipboard.getMaximumPoint(); - for (int i = min.getBlockX(); i <= max.getBlockX(); i++) { - for (int j = min.getBlockY(); j <= max.getBlockY(); j++) { - for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) { - BlockVector3 vector = BlockVector3.at(i, j, k); - BaseBlock block = clipboard.getFullBlock(vector); - if(toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) { - clipboard.setBlock(vector, replaceType.toBaseBlock()); - } - } - } - } - } - - return clipboard; - } - - @Override - public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException { - Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint())); - } -} From 8132e4fca08b020795b43f453b21bf9d59cc990e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 10:34:41 +0200 Subject: [PATCH 26/49] Remove code duplication --- .../autocheck/AutoChecker15.java | 55 +---- .../autocheck/AutoCheckerItems15.java | 90 ++++++++ .../autocheck/AutoChecker19.java | 213 ------------------ .../autocheck/AutoCheckerItems19.java | 111 +++++++++ .../autocheck/AutoCheckerItems.java | 34 +++ 5 files changed, 237 insertions(+), 266 deletions(-) create mode 100644 SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java delete mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java create mode 100644 SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java create mode 100644 SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java index 9dd5e456..a97cb133 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java @@ -31,57 +31,6 @@ import java.util.*; import java.util.stream.Collectors; public class AutoChecker15 implements AutoChecker.IAutoChecker { - 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.HONEY_BOTTLE); public AutoChecker.BlockScanResult scan(Clipboard clipboard) { AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult(); @@ -98,7 +47,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { result.getBlockCounts().merge(material, 1, Integer::sum); - if(INVENTORY.contains(material)) { + if(AutoCheckerItems.impl.getInventoryMaterials().contains(material)) { checkInventory(result, block, material, new BlockPos(x, y, z)); } @@ -125,7 +74,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { )); itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER)); itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER)); - FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); + AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials())); } private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) { diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java new file mode 100644 index 00000000..0d853c16 --- /dev/null +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems15.java @@ -0,0 +1,90 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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.HONEY_BOTTLE); + + @Override + public Set getInventoryMaterials() { + return INVENTORY; + } + + @Override + public Set getAllowedMaterialsInInventory() { + return FLOWERS; + } +} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java deleted file mode 100644 index 0f456ee2..00000000 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoChecker19.java +++ /dev/null @@ -1,213 +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.schematicsystem.CheckSchemType; -import org.bukkit.Material; - -import java.util.*; -import java.util.stream.Collectors; - -public class AutoChecker19 implements AutoChecker.IAutoChecker { - 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( - // 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, - // 16-stackable Items - Material.HONEY_BOTTLE, - // Non-stackable items - Material.DIAMOND_HORSE_ARMOR, - Material.IRON_HORSE_ARMOR, - Material.GOLDEN_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 - ); - - 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(INVENTORY.contains(material)) { - checkInventory(result, block, material, 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)); - } - } - } - } - 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)); - FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY)); - } - - 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 += 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, CheckSchemType 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, CheckSchemType type) { - return AutoCheckerResult.builder() - .type(type) - .height(clipboard.getDimensions().getBlockY()) - .width(clipboard.getDimensions().getBlockX()) - .depth(clipboard.getDimensions().getBlockZ()) - .build(); - } -} diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java new file mode 100644 index 00000000..556d354f --- /dev/null +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java @@ -0,0 +1,111 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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 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 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, + // 16-stackable Items + Material.HONEY_BOTTLE, + // Non-stackable items + Material.DIAMOND_HORSE_ARMOR, + Material.IRON_HORSE_ARMOR, + Material.GOLDEN_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 getInventoryMaterials() { + return INVENTORY; + } + + @Override + public Set getAllowedMaterialsInInventory() { + return ALLOWED_ITEMS_IN_INVENTORY; + } +} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java new file mode 100644 index 00000000..fb103f67 --- /dev/null +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems.java @@ -0,0 +1,34 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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(); +} From 7f215b921ec427693dc67c985aec739a67150ab4 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 13:32:09 +0200 Subject: [PATCH 27/49] Add "/event vote" command for SteamWarArcade Event To be removed after event --- .../steamwar/messages/BungeeCore.properties | 2 ++ .../steamwar/velocitycore/EventStarter.java | 32 +++++++++++++++++ .../velocitycore/commands/EventCommand.java | 34 +++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index c46cd317..8531389b 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -755,3 +755,5 @@ DC_SCHEMUPLOAD_IGNORED=Skipping `{0}`, not a schematic file. DC_SCHEMUPLOAD_INVCHAR=`{0}` has invalid characters in its name. DC_SCHEMUPLOAD_SUCCESS=`{0}` was uploaded successfully. DC_SCHEMUPLOAD_ERROR=An error has occured during the upload of `{0}`. For more information ask a Developer. + +EVENT_VOTE_SUCCESS=§aYour teams vote was accepted! diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index 15c16b64..54d17747 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -24,6 +24,7 @@ import de.steamwar.messages.Message; import de.steamwar.persistent.Subserver; import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; +import de.steamwar.velocitycore.commands.EventCommand; import net.kyori.adventure.text.event.ClickEvent; import java.sql.Timestamp; @@ -42,6 +43,19 @@ public class EventStarter { spectatePorts.put(port, command); } + private static final Map VOTES = new HashMap<>(); + private static final Map VOTES_REVERSE = new HashMap<>(); + + static { + VOTES.put("MissileWars", 0); + VOTES.put("TowerRun", 1); + VOTES.put("TNTLeague", 2); + + VOTES_REVERSE.put(0, "MissileWars"); + VOTES_REVERSE.put(1, "TowerRun"); + VOTES_REVERSE.put(2, "TNTLeague"); + } + public EventStarter() { EventFight.loadAllComingFights(); VelocityCore.schedule(this::run).repeat(10, TimeUnit.SECONDS).schedule(); @@ -63,6 +77,24 @@ public class EventStarter { //Don't start EventServer if not the event bungee String command; if(VelocityCore.get().getConfig().isEventmode() || next.getSpectatePort() == null) { + ArenaMode blueVote = ArenaMode.getByChat(EventCommand.TEAM_VOTES.getOrDefault(blue.getTeamId(), "TowerRun")); + ArenaMode redVote = ArenaMode.getByChat(EventCommand.TEAM_VOTES.getOrDefault(red.getTeamId(), "TowerRun")); + + ArenaMode mode = blueVote; + + if (!blueVote.getInternalName().equals(redVote.getInternalName())) { + mode = ArenaMode.getByChat(VOTES_REVERSE.get(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName()))); + } + + next.update( + next.getStartTime(), + mode.getInternalName(), + mode.getRandomMap(), + next.getTeamBlue(), + next.getTeamRed(), + next.getSpectatePort() + ); + ServerStarter starter = new ServerStarter().event(next); starter.callback(subserver -> { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java index b57d6aad..d718073b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java @@ -27,6 +27,7 @@ import de.steamwar.messages.Chatter; import de.steamwar.messages.PlayerChatter; import de.steamwar.persistent.Subserver; import de.steamwar.sql.*; +import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.EventStarter; import de.steamwar.velocitycore.SubserverSystem; @@ -48,6 +49,39 @@ public class EventCommand extends SWCommand { return (sender, value, messageSender) -> Event.get() == null; } + public static final Map TEAM_VOTES = new HashMap<>(); + + @Register("vote") + public void eventVote(@Validator(value = "noEvent", invert = true) PlayerChatter sender, ArenaMode gamemode) { + if (!TeamTeilnahme.nimmtTeil(sender.user().getTeam(), Event.get().getEventID())) { + return; + } + + TEAM_VOTES.put(sender.user().getTeam(), gamemode.getChatName()); + sender.system("EVENT_VOTE_SUCCESS"); + } + + @ClassMapper(value = ArenaMode.class, local = true) + public TypeMapper eventGamemode() { + return new TypeMapper<>() { + @Override + public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) { + ArenaMode mode = ArenaMode.getByChat(s); + + if (tabCompletes(null, previousArguments, null).contains(mode.getChatName())) { + return mode; + } + + return null; + } + + @Override + public Collection tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) { + return Arrays.asList("TowerRun", "MissileWars", "TNTLeague"); + } + }; + } + @Register public void noCurrentEvent(@Validator("noEvent") Chatter sender) { sender.system("EVENT_NO_CURRENT"); From f7e81f82047a59f256cd44f6de31dbedcbe94bac Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 13:34:42 +0200 Subject: [PATCH 28/49] Hotfix OOM in IngameListener --- .../towerrun/listener/IngameListener.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index a4e2bec6..a7dcd60a 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -20,13 +20,13 @@ package de.steamwar.towerrun.listener; import de.steamwar.inventory.SWItem; -import de.steamwar.network.packets.server.BaumemberUpdatePacket; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.state.GameStateBukkitListener; import de.steamwar.towerrun.state.GameStates; +import lombok.AllArgsConstructor; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; @@ -43,16 +43,22 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; -import java.util.function.Function; import java.util.stream.Stream; public class IngameListener extends GameStateBukkitListener { private int time = 0; - private final Map> blocksToMelt = new HashMap<>(); + private final Map> blocksToMelt = new HashMap<>(); private BukkitRunnable blocksToMeltRunnable; private BukkitRunnable antiCampRunnable; + @AllArgsConstructor + private class Pos { + private final int x; + private final int y; + private final int z; + } + public IngameListener() { super(EnumSet.of(GameStates.RUNNING)); } @@ -63,20 +69,21 @@ public class IngameListener extends GameStateBukkitListener { blocksToMeltRunnable = new BukkitRunnable() { @Override public void run() { - List blocks = blocksToMelt.remove(time); + List posList = blocksToMelt.remove(time); time++; - if (blocks == null) { + if (posList == null) { return; } int maxBlocks = 1_000; - while (maxBlocks > 0 && !blocks.isEmpty()) { - Block block = blocks.removeFirst(); + while (maxBlocks > 0 && !posList.isEmpty()) { + Pos pos = posList.removeFirst(); + Block block = Bukkit.getWorlds().get(0).getBlockAt(pos.x, pos.y, pos.z); if (block.getType() == Material.AIR || block.getType() == Material.LAVA) continue; block.setType(Material.AIR); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1); maxBlocks--; } - blocksToMelt.computeIfAbsent(time, __ -> new ArrayList<>()).addAll(0, blocks); + blocksToMelt.computeIfAbsent(time, __ -> new ArrayList<>()).addAll(0, posList); } }; blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1); @@ -213,6 +220,8 @@ public class IngameListener extends GameStateBukkitListener { private void shouldMelt(Block block) { if (block.getType().isBurnable()) return; + if (block.getType().isAir()) return; + if (block.isLiquid()) return; int meltingTime = (int) (block.getType().getHardness() * 48 * 20); switch (block.getType()) { case TINTED_GLASS: @@ -254,7 +263,7 @@ public class IngameListener extends GameStateBukkitListener { default: break; } - blocksToMelt.computeIfAbsent(time + meltingTime, integer -> new ArrayList<>()).add(block); + blocksToMelt.computeIfAbsent(time + meltingTime, integer -> new ArrayList<>()).add(new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ())); } @EventHandler From 6ed639fbb3f9bbd05cae8a4883697512f253434f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 13:46:39 +0200 Subject: [PATCH 29/49] Add sout --- TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index a7dcd60a..f3fc9809 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -70,6 +70,7 @@ public class IngameListener extends GameStateBukkitListener { @Override public void run() { List posList = blocksToMelt.remove(time); + System.out.println(blocksToMelt.size() + (posList != null ? 1 : 0) + " " + (posList != null ? posList.size() : "")); time++; if (posList == null) { return; From 2a314e703589ff90b1cf2c76f53890f044fca7d7 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 15:31:48 +0200 Subject: [PATCH 30/49] Add sout --- TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index f3fc9809..bd38466e 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -70,11 +70,11 @@ public class IngameListener extends GameStateBukkitListener { @Override public void run() { List posList = blocksToMelt.remove(time); - System.out.println(blocksToMelt.size() + (posList != null ? 1 : 0) + " " + (posList != null ? posList.size() : "")); time++; if (posList == null) { return; } + System.out.println(blocksToMelt.size() + " " + posList.size() + " " + blocksToMelt.values().stream().mapToInt(List::size).sum()); int maxBlocks = 1_000; while (maxBlocks > 0 && !posList.isEmpty()) { Pos pos = posList.removeFirst(); From 778d0282d35f9f408a13d2025a92c19d004e8655 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 15:37:43 +0200 Subject: [PATCH 31/49] Fix IngameListener --- .../towerrun/listener/IngameListener.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index bd38466e..cc3723ef 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -27,6 +27,7 @@ import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.state.GameStateBukkitListener; import de.steamwar.towerrun.state.GameStates; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; @@ -43,16 +44,18 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; +import java.util.stream.Collectors; import java.util.stream.Stream; public class IngameListener extends GameStateBukkitListener { private int time = 0; - private final Map> blocksToMelt = new HashMap<>(); + private final Map blocksToMelt = new HashMap<>(); private BukkitRunnable blocksToMeltRunnable; private BukkitRunnable antiCampRunnable; @AllArgsConstructor + @EqualsAndHashCode private class Pos { private final int x; private final int y; @@ -69,22 +72,22 @@ public class IngameListener extends GameStateBukkitListener { blocksToMeltRunnable = new BukkitRunnable() { @Override public void run() { - List posList = blocksToMelt.remove(time); + List blocksToBreak = blocksToMelt.entrySet().stream() + .filter(entry -> entry.getValue() == time) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); time++; - if (posList == null) { + if (blocksToBreak.isEmpty()) { return; } - System.out.println(blocksToMelt.size() + " " + posList.size() + " " + blocksToMelt.values().stream().mapToInt(List::size).sum()); - int maxBlocks = 1_000; - while (maxBlocks > 0 && !posList.isEmpty()) { - Pos pos = posList.removeFirst(); + System.out.println(blocksToBreak.size() + "/" + blocksToMelt.size()); + for (Pos pos : blocksToBreak) { + blocksToMelt.remove(pos); Block block = Bukkit.getWorlds().get(0).getBlockAt(pos.x, pos.y, pos.z); if (block.getType() == Material.AIR || block.getType() == Material.LAVA) continue; block.setType(Material.AIR); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1); - maxBlocks--; } - blocksToMelt.computeIfAbsent(time, __ -> new ArrayList<>()).addAll(0, posList); } }; blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1); @@ -264,7 +267,8 @@ public class IngameListener extends GameStateBukkitListener { default: break; } - blocksToMelt.computeIfAbsent(time + meltingTime, integer -> new ArrayList<>()).add(new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ())); + Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ()); + blocksToMelt.putIfAbsent(pos, time + meltingTime); } @EventHandler From 400c78447ad9ee9653dac349aae18577bd50e721 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 15:41:43 +0200 Subject: [PATCH 32/49] Fix IngameListener --- .../src/de/steamwar/towerrun/listener/IngameListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index cc3723ef..c732ff72 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -73,7 +73,7 @@ public class IngameListener extends GameStateBukkitListener { @Override public void run() { List blocksToBreak = blocksToMelt.entrySet().stream() - .filter(entry -> entry.getValue() == time) + .filter(entry -> entry.getValue() <= time) .map(Map.Entry::getKey) .collect(Collectors.toList()); time++; @@ -268,7 +268,7 @@ public class IngameListener extends GameStateBukkitListener { break; } Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ()); - blocksToMelt.putIfAbsent(pos, time + meltingTime); + blocksToMelt.putIfAbsent(pos, time + meltingTime + 1); } @EventHandler From 297e6c9b599a6f05eba6daae37006524a14b5287 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 18 May 2025 15:58:31 +0200 Subject: [PATCH 33/49] Fix OOM? --- TowerRun/src/TowerRun.properties | 2 +- TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/TowerRun/src/TowerRun.properties b/TowerRun/src/TowerRun.properties index 2a6c0e04..0935bd83 100644 --- a/TowerRun/src/TowerRun.properties +++ b/TowerRun/src/TowerRun.properties @@ -17,7 +17,7 @@ # along with this program. If not, see . # -PREFIX=§eTowerRun§8§§r +PREFIX=§eTowerRun§8»§r PLAYER_DIED=§c{0} §7died§8! PLAYER_ESCAPE=§a{0} §7escaped§8! diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index c732ff72..bc74e57f 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -80,7 +80,6 @@ public class IngameListener extends GameStateBukkitListener { if (blocksToBreak.isEmpty()) { return; } - System.out.println(blocksToBreak.size() + "/" + blocksToMelt.size()); for (Pos pos : blocksToBreak) { blocksToMelt.remove(pos); Block block = Bukkit.getWorlds().get(0).getBlockAt(pos.x, pos.y, pos.z); From a5b61fb0d6f1f299f9f439ed5a7e7bc1ead9af54 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 16:22:50 +0200 Subject: [PATCH 34/49] Add "/event vote" command for SteamWarArcade Event To be removed after event --- VelocityCore/src/de/steamwar/velocitycore/EventStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index 54d17747..c21a5e01 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -83,7 +83,7 @@ public class EventStarter { ArenaMode mode = blueVote; if (!blueVote.getInternalName().equals(redVote.getInternalName())) { - mode = ArenaMode.getByChat(VOTES_REVERSE.get(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName()))); + mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName())))); } next.update( From b0bbc09113976fda9775399728acf452cb0fd553 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 16:28:26 +0200 Subject: [PATCH 35/49] Fix TowerRun event --- TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java index 78fe59c5..0a4e4358 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java @@ -62,6 +62,7 @@ public class LobbyListener extends GameStateBukkitListener { int team = user.getTeam(); if (team != Config.EVENT_TEAM_BLUE_ID && team != Config.EVENT_TEAM_RED_ID) { + player.setGameMode(GameMode.SPECTATOR); return; } From 8cd088050d15e251a05e42c348e8942c5774a2cb Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 16:32:01 +0200 Subject: [PATCH 36/49] Fix TowerRun event --- VelocityCore/src/de/steamwar/velocitycore/EventStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index c21a5e01..467d4285 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -83,7 +83,7 @@ public class EventStarter { ArenaMode mode = blueVote; if (!blueVote.getInternalName().equals(redVote.getInternalName())) { - mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName())))); + mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getChatName()) - VOTES.get(redVote.getChatName())))); } next.update( From 7fa97ce36ca8adb5bb03d75ea0906590cfdae8d8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 19:44:28 +0200 Subject: [PATCH 37/49] Revert "Fix TowerRun event" This reverts commit 8cd088050d15e251a05e42c348e8942c5774a2cb. --- VelocityCore/src/de/steamwar/velocitycore/EventStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index 467d4285..c21a5e01 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -83,7 +83,7 @@ public class EventStarter { ArenaMode mode = blueVote; if (!blueVote.getInternalName().equals(redVote.getInternalName())) { - mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getChatName()) - VOTES.get(redVote.getChatName())))); + mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName())))); } next.update( From 0d15bbc2664d50a5818ec7d97bf14b939df7e405 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 19:44:28 +0200 Subject: [PATCH 38/49] Revert "Add "/event vote" command for SteamWarArcade Event" This reverts commit a5b61fb0d6f1f299f9f439ed5a7e7bc1ead9af54. --- VelocityCore/src/de/steamwar/velocitycore/EventStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index c21a5e01..54d17747 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -83,7 +83,7 @@ public class EventStarter { ArenaMode mode = blueVote; if (!blueVote.getInternalName().equals(redVote.getInternalName())) { - mode = ArenaMode.getByChat(VOTES_REVERSE.get(Math.abs(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName())))); + mode = ArenaMode.getByChat(VOTES_REVERSE.get(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName()))); } next.update( From 45a8aab321bb568e82286b84310ff0a9207228a7 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 May 2025 19:44:29 +0200 Subject: [PATCH 39/49] Revert "Add "/event vote" command for SteamWarArcade Event" This reverts commit 7f215b921ec427693dc67c985aec739a67150ab4. --- .../steamwar/messages/BungeeCore.properties | 2 -- .../steamwar/velocitycore/EventStarter.java | 32 ----------------- .../velocitycore/commands/EventCommand.java | 34 ------------------- 3 files changed, 68 deletions(-) diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index 8531389b..c46cd317 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -755,5 +755,3 @@ DC_SCHEMUPLOAD_IGNORED=Skipping `{0}`, not a schematic file. DC_SCHEMUPLOAD_INVCHAR=`{0}` has invalid characters in its name. DC_SCHEMUPLOAD_SUCCESS=`{0}` was uploaded successfully. DC_SCHEMUPLOAD_ERROR=An error has occured during the upload of `{0}`. For more information ask a Developer. - -EVENT_VOTE_SUCCESS=§aYour teams vote was accepted! diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index 54d17747..15c16b64 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -24,7 +24,6 @@ import de.steamwar.messages.Message; import de.steamwar.persistent.Subserver; import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; -import de.steamwar.velocitycore.commands.EventCommand; import net.kyori.adventure.text.event.ClickEvent; import java.sql.Timestamp; @@ -43,19 +42,6 @@ public class EventStarter { spectatePorts.put(port, command); } - private static final Map VOTES = new HashMap<>(); - private static final Map VOTES_REVERSE = new HashMap<>(); - - static { - VOTES.put("MissileWars", 0); - VOTES.put("TowerRun", 1); - VOTES.put("TNTLeague", 2); - - VOTES_REVERSE.put(0, "MissileWars"); - VOTES_REVERSE.put(1, "TowerRun"); - VOTES_REVERSE.put(2, "TNTLeague"); - } - public EventStarter() { EventFight.loadAllComingFights(); VelocityCore.schedule(this::run).repeat(10, TimeUnit.SECONDS).schedule(); @@ -77,24 +63,6 @@ public class EventStarter { //Don't start EventServer if not the event bungee String command; if(VelocityCore.get().getConfig().isEventmode() || next.getSpectatePort() == null) { - ArenaMode blueVote = ArenaMode.getByChat(EventCommand.TEAM_VOTES.getOrDefault(blue.getTeamId(), "TowerRun")); - ArenaMode redVote = ArenaMode.getByChat(EventCommand.TEAM_VOTES.getOrDefault(red.getTeamId(), "TowerRun")); - - ArenaMode mode = blueVote; - - if (!blueVote.getInternalName().equals(redVote.getInternalName())) { - mode = ArenaMode.getByChat(VOTES_REVERSE.get(3 - VOTES.get(blueVote.getInternalName()) - VOTES.get(redVote.getInternalName()))); - } - - next.update( - next.getStartTime(), - mode.getInternalName(), - mode.getRandomMap(), - next.getTeamBlue(), - next.getTeamRed(), - next.getSpectatePort() - ); - ServerStarter starter = new ServerStarter().event(next); starter.callback(subserver -> { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java index d718073b..b57d6aad 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java @@ -27,7 +27,6 @@ import de.steamwar.messages.Chatter; import de.steamwar.messages.PlayerChatter; import de.steamwar.persistent.Subserver; import de.steamwar.sql.*; -import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.EventStarter; import de.steamwar.velocitycore.SubserverSystem; @@ -49,39 +48,6 @@ public class EventCommand extends SWCommand { return (sender, value, messageSender) -> Event.get() == null; } - public static final Map TEAM_VOTES = new HashMap<>(); - - @Register("vote") - public void eventVote(@Validator(value = "noEvent", invert = true) PlayerChatter sender, ArenaMode gamemode) { - if (!TeamTeilnahme.nimmtTeil(sender.user().getTeam(), Event.get().getEventID())) { - return; - } - - TEAM_VOTES.put(sender.user().getTeam(), gamemode.getChatName()); - sender.system("EVENT_VOTE_SUCCESS"); - } - - @ClassMapper(value = ArenaMode.class, local = true) - public TypeMapper eventGamemode() { - return new TypeMapper<>() { - @Override - public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) { - ArenaMode mode = ArenaMode.getByChat(s); - - if (tabCompletes(null, previousArguments, null).contains(mode.getChatName())) { - return mode; - } - - return null; - } - - @Override - public Collection tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) { - return Arrays.asList("TowerRun", "MissileWars", "TNTLeague"); - } - }; - } - @Register public void noCurrentEvent(@Validator("noEvent") Chatter sender) { sender.system("EVENT_NO_CURRENT"); From 374e314faa4d1859f99ae94fda94721634570a98 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 22 May 2025 18:19:31 +0200 Subject: [PATCH 40/49] Add new WATUT Channel --- .../src/de/steamwar/velocitycore/listeners/PluginMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java index 33e431fb..5d84eb17 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java @@ -405,7 +405,7 @@ public class PluginMessage extends BasicListener { for(String channel : Arrays.asList( "floodgate:skin", - "watut:nbt", //https://github.com/Corosauce/WATUT + "watut:nbt", "watut:nbt_server", //https://github.com/Corosauce/WATUT "bclib:hello_server", "vivecraft:data", //https://github.com/Vivecraft/VivecraftMod https://github.com/jrbudda/Vivecraft_Spigot_Extensions https://github.com/Techjar/Vivecraft_BungeeCord_Extensions (VR support) "badpackets:channel_sync", //https://github.com/badasintended/badpackets (Forge fabric translation layer) From d410484e4c5ce540877f2c128a1b8e52c950fb83 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 22 May 2025 19:47:14 +0200 Subject: [PATCH 41/49] Update JDA to newest version --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index dc94bc0c..8f25cf52 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -138,7 +138,7 @@ dependencyResolutionManagement { library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") library("viaapi", "com.viaversion:viaversion-api:4.3.1") library("viavelocity", "com.viaversion:viaversion-velocity:4.3.1") - library("jda", "net.dv8tion:JDA:5.2.0") + library("jda", "net.dv8tion:JDA:5.5.1") library("msgpack", "org.msgpack:msgpack-core:0.9.8") library("apolloprotos", "com.lunarclient:apollo-protos:1.0-SNAPSHOT") From 380506542f2df4db70769dbccfd13eb14ded37d1 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 23 May 2025 09:13:23 +0200 Subject: [PATCH 42/49] Remove some more duplicates --- .../SchematicSystem_19/build.gradle.kts | 1 + .../autocheck/AutoCheckerItems19.java | 38 +------------------ 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/SchematicSystem/SchematicSystem_19/build.gradle.kts b/SchematicSystem/SchematicSystem_19/build.gradle.kts index 99b982c8..38fcd471 100644 --- a/SchematicSystem/SchematicSystem_19/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_19/build.gradle.kts @@ -24,6 +24,7 @@ plugins { dependencies { compileOnly(project(":SpigotCore", "default")) compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) + compileOnly(project(":SchematicSystem:SchematicSystem_15", "default")) compileOnly(libs.spigotapi) diff --git a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java index 556d354f..0c004cfe 100644 --- a/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java +++ b/SchematicSystem/SchematicSystem_19/src/de/steamwar/schematicsystem/autocheck/AutoCheckerItems19.java @@ -24,38 +24,7 @@ import org.bukkit.Material; import java.util.EnumSet; import java.util.Set; -public class AutoCheckerItems19 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); +public class AutoCheckerItems19 extends AutoCheckerItems15 { private static final Set ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of( // 64-stackable Items @@ -99,11 +68,6 @@ public class AutoCheckerItems19 implements AutoCheckerItems { Material.MUSIC_DISC_5 ); - @Override - public Set getInventoryMaterials() { - return INVENTORY; - } - @Override public Set getAllowedMaterialsInInventory() { return ALLOWED_ITEMS_IN_INVENTORY; From 277e1f9f9b036103846be2f9c9f985cae093d4d3 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 27 May 2025 18:15:03 +0200 Subject: [PATCH 43/49] Add NoGravity --- .../de/steamwar/fightsystem/FightSystem.java | 6 +-- .../steamwar/fightsystem/event/NoGravity.java | 41 +++++++++++++++++++ .../winconditions/Winconditions.java | 3 +- 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index b32a41b9..bff38170 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -23,10 +23,7 @@ import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.core.Core; import de.steamwar.fightsystem.commands.*; import de.steamwar.fightsystem.countdown.*; -import de.steamwar.fightsystem.event.HellsBells; -import de.steamwar.fightsystem.event.Meteor; -import de.steamwar.fightsystem.event.PersistentDamage; -import de.steamwar.fightsystem.event.TNTDistributor; +import de.steamwar.fightsystem.event.*; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightWorld; @@ -136,6 +133,7 @@ public class FightSystem extends JavaPlugin { new PersistentDamage(); new TNTDistributor(); new WinconditionAmongUs(); + new NoGravity(); new NoPlayersOnlineCountdown(); new PreSchemCountdown(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java new file mode 100644 index 00000000..12246f8e --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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.event; + +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.winconditions.Winconditions; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; + +public class NoGravity implements Listener { + + public NoGravity() { + new StateDependentListener(Winconditions.NO_GRAVITY, FightState.All, this); + } + + @EventHandler + public void onEntitySpawn(EntitySpawnEvent event) { + if (event.getEntityType() == EntityType.PLAYER) return; + event.getEntity().setGravity(false); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java index 296cf97e..2aaecae6 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java @@ -39,5 +39,6 @@ public enum Winconditions { METEOR, AMONG_US, PERSISTENT_DAMAGE, - TNT_DISTRIBUTION + TNT_DISTRIBUTION, + NO_GRAVITY, } From 8defbaa18b475526a0f236fb74af6214c943dde9 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 29 May 2025 00:03:25 +0200 Subject: [PATCH 44/49] Add tech hider bug handling for arena subservers in BugCommand --- .../src/de/steamwar/velocitycore/commands/BugCommand.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java index 22c9f391..088acb09 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java @@ -19,9 +19,11 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.persistent.Subserver; import de.steamwar.sql.SWException; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; +import de.steamwar.velocitycore.SubserverSystem; public class BugCommand extends SWCommand { public BugCommand() { @@ -35,5 +37,9 @@ public class BugCommand extends SWCommand { sender.withPlayerOrOffline(player -> player.getCurrentServer().map(connection -> connection.getServerInfo().getName()).orElse("offline"), () -> "offline") + " " + sender.user().getUserName() + " " + sender.user().getId() ); sender.system("BUG_MESSAGE", id); + + if (Subserver.isArena(Subserver.getSubserver(sender.getPlayer()))) { + sender.getPlayer().spoofChatInput("/techhiderbug"); + } } } From b14cf445dfbc017a57aeaa06d494ec8ee403039d Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 29 May 2025 11:32:50 +0200 Subject: [PATCH 45/49] Fix PR stuff --- .../src/de/steamwar/fightsystem/commands/GUI.java | 11 +++-------- .../src/de/steamwar/fightsystem/fight/FightTeam.java | 5 ----- .../fightsystem/winconditions/WinconditionBlocks.java | 5 ++++- .../winconditions/WinconditionCaptainDead.java | 2 -- .../winconditions/WinconditionPercent.java | 11 ++++++++--- 5 files changed, 15 insertions(+), 19 deletions(-) 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 87e72c08..237d860e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -212,9 +212,7 @@ public class GUI { SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null); if (node != null) { inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> { - schemSelect(p, node, fightTeam -> { - fightTeam.setIgnoreWinconditions(true); - }); + schemSelect(p, node); })); } } @@ -253,19 +251,16 @@ public class GUI { private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){ SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> { - schemSelect(p, node, fightTeam -> { - fightTeam.setIgnoreWinconditions(false); - }); + schemSelect(p, node); }); selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY); selector.open(); } - private static void schemSelect(Player p, SchematicNode node, Consumer fightTeamConsumer) { + private static void schemSelect(Player p, SchematicNode node) { FightTeam fightTeam = Fight.getPlayerTeam(p); if(fightTeam == null) return; - fightTeamConsumer.accept(fightTeam); if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) fightTeam.pasteSchem(node); p.closeInventory(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 19d45690..8eed2f2a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -42,7 +42,6 @@ import de.steamwar.inventory.SWItem; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import lombok.Getter; -import lombok.Setter; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.*; import org.bukkit.entity.LivingEntity; @@ -101,10 +100,6 @@ public class FightTeam { @Getter private boolean publicsOnly; - @Getter - @Setter - private boolean ignoreWinconditions; - private final Map players = new HashMap<>(); @Getter diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java index 4bbaa241..72c0873a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java @@ -84,8 +84,11 @@ public class WinconditionBlocks extends Wincondition implements PrintableWincond } private void check() { + // Edge Case for DirtBlock + if (blocks.isEmpty()) return; + blocks.removeIf(block -> !isOfType.test(block)); - if(blocks.isEmpty() && !team.isIgnoreWinconditions()) + if(blocks.isEmpty()) win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName()); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java index df7651ee..de0205ab 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java @@ -42,8 +42,6 @@ public class WinconditionCaptainDead extends Wincondition implements Listener { return; FightTeam team = leader.getTeam(); - if (team.isIgnoreWinconditions()) - return; win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName()); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java index 5a2cbe4f..f98bdecc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java @@ -40,8 +40,6 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon private final Map teamMap = new HashMap<>(); protected Consumer checkWin = team -> { - if (team.isIgnoreWinconditions()) - return; if (getPercent(team) >= Config.PercentWin) { win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName()); } @@ -80,6 +78,7 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon private int totalBlocks = 0; private int currentBlocks = 0; + private boolean countAnyBlock = false; private TeamPercent(FightTeam team, Winconditions wincondition) { this.team = team; @@ -100,7 +99,7 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon } event.blockList().forEach(block -> { - if (Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) { + if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) { currentBlocks--; } }); @@ -110,10 +109,16 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon private void enable() { totalBlocks = 0; + countAnyBlock = false; team.getSchemRegion().forEach((x, y, z) -> { if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist) totalBlocks++; }); + // Edge Case for DirtBlock + if (totalBlocks == 0) { + totalBlocks = team.getSchemRegion().volume(); + countAnyBlock = true; + } currentBlocks = totalBlocks; postEnable.accept(team); } From 9bc01a4e3bd92506ec05fbef3b2bf56cf96ed890 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 29 May 2025 12:00:12 +0200 Subject: [PATCH 46/49] Revert FightTeam --- .../src/de/steamwar/fightsystem/fight/FightTeam.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 8eed2f2a..0cb68f71 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -385,7 +385,7 @@ public class FightTeam { } public void pasteSchem(SchematicNode schematic){ - if(schematic.getSchemtype().check() || schematic.getSchemtype().writeable()) { + if(schematic.getSchemtype().check()) { FightStatistics.unrank(); FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName()); } From 30fa3fd66e1208ba0edfcfa7890bc7690ec4cef8 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 30 May 2025 21:37:07 +0200 Subject: [PATCH 47/49] Add WeatherCommand --- .../src/de/steamwar/teamserver/Builder.java | 1 + .../teamserver/command/WeatherCommand.java | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java diff --git a/Teamserver/src/de/steamwar/teamserver/Builder.java b/Teamserver/src/de/steamwar/teamserver/Builder.java index 137906ad..e049cdc6 100644 --- a/Teamserver/src/de/steamwar/teamserver/Builder.java +++ b/Teamserver/src/de/steamwar/teamserver/Builder.java @@ -46,6 +46,7 @@ public final class Builder extends JavaPlugin { new SpeedCommand(); new FreezeCommand(); new ArenaconfigCommand(); + new WeatherCommand(); if (Bukkit.getPluginManager().getPlugin("AxiomPaper") != null) { Bukkit.getPluginManager().registerEvents(new AxiomHandshakeListener(), this); diff --git a/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java b/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java new file mode 100644 index 00000000..2684370c --- /dev/null +++ b/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java @@ -0,0 +1,53 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public 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.teamserver.command; + +import de.steamwar.command.SWCommand; +import org.bukkit.WeatherType; +import org.bukkit.entity.Player; + +public class WeatherCommand extends SWCommand { + + public WeatherCommand() { + super("weather"); + } + + @Register("clear") + public void clearWeather(Player player, @OptionalValue("0") int duration) { + player.getWorld().setClearWeatherDuration(duration); + player.getWorld().setThundering(false); + } + + @Register + public void rainyWeather(Player player, WeatherType type, int duration) { + player.getWorld().setThundering(false); + if (type == WeatherType.CLEAR) { + clearWeather(player, duration); + } else { + player.getWorld().setWeatherDuration(duration); + } + } + + @Register("thunder") + public void thunderWeather(Player player, @OptionalValue("0") int duration) { + player.getWorld().setThunderDuration(duration); + player.getWorld().setThundering(true); + } +} From daede98a0fe28d8e8bb60128d66ffe2dd19eb5fc Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 31 May 2025 17:45:24 +0200 Subject: [PATCH 48/49] Hotfix TeamCommand --- .../src/de/steamwar/velocitycore/commands/TeamCommand.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java index 0dd865b1..f77207a6 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java @@ -19,9 +19,14 @@ package de.steamwar.velocitycore.commands; +import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.ConnectionRequestBuilder; import com.velocitypowered.api.proxy.server.ServerInfo; +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.velocity.platform.VelocityViaAPI; +import com.viaversion.viaversion.velocity.platform.VelocityViaConfig; import de.steamwar.persistent.Storage; +import de.steamwar.velocitycore.ServerVersion; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.inventory.SWItem; @@ -405,6 +410,8 @@ public class TeamCommand extends SWCommand { ServerInfo serverInfo = Storage.teamServers.computeIfAbsent(targetTeam.getTeamId(), integer -> { ServerInfo info = new ServerInfo("Team " + targetTeam.getTeamKuerzel(), address); VelocityCore.getProxy().registerServer(info); + // This is needed because otherwise ViaVersion uses the wrong version! + ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(info.getName(), ProtocolVersion.MAXIMUM_VERSION.getProtocol()); return info; }); From f2a46e54ea9ab23bcb4d0aa7ed71d6e426c0e312 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 31 May 2025 19:40:08 +0200 Subject: [PATCH 49/49] Revert "Add WeatherCommand" This reverts commit 30fa3fd66e1208ba0edfcfa7890bc7690ec4cef8. --- .../src/de/steamwar/teamserver/Builder.java | 1 - .../teamserver/command/WeatherCommand.java | 53 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java diff --git a/Teamserver/src/de/steamwar/teamserver/Builder.java b/Teamserver/src/de/steamwar/teamserver/Builder.java index e049cdc6..137906ad 100644 --- a/Teamserver/src/de/steamwar/teamserver/Builder.java +++ b/Teamserver/src/de/steamwar/teamserver/Builder.java @@ -46,7 +46,6 @@ public final class Builder extends JavaPlugin { new SpeedCommand(); new FreezeCommand(); new ArenaconfigCommand(); - new WeatherCommand(); if (Bukkit.getPluginManager().getPlugin("AxiomPaper") != null) { Bukkit.getPluginManager().registerEvents(new AxiomHandshakeListener(), this); diff --git a/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java b/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java deleted file mode 100644 index 2684370c..00000000 --- a/Teamserver/src/de/steamwar/teamserver/command/WeatherCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public 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.teamserver.command; - -import de.steamwar.command.SWCommand; -import org.bukkit.WeatherType; -import org.bukkit.entity.Player; - -public class WeatherCommand extends SWCommand { - - public WeatherCommand() { - super("weather"); - } - - @Register("clear") - public void clearWeather(Player player, @OptionalValue("0") int duration) { - player.getWorld().setClearWeatherDuration(duration); - player.getWorld().setThundering(false); - } - - @Register - public void rainyWeather(Player player, WeatherType type, int duration) { - player.getWorld().setThundering(false); - if (type == WeatherType.CLEAR) { - clearWeather(player, duration); - } else { - player.getWorld().setWeatherDuration(duration); - } - } - - @Register("thunder") - public void thunderWeather(Player player, @OptionalValue("0") int duration) { - player.getWorld().setThunderDuration(duration); - player.getWorld().setThundering(true); - } -}