Merge branch 'schematic_search' of SteamWar/SchematicSystem into master
Dieser Commit ist enthalten in:
Commit
c28997aa58
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
target
|
target
|
||||||
dependency-reduced-pom.xml
|
dependency-reduced-pom.xml
|
||||||
|
*.iml
|
@ -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,36 @@ class GUI {
|
|||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean listSearch(Player player, String search) {
|
||||||
|
List<Pair<SWItem, Schematic>> schemList = new LinkedList<>();
|
||||||
|
List<Schematic> filteredSchems = new ArrayList<>();
|
||||||
|
|
||||||
|
for(Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) {
|
||||||
|
if(currentSchem.getSchemName().toLowerCase().contains(search.toLowerCase()))
|
||||||
|
filteredSchems.add(currentSchem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filteredSchems.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
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();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,15 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
download(player, schematic);
|
download(player, schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void search(Player player, String[] args) {
|
||||||
|
if(args.length < 2) {
|
||||||
|
help(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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){
|
||||||
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!");
|
||||||
@ -426,6 +438,7 @@ public class SchematicCommand implements CommandExecutor {
|
|||||||
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
|
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
|
||||||
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
|
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
|
||||||
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
|
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
|
||||||
|
player.sendMessage("§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics");
|
||||||
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
|
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
|
||||||
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
|
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
|
||||||
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
|
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren