From edb108b7b337712405cdbaef9bddb9a5735f0eeb Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 6 Apr 2023 17:11:17 +0200 Subject: [PATCH] Add Softreload cancel --- src/de/steamwar/bungeecore/util/SchematicSearch.java | 8 ++++++-- src/de/steamwar/messages/BungeeCore.properties | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/util/SchematicSearch.java b/src/de/steamwar/bungeecore/util/SchematicSearch.java index 2dd1e40..b458223 100644 --- a/src/de/steamwar/bungeecore/util/SchematicSearch.java +++ b/src/de/steamwar/bungeecore/util/SchematicSearch.java @@ -67,19 +67,23 @@ public class SchematicSearch { public static void abortAll() { synchronized (searchQueue) { + searchQueue.stream().map(schematicSearch -> schematicSearch.player).collect(Collectors.toSet()).forEach(player -> { + Message.send("SCHEMATIC_SEARCH_REMOVED_FROM_QUEUE_SOFTRELOAD", player); + }); searchQueue.clear(); } if(currentSearch != null) { + Message.send("SCHEMATIC_SEARCH_CANCELED_SOFTRELOAD", currentSearch.player); currentSearch.end(); } } private static List constructArguments(SteamwarUser user, File pattern) { - return Arrays.asList(searchBinary, "-T", "1", "-s", "-u", String.valueOf(user.getId()), "-o", "json:std", "-m", "50", pattern.getAbsolutePath()); + return Arrays.asList(searchBinary, "-T", "2", "-s", "-u", String.valueOf(user.getId()), "-o", "json:std", "-m", "50", pattern.getAbsolutePath()); } public static boolean removeFromQueue(ProxiedPlayer player) { - boolean removed = false; + boolean removed; synchronized (searchQueue) { removed = searchQueue.removeIf(search -> search.player.equals(player)); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index e06383e..852f24c 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -690,4 +690,6 @@ SCHEMATIC_SEARCH_RESULT=§7{0}: §e{1}§7% §8(§e{2}§7,§e{3},§e{4}§8) SCHEMATIC_SEARCH_RESULT_HOVER=§7Click to get more info about {0}. SCHEMATIC_SEARCH_NOT_SUPPORTED=§cThis schematic is not supported by the schematic search. SCHEMATIC_SEARCH_REMOVED_FROM_QUEUE=§cYour search has been removed from the queue because you switched servers. +SCHEMATIC_SEARCH_REMOVED_FROM_QUEUE_SOFTRELOAD=§cYour search has been removed from the queue because of an update. +SCHEMATIC_SEARCH_CANCELED_SOFTRELOAD=§cYour search has been canceled because of an update. SCHEMATIC_SEARCH_TOO_MANY_RESULTS=§cToo many results found. Please be more specific. \ No newline at end of file