From bad4b795009027a7d1746d5c8f8fff9291b559ac Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 30 Apr 2021 16:07:57 +0200 Subject: [PATCH] =?UTF-8?q?Add=20more=20Some=E2=84=A2=20GuiItems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaoscaot --- .../bausystem/features/gui/BauGUI.java | 8 +- .../bausystem/features/gui/BauGUICommand.java | 2 +- .../bausystem/features/gui/BauGuiGuiItem.java | 7 +- .../features/gui/BauGuiListener.java | 66 +++++++++++ .../other/{ => items}/TeleportGuiItem.java | 2 +- .../features/script/ScriptBookGuiItem.java | 56 +++++++++ .../features/simulator/SimulatorGuiItem.java | 56 +++++++++ .../features/tpslimit/TPSLimitGuiItem.java | 63 +++++++++++ .../features/tracer/TracerGuiItem.java | 58 ++++++++++ .../util/items/DebugstickGuiItem.java | 56 +++++++++ .../util/items/NightVisionGuiItem.java | 68 +++++++++++ .../features/util/items/SelectGuiItem.java | 107 ++++++++++++++++++ .../features/util/items/SkullGuiItem.java | 60 ++++++++++ .../features/util/items/SpeedGuiItem.java | 63 +++++++++++ .../util/items/WaterVisionGuiItem.java | 60 ++++++++++ .../steamwar/bausystem/linkage/GuiItem.java | 8 -- 16 files changed, 726 insertions(+), 14 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java rename BauSystem_Main/src/de/steamwar/bausystem/features/other/{ => items}/TeleportGuiItem.java (97%) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptBookGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionGuiItem.java 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 d27dbf54..33695d54 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -25,13 +25,17 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.linkage.GuiItem; import de.steamwar.inventory.SWInventory; +import lombok.Getter; import lombok.experimental.UtilityClass; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; @UtilityClass public class BauGUI { @@ -41,6 +45,7 @@ public class BauGUI { private static final Set OPEN_INVS = new HashSet<>(); private static boolean updating = false; + @Getter private static final ItemStack GUI_ITEM; static { @@ -75,7 +80,6 @@ public class BauGUI { } }); inv.open(); - System.out.println(Arrays.toString(ITEMS.toArray())); } public static void update() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java index dcaec145..475331d3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java @@ -28,7 +28,7 @@ import org.bukkit.entity.Player; public class BauGUICommand extends SWCommand { protected BauGUICommand() { - super("gui", "baugui"); + super("gui", "baugui", "g"); } @Register(help = true) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java index f6666332..d4f8792c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiGuiItem.java @@ -22,6 +22,8 @@ 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.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -30,10 +32,11 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; +@Linked(LinkageType.GUI_ITEM) public class BauGuiGuiItem extends GuiItem { public BauGuiGuiItem() { - super(9); + super(14); } @Override @@ -51,6 +54,6 @@ public class BauGuiGuiItem extends GuiItem { @Override public Permission permission() { - return null; + return Permission.MEMBER; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java new file mode 100644 index 00000000..03981011 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java @@ -0,0 +1,66 @@ +/* + * 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.BauSystem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerSwapHandItemsEvent; + +import java.util.HashSet; +import java.util.Set; + +@Linked(LinkageType.LISTENER) +public class BauGuiListener implements Listener { + + private static final Set LAST_FS = new HashSet<>(); + + public BauGuiListener() { + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), LAST_FS::clear, 15, 15); + } + + @EventHandler + public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { + if (LAST_FS.contains(event.getPlayer())) { + BauGUI.openBauGui(event.getPlayer()); + } else { + LAST_FS.add(event.getPlayer()); + } + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + if (event.getItem() == null) { + return; + } + + if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { + if (event.getItem().isSimilar(BauGUI.getGUI_ITEM())) { + BauGUI.openBauGui(event.getPlayer()); + } + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportGuiItem.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportGuiItem.java index 8deaa90b..7cff9862 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportGuiItem.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.other.items; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptBookGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptBookGuiItem.java new file mode 100644 index 00000000..696918cf --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptBookGuiItem.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.script; + +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.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 ScriptBookGuiItem extends GuiItem { + + public ScriptBookGuiItem() { + super(15); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.WRITTEN_BOOK, ColorConfig.HIGHLIGHT + "Script Hilfe").getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + p.performCommand("script"); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorGuiItem.java new file mode 100644 index 00000000..97b46d2d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorGuiItem.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.simulator; + +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.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 SimulatorGuiItem extends GuiItem { + + public SimulatorGuiItem() { + super(20); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.REDSTONE_TORCH, ColorConfig.HIGHLIGHT + "TNT Simulator").getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + p.performCommand("sim"); + return false; + } + + @Override + public Permission permission() { + return Permission.WORLD; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitGuiItem.java new file mode 100644 index 00000000..2cd1924a --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitGuiItem.java @@ -0,0 +1,63 @@ +/* + * 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.tpslimit; + +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; + +import java.util.Arrays; + +@Linked(LinkageType.GUI_ITEM) +public class TPSLimitGuiItem extends GuiItem { + + public TPSLimitGuiItem() { + super(19); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.CLOCK, ColorConfig.HIGHLIGHT + "TPS Limiter", Arrays.asList(ColorConfig.BASE + "Aktuell: " + ColorConfig.HIGHLIGHT + TPSLimitUtils.getCurrentTPSLimit()), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + SWAnvilInv inv = new SWAnvilInv(p, "Neues TPS Limit"); + inv.setItem(Material.CLOCK); + inv.setCallback(s -> p.performCommand("tpslimit " + s)); + inv.open(); + return false; + } + + @Override + public Permission permission() { + return Permission.WORLD; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerGuiItem.java new file mode 100644 index 00000000..6b9d61d0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerGuiItem.java @@ -0,0 +1,58 @@ +/* + * 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.tracer; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +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 TracerGuiItem extends GuiItem { + + public TracerGuiItem() { + super(21); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.OBSERVER, ColorConfig.HIGHLIGHT + "Tracer", Arrays.asList(ColorConfig.BASE + "Status: " + RecordStateMachine.getRecordStatus().getName()), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + return false; + } + + @Override + public Permission permission() { + return Permission.WORLD; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickGuiItem.java new file mode 100644 index 00000000..b187f728 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickGuiItem.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.util.items; + +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.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 DebugstickGuiItem extends GuiItem { + + public DebugstickGuiItem() { + super(12); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.DEBUG_STICK, ColorConfig.HIGHLIGHT + "Debugstick").getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + p.performCommand("debugstick"); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionGuiItem.java new file mode 100644 index 00000000..b168e336 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionGuiItem.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.util.items; + +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.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffectType; + +@Linked(LinkageType.GUI_ITEM) +public class NightVisionGuiItem extends GuiItem { + + public NightVisionGuiItem() { + super(11); + } + + @Override + public ItemStack getItem(Player player) { + if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + ItemStack itemStack = new ItemStack(Material.POTION); + PotionMeta meta = (PotionMeta) itemStack.getItemMeta(); + meta.setColor(PotionEffectType.NIGHT_VISION.getColor()); + meta.setDisplayName(ColorConfig.BASE + "Nightvision: " + ColorConfig.HIGHLIGHT + "Aktiviert"); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + itemStack.setItemMeta(meta); + return itemStack; + } else { + return new SWItem(Material.GLASS_BOTTLE, ColorConfig.BASE + "Nightvision: " + ColorConfig.HIGHLIGHT + "Deaktiviert").getItemStack(); + } + } + + @Override + public boolean click(ClickType click, Player p) { + p.performCommand("nv"); + return true; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectGuiItem.java new file mode 100644 index 00000000..24d8c304 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectGuiItem.java @@ -0,0 +1,107 @@ +/* + * 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.items; + +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.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +@Linked(LinkageType.GUI_ITEM) +public class SelectGuiItem extends GuiItem { + + private static final Map LAST_SELECT_MAP = new HashMap<>(); + + public SelectGuiItem() { + super(13); + } + + private static void selectExtension(Player p, RegionType type) { + p.closeInventory(); + SWInventory inv = new SWInventory(p, 9, "Extension auswählen"); + inv.setItem(2, new SWItem(Material.END_STONE, ColorConfig.HIGHLIGHT + "Normal", clickType -> selectFinish(p, type, RegionExtensionType.NORMAL))); + inv.setItem(6, new SWItem(Material.PISTON, ColorConfig.HIGHLIGHT + "Ausfahrmaße", clickType -> selectFinish(p, type, RegionExtensionType.EXTENSION))); + inv.open(); + } + + private static void selectFinish(Player p, RegionType type, RegionExtensionType extensionType) { + p.closeInventory(); + LAST_SELECT_MAP.put(p, new LastSelect(type, extensionType)); + p.performCommand("select " + type.name() + " " + extensionType.toString()); + } + + @Override + public ItemStack getItem(Player player) { + LastSelect last = LAST_SELECT_MAP.getOrDefault(player, new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL)); + return new SWItem(Material.SCAFFOLDING, ColorConfig.HIGHLIGHT + "Select", Arrays.asList(ColorConfig.BASE + "Auswahl: " + ColorConfig.HIGHLIGHT + last.toString(), ColorConfig.BASE + "Rechtklick zum ändern"), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + if (click == ClickType.RIGHT) { + p.closeInventory(); + SWInventory inv = new SWInventory(p, 9, "Auswahl auswählen"); + inv.setItem(2, new SWItem(Material.REDSTONE_BLOCK, ColorConfig.HIGHLIGHT + "Baurahmen", clickType -> selectExtension(p, RegionType.BUILD))); + inv.setItem(4, new SWItem(Material.LECTERN, ColorConfig.HIGHLIGHT + "Bauplattform", clickType -> selectFinish(p, RegionType.NORMAL, RegionExtensionType.NORMAL))); + inv.setItem(6, new SWItem(Material.END_STONE, ColorConfig.HIGHLIGHT + "Testblock", clickType -> selectExtension(p, RegionType.TESTBLOCK))); + inv.open(); + } else { + p.closeInventory(); + LastSelect last = LAST_SELECT_MAP.getOrDefault(p, new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL)); + p.performCommand("select " + last.getType().name() + " " + last.getExtensionType().toString()); + } + return false; + } + + @Override + public Permission permission() { + return Permission.WORLDEDIT; + } + + @AllArgsConstructor + private static class LastSelect { + @Getter + private final RegionType type; + @Getter + private final RegionExtensionType extensionType; + + @Override + public String toString() { + return type.getChatValue() + " " + extensionType.name().toLowerCase(Locale.ROOT); + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullGuiItem.java new file mode 100644 index 00000000..e14f4c2f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullGuiItem.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.util.items; + +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 SkullGuiItem extends GuiItem { + + public SkullGuiItem() { + super(16); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.PLAYER_HEAD, ColorConfig.HIGHLIGHT + "Spieler Köpfe").getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + SWAnvilInv inv = new SWAnvilInv(p, "Spieler namen"); + inv.setItem(Material.NAME_TAG); + inv.setCallback(s -> p.performCommand("skull " + s)); + inv.open(); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedGuiItem.java new file mode 100644 index 00000000..d2139886 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedGuiItem.java @@ -0,0 +1,63 @@ +/* + * 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.items; + +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; + +import java.util.Arrays; + +@Linked(LinkageType.GUI_ITEM) +public class SpeedGuiItem extends GuiItem { + + public SpeedGuiItem() { + super(17); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.SUGAR, ColorConfig.HIGHLIGHT + "Geschwindigkeit", Arrays.asList(ColorConfig.BASE + "Aktuell: " + ColorConfig.HIGHLIGHT + player.getFlySpeed() * 10f), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + SWAnvilInv inv = new SWAnvilInv(p, "Geschwindigkeit eingeben"); + inv.setItem(Material.SUGAR); + inv.setCallback(s -> p.performCommand("speed " + s)); + inv.open(); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionGuiItem.java new file mode 100644 index 00000000..c6a8999d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionGuiItem.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.util.items; + +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.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; + +@Linked(LinkageType.GUI_ITEM) +public class WaterVisionGuiItem extends GuiItem { + + public WaterVisionGuiItem() { + super(18); + } + + @Override + public ItemStack getItem(Player player) { + if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { + return new SWItem(Material.WATER_BUCKET, ColorConfig.BASE + "Wassersicht: " + ColorConfig.HIGHLIGHT + "Aktiviert").getItemStack(); + } else { + return new SWItem(Material.BUCKET, ColorConfig.BASE + "Wassersicht: " + ColorConfig.HIGHLIGHT + "Deaktiviert").getItemStack(); + } + } + + @Override + public boolean click(ClickType click, Player p) { + p.performCommand("wv"); + return true; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java index 1bfeda28..7e13c9ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/GuiItem.java @@ -42,12 +42,4 @@ public abstract class GuiItem { } public abstract Permission permission(); - - @Override - public String toString() { - return "GuiItem{" + - "slot=" + slot + ", " + - "class=" + this.getClass().getName() + - '}'; - } }