Fix and Add some GUI Stuff and All Region Items
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
f0fa92f5ca
Commit
4228ea291d
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -31,7 +31,7 @@ public class RegionUtils_15 {
|
|||||||
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockType mapColor(BlockType original, Color color) {
|
public BlockType mapColor(BlockType original, Color color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case WHITE:
|
case WHITE:
|
||||||
if (original == BlockTypes.YELLOW_CONCRETE) {
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
@ -42,10 +42,12 @@ public enum Permission {
|
|||||||
target.setWorldEdit(!target.isWorldEdit());
|
target.setWorldEdit(!target.isWorldEdit());
|
||||||
sendMessages(player, target.isWorldEdit(), target, "WorldEdit verwenden");
|
sendMessages(player, target.isWorldEdit(), target, "WorldEdit verwenden");
|
||||||
}),
|
}),
|
||||||
MEMBER(bauweltMember -> true);
|
MEMBER(bauweltMember -> true),
|
||||||
|
OWNER(bauweltMember -> false);
|
||||||
|
|
||||||
private final Predicate<BauweltMember> permissionPredicate;
|
private final Predicate<BauweltMember> permissionPredicate;
|
||||||
private BiConsumer<Player, BauweltMember> permissionChange = (player, bauweltMember) -> {};
|
private final BiConsumer<Player, BauweltMember> permissionChange = (player, bauweltMember) -> {
|
||||||
|
};
|
||||||
|
|
||||||
public boolean hasPermission(Player member) {
|
public boolean hasPermission(Player member) {
|
||||||
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||||
|
@ -19,13 +19,19 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.gui;
|
package de.steamwar.bausystem.features.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
import de.steamwar.bausystem.linkage.GuiItem;
|
import de.steamwar.bausystem.linkage.GuiItem;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class BauGUI {
|
public class BauGUI {
|
||||||
@ -35,6 +41,15 @@ public class BauGUI {
|
|||||||
private static final Set<Player> OPEN_INVS = new HashSet<>();
|
private static final Set<Player> OPEN_INVS = new HashSet<>();
|
||||||
private static boolean updating = false;
|
private static boolean updating = false;
|
||||||
|
|
||||||
|
private static final ItemStack GUI_ITEM;
|
||||||
|
|
||||||
|
static {
|
||||||
|
GUI_ITEM = new ItemStack(Material.NETHER_STAR);
|
||||||
|
ItemMeta meta = GUI_ITEM.getItemMeta();
|
||||||
|
meta.setDisplayName(ColorConfig.HIGHLIGHT + "Bau GUI");
|
||||||
|
GUI_ITEM.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
public static void addItem(GuiItem item) {
|
public static void addItem(GuiItem item) {
|
||||||
ITEMS.add(item);
|
ITEMS.add(item);
|
||||||
}
|
}
|
||||||
@ -44,12 +59,23 @@ public class BauGUI {
|
|||||||
OPEN_INVS.add(p);
|
OPEN_INVS.add(p);
|
||||||
}
|
}
|
||||||
SWInventory inv = new SWInventory(p, 5 * 9, "Bau GUI");
|
SWInventory inv = new SWInventory(p, 5 * 9, "Bau GUI");
|
||||||
ITEMS.forEach(item -> inv.setItem(item.getSlot(), item.getItem(p), item::click));
|
ITEMS.forEach(item -> inv.setItem(item.getSlot(), permissionLore(item.getItem(p), item.permission(), p), clickType -> {
|
||||||
|
if (item.permission().hasPermission(p)) {
|
||||||
|
if (item.click(clickType, p)) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.closeInventory();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Du hast nicht genug rechte um dies zu tun");
|
||||||
|
}
|
||||||
|
}));
|
||||||
inv.addCloseCallback(clickType -> {
|
inv.addCloseCallback(clickType -> {
|
||||||
if (!updating) {
|
if (!updating) {
|
||||||
OPEN_INVS.remove(p);
|
OPEN_INVS.remove(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
inv.open();
|
||||||
|
System.out.println(Arrays.toString(ITEMS.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update() {
|
public static void update() {
|
||||||
@ -57,4 +83,36 @@ public class BauGUI {
|
|||||||
OPEN_INVS.forEach(BauGUI::openBauGui);
|
OPEN_INVS.forEach(BauGUI::openBauGui);
|
||||||
updating = false;
|
updating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void giveItem(Player p) {
|
||||||
|
SWUtils.giveItemToPlayer(p, GUI_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack permissionLore(ItemStack itemStack, Permission permission, Player p) {
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
if (!permission.hasPermission(p)) {
|
||||||
|
List<String> lore = meta.getLore();
|
||||||
|
if (lore == null) {
|
||||||
|
lore = Collections.singletonList(ColorConfig.ERROR + permissionString(permission));
|
||||||
|
} else {
|
||||||
|
lore.add(ColorConfig.ERROR + permissionString(permission));
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
}
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String permissionString(Permission permission) {
|
||||||
|
switch (permission) {
|
||||||
|
case OWNER:
|
||||||
|
return "Das ist nicht deine Bauwelt";
|
||||||
|
case WORLD:
|
||||||
|
return "Du darfst hier die Welt nicht einstellen";
|
||||||
|
case WORLDEDIT:
|
||||||
|
return "Du darfst hier kein Worldedit benutzen";
|
||||||
|
default:
|
||||||
|
return "Du must ein Member der Bauwelt sein";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,25 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.gui;
|
package de.steamwar.bausystem.features.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
public class BauGUICommand extends SWCommand {
|
public class BauGUICommand extends SWCommand {
|
||||||
|
|
||||||
protected BauGUICommand() {
|
protected BauGUICommand() {
|
||||||
super("gui", "baugui");
|
super("gui", "baugui");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String... args) {
|
||||||
|
BauGUI.openBauGui(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("item")
|
||||||
|
public void giveItem(Player p) {
|
||||||
|
BauGUI.giveItem(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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.Color;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.inventory.SWListInv;
|
||||||
|
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;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class ColorGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public ColorGuiItem() {
|
||||||
|
super(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material mapColor(Color color) {
|
||||||
|
switch (color) {
|
||||||
|
case RED:
|
||||||
|
return Material.RED_CONCRETE;
|
||||||
|
case CYAN:
|
||||||
|
return Material.CYAN_CONCRETE;
|
||||||
|
case BLACK:
|
||||||
|
return Material.BLACK_CONCRETE;
|
||||||
|
case BLUE:
|
||||||
|
return Material.BLUE_CONCRETE;
|
||||||
|
case BROWN:
|
||||||
|
return Material.BROWN_CONCRETE;
|
||||||
|
case GRAY:
|
||||||
|
return Material.GRAY_CONCRETE;
|
||||||
|
case GREEN:
|
||||||
|
return Material.GREEN_CONCRETE;
|
||||||
|
case LIGHT_BLUE:
|
||||||
|
return Material.LIGHT_BLUE_CONCRETE;
|
||||||
|
case LIGHT_GRAY:
|
||||||
|
return Material.LIGHT_GRAY_CONCRETE;
|
||||||
|
case LIME:
|
||||||
|
return Material.LIME_CONCRETE;
|
||||||
|
case MAGENTA:
|
||||||
|
return Material.MAGENTA_CONCRETE;
|
||||||
|
case ORANGE:
|
||||||
|
return Material.ORANGE_CONCRETE;
|
||||||
|
case PINK:
|
||||||
|
return Material.PINK_CONCRETE;
|
||||||
|
case PURPLE:
|
||||||
|
return Material.PURPLE_CONCRETE;
|
||||||
|
case WHITE:
|
||||||
|
return Material.WHITE_CONCRETE;
|
||||||
|
default:
|
||||||
|
return Material.YELLOW_CONCRETE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.closeInventory();
|
||||||
|
ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class);
|
||||||
|
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||||
|
for (ColorMode value : ColorMode.values()) {
|
||||||
|
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, value.getChatValue(), Collections.emptyList(), value == current, clickType -> {
|
||||||
|
}), value));
|
||||||
|
}
|
||||||
|
SWListInv<ColorMode> inv = new SWListInv<ColorMode>(p, "Farbe Wählen", items, (clickType, colorMode) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("color " + colorMode.getChatValue());
|
||||||
|
});
|
||||||
|
inv.open();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.OWNER;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
public FireGuiItem() {
|
||||||
|
super(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.performCommand("fire");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLD;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
public FreezeGuiItem() {
|
||||||
|
super(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
ItemStack itemStack = new ItemStack(Material.REDSTONE);
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
meta.setDisplayName(ColorConfig.BASE + "Freeze: " + ColorConfig.HIGHLIGHT + "Ausgeschaltet");
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.performCommand("freeze");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLD;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
public ProtectGuiItem() {
|
||||||
|
super(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
ItemStack itemStack = new ItemStack(Material.STONE);
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
meta.setDisplayName(ColorConfig.BASE + "Protect: " + ColorConfig.HIGHLIGHT + "Eingeschaltet");
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.performCommand("protect");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLDEDIT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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 de.steamwar.inventory.SWListInv;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
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;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class ResetGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public ResetGuiItem() {
|
||||||
|
super(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
if (click == ClickType.LEFT) {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("reset");
|
||||||
|
} else {
|
||||||
|
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
|
||||||
|
for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) {
|
||||||
|
Material m;
|
||||||
|
if (schem.getItem().isEmpty())
|
||||||
|
m = SWItem.getMaterial("CAULDRON_ITEM");
|
||||||
|
else
|
||||||
|
m = SWItem.getMaterial(schem.getItem());
|
||||||
|
|
||||||
|
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> {
|
||||||
|
});
|
||||||
|
schemList.add(new SWListInv.SWListEntry<>(item, schem));
|
||||||
|
}
|
||||||
|
SWListInv<Schematic> inv = new SWListInv<>(p, "Reset Prototypen wählen", schemList, (clickType, schematic) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("reset " + schematic.getSchemName());
|
||||||
|
});
|
||||||
|
p.closeInventory();
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLDEDIT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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 de.steamwar.inventory.SWListInv;
|
||||||
|
import de.steamwar.sql.Schematic;
|
||||||
|
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;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class TestblockGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public TestblockGuiItem() {
|
||||||
|
super(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
if (click == ClickType.LEFT) {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("testblock");
|
||||||
|
} else {
|
||||||
|
p.closeInventory();
|
||||||
|
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
|
||||||
|
for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) {
|
||||||
|
Material m;
|
||||||
|
if (schem.getItem().isEmpty())
|
||||||
|
m = SWItem.getMaterial("CAULDRON_ITEM");
|
||||||
|
else
|
||||||
|
m = SWItem.getMaterial(schem.getItem());
|
||||||
|
|
||||||
|
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> {
|
||||||
|
});
|
||||||
|
schemList.add(new SWListInv.SWListEntry<>(item, schem));
|
||||||
|
}
|
||||||
|
SWListInv<Schematic> inv = new SWListInv<>(p, "Testblock wählen", schemList, (clickType, schematic) -> {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("testblock " + schematic.getSchemName());
|
||||||
|
});
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLDEDIT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* 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.region.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.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||||
|
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 org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class TntGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public TntGuiItem() {
|
||||||
|
super(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
if (click == ClickType.LEFT) {
|
||||||
|
p.performCommand("tnt");
|
||||||
|
return true;
|
||||||
|
} 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.open();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTntMode(TNTMode mode, Player p) {
|
||||||
|
p.closeInventory();
|
||||||
|
switch (mode) {
|
||||||
|
case ONLY_TB:
|
||||||
|
p.performCommand("tnt tb");
|
||||||
|
break;
|
||||||
|
case ALLOW:
|
||||||
|
p.performCommand("tnt on");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
p.performCommand("tnt off");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLD;
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.linkage;
|
package de.steamwar.bausystem.linkage;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -34,9 +35,19 @@ public abstract class GuiItem {
|
|||||||
|
|
||||||
public abstract ItemStack getItem(Player player);
|
public abstract ItemStack getItem(Player player);
|
||||||
|
|
||||||
public abstract boolean click(ClickType click);
|
public abstract boolean click(ClickType click, Player p);
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
BauGUI.update();
|
BauGUI.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Permission permission();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GuiItem{" +
|
||||||
|
"slot=" + slot +
|
||||||
|
"class=" + this.getClass().getName() +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren