diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index f8b27f59..51d6bf14 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -146,7 +146,7 @@ public final class GameModeConfig { public final List CheckQuestions; /** - * The allowed checkers to check this schematic type denoted by a list of SteamWar ids. + * The allowed checkers to check this schematic type denoted by a list of SteamwarUser ids. * The people need the {@link UserPerm#CHECK} to be able to check though. * * @implSpec {@code []} by default -> denoting every person with {@link UserPerm#CHECK} can check it diff --git a/VelocityCore/src/de/steamwar/command/SWCommand.java b/VelocityCore/src/de/steamwar/command/SWCommand.java index 2fdf204f..e1e0c066 100644 --- a/VelocityCore/src/de/steamwar/command/SWCommand.java +++ b/VelocityCore/src/de/steamwar/command/SWCommand.java @@ -20,6 +20,7 @@ package de.steamwar.command; import com.velocitypowered.api.command.SimpleCommand; +import com.velocitypowered.api.command.SimpleCommand.Invocation; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.sql.UserPerm; @@ -91,11 +92,15 @@ public class SWCommand extends AbstractSWCommand { @Override public boolean hasPermission(Invocation invocation) { - return permission == null || Chatter.of(invocation.source()).user().perms().contains(permission); + return SWCommand.this.hasPermission(invocation); } }; } + protected boolean hasPermission(Invocation invocation) { + return permission == null || Chatter.of(invocation.source()).user().perms().contains(permission); + } + @Override public void unregister() { if (command == null) return; diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 637218e3..1b3aaa43 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import com.velocitypowered.api.command.SimpleCommand; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import de.steamwar.command.SWCommand; @@ -70,9 +71,38 @@ public class CheckCommand extends SWCommand { } public CheckCommand() { - super("check", UserPerm.CHECK); + super("check"); - VelocityCore.schedule(() -> sendReminder(Chatter.serverteam())).repeat(10, TimeUnit.MINUTES).schedule(); + VelocityCore.schedule(() -> sendReminder(Chatter.allStream())).repeat(10, TimeUnit.MINUTES).schedule(); + } + + @Override + protected boolean hasPermission(SimpleCommand.Invocation invocation) { + return mayCheck(Chatter.of(invocation.source()).user()); + } + + private boolean mayCheck(SteamwarUser user) { + if (user.perms().contains(UserPerm.CHECK)) return true; + return GameModeConfig.getAll() + .stream() + .filter(GameModeConfig::isActive) + .flatMap(gameMode -> gameMode.Checkers.stream()) + .anyMatch(integer -> integer == user.getId()); + } + + private boolean hasThingsToCheck(SteamwarUser user) { + return getSchemsToCheck().stream().anyMatch(schematicNode -> mayCheck(user, schematicNode)); + } + + private boolean mayCheck(SteamwarUser user, SchematicNode schematic) { + GameModeConfig gameModeConfig = ArenaMode.getBySchemType(schematic.getSchemtype()); + if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults(); + if (gameModeConfig.Checkers.isEmpty() && user.hasPerm(UserPerm.CHECK)) return true; + return gameModeConfig.Checkers.contains(user.getId()); + } + + private boolean needsCheck(SchematicNode schematicNode) { + return currentSchems.containsKey(schematicNode.getId()); } public static void sendReminder(Chatter chatter) { @@ -142,8 +172,7 @@ public class CheckCommand extends SWCommand { } int playerTeam = sender.user().hasPerm(UserPerm.MODERATION) ? 0 : sender.user().getTeam(); - // Ignore 795 SteamWar Team - if (playerTeam != 0 && playerTeam != 795 && SteamwarUser.byId(schem.getOwner()).getTeam() == playerTeam) { + if (playerTeam != 0 && SteamwarUser.byId(schem.getOwner()).getTeam() == playerTeam) { sender.system("CHECK_SCHEMATIC_OWN_TEAM"); return; } diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand2.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand2.java new file mode 100644 index 00000000..e90043ef --- /dev/null +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand2.java @@ -0,0 +1,51 @@ +/* + * 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.velocitycore.commands; + +import com.velocitypowered.api.command.SimpleCommand; +import de.steamwar.command.SWCommand; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SchematicType; + +import java.util.ArrayList; +import java.util.List; + +public class CheckCommand2 extends SWCommand { + + public CheckCommand2() { + super("check"); + } + + @Override + protected boolean hasPermission(SimpleCommand.Invocation invocation) { + return false; // TODO: Implement! + } + + public static List getSchemsToCheck() { + List schematicList = new ArrayList<>(); + + for (SchematicType type : SchematicType.values()) { + if (type.check()) { + schematicList.addAll(SchematicNode.getAllSchematicsOfType(type)); + } + } + return schematicList; + } +}