13
0

added empty check

Dieser Commit ist enthalten in:
Yaruma3341 2020-01-07 22:51:06 +01:00
Ursprung 44f0f0bd37
Commit d2f54b9206
2 geänderte Dateien mit 8 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -180,7 +180,7 @@ class GUI {
inv.open(); inv.open();
} }
static void listSearch(Player player, String search) { static boolean listSearch(Player player, String search) {
List<Pair<SWItem, Schematic>> schemList = new LinkedList<>(); List<Pair<SWItem, Schematic>> schemList = new LinkedList<>();
List<Schematic> filteredSchems = new ArrayList<>(); List<Schematic> filteredSchems = new ArrayList<>();
@ -189,6 +189,9 @@ class GUI {
filteredSchems.add(currentSchem); filteredSchems.add(currentSchem);
} }
if(filteredSchems.isEmpty())
return false;
for(Schematic currentSchem : filteredSchems) { for(Schematic currentSchem : filteredSchems) {
Material m; Material m;
if (currentSchem.getItem().isEmpty()) if (currentSchem.getItem().isEmpty())
@ -206,5 +209,6 @@ class GUI {
}, schemList); }, schemList);
inv.setCallback(-999, (ClickType click) -> player.closeInventory()); inv.setCallback(-999, (ClickType click) -> player.closeInventory());
inv.open(); inv.open();
return true;
} }
} }

Datei anzeigen

@ -334,11 +334,12 @@ public class SchematicCommand implements CommandExecutor {
} }
private void search(Player player, String[] args) { private void search(Player player, String[] args) {
if(args.length != 1) { if(args.length < 2) {
help(player); help(player);
return; 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){ static void download(Player player, Schematic schematic){