From 1dc78b8eb866ffabdb5bba2c55f4e677b3258b73 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 31 May 2026 00:44:56 +0200 Subject: [PATCH 1/4] Add RedstoneEngineCommand --- .../RedstoneEngineCommand.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java new file mode 100644 index 00000000..40c8ff08 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java @@ -0,0 +1,130 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.experimental.redstone_engine; + +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import io.papermc.paper.configuration.WorldConfiguration; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.title.TitlePart; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.Collection; +import java.util.List; + +@Linked +public class RedstoneEngineCommand extends SWCommand implements Listener, ScoreboardElement { + + public RedstoneEngineCommand() { + super("redstoneengine"); + } + + private WorldConfiguration.Misc getConfig() { + return ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().paperConfig().misc; + } + + @Register + public void setRedstoneEngine(Player player, @StaticValue("alternate_current") String __, WorldConfiguration.Misc.AlternateCurrentUpdateOrder updateOrder) { + WorldConfiguration.Misc misc = getConfig(); + misc.redstoneImplementation = WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT; + misc.alternateCurrentUpdateOrder = updateOrder; + broadcastTitle(Bukkit.getOnlinePlayers()); + } + + @Register + public void setRedstoneEngine(Player player, WorldConfiguration.Misc.RedstoneImplementation implementation) { + getConfig().redstoneImplementation = implementation; + broadcastTitle(Bukkit.getOnlinePlayers()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + WorldConfiguration.Misc misc = getConfig(); + if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) { + broadcastTitle(List.of(event.getPlayer())); + } + } + + private void broadcastTitle(Collection players) { + WorldConfiguration.Misc misc = getConfig(); + Component title = switch (misc.redstoneImplementation) { + case VANILLA -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: Vanilla ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED)); + case EIGENCRAFT -> Component.text("Redstone: Eigencraft"); + case ALTERNATE_CURRENT -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: AC ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED)); + }; + Component subtitle; + if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { + subtitle = Component.text().build(); + } else { + subtitle = switch (misc.alternateCurrentUpdateOrder) { + case VERTICAL_FIRST_INWARD -> Component.text("Y first inwards"); // Y before XZ + case VERTICAL_FIRST_OUTWARD -> Component.text("Y first outwards"); // XZ before Y + case HORIZONTAL_FIRST_INWARD -> Component.text("XZ first inwards"); // Y before XZ + case HORIZONTAL_FIRST_OUTWARD -> Component.text("XZ first outwards"); // XZ before Y + }; + } + players.forEach(player -> { + player.sendTitlePart(TitlePart.TITLE, title); + player.sendTitlePart(TitlePart.SUBTITLE, subtitle); + }); + } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.FOOTER; + } + + @Override + public int order() { + return Integer.MAX_VALUE; + } + + @Override + public String get(Region region, Player p) { + WorldConfiguration.Misc misc = getConfig(); + switch (misc.redstoneImplementation) { + case ALTERNATE_CURRENT: + switch (misc.alternateCurrentUpdateOrder) { + case VERTICAL_FIRST_INWARD: + return "§eRedstone§8: §cAC §8(§7Y in§8)"; + case VERTICAL_FIRST_OUTWARD: + return "§eRedstone§8: §cAC §8(§7Y out§8)"; + case HORIZONTAL_FIRST_INWARD: + return "§eRedstone§8: §cAC §8(§7XZ in§8)"; + case HORIZONTAL_FIRST_OUTWARD: + return "§eRedstone§8: §cAC §8(§7XZ out§8)"; + } + return "§eRedstone§8: §cAC"; + case EIGENCRAFT: + return null; + case VANILLA: + default: + return "§eRedstone§8: §cVanilla"; + } + } +} From bc0177df43fd4c424647328cd66df33b2c4761bf Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 31 May 2026 00:56:05 +0200 Subject: [PATCH 2/4] Add ExperimentalCommand --- .../experimental/ExperimentalCommand.java | 31 +++++++++++++++++++ ...EngineCommand.java => RedstoneEngine.java} | 16 +++++----- 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/ExperimentalCommand.java rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/{RedstoneEngineCommand.java => RedstoneEngine.java} (93%) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/ExperimentalCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/ExperimentalCommand.java new file mode 100644 index 00000000..a765a351 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/ExperimentalCommand.java @@ -0,0 +1,31 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.experimental; + +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; + +@Linked +public class ExperimentalCommand extends SWCommand { + + public ExperimentalCommand() { + super("experimental", "experiment"); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java similarity index 93% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java index 40c8ff08..8dc99349 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngineCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java @@ -21,8 +21,8 @@ package de.steamwar.bausystem.features.experimental.redstone_engine; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; -import de.steamwar.linkage.Linked; import io.papermc.paper.configuration.WorldConfiguration; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -37,18 +37,19 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.Collection; import java.util.List; -@Linked -public class RedstoneEngineCommand extends SWCommand implements Listener, ScoreboardElement { +@AbstractSWCommand.PartOf(RedstoneEngine.class) +public class RedstoneEngine extends SWCommand implements Listener, ScoreboardElement { - public RedstoneEngineCommand() { - super("redstoneengine"); + public RedstoneEngine() { + super(""); } private WorldConfiguration.Misc getConfig() { return ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().paperConfig().misc; } - @Register + @Register("redstone") + @Register("redstoneengine") public void setRedstoneEngine(Player player, @StaticValue("alternate_current") String __, WorldConfiguration.Misc.AlternateCurrentUpdateOrder updateOrder) { WorldConfiguration.Misc misc = getConfig(); misc.redstoneImplementation = WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT; @@ -56,7 +57,8 @@ public class RedstoneEngineCommand extends SWCommand implements Listener, Scoreb broadcastTitle(Bukkit.getOnlinePlayers()); } - @Register + @Register("redstone") + @Register("redstoneengine") public void setRedstoneEngine(Player player, WorldConfiguration.Misc.RedstoneImplementation implementation) { getConfig().redstoneImplementation = implementation; broadcastTitle(Bukkit.getOnlinePlayers()); From eab8826583f39e1bbc43f68e6f481379fe85cdf9 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 31 May 2026 11:36:21 +0200 Subject: [PATCH 3/4] Fix RedstoneEngine not registering --- .../features/experimental/redstone_engine/RedstoneEngine.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java index 8dc99349..f6d7934a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import io.papermc.paper.configuration.WorldConfiguration; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -38,6 +39,7 @@ import java.util.Collection; import java.util.List; @AbstractSWCommand.PartOf(RedstoneEngine.class) +@Linked public class RedstoneEngine extends SWCommand implements Listener, ScoreboardElement { public RedstoneEngine() { From fd8f942014a308f666d56b181ef52d6b60e6050c Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 31 May 2026 11:37:43 +0200 Subject: [PATCH 4/4] Fix RedstoneEngine not registering --- .../features/experimental/redstone_engine/RedstoneEngine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java index f6d7934a..1247b667 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/experimental/redstone_engine/RedstoneEngine.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.experimental.redstone_engine; +import de.steamwar.bausystem.features.experimental.ExperimentalCommand; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.command.AbstractSWCommand; @@ -38,7 +39,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.Collection; import java.util.List; -@AbstractSWCommand.PartOf(RedstoneEngine.class) +@AbstractSWCommand.PartOf(ExperimentalCommand.class) @Linked public class RedstoneEngine extends SWCommand implements Listener, ScoreboardElement {