gui
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package hu.jgj52.wolfFFA.Commands;
|
||||
|
||||
import hu.jgj52.wolfFFA.WolfFFA;
|
||||
import hu.jgj52.wolfFFA.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -11,52 +12,96 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
private final WolfFFA plugin;
|
||||
private final Main plugin;
|
||||
|
||||
public EditKitCommand(WolfFFA plugin) {
|
||||
public EditKitCommand(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private int getItemSlot(String key, String kit, Player player) {
|
||||
String path = "kits." + kit + "." + player.getUniqueId() + "." + key;
|
||||
|
||||
if (plugin.getConfig().contains(path)) {
|
||||
try {
|
||||
return plugin.getConfig().getInt(path);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.getLogger().warning("Invalid slot number in config for " + path);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
if (cmds.hasPermission("wolfffa.command.editkit")) {
|
||||
if (cmds instanceof Player player) {
|
||||
if (args.length > 0) {
|
||||
Inventory gui = Bukkit.createInventory(null, 45, "Kit Edit");
|
||||
Inventory gui = Bukkit.createInventory(null, 27, "Kit Editor");
|
||||
|
||||
ItemStack saveKit = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta saveMeta = (SkullMeta) saveKit.getItemMeta();
|
||||
ItemStack saveKit = new ItemStack(Material.GREEN_STAINED_GLASS_PANE);
|
||||
ItemMeta saveMeta = saveKit.getItemMeta();
|
||||
|
||||
ItemStack info = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta infoMeta = (SkullMeta) info.getItemMeta();
|
||||
ItemStack infoItem = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||
ItemMeta infoMeta = infoItem.getItemMeta();
|
||||
|
||||
ItemStack undoKit = new ItemStack(Material.RED_STAINED_GLASS_PANE);
|
||||
ItemMeta undoMeta = undoKit.getItemMeta();
|
||||
if (saveMeta != null) {
|
||||
saveMeta.setDisplayName("§aSave");
|
||||
saveKit.setItemMeta(saveMeta);
|
||||
saveMeta.setDisplayName("§aSave Kit");
|
||||
saveKit.setItemMeta(saveMeta);
|
||||
} if (infoMeta != null) {
|
||||
infoMeta.setDisplayName("§fKit editor, you can customize your kit.");
|
||||
infoItem.setItemMeta(infoMeta);
|
||||
} if (undoMeta != null) {
|
||||
undoMeta.setDisplayName("§cUndo Changes");
|
||||
undoKit.setItemMeta(undoMeta);
|
||||
}
|
||||
|
||||
if (infoMeta != null) {
|
||||
infoMeta.setDisplayName("§aInformáció");
|
||||
infoMeta.setLore(Collections.singletonList("§5A 4. sor a hotbar, 5. sor 1. iteme az offhand."));
|
||||
info.setItemMeta(infoMeta);
|
||||
}
|
||||
|
||||
gui.setItem(37, info);
|
||||
gui.setItem(44, saveKit);
|
||||
gui.setItem(0, saveKit);
|
||||
gui.setItem(1, saveKit);
|
||||
gui.setItem(2, saveKit);
|
||||
gui.setItem(3, infoItem);
|
||||
gui.setItem(4, infoItem);
|
||||
gui.setItem(5, infoItem);
|
||||
gui.setItem(6, undoKit);
|
||||
gui.setItem(7, undoKit);
|
||||
gui.setItem(8, undoKit);
|
||||
gui.setItem(9, saveKit);
|
||||
gui.setItem(10, saveKit);
|
||||
gui.setItem(11, saveKit);
|
||||
gui.setItem(12, infoItem);
|
||||
gui.setItem(13, infoItem);
|
||||
gui.setItem(14, infoItem);
|
||||
gui.setItem(15, undoKit);
|
||||
gui.setItem(16, undoKit);
|
||||
gui.setItem(17, undoKit);
|
||||
gui.setItem(18, saveKit);
|
||||
gui.setItem(19, saveKit);
|
||||
gui.setItem(20, saveKit);
|
||||
gui.setItem(21, infoItem);
|
||||
gui.setItem(22, infoItem);
|
||||
gui.setItem(23, infoItem);
|
||||
gui.setItem(24, undoKit);
|
||||
gui.setItem(25, undoKit);
|
||||
gui.setItem(26, undoKit);
|
||||
Inventory inv = player.getInventory();
|
||||
switch (args[0]) {
|
||||
case "sword":
|
||||
ItemStack swordsword = new ItemStack(Material.DIAMOND_SWORD);
|
||||
swordsword.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
|
||||
gui.setItem(27, swordsword);
|
||||
inv.clear();
|
||||
|
||||
inv.setItem(getItemSlot("sword", "sword", player), swordsword);
|
||||
|
||||
player.openInventory(gui);
|
||||
break;
|
||||
@@ -68,10 +113,14 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
ItemStack uhcaxe = new ItemStack(Material.DIAMOND_AXE);
|
||||
ItemStack uhcsword = new ItemStack(Material.DIAMOND_SWORD);
|
||||
ItemStack uhclava = new ItemStack(Material.LAVA_BUCKET);
|
||||
ItemStack uhclava2 = new ItemStack(Material.LAVA_BUCKET);
|
||||
ItemStack uhccobweb = new ItemStack(Material.COBWEB, 8);
|
||||
ItemStack uhccobblestone = new ItemStack(Material.COBBLESTONE, 64);
|
||||
ItemStack uhcgoldenapple = new ItemStack(Material.GOLDEN_APPLE, 13);
|
||||
ItemStack uhcwater = new ItemStack(Material.WATER_BUCKET);
|
||||
ItemStack uhcwater2 = new ItemStack(Material.WATER_BUCKET);
|
||||
ItemStack uhcwater3 = new ItemStack(Material.WATER_BUCKET);
|
||||
ItemStack uhcwater4 = new ItemStack(Material.WATER_BUCKET);
|
||||
ItemStack uhccrossbow = new ItemStack(Material.CROSSBOW);
|
||||
ItemStack uhcbow = new ItemStack(Material.BOW);
|
||||
ItemStack uhcarrow = new ItemStack(Material.ARROW, 16);
|
||||
@@ -79,6 +128,7 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
ItemStack uhcplanks = new ItemStack(Material.OAK_PLANKS, 64);
|
||||
ItemStack uhcpickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
|
||||
|
||||
inv.clear();
|
||||
|
||||
uhchelmet.addEnchantment(Enchantment.PROTECTION, 2);
|
||||
uhcchestplate.addEnchantment(Enchantment.PROTECTION, 3);
|
||||
@@ -92,24 +142,41 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
uhcpickaxe.addEnchantment(Enchantment.UNBREAKING,3);
|
||||
uhcpickaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
|
||||
|
||||
gui.setItem(27, uhcaxe);
|
||||
gui.setItem(28, uhcsword);
|
||||
gui.setItem(29, uhclava);
|
||||
gui.setItem(30, uhccobweb);
|
||||
gui.setItem(31, uhccobblestone);
|
||||
gui.setItem(32, uhcgoldenapple);
|
||||
gui.setItem(33, uhcwater);
|
||||
gui.setItem(34, uhccrossbow);
|
||||
gui.setItem(35, uhcbow);
|
||||
gui.setItem(36, uhcshield);
|
||||
gui.setItem(0, uhcarrow);
|
||||
gui.setItem(4, uhcshield);
|
||||
gui.setItem(8, uhcplanks);
|
||||
gui.setItem(11, uhcpickaxe);
|
||||
gui.setItem(12, uhclava);
|
||||
gui.setItem(13, uhcwater);
|
||||
gui.setItem(14, uhcwater);
|
||||
gui.setItem(15, uhcwater);
|
||||
ItemMeta uhcmetalava2 = uhclava2.getItemMeta();
|
||||
ItemMeta uhcmetawater2 = uhcwater2.getItemMeta();
|
||||
ItemMeta uhcmetawater3 = uhcwater3.getItemMeta();
|
||||
ItemMeta uhcmetawater4 = uhcwater4.getItemMeta();
|
||||
|
||||
uhcmetalava2.getPersistentDataContainer().set(new NamespacedKey(String.valueOf(this), "lavab"), PersistentDataType.STRING, "lava2uuid");
|
||||
uhclava2.setItemMeta(uhcmetalava2);
|
||||
|
||||
uhcmetawater2.getPersistentDataContainer().set(new NamespacedKey(String.valueOf(this), "waterb"), PersistentDataType.STRING, "water2uuid");
|
||||
uhcwater2.setItemMeta(uhcmetawater2);
|
||||
|
||||
uhcmetawater3.getPersistentDataContainer().set(new NamespacedKey(String.valueOf(this), "waterc"), PersistentDataType.STRING, "water3uuid");
|
||||
uhcwater3.setItemMeta(uhcmetawater3);
|
||||
|
||||
uhcmetawater4.getPersistentDataContainer().set(new NamespacedKey(String.valueOf(this), "waterd"), PersistentDataType.STRING, "water4uuid");
|
||||
uhcwater4.setItemMeta(uhcmetawater4);
|
||||
|
||||
inv.setItem(getItemSlot("axe", "uhc", player), uhcaxe);
|
||||
inv.setItem(getItemSlot("sword", "uhc", player), uhcsword);
|
||||
inv.setItem(getItemSlot("lava", "uhc", player), uhclava);
|
||||
inv.setItem(getItemSlot("cobweb", "uhc", player), uhccobweb);
|
||||
inv.setItem(getItemSlot("cobblestone", "uhc", player), uhccobblestone);
|
||||
inv.setItem(getItemSlot("goldenapple", "uhc", player), uhcgoldenapple);
|
||||
inv.setItem(getItemSlot("water", "uhc", player), uhcwater);
|
||||
inv.setItem(getItemSlot("crossbow", "uhc", player), uhccrossbow);
|
||||
inv.setItem(getItemSlot("bow", "uhc", player), uhcbow);
|
||||
inv.setItem(getItemSlot("shield", "uhc", player), uhcshield);
|
||||
inv.setItem(getItemSlot("arrow", "uhc", player), uhcarrow);
|
||||
inv.setItem(getItemSlot("shield2", "uhc", player), uhcshield);
|
||||
inv.setItem(getItemSlot("planks", "uhc", player), uhcplanks);
|
||||
inv.setItem(getItemSlot("pickaxe", "uhc", player), uhcpickaxe);
|
||||
inv.setItem(getItemSlot("lava2", "uhc", player), uhclava2);
|
||||
inv.setItem(getItemSlot("water2", "uhc", player), uhcwater2);
|
||||
inv.setItem(getItemSlot("water3", "uhc", player), uhcwater3);
|
||||
inv.setItem(getItemSlot("water4", "uhc", player), uhcwater4);
|
||||
|
||||
player.openInventory(gui);
|
||||
break;
|
||||
@@ -127,28 +194,4 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
/*
|
||||
Inventory gui = Bukkit.createInventory(null, 45, "Sword Kit");
|
||||
|
||||
ItemStack saveKit = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta saveMeta = (SkullMeta) saveKit.getItemMeta();
|
||||
|
||||
ItemStack info = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta infoMeta = (SkullMeta) info.getItemMeta();
|
||||
|
||||
if (saveMeta != null) {
|
||||
saveMeta.setDisplayName("§aSave");
|
||||
saveKit.setItemMeta(saveMeta);
|
||||
}
|
||||
|
||||
if (infoMeta != null) {
|
||||
infoMeta.setDisplayName("§aInformáció");
|
||||
infoMeta.setLore(Collections.singletonList("§5A 4. sor a hotbar, 5. sor 1. iteme az offhand."));
|
||||
}
|
||||
|
||||
gui.setItem(44, saveKit);
|
||||
|
||||
player.openInventory(gui);
|
||||
break;
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user