Add more Some™ GuiItems
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
d74102b66d
Commit
bad4b79500
@ -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<Player> 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() {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Player> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.other;
|
||||
package de.steamwar.bausystem.features.other.items;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.ColorConfig;
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Player, LastSelect> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -42,12 +42,4 @@ public abstract class GuiItem {
|
||||
}
|
||||
|
||||
public abstract Permission permission();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GuiItem{" +
|
||||
"slot=" + slot + ", " +
|
||||
"class=" + this.getClass().getName() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren