From 98bb9bfb77517b20eb32710ad16d65848de61d83 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 1 Feb 2022 13:56:27 +0100 Subject: [PATCH] Add 4 new GuiItems Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 8 +++ .../bausystem/features/gui/BauGUI.java | 1 + .../features/other/items/ClearBauGuiItem.java | 56 +++++++++++++++ .../other/items/DeclutterBauGuiItem.java | 60 ++++++++++++++++ .../other/items/GamemodeBauGuiItem.java | 72 +++++++++++++++++++ .../other/items/KillAllBauGuiItem.java | 68 ++++++++++++++++++ 6 files changed, 265 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 986e5b91..8fe57999 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -870,6 +870,14 @@ OBSERVER_RETRACE_NO_TRACE = §7Kein Observer Trace zum neu berechnen OTHER_ITEMS_TELEPORT_NAME=§eTeleporter OTHER_ITEMS_TELEPORT_GUI_NAME=Teleportieren OTHER_ITEMS_TELEPORT_PLAYER_OFFLINE=§cDer Spieler ist Offline +OTHER_ITEMS_CLEAR_NAME=§eClear +OTHER_ITEMS_DECLUTTER_NAME=§eDeclutter +OTHER_ITEMS_GAMEMODE_NAME=§eGamemode +OTHER_ITEMS_GAMEMODE_LORE_1=§eRechts-Click§8:§7 Umschalten zwischen Creative und Spectator +OTHER_ITEMS_GAMEMODE_LORE_2=§eLinks-Click§8:§7 Umschalten zwischen Survival und Adventure +OTHER_ITEMS_KILLALL_NAME=§eKillAll +OTHER_ITEMS_KILLALL_LORE_1=§eOhne Shift§8:§7 nur die Region +OTHER_ITEMS_KILLALL_LORE_2=§eMit Shift§8:§7 Global OTHER_SLOT_INVALID_SLOT=§cInvalider Slot OTHER_NOCLIP_SLOT_INFO=§7Mit /slot kannst du den ausgewählten Slot ändern und einen anderen Block in den Slot nehmen. OTHER_NOCLIP_SLOT_HELP_PICK = §8/§eslot pick §8-§7 Lege den angeguckten Block ins Inventar 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 72087f9d..a8978852 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -56,6 +56,7 @@ public class BauGUI { 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()); } + System.out.println("Added Item: " + item.getId()); ITEMS.put(item.getId(), item); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java new file mode 100644 index 00000000..3c9a56b0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.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.other.items; + +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 ClearBauGuiItem extends BauGuiItem { + + public ClearBauGuiItem() { + super(29); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("OTHER_ITEMS_CLEAR_NAME", player)).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + p.getInventory().clear(); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java new file mode 100644 index 00000000..09077542 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.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.items; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.other.DeclutterCommand; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; +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 DeclutterBauGuiItem extends BauGuiItem { + + @LinkedInstance + private DeclutterCommand declutterCommand; + + public DeclutterBauGuiItem() { + super(30); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("OTHER_ITEMS_DECLUTTER_NAME", player)).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + declutterCommand.genericCommand(p); + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java new file mode 100644 index 00000000..cc4a6c1d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java @@ -0,0 +1,72 @@ +/* + * 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.items; + +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.GameMode; +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.BAU_GUI_ITEM) +public class GamemodeBauGuiItem extends BauGuiItem { + + public GamemodeBauGuiItem() { + super(31); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_2", player)), false, clickType -> {}).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + GameMode gameMode = p.getGameMode(); + if (click.isRightClick()) { + if (gameMode != GameMode.CREATIVE) { + p.setGameMode(GameMode.CREATIVE); + } else { + p.setGameMode(GameMode.SPECTATOR); + } + } else if (click.isLeftClick()) { + if (gameMode != GameMode.SURVIVAL) { + p.setGameMode(GameMode.SURVIVAL); + } else { + p.setGameMode(GameMode.ADVENTURE); + } + } + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java new file mode 100644 index 00000000..95b6567f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.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.other.items; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.other.KillAllCommand; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.bausystem.region.utils.RegionSelectionType; +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.BAU_GUI_ITEM) +public class KillAllBauGuiItem extends BauGuiItem { + + @LinkedInstance + private KillAllCommand killAllCommand; + + public KillAllBauGuiItem() { + super(32); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.LAVA_BUCKET, BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_2", player)), false, clickType -> {}).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + if (click.isShiftClick()) { + killAllCommand.genericCommand(p, RegionSelectionType.GLOBAL); + } else { + killAllCommand.genericCommand(p, RegionSelectionType.LOCAL); + } + return false; + } + + @Override + public Permission permission() { + return Permission.MEMBER; + } +}