added schematic search
Dieser Commit ist enthalten in:
Ursprung
f36ea44633
Commit
44f0f0bd37
@ -13,10 +13,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
class GUI {
|
class GUI {
|
||||||
private GUI(){}
|
private GUI(){}
|
||||||
@ -182,4 +179,32 @@ class GUI {
|
|||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,9 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
case "download":
|
case "download":
|
||||||
download(player, args);
|
download(player, args);
|
||||||
break;
|
break;
|
||||||
|
case "search":
|
||||||
|
search(player, args);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
help(player);
|
help(player);
|
||||||
}
|
}
|
||||||
@ -330,6 +333,14 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
download(player, schematic);
|
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){
|
static void download(Player player, Schematic schematic){
|
||||||
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
|
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
|
||||||
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
|
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren