From d2f54b9206f87a0d5eb1122a99a9c09af8858fea Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Tue, 7 Jan 2020 22:51:06 +0100 Subject: [PATCH] added empty check --- .../src/de/steamwar/schematicsystem/commands/GUI.java | 6 +++++- .../steamwar/schematicsystem/commands/SchematicCommand.java | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index b56a3e0..b301821 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -180,7 +180,7 @@ class GUI { inv.open(); } - static void listSearch(Player player, String search) { + static boolean listSearch(Player player, String search) { List> schemList = new LinkedList<>(); List filteredSchems = new ArrayList<>(); @@ -189,6 +189,9 @@ class GUI { filteredSchems.add(currentSchem); } + if(filteredSchems.isEmpty()) + return false; + for(Schematic currentSchem : filteredSchems) { Material m; if (currentSchem.getItem().isEmpty()) @@ -206,5 +209,6 @@ class GUI { }, schemList); inv.setCallback(-999, (ClickType click) -> player.closeInventory()); inv.open(); + return true; } } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 82c559b..a78502f 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -334,11 +334,12 @@ public class SchematicCommand implements CommandExecutor { } private void search(Player player, String[] args) { - if(args.length != 1) { + if(args.length < 2) { help(player); return; } - GUI.listSearch(player, args[0]); + if(!GUI.listSearch(player, args[1])) + player.sendMessage("§cEs wurden keine Schematics gefunden!"); } static void download(Player player, Schematic schematic){