13
0

added schematic search

Dieser Commit ist enthalten in:
Yaruma3341 2020-01-07 17:15:24 +01:00
Ursprung f36ea44633
Commit 44f0f0bd37
2 geänderte Dateien mit 40 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -13,10 +13,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
class GUI {
private GUI(){}
@ -182,4 +179,32 @@ class GUI {
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
static void listSearch(Player player, String search) {
List<Pair<SWItem, Schematic>> schemList = new LinkedList<>();
List<Schematic> filteredSchems = new ArrayList<>();
for(Schematic currentSchem : filteredSchems) {
if(currentSchem.getSchemName().toLowerCase().contains(search.toLowerCase()))
filteredSchems.add(currentSchem);
}
for(Schematic currentSchem : filteredSchems) {
Material m;
if (currentSchem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(currentSchem.getItem());
SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {});
schemList.add(new Pair<>(item, currentSchem));
}
SWListInv<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", (clickType, schem) -> {
player.closeInventory();
info(player, schem);
}, schemList);
inv.setCallback(-999, (ClickType click) -> player.closeInventory());
inv.open();
}
}

Datei anzeigen

@ -68,6 +68,9 @@ public class SchematicCommand implements CommandExecutor {
case "download":
download(player, args);
break;
case "search":
search(player, args);
break;
default:
help(player);
}
@ -330,6 +333,14 @@ public class SchematicCommand implements CommandExecutor {
download(player, schematic);
}
private void search(Player player, String[] args) {
if(args.length != 1) {
help(player);
return;
}
GUI.listSearch(player, args[0]);
}
static void download(Player player, Schematic schematic){
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");