From fbe70e7eaded319cfb24a348aba10fc00e446482 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 24 Apr 2026 10:09:56 +0200 Subject: [PATCH] Improve CheckCommand for WGS --- .../velocitycore/commands/CheckCommand.java | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index c3957503..3b95a338 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -40,6 +40,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import java.awt.*; import java.sql.Timestamp; import java.time.Instant; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.List; import java.util.concurrent.TimeUnit; @@ -136,7 +137,7 @@ public class CheckCommand extends SWCommand { if(!schem.getSchemtype().check()){ VelocityCore.getLogger().log(Level.SEVERE, () -> sender.user().getUserName() + " tried to check an uncheckable schematic!"); return; - }else if(schem.getOwner() == sender.user().getId()) { + }else if(schem.getOwner() == sender.user().getId() && !sender.user().hasPerm(UserPerm.ADMINISTRATION)) { sender.system("CHECK_SCHEMATIC_OWN"); return; } @@ -293,6 +294,49 @@ public class CheckCommand extends SWCommand { } private void accept(){ + // TODO: This Code is only for the WGS and because YoyoNow is not available this can be removed or changed after the WGS! + if (schematic.getSchemtype().toDB().equals("cwargearseason26")) { + int userId = schematic.getOwner(); + SteamwarUser user = SteamwarUser.byId(userId); + int teamId = user.getTeam(); + + SchematicNode teamFolder = SchematicNode.getSchematicNodeInNode(172325) + .stream() + .filter(schematicNode -> schematicNode.getName().startsWith(teamId + "_")) + .findFirst() + .orElse(null); + if (teamFolder == null) { + internalAccept(); + return; + } + + // Copy Schem into team folder of -1 user + String name = DateTimeFormatter.ofPattern("yyyy.MM.dd_HH:mm:ss").format(schematic.getLastUpdate().toLocalDateTime()); + NodeData data = NodeData.getLatest(schematic); + SchematicNode node = SchematicNode.createSchematic(-1, name, teamFolder.getNodeId()); + NodeData.saveFromStream(node, data.schemData(false), data.getNodeFormat()); + + // Accept the team folder schematic and set other to Normal + node.setSchemtype(GameModeConfig.getBySchematicType(schematic.getSchemtype()).Schematic.Type); + + // Conclude by setting send in schematic to normal and broadcast + concludeCheckSession("freigegeben", SchematicType.Normal, () -> { + Chatter owner = Chatter.of(SteamwarUser.byId(schematic.getOwner()).getUUID()); + owner.withPlayerOrOffline( + player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()), + () -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true) + ); + notifyTeam(new Message("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName())); + + return owner.getPlayer() != null; + }); + return; + } + + internalAccept(); + } + + private void internalAccept() { concludeCheckSession("freigegeben", GameModeConfig.getBySchematicType(schematic.getSchemtype()).Schematic.Type, () -> { Chatter owner = Chatter.of(SteamwarUser.byId(schematic.getOwner()).getUUID()); owner.withPlayerOrOffline(