Add MaterialCommand.searchGUI
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
834d2eb389
Commit
e5e8211c70
@ -370,7 +370,21 @@ NIGHT-VISION_COMMAND_HELP=§8/§enightvision §8-§7 Schalte Nightvision an oder
|
||||
NIGHT-VISION_OFF=§eNightvision deaktiviert
|
||||
NIGHT-VISION_ON=§eNightvision aktiviert
|
||||
# Material
|
||||
MATERIAL_INV_NAME=Material
|
||||
MATERIAL_INV_NAME=§eMaterial {0}/{1}
|
||||
MATERIAL_SEARCH=§eSuchen
|
||||
MATERIAL_BACK=§eZurück
|
||||
MATERIAL_SEARCH_NAME=§eName
|
||||
MATERIAL_SEARCH_TRANSPARENT=§eTransparent
|
||||
MATERIAL_SEARCH_SOLID=§eSolide
|
||||
MATERIAL_SEARCH_GRAVITY=§eFallend
|
||||
MATERIAL_SEARCH_OCCLUDING=§eOccluding
|
||||
MATERIAL_SEARCH_INTERACTEABLE=§eInterargierbar
|
||||
MATERIAL_SEARCH_FLAMMABLE=§eFlammbar
|
||||
MATERIAL_SEARCH_BLASTRESISTANCE=§eBlast Resistance
|
||||
MATERIAL_SEARCH_BLASTRESISTANCE_MIN=§eBlast Resistance mindestens
|
||||
MATERIAL_SEARCH_BLASTRESISTANCE_MAX=§eBlast Resistance maximal
|
||||
MATERIAL_SEARCH_BLASTRESISTANCE_EXACT=§eBlast Resistance
|
||||
MATERIAL_SEARCH_VALUE=§8: §e{0}
|
||||
MATERIAL_BLAST-RESISTANCE=§8- §eBlast Resistance§8: §7{0}
|
||||
MATERIAL_TNT_BREAKABLE=§8- §eZerstörbar durch TNT
|
||||
MATERIAL_TNT_UNBREAKABLE=§8- §eNicht Zerstörbar durch TNT
|
||||
|
@ -23,24 +23,36 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class MaterialCommand extends SWCommand {
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class MaterialCommand extends SWCommand implements Listener {
|
||||
|
||||
public MaterialCommand() {
|
||||
super("material");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void materialGUI(Player p) {
|
||||
List<SWListInv.SWListEntry<Material>> swListEntries = new ArrayList<>();
|
||||
private List<MaterialData> materialData = new ArrayList<>();
|
||||
private Map<Player, Search> searchMap = new HashMap<>();
|
||||
|
||||
{
|
||||
for (Material value : Material.values()) {
|
||||
if (!value.isBlock()) {
|
||||
continue;
|
||||
@ -48,31 +60,235 @@ public class MaterialCommand extends SWCommand {
|
||||
if (value.isLegacy()) {
|
||||
continue;
|
||||
}
|
||||
materialData.add(new MaterialData(value));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MaterialData {
|
||||
private Material material;
|
||||
private Material originalMaterial;
|
||||
|
||||
private String name;
|
||||
private double blastResistance;
|
||||
private boolean transparent;
|
||||
private boolean solid;
|
||||
private boolean gravity;
|
||||
private boolean occluding;
|
||||
private boolean interacteable;
|
||||
private boolean flammable;
|
||||
|
||||
public MaterialData(Material material) {
|
||||
this.originalMaterial = material;
|
||||
|
||||
name = material.name();
|
||||
blastResistance = material.getBlastResistance();
|
||||
transparent = material.isTransparent();
|
||||
solid = material.isSolid();
|
||||
gravity = material.hasGravity();
|
||||
occluding = material.isOccluding();
|
||||
interacteable = material.isInteractable();
|
||||
flammable = material.isFlammable();
|
||||
|
||||
if (material.isItem() && material != Material.AIR) {
|
||||
this.material = material;
|
||||
} else {
|
||||
this.material = Material.GHAST_TEAR;
|
||||
}
|
||||
}
|
||||
|
||||
public SWListInv.SWListEntry<Material> toSWItem(Player p) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_BLAST-RESISTANCE", p, value.getBlastResistance()));
|
||||
lore.add(BauSystem.MESSAGE.parse(value.getBlastResistance() > 9 ? "MATERIAL_TNT_UNBREAKABLE" : "MATERIAL_TNT_BREAKABLE", p));
|
||||
if (value.isTransparent()) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_BLAST-RESISTANCE", p, blastResistance));
|
||||
lore.add(BauSystem.MESSAGE.parse(blastResistance > 9 ? "MATERIAL_TNT_UNBREAKABLE" : "MATERIAL_TNT_BREAKABLE", p));
|
||||
if (transparent) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_TRANSPARENT", p));
|
||||
}
|
||||
if (value.isSolid()) {
|
||||
if (solid) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_SOLID", p));
|
||||
}
|
||||
if (value.hasGravity()) {
|
||||
if (gravity) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_GRAVITY", p));
|
||||
}
|
||||
if (value.isOccluding()) {
|
||||
if (occluding) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_OCCLUDING", p));
|
||||
}
|
||||
if (value.isInteractable()) {
|
||||
if (interacteable) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_INTERACT-ABLE", p));
|
||||
}
|
||||
if (value.isFlammable()) {
|
||||
if (flammable) {
|
||||
lore.add(BauSystem.MESSAGE.parse("MATERIAL_FLAMMABLE", p));
|
||||
}
|
||||
SWItem swItem = new SWItem(value.isItem() || value == Material.AIR ? value : Material.GHAST_TEAR, "§e" + value.name(), lore, false, clickType -> {});
|
||||
swListEntries.add(new SWListInv.SWListEntry<>(swItem, value));
|
||||
return new SWListInv.SWListEntry<>(new SWItem(material, "§e" + name, lore, false, clickType -> {}), originalMaterial);
|
||||
}
|
||||
SWListInv<Material> materialSWListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("MATERIAL_INV_NAME", p), false, swListEntries, (clickType, material) -> {});
|
||||
|
||||
public boolean is(Search search) {
|
||||
boolean result = true;
|
||||
if (search.transparent) {
|
||||
result &= transparent;
|
||||
}
|
||||
if (search.solid) {
|
||||
result &= solid;
|
||||
}
|
||||
if (search.gravity) {
|
||||
result &= gravity;
|
||||
}
|
||||
if (search.occluding) {
|
||||
result &= occluding;
|
||||
}
|
||||
if (search.interacteable) {
|
||||
result &= interacteable;
|
||||
}
|
||||
if (search.flammable) {
|
||||
result &= flammable;
|
||||
}
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
if (!(blastResistance >= search.blastResistanceMin && blastResistance < search.blastResistanceMax)) {
|
||||
return false;
|
||||
}
|
||||
if (search.name.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (!name.toLowerCase().contains(search.name.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private static class Search {
|
||||
private boolean transparent = false;
|
||||
private boolean solid = false;
|
||||
private boolean gravity = false;
|
||||
private boolean occluding = false;
|
||||
private boolean interacteable = false;
|
||||
private boolean flammable = false;
|
||||
|
||||
private double blastResistanceMin = 0;
|
||||
private double blastResistanceMax = 5000000;
|
||||
private String name = "";
|
||||
}
|
||||
|
||||
@Register
|
||||
public void materialGUI(Player p) {
|
||||
List<SWListInv.SWListEntry<Material>> swListEntries = new ArrayList<>();
|
||||
materialData.forEach(data -> {
|
||||
if (data.is(searchMap.get(p))) {
|
||||
swListEntries.add(data.toSWItem(p));
|
||||
}
|
||||
});
|
||||
SWListInv<Material> materialSWListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("MATERIAL_INV_NAME", p, swListEntries.size(), materialData.size()), false, swListEntries, (clickType, material) -> {});
|
||||
materialSWListInv.setItem(49, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p), clickType -> {
|
||||
searchGUI(p);
|
||||
}));
|
||||
materialSWListInv.open();
|
||||
}
|
||||
|
||||
private void searchGUI(Player p) {
|
||||
SWInventory swInventory = new SWInventory(p, 54, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p));
|
||||
Search search = searchMap.get(p);
|
||||
swInventory.setItem(45, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
materialGUI(p);
|
||||
}));
|
||||
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
|
||||
swAnvilInv.setCallback(s -> {
|
||||
search.name = s;
|
||||
searchGUI(p);
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
swInventory.setItem(19, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_TRANSPARENT", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.transparent), clickType -> {
|
||||
search.transparent = !search.transparent;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(20, new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_SOLID", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.solid), clickType -> {
|
||||
search.solid = !search.solid;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(21, new SWItem(Material.BLACK_CONCRETE_POWDER, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_GRAVITY", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.gravity), clickType -> {
|
||||
search.gravity = !search.gravity;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(22, new SWItem(Material.BIRCH_LOG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_OCCLUDING", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.occluding), clickType -> {
|
||||
search.occluding = !search.occluding;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_INTERACTEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.interacteable), clickType -> {
|
||||
search.interacteable = !search.interacteable;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(24, new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_FLAMMABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.flammable), clickType -> {
|
||||
search.flammable = !search.flammable;
|
||||
searchGUI(p);
|
||||
}));
|
||||
swInventory.setItem(28, new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_MIN", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMin), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMin + "");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
try {
|
||||
search.blastResistanceMin = Double.parseDouble(s);
|
||||
if (search.blastResistanceMin < 0) search.blastResistanceMin = 0;
|
||||
if (search.blastResistanceMin > 5000000) search.blastResistanceMin = 5000000;
|
||||
if (search.blastResistanceMin > search.blastResistanceMax) search.blastResistanceMin = search.blastResistanceMax;
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignored
|
||||
}
|
||||
searchGUI(p);
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
swInventory.setItem(29, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_MAX", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMax), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMax + "");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
try {
|
||||
search.blastResistanceMax = Double.parseDouble(s);
|
||||
if (search.blastResistanceMax > 5000000) search.blastResistanceMax = 5000000;
|
||||
if (search.blastResistanceMax < 0) search.blastResistanceMax = 0;
|
||||
if (search.blastResistanceMax < search.blastResistanceMin) search.blastResistanceMax = search.blastResistanceMin;
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignored
|
||||
}
|
||||
searchGUI(p);
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
swInventory.setItem(31, new SWItem(Material.NETHER_BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE_EXACT", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistanceMin + "-" + search.blastResistanceMax), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistanceMax + "");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
try {
|
||||
search.blastResistanceMax = Double.parseDouble(s);
|
||||
if (search.blastResistanceMax > 5000000) search.blastResistanceMax = 5000000;
|
||||
if (search.blastResistanceMax < 0) search.blastResistanceMax = 0;
|
||||
search.blastResistanceMin = search.blastResistanceMax;
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignored
|
||||
}
|
||||
searchGUI(p);
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
swInventory.open();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
/*
|
||||
switch (event.getPlayer().getName()) {
|
||||
case "iSlaymassive":
|
||||
case "maatthias":
|
||||
case "xNTraY":
|
||||
event.getPlayer().kickPlayer("");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
searchMap.put(event.getPlayer(), new Search());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
searchMap.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +124,9 @@ if (steamwarProperties.containsKey("hostname")) {
|
||||
|
||||
doLast {
|
||||
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
|
||||
if (!answer("Start ${server} server?")) {
|
||||
/*if (!answer("Start ${server} server?")) {
|
||||
return
|
||||
}
|
||||
}*/
|
||||
serverStart(server, serverStartFlags, hostname)
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren