From 48d6a0ed50b1d6a71cff4cb051f2cf9eb3b23b9b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 10 May 2021 20:53:39 +0200 Subject: [PATCH] Irgendein GuiItem und noch nen bissle mehr. Signed-off-by: Chaoscaot --- BauSystem_Main/src/BauSystem.properties | 61 +++++++++++++------ .../bausystem/features/gui/BauGUI.java | 3 + .../gui/editor/BauGuiEditorGuiItem.java | 55 +++++++++++++++++ .../other/items/TeleportBauGuiItem.java | 19 ++++-- .../features/tracer/TracerBauGuiItem.java | 53 +++++++++++++++- 5 files changed, 168 insertions(+), 23 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index b0dddcee..a303f8ce 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -1,23 +1,50 @@ +# +# 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 . +# + PREFIX = §eBau§8System §8» - # Permission -PERMISSION_WORLD = Einstellungen vornehmen -PERMISSION_WORLD_EDIT = WorldEdit verwenden - -PERMISSION_CHANGE_YOU_ENABLE = §aDer Spieler darf nun {0} -PERMISSION_CHANGE_YOU_DISABLE = §cDer Spieler darf nun nicht mehr {0} -PERMISSION_CHANGE_OTHER_ENABLE = §aDu kannst nun auf der Welt von §6{0} §a{1} -PERMISSION_CHANGE_OTHER_DISABLE = §cDu kannst nun nicht mehr auf der Welt von §6{0} §c{1} - +PERMISSION_WORLD=Einstellungen vornehmen +PERMISSION_WORLD_EDIT=WorldEdit verwenden +PERMISSION_CHANGE_YOU_ENABLE=§aDer Spieler darf nun {0} +PERMISSION_CHANGE_YOU_DISABLE=§cDer Spieler darf nun nicht mehr {0} +PERMISSION_CHANGE_OTHER_ENABLE=§aDu kannst nun auf der Welt von §6{0} §a{1} +PERMISSION_CHANGE_OTHER_DISABLE=§cDu kannst nun nicht mehr auf der Welt von §6{0} §c{1} +# Feature +FEATURE_OTHER_ITEMS_TELEPORT_GUI_NAME=Teleportieren +FEATURE_OTHER_ITEMS_TELEPORT_PLAYER_OFFLINE=§cDer Spieler ist Offline +FEATURE_GUI_EDITOR_ITEM_NAME=§eGui Editor +FEATURE_TRACER_GUI_NAME=Tracer Gui +FEATURE_TRACER_GUI_TRACE_INACTIVE=§eTracer Starten +FEATURE_TRACER_GUI_TRACE_ACTIVE=§eTracer Stoppen +FEATURE_TRACER_GUI_TRACE_ACTIVE_AUTO=§eAuto-Trace ist Aktiv +FEATURE_TRACER_GUI_AUTO_TRACE_INACTIVE=§eAuto-Tracer Aktivieren +FEATURE_TRACER_GUI_AUTO_TRACE_ACTIVE=§eAuto-Tracer Deaktivieren +FEATURE_TRACER_GUI_SHOW_GUI=§eTrace Show Gui +FEATURE_TRACER_GUI_DELETE=§eTrace Löschen # Flags -FLAG_COLOR = Color -FLAG_TNT = TNT -FLAG_FIRE = Fire -FLAG_FREEZE = Freeze -FLAG_PROTECT = Protect - -FLAG_FIRE_ALLOW = §can -FLAG_FIRE_DENY = §aaus +FLAG_COLOR=Color +FLAG_TNT=TNT +FLAG_FIRE=Fire +FLAG_FREEZE=Freeze +FLAG_PROTECT=Protect +FLAG_FIRE_ALLOW=§can +FLAG_FIRE_DENY=§aaus FLAG_FREEZE_ACTIVE = §aan FLAG_FREEZE_INACTIVE = §aaus diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java index 21324395..a213969b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -55,6 +55,9 @@ public class BauGUI { } public static void addItem(BauGuiItem item) { + if (ITEMS.containsKey(item.getId())) { + throw new IllegalArgumentException("Duplicate Id Key: " + item.getId() + ". From Classes: " + ITEMS.get(item.getId()).getClass().getName() + " and " + item.getClass().getName()); + } ITEMS.put(item.getId(), item); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java new file mode 100644 index 00000000..573c8ec2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java @@ -0,0 +1,55 @@ +/* + * 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.gui.editor; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +@Linked(LinkageType.BAU_GUI_ITEM) +public class BauGuiEditorGuiItem extends BauGuiItem { + + public BauGuiEditorGuiItem() { + super(23); + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.IRON_PICKAXE, BauSystem.MESSAGE.parse("FEATURE_GUI_EDITOR_ITEM_NAME", player)).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.performCommand("gui editor"); + return false; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java index 3657e96f..a7abd034 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java @@ -19,18 +19,22 @@ package de.steamwar.bausystem.features.other.items; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import java.util.UUID; + @Linked(LinkageType.BAU_GUI_ITEM) public class TeleportBauGuiItem extends BauGuiItem { @@ -46,9 +50,14 @@ public class TeleportBauGuiItem extends BauGuiItem { @Override public boolean click(ClickType click, Player p) { p.closeInventory(); - SWAnvilInv inv = new SWAnvilInv(p, "Teleportieren"); - inv.setItem(Material.ENDER_PEARL); - inv.setCallback(s -> p.performCommand("tp " + s)); + SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("FEATURE_OTHER_ITEMS_TELEPORT_GUI_NAME", p), SWListInv.createPlayerList(p.getUniqueId()), (clickType, o) -> { + Player t = Bukkit.getPlayer(o); + if (t == null) { + BauSystem.MESSAGE.send("FEATURE_OTHER_ITEMS_TELEPORT_PLAYER_OFFLINE", p); + } else { + p.performCommand("tp " + t.getName()); + } + }); inv.open(); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index 9aa1121e..e73e5ce0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -19,12 +19,16 @@ package de.steamwar.bausystem.features.tracer; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.bausystem.features.tracer.record.RecordStatus; +import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -46,8 +50,55 @@ public class TracerBauGuiItem extends BauGuiItem { }).getItemStack(); } + private static void open(Player p) { + RecordStatus status = RecordStateMachine.getRecordStatus(); + SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_NAME", p)); + if (status.isTracing()) { + if (status.isAutoTrace()) { + inv.setItem(1, new SWItem(Material.GRAY_DYE, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_TRACE_ACTIVE_AUTO", p))); + } else { + inv.setItem(1, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_TRACE_ACTIVE", p), clickType -> { + p.performCommand("trace stop"); + open(p); + })); + } + } else { + inv.setItem(1, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_TRACE_INACTIVE", p), clickType -> { + p.performCommand("trace start"); + open(p); + })); + } + if (status.isAutoTrace()) { + inv.setItem(3, new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_AUTO_TRACE_ACTIVE", p), clickType -> { + p.performCommand("trace auto"); + open(p); + })); + } else { + inv.setItem(3, new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_AUTO_TRACE_INACTIVE", p), clickType -> { + p.performCommand("trace auto"); + open(p); + })); + } + if (TraceShowManager.hasActiveShow(p)) { + inv.setItem(5, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_SHOW_GUI", p), clickType -> { + p.performCommand("trace show gui"); + })); + } else { + inv.setItem(5, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_SHOW_GUI", p), clickType -> { + p.performCommand("trace show gui"); + })); + } + inv.setItem(7, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("FEATURE_TRACER_GUI_DELETE", p), clickType -> { + p.performCommand("trace delete"); + open(p); + })); + + inv.open(); + } + @Override public boolean click(ClickType click, Player p) { + open(p); return false; }