4 Commits

Author SHA1 Message Date
6d801e473c Add block/unblock commands and update investigation state handling
All checks were successful
SteamWarCI Build successful
2025-07-18 14:23:38 +02:00
e17ba8bdcb Add investigation support to schematics and refine rejection handling
All checks were successful
SteamWarCI Build successful
2025-07-18 14:11:26 +02:00
a21760003e Merge branch 'main' into schematic-investigations
# Conflicts:
#	CommonCore/SQL/src/de/steamwar/sql/CheckedSchematic.java
#	VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java
2025-07-16 14:32:55 +02:00
9ba8a83a3b Add investigation state handling for CheckedSchematic
All checks were successful
SteamWarCI Build successful
2025-05-31 22:44:40 +02:00
6 changed files with 56 additions and 7 deletions

View File

@@ -466,6 +466,16 @@ public class SchematicNode {
setConfig(ConfigFlags.IS_PREPARED, prepared); setConfig(ConfigFlags.IS_PREPARED, prepared);
} }
public boolean isInvestigation() {
return getConfig(ConfigFlags.INVESTIGATION);
}
public void setInvestigation(boolean investigation) {
if (isDir())
throw new SecurityException("Is Directory");
setConfig(ConfigFlags.INVESTIGATION, investigation);
}
public boolean getConfig(ConfigFlags flag) { public boolean getConfig(ConfigFlags flag) {
return (config & (1 << flag.ordinal())) != 0; return (config & (1 << flag.ordinal())) != 0;
} }
@@ -629,6 +639,7 @@ public class SchematicNode {
public static enum ConfigFlags { public static enum ConfigFlags {
REPLACE_COLOR, REPLACE_COLOR,
ALLOW_REPLAY, ALLOW_REPLAY,
IS_PREPARED IS_PREPARED,
INVESTIGATION,
} }
} }

View File

@@ -125,7 +125,7 @@ public class GUI {
}).setCustomModelData(CMDs.Schematic.BACK)); }).setCustomModelData(CMDs.Schematic.BACK));
if(node.getOwner() == user.getId()){ if(node.getOwner() == user.getId()){
if(!node.isDir() && node.getSchemtype().writeable()){ if(!node.isDir() && node.getSchemtype().writeable() && !node.isInvestigation()){
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic ->
inv.setItem(1, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS", player, node.getSchemtype().name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS_LORE", player, checkedSchematic.getDeclineReason().replaceAll("&", "§"))), false, click -> {})); inv.setItem(1, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS", player, node.getSchemtype().name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS_LORE", player, checkedSchematic.getDeclineReason().replaceAll("&", "§"))), false, click -> {}));
} }

View File

@@ -251,7 +251,9 @@ public class SchematicCommandUtils {
} }
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_FORMAT", player, node.getFileEnding()); SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_FORMAT", player, node.getFileEnding());
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_STATUS", player, checkedSchematic.getEndTime(), checkedSchematic.getDeclineReason())); if (!node.isInvestigation()) {
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_STATUS", player, checkedSchematic.getEndTime(), checkedSchematic.getDeclineReason()));
}
} else { } else {
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, SchematicSystem.MESSAGE.parse("UTIL_INFO_TYPE_DIR", player)); SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, SchematicSystem.MESSAGE.parse("UTIL_INFO_TYPE_DIR", player));
} }

View File

@@ -319,6 +319,7 @@ CHECK_LIST_CHECKING_HOVER=§eTo the reviewer
CHECK_SCHEMATIC_ALREADY_CHECKING=§cYou are already reviewing a schematic! CHECK_SCHEMATIC_ALREADY_CHECKING=§cYou are already reviewing a schematic!
CHECK_SCHEMATIC_OWN=§cYou cannot review your own schematics. CHECK_SCHEMATIC_OWN=§cYou cannot review your own schematics.
CHECK_SCHEMATIC_OWN_TEAM=§cYou cannot review your team schematics. CHECK_SCHEMATIC_OWN_TEAM=§cYou cannot review your team schematics.
CHECK_SCHEMATIC_INVESTIGATION_PENDING=§cThis schematic is currently under investigation
CHECK_SCHEMATIC_PREVIOUS=§7{0} from {1}§8: §e{2} CHECK_SCHEMATIC_PREVIOUS=§7{0} from {1}§8: §e{2}
CHECK_INVALID_RANK=§cUnknown schematic rank. CHECK_INVALID_RANK=§cUnknown schematic rank.
CHECK_ABORT=§aThe test operation was canceled! CHECK_ABORT=§aThe test operation was canceled!

View File

@@ -301,6 +301,7 @@ CHECK_LIST_CHECKING_HOVER=§eZum Prüfer
CHECK_SCHEMATIC_ALREADY_CHECKING=§cDu prüfst schon eine Schematic! CHECK_SCHEMATIC_ALREADY_CHECKING=§cDu prüfst schon eine Schematic!
CHECK_SCHEMATIC_OWN=§cDu kannst nicht deine eigenen Schematics prüfen. CHECK_SCHEMATIC_OWN=§cDu kannst nicht deine eigenen Schematics prüfen.
CHECK_SCHEMATIC_OWN_TEAM=§cDu kannst nicht Schematics deines Teams prüfen. CHECK_SCHEMATIC_OWN_TEAM=§cDu kannst nicht Schematics deines Teams prüfen.
CHECK_SCHEMATIC_INVESTIGATION_PENDING=§cDiese Schematic wird grade untersucht!
CHECK_SCHEMATIC_PREVIOUS=§7{0} von {1}§8: §e{2} CHECK_SCHEMATIC_PREVIOUS=§7{0} von {1}§8: §e{2}
CHECK_INVALID_RANK=§cUnbekannter Schematicrang. CHECK_INVALID_RANK=§cUnbekannter Schematicrang.
CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen! CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen!

View File

@@ -99,11 +99,13 @@ public class CheckCommand extends SWCommand {
for (SchematicNode schematic : schematicList) { for (SchematicNode schematic : schematicList) {
CheckSession current = currentSchems.get(schematic.getId()); CheckSession current = currentSchems.get(schematic.getId());
if (current == null) { if (current == null) {
boolean isInvestigation = schematic.isInvestigation();
sender.prefixless("CHECK_LIST_TO_CHECK", sender.prefixless("CHECK_LIST_TO_CHECK",
new Message("CHECK_LIST_TO_CHECK_HOVER"), isInvestigation ? new Message("PLAIN_STRING", CheckedSchematic.getLastDeclinedOfNode(schematic.getId()).stream().map(CheckedSchematic::getDeclineReason).findFirst().orElse("")) : new Message("CHECK_LIST_TO_CHECK_HOVER"),
ClickEvent.runCommand("/check schematic " + schematic.getId()), isInvestigation ? ClickEvent.suggestCommand("") : ClickEvent.runCommand("/check schematic " + schematic.getId()),
getWaitTime(schematic), getWaitTime(schematic),
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName()); schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), (isInvestigation ? "§c" : "") + schematic.getName());
} else { } else {
sender.prefixless("CHECK_LIST_CHECKING", sender.prefixless("CHECK_LIST_CHECKING",
new Message("CHECK_LIST_CHECKING_HOVER"), new Message("CHECK_LIST_CHECKING_HOVER"),
@@ -130,6 +132,10 @@ public class CheckCommand extends SWCommand {
return; return;
} }
if(schem.isInvestigation() && !sender.user().hasPerm(UserPerm.MODERATION)) {
sender.system("CHECK_SCHEMATIC_INVESTIGATION_PENDING");
}
int playerTeam = sender.user().hasPerm(UserPerm.MODERATION) ? 0 : sender.user().getTeam(); int playerTeam = sender.user().hasPerm(UserPerm.MODERATION) ? 0 : sender.user().getTeam();
if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) { if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) {
sender.system("CHECK_SCHEMATIC_OWN_TEAM"); sender.system("CHECK_SCHEMATIC_OWN_TEAM");
@@ -181,6 +187,22 @@ public class CheckCommand extends SWCommand {
currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message)); currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message));
} }
@Register(value = "block")
public void investigate(PlayerChatter sender, String... message) {
if(notChecking(sender.getPlayer()))
return;
currentCheckers.get(sender.getPlayer().getUniqueId()).investigate(String.join(" ", message));
}
@Register(value = "unblock")
public void uninvestigate(PlayerChatter sender) {
if(notChecking(sender.getPlayer()))
return;
currentCheckers.get(sender.getPlayer().getUniqueId()).unblock();
}
public static List<SchematicNode> getSchemsToCheck(){ public static List<SchematicNode> getSchemsToCheck(){
List<SchematicNode> schematicList = new ArrayList<>(); List<SchematicNode> schematicList = new ArrayList<>();
@@ -223,7 +245,7 @@ public class CheckCommand extends SWCommand {
currentCheckers.put(checker.user().getUUID(), this); currentCheckers.put(checker.user().getUUID(), this);
currentSchems.put(schematic.getId(), this); currentSchems.put(schematic.getId(), this);
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic)) for(CheckedSchematic previous : CheckedSchematic.getLastDeclinedOfNode(schematic.getId()))
checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getDeclineReason()); checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getDeclineReason());
next(); next();
}).start(); }).start();
@@ -309,7 +331,9 @@ public class CheckCommand extends SWCommand {
private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) { private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) {
if(SchematicNode.getSchematicNode(schematic.getId()) != null) { if(SchematicNode.getSchematicNode(schematic.getId()) != null) {
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean()); CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean());
if(type != null) { if(type != null) {
schematic.setInvestigation(false);
schematic.setSchemtype(type); schematic.setSchemtype(type);
if (type == SchematicType.Normal) { if (type == SchematicType.Normal) {
schematic.setPrepared(false); schematic.setPrepared(false);
@@ -329,5 +353,15 @@ public class CheckCommand extends SWCommand {
currentCheckers.remove(checker.user().getUUID()); currentCheckers.remove(checker.user().getUUID());
currentSchems.remove(schematic.getId()); currentSchems.remove(schematic.getId());
} }
public void investigate(String reason) {
schematic.setInvestigation(true);
concludeCheckSession(reason, null, () -> true);
}
public void unblock() {
schematic.setInvestigation(false);
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), "", true);
}
} }
} }