From a08bb3b46dfe5610b368d721d73e9b269f0e39a7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 25 May 2021 13:55:48 +0200 Subject: [PATCH] Add MaterialCommand Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 13 +++- .../features/util/MaterialCommand.java | 78 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index a9e4444f..4450aecd 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -198,4 +198,15 @@ LOADER_BUTTON_INVALID = Invalider # Other OTHER_ITEMS_TELEPORT_GUI-NAME = Teleportieren -OTHER_ITEMS_TELEPORT_PLAYER-OFFLINE = §cDer Spieler ist Offline \ No newline at end of file +OTHER_ITEMS_TELEPORT_PLAYER-OFFLINE = §cDer Spieler ist Offline + +# Material +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 +MATERIAL_TRANSPARENT = §8- §eTransparenter Block +MATERIAL_SOLID = §8- §eSolider Block +MATERIAL_GRAVITY = §8- §eFallender Block +MATERIAL_OCCLUDING = §8- §eOccluding Block +MATERIAL_INTERACT-ABLE = §8- §eInterargierbarer Block +MATERIAL_FLAMMABLE = §8- §eFlammbarer Block \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java new file mode 100644 index 00000000..e974b8bd --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java @@ -0,0 +1,78 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.util; + +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.SWItem; +import de.steamwar.inventory.SWListInv; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@Linked(LinkageType.COMMAND) +public class MaterialCommand extends SWCommand { + + public MaterialCommand() { + super("material"); + } + + @Register + public void materialGUI(Player p) { + List> swListEntries = new ArrayList<>(); + for (Material value : Material.values()) { + if (!value.isBlock()) { + continue; + } + if (value.isLegacy()) { + continue; + } + List 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_TRANSPARENT", p)); + } + if (value.isSolid()) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_SOLID", p)); + } + if (value.hasGravity()) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_GRAVITY", p)); + } + if (value.isOccluding()) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_OCCLUDING", p)); + } + if (value.isInteractable()) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_INTERACT-ABLE", p)); + } + if (value.isFlammable()) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_FLAMMABLE", p)); + } + SWItem swItem = new SWItem(value.isItem() ? value : Material.GHAST_TEAR, "§e" + value.name(), lore, false, clickType -> {}); + swListEntries.add(new SWListInv.SWListEntry<>(swItem, value)); + } + SWListInv materialSWListInv = new SWListInv<>(p, "Material", false, swListEntries, (clickType, material) -> {}); + materialSWListInv.open(); + } +}