From b31578ec8b895bb16d1d72cadd76f3917fc99c3c Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 26 Apr 2021 20:08:13 +0200 Subject: [PATCH] =?UTF-8?q?Add=20Some=E2=84=A2=20GuiItems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaoscaot --- .../features/bau/BauInfoGuiItem.java | 68 +++++++++++ .../features/detonator/DetonatorGuiItem.java | 53 +++++++++ .../bausystem/features/gui/BauGuiGuiItem.java | 56 +++++++++ .../features/loader/LoaderGuiItem.java | 106 ++++++++++++++++++ .../features/other/TeleportGuiItem.java | 60 ++++++++++ .../features/region/items/ColorGuiItem.java | 7 +- .../features/region/items/FireGuiItem.java | 14 +-- .../features/region/items/FreezeGuiItem.java | 14 +-- .../features/region/items/ProtectGuiItem.java | 14 +-- .../features/region/items/ResetGuiItem.java | 7 +- .../region/items/TestblockGuiItem.java | 7 +- .../features/region/items/TntGuiItem.java | 62 +++++----- .../steamwar/bausystem/linkage/GuiItem.java | 2 +- 13 files changed, 388 insertions(+), 82 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoGuiItem.java new file mode 100644 index 00000000..024df347 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoGuiItem.java @@ -0,0 +1,68 @@ +/* + * 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.bau; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.BauServer; +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.*; +import de.steamwar.inventory.SWItem; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +@Linked(LinkageType.GUI_ITEM) +public class BauInfoGuiItem extends GuiItem { + + public BauInfoGuiItem() { + super(7); + } + + @Override + public ItemStack getItem(Player player) { + SWItem itemStack = SWItem.getPlayerSkull(SteamwarUser.get(BauServer.getInstance().getOwner()).getUserName()); + itemStack.setName(ColorConfig.HIGHLIGHT + "Bau management"); + Region region = Region.getRegion(player.getLocation()); + itemStack.setLore(Arrays.asList(ColorConfig.BASE + "TNT" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.TNT, TNTMode.class).getChatValue(), + ColorConfig.BASE + "Freeze" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.FREEZE, FreezeMode.class).getChatValue(), + ColorConfig.BASE + "Feuer" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.FIRE, FireMode.class).getChatValue(), + ColorConfig.BASE + "Farbe" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.COLOR, ColorMode.class).getChatValue(), + ColorConfig.BASE + "Protect" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.PROTECT, ProtectMode.class).getChatValue())); + return itemStack.getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorGuiItem.java new file mode 100644 index 00000000..65633e94 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorGuiItem.java @@ -0,0 +1,53 @@ +/* + * 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.detonator; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +@Linked(LinkageType.GUI_ITEM) +public class DetonatorGuiItem extends GuiItem { + + public DetonatorGuiItem() { + super(8); + } + + @Override + public ItemStack getItem(Player player) { + return DetonatorCommand.getWAND(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + p.performCommand("detonator wand"); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java new file mode 100644 index 00000000..f6666332 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java @@ -0,0 +1,56 @@ +/* + * 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; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.linkage.GuiItem; +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; + +import java.util.Arrays; + +public class BauGuiGuiItem extends GuiItem { + + public BauGuiGuiItem() { + super(9); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.NETHER_STAR, ColorConfig.HIGHLIGHT + "Bau GUI", Arrays.asList(ColorConfig.BASE + "Du kannst dieses Item zum Öffnen der BauGUI nutzen", ColorConfig.BASE + "oder Doppel F (Swap hands) drücken."), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + BauGUI.giveItem(p); + return false; + } + + @Override + public Permission permission() { + return null; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderGuiItem.java new file mode 100644 index 00000000..72146653 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderGuiItem.java @@ -0,0 +1,106 @@ +/* + * 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.loader; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWInventory; +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; + +import java.util.Arrays; + +@Linked(LinkageType.GUI_ITEM) +public class LoaderGuiItem extends GuiItem { + + public LoaderGuiItem() { + super(9); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.FLINT_AND_STEEL, ColorConfig.HIGHLIGHT + "Loader").getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + openLoaderGui(p); + return false; + } + + private void openLoaderGui(Player p) { + SWInventory inv = new SWInventory(p, 9, "Loader"); + if (Loader.getLoader(p) == null) { + inv.setItem(4, new SWItem(Material.SCUTE, ColorConfig.HIGHLIGHT + "Neuer Loader", clickType -> { + p.closeInventory(); + p.performCommand("loader setup"); + })); + } else { + Loader loader = Loader.getLoader(p); + if (loader.getStage() != Loader.Stage.RUNNING) { + inv.setItem(0, new SWItem(Material.GREEN_DYE, ColorConfig.HIGHLIGHT + "Loader Starten", clickType -> { + p.closeInventory(); + p.performCommand("loader start"); + })); + } else { + inv.setItem(0, new SWItem(Material.RED_DYE, ColorConfig.HIGHLIGHT + "Loader pausieren", clickType -> { + p.closeInventory(); + p.performCommand("loader pause"); + })); + } + inv.setItem(2, new SWItem(Material.ARROW, ColorConfig.HIGHLIGHT + "Letzte Aktion Rückgängig machen", clickType -> { + p.closeInventory(); + p.performCommand("loader undo"); + })); + inv.setItem(4, new SWItem(Material.COMPASS, ColorConfig.HIGHLIGHT + "Schuss Delay", Arrays.asList(ColorConfig.BASE + "Aktuell: " + ColorConfig.HIGHLIGHT + loader.getTicksBetweenShots()), false, clickType -> { + p.closeInventory(); + SWAnvilInv anvilInv = new SWAnvilInv(p, "Schuss Delay"); + anvilInv.setItem(Material.CLOCK); + anvilInv.setCallback(s -> p.performCommand("loader delay " + s)); + anvilInv.open(); + })); + inv.setItem(6, new SWItem(Material.CLOCK, ColorConfig.HIGHLIGHT + "Geschwindigkeit", Arrays.asList(ColorConfig.BASE + "Aktuell: " + ColorConfig.HIGHLIGHT + loader.getTicksBetweenBlocks()), false, clickType -> { + p.closeInventory(); + SWAnvilInv anvilInv = new SWAnvilInv(p, "Block Platzier Geschwindigkeit"); + anvilInv.setItem(Material.CLOCK); + anvilInv.setCallback(s -> p.performCommand("loader speed " + s)); + anvilInv.open(); + })); + inv.setItem(8, new SWItem(Material.BARRIER, ColorConfig.HIGHLIGHT + "Loader Stoppen", clickType -> { + p.closeInventory(); + p.performCommand("loader stop"); + })); + } + inv.open(); + } + + @Override + public Permission permission() { + return Permission.WORLD; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java new file mode 100644 index 00000000..8deaa90b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java @@ -0,0 +1,60 @@ +/* + * 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.other; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.inventory.SWAnvilInv; +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.GUI_ITEM) +public class TeleportGuiItem extends GuiItem { + + public TeleportGuiItem() { + super(10); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.ENDER_PEARL, ColorConfig.HIGHLIGHT + "Teleporter").getItemStack(); + } + + @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)); + inv.open(); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorGuiItem.java index 50efc5f6..6e86f23f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorGuiItem.java @@ -34,7 +34,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.Collections; @@ -88,11 +87,7 @@ public class ColorGuiItem extends GuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class); - ItemStack itemStack = new ItemStack(mapColor(mode.getColor())); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Color: " + ColorConfig.HIGHLIGHT + mode.getChatValue()); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(mapColor(mode.getColor()), ColorConfig.BASE + "Color: " + ColorConfig.HIGHLIGHT + mode.getChatValue()).getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireGuiItem.java index a6e98f54..d7e95a8e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireGuiItem.java @@ -27,11 +27,11 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; +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; -import org.bukkit.inventory.meta.ItemMeta; @Linked(LinkageType.GUI_ITEM) public class FireGuiItem extends GuiItem { @@ -44,17 +44,9 @@ public class FireGuiItem extends GuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW) { - ItemStack itemStack = new ItemStack(Material.FIRE_CHARGE); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Feuer: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.FIRE_CHARGE, ColorConfig.BASE + "Feuer: " + ColorConfig.HIGHLIGHT + "Eingeschaltet").getItemStack(); } else { - ItemStack itemStack = new ItemStack(Material.FIREWORK_STAR); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Feuer: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.FIREWORK_STAR, ColorConfig.BASE + "Feuer: " + ColorConfig.HIGHLIGHT + "Eingeschaltet").getItemStack(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeGuiItem.java index ea75366b..e1be375f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeGuiItem.java @@ -27,11 +27,11 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; +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; -import org.bukkit.inventory.meta.ItemMeta; @Linked(LinkageType.GUI_ITEM) public class FreezeGuiItem extends GuiItem { @@ -44,17 +44,9 @@ public class FreezeGuiItem extends GuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) { - ItemStack itemStack = new ItemStack(Material.GUNPOWDER); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Freeze: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.GUNPOWDER, ColorConfig.BASE + "Freeze: " + ColorConfig.HIGHLIGHT + "Eingeschaltet").getItemStack(); } else { - ItemStack itemStack = new ItemStack(Material.REDSTONE); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Freeze: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.REDSTONE, ColorConfig.BASE + "Freeze: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet").getItemStack(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectGuiItem.java index ecfcb8e5..e205d078 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectGuiItem.java @@ -27,11 +27,11 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; +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; -import org.bukkit.inventory.meta.ItemMeta; @Linked(LinkageType.GUI_ITEM) public class ProtectGuiItem extends GuiItem { @@ -44,17 +44,9 @@ public class ProtectGuiItem extends GuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) { - ItemStack itemStack = new ItemStack(Material.OBSIDIAN); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Protect: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.OBSIDIAN, ColorConfig.BASE + "Protect: " + ColorConfig.HIGHLIGHT + "Eingeschaltet").getItemStack(); } else { - ItemStack itemStack = new ItemStack(Material.STONE); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "Protect: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.STONE, ColorConfig.BASE + "Protect: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet").getItemStack(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetGuiItem.java index 81659904..320da440 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetGuiItem.java @@ -31,7 +31,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.Collections; @@ -46,11 +45,7 @@ public class ResetGuiItem extends GuiItem { @Override public ItemStack getItem(Player player) { - ItemStack itemStack = new ItemStack(Material.END_STONE); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.HIGHLIGHT + "Reset"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, ColorConfig.HIGHLIGHT + "Reset").getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockGuiItem.java index ab662f24..d05151a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockGuiItem.java @@ -31,7 +31,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.Collections; @@ -46,11 +45,7 @@ public class TestblockGuiItem extends GuiItem { @Override public ItemStack getItem(Player player) { - ItemStack itemStack = new ItemStack(Material.END_STONE); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.HIGHLIGHT + "Testblock"); - itemStack.setItemMeta(meta); - return itemStack; + return new SWItem(Material.END_STONE, ColorConfig.HIGHLIGHT + "Testblock").getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntGuiItem.java index b2c18f8d..af9e7a6c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntGuiItem.java @@ -33,7 +33,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; @Linked(LinkageType.GUI_ITEM) public class TntGuiItem extends GuiItem { @@ -45,49 +44,51 @@ public class TntGuiItem extends GuiItem { @Override public ItemStack getItem(Player player) { switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { - case DENY: { - ItemStack itemStack = new ItemStack(Material.MINECART); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; - } - case ONLY_TB: { - ItemStack itemStack = new ItemStack(Material.TNT_MINECART); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "nur Testblock"); - itemStack.setItemMeta(meta); - return itemStack; - } - default: { - ItemStack itemStack = new ItemStack(Material.TNT); - ItemMeta meta = itemStack.getItemMeta(); - meta.setDisplayName(ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "Eingeschaltet"); - itemStack.setItemMeta(meta); - return itemStack; - } + case DENY: + return new SWItem(Material.MINECART, ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet").getItemStack(); + case ONLY_TB: + return new SWItem(Material.TNT_MINECART, ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "nur Testblock").getItemStack(); + default: + return new SWItem(Material.TNT, ColorConfig.BASE + "TNT: " + ColorConfig.HIGHLIGHT + "Eingeschaltet").getItemStack(); } } @Override public boolean click(ClickType click, Player p) { if (click == ClickType.LEFT) { - p.performCommand("tnt"); - return true; + switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { + case DENY: + updateTntMode(TNTMode.ALLOW, p); + break; + case ALLOW: + updateTntMode(TNTMode.ONLY_TB, p); + break; + default: + updateTntMode(TNTMode.DENY, p); + } } else { p.closeInventory(); SWInventory selector = new SWInventory(p, 9, "Tnt Modus"); - selector.setItem(1, new SWItem(Material.TNT, ColorConfig.HIGHLIGHT + "Einschalten", clickType -> updateTntMode(TNTMode.ALLOW, p))); - if (!Region.getRegion(p.getLocation()).isGlobal()) - selector.setItem(4, new SWItem(Material.TNT_MINECART, ColorConfig.HIGHLIGHT + "nur Testblock", clickType -> updateTntMode(TNTMode.ONLY_TB, p))); - selector.setItem(7, new SWItem(Material.MINECART, ColorConfig.HIGHLIGHT + "Ausschalten", clickType -> updateTntMode(TNTMode.DENY, p))); + selector.setItem(1, new SWItem(Material.TNT, ColorConfig.HIGHLIGHT + "Einschalten", clickType -> { + updateTntMode(TNTMode.ALLOW, p); + p.closeInventory(); + })); + if (!Region.getRegion(p.getLocation()).isGlobal()) { + selector.setItem(4, new SWItem(Material.TNT_MINECART, ColorConfig.HIGHLIGHT + "nur Testblock", clickType -> { + updateTntMode(TNTMode.ONLY_TB, p); + p.closeInventory(); + })); + } + selector.setItem(7, new SWItem(Material.MINECART, ColorConfig.HIGHLIGHT + "Ausschalten", clickType -> { + updateTntMode(TNTMode.DENY, p); + p.closeInventory(); + })); selector.open(); - return false; } + return false; } private void updateTntMode(TNTMode mode, Player p) { - p.closeInventory(); switch (mode) { case ONLY_TB: p.performCommand("tnt tb"); @@ -99,6 +100,7 @@ public class TntGuiItem extends GuiItem { p.performCommand("tnt off"); break; } + update(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java index 3676d5d8..1bfeda28 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java @@ -46,7 +46,7 @@ public abstract class GuiItem { @Override public String toString() { return "GuiItem{" + - "slot=" + slot + + "slot=" + slot + ", " + "class=" + this.getClass().getName() + '}'; }