diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.java b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.java index e355419b..13f0988c 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.java +++ b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.java @@ -466,6 +466,16 @@ public class SchematicNode { 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) { return (config & (1 << flag.ordinal())) != 0; } @@ -629,6 +639,7 @@ public class SchematicNode { public static enum ConfigFlags { REPLACE_COLOR, ALLOW_REPLAY, - IS_PREPARED + IS_PREPARED, + INVESTIGATION, } } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java index 2c1b6f4f..5b997c83 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/GUI.java @@ -125,8 +125,8 @@ public class GUI { }).setCustomModelData(CMDs.Schematic.BACK)); if(node.getOwner() == user.getId()){ - if(!node.isDir() && node.getSchemtype().writeable()){ - CheckedSchematic.getLastCheck(node.getId()).flatMap(CheckedSchematic::castToUserSafe).ifPresent(checkedSchematic -> + if(!node.isDir() && node.getSchemtype().writeable() && !node.isInvestigation()){ + 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 -> {})); } Material mat = SWItem.getMaterial(node.getItem()); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java index 66d22817..1cbe3289 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandUtils.java @@ -251,7 +251,9 @@ public class SchematicCommandUtils { } SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_FORMAT", player, node.getFileEnding()); - CheckedSchematic.getLastCheck(node.getId()).flatMap(CheckedSchematic::castToUserSafe).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 { SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, SchematicSystem.MESSAGE.parse("UTIL_INFO_TYPE_DIR", player)); } diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 8d618600..123f91fa 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -99,11 +99,13 @@ public class CheckCommand extends SWCommand { for (SchematicNode schematic : schematicList) { CheckSession current = currentSchems.get(schematic.getId()); if (current == null) { + boolean isInvestigation = schematic.isInvestigation(); + sender.prefixless("CHECK_LIST_TO_CHECK", new Message("CHECK_LIST_TO_CHECK_HOVER"), - ClickEvent.runCommand("/check schematic " + schematic.getId()), + isInvestigation ? ClickEvent.suggestCommand("") : ClickEvent.runCommand("/check schematic " + schematic.getId()), 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 { sender.prefixless("CHECK_LIST_CHECKING", new Message("CHECK_LIST_CHECKING_HOVER"), @@ -130,6 +132,10 @@ public class CheckCommand extends SWCommand { 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(); if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) { sender.system("CHECK_SCHEMATIC_OWN_TEAM"); @@ -181,6 +187,14 @@ public class CheckCommand extends SWCommand { currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message)); } + @Register(value = "investigate") + public void investigate(PlayerChatter sender, String... message) { + if(notChecking(sender.getPlayer())) + return; + + currentCheckers.get(sender.getPlayer().getUniqueId()).investigate(String.join(" ", message)); + } + public static List getSchemsToCheck(){ List schematicList = new ArrayList<>(); @@ -223,7 +237,7 @@ public class CheckCommand extends SWCommand { currentCheckers.put(checker.user().getUUID(), 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()); next(); }).start(); @@ -309,6 +323,7 @@ public class CheckCommand extends SWCommand { private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) { if(SchematicNode.getSchematicNode(schematic.getId()) != null) { CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean()); + if(type != null) { schematic.setSchemtype(type); if (type == SchematicType.Normal) { @@ -329,5 +344,9 @@ public class CheckCommand extends SWCommand { currentCheckers.remove(checker.user().getUUID()); currentSchems.remove(schematic.getId()); } + + public void investigate(String reason) { + concludeCheckSession(reason, null, () -> true); + } } }