mondtam ma megcsinalom

This commit is contained in:
2025-02-23 23:06:12 +01:00
parent dc0072ae62
commit 2b5b840cbf
9 changed files with 353 additions and 121 deletions

View File

@@ -3,7 +3,6 @@ package hu.jgj52.wolfFFA.Commands;
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;
@@ -13,10 +12,13 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
public class EditKitCommand implements CommandExecutor, TabCompleter {
@@ -40,18 +42,20 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
return -1;
}
private int[] getItemSlotArray(String key, String kit, Player player) {
private @NotNull List<Integer> getItemSlotArray(String key, String kit, Player player) {
String path = "kits." + kit + "." + player.getUniqueId() + "." + key;
if (plugin.getConfig().contains(path)) {
try {
return new int[]{plugin.getConfig().getInt(path)};
} catch (NumberFormatException e) {
plugin.getLogger().warning("Invalid slot number in config for " + path);
List<Integer> slots = plugin.getConfig().getIntegerList(path);
if (!slots.isEmpty()) {
return slots;
} else {
plugin.getLogger().warning("Invalid or empty slot numbers in config for " + path);
}
}
return new int[]{-1};
return Collections.singletonList(-1);
}
@Override
@@ -95,93 +99,197 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
Inventory inv = player.getInventory();
switch (args[0]) {
case "sword":
ItemStack swordsword = new ItemStack(Material.DIAMOND_SWORD);
swordsword.addEnchantment(Enchantment.UNBREAKING, 3);
if (true) {
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
inv.clear();
inv.clear();
inv.setItem(getItemSlot("sword", "sword", player), swordsword);
inv.setItem(getItemSlot("sword", "sword", player), sword);
infoMeta.setDisplayName("§fSword Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
infoMeta.setDisplayName("§fSword Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
player.openInventory(gui);
}
break;
case "uhc":
ItemStack uhchelmet = new ItemStack(Material.DIAMOND_HELMET);
ItemStack uhcchestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack uhcleggings = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack uhcboots = new ItemStack(Material.DIAMOND_BOOTS);
ItemStack uhcaxe = new ItemStack(Material.DIAMOND_AXE);
ItemStack uhcsword = new ItemStack(Material.DIAMOND_SWORD);
ItemStack uhclava = 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 uhccrossbow = new ItemStack(Material.CROSSBOW);
ItemStack uhcbow = new ItemStack(Material.BOW);
ItemStack uhcarrow = new ItemStack(Material.ARROW, 16);
ItemStack uhcshield = new ItemStack(Material.SHIELD);
ItemStack uhcplanks = new ItemStack(Material.OAK_PLANKS, 64);
ItemStack uhcpickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
if (true) {
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
ItemStack axe = new ItemStack(Material.DIAMOND_AXE);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemStack lava = new ItemStack(Material.LAVA_BUCKET);
ItemStack cobweb = new ItemStack(Material.COBWEB, 8);
ItemStack cobblestone = new ItemStack(Material.COBBLESTONE, 64);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 13);
ItemStack water = new ItemStack(Material.WATER_BUCKET);
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
ItemStack bow = new ItemStack(Material.BOW);
ItemStack arrow = new ItemStack(Material.ARROW, 16);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack planks = new ItemStack(Material.OAK_PLANKS, 64);
ItemStack pickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
inv.clear();
inv.clear();
uhchelmet.addEnchantment(Enchantment.PROTECTION, 2);
uhcchestplate.addEnchantment(Enchantment.PROTECTION, 3);
uhcleggings.addEnchantment(Enchantment.PROTECTION, 3);
uhcboots.addEnchantment(Enchantment.PROTECTION, 3);
uhcaxe.addEnchantment(Enchantment.SHARPNESS, 1);
uhcaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
uhcsword.addEnchantment(Enchantment.SHARPNESS, 4);
uhccrossbow.addEnchantment(Enchantment.PIERCING, 1);
uhcbow.addEnchantment(Enchantment.POWER, 1);
uhcpickaxe.addEnchantment(Enchantment.UNBREAKING,3);
uhcpickaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
helmet.addEnchantment(Enchantment.PROTECTION, 2);
chestplate.addEnchantment(Enchantment.PROTECTION, 3);
leggings.addEnchantment(Enchantment.PROTECTION, 3);
boots.addEnchantment(Enchantment.PROTECTION, 3);
axe.addEnchantment(Enchantment.SHARPNESS, 1);
axe.addEnchantment(Enchantment.EFFICIENCY, 3);
sword.addEnchantment(Enchantment.SHARPNESS, 4);
crossbow.addEnchantment(Enchantment.PIERCING, 1);
bow.addEnchantment(Enchantment.POWER, 1);
pickaxe.addEnchantment(Enchantment.UNBREAKING, 3);
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
inv.setItem(getItemSlot("axe", "uhc", player), uhcaxe);
inv.setItem(getItemSlot("sword", "uhc", player), uhcsword);
for (int slot : getItemSlotArray("lava", "uhc", player)) {
inv.setItem(slot, uhclava);
inv.setItem(getItemSlot("axe", "uhc", player), axe);
inv.setItem(getItemSlot("sword", "uhc", player), sword);
for (int slot : getItemSlotArray("lava", "uhc", player)) {
inv.setItem(slot, lava);
}
inv.setItem(getItemSlot("cobweb", "uhc", player), cobweb);
inv.setItem(getItemSlot("cobblestone", "uhc", player), cobblestone);
inv.setItem(getItemSlot("goldenapple", "uhc", player), goldenapple);
for (int slot : getItemSlotArray("water", "uhc", player)) {
inv.setItem(slot, water);
}
inv.setItem(getItemSlot("crossbow", "uhc", player), crossbow);
inv.setItem(getItemSlot("bow", "uhc", player), bow);
for (int slot : getItemSlotArray("shield", "uhc", player)) {
inv.setItem(slot, shield);
}
inv.setItem(getItemSlot("arrow", "uhc", player), arrow);
inv.setItem(getItemSlot("planks", "uhc", player), planks);
inv.setItem(getItemSlot("pickaxe", "uhc", player), pickaxe);
infoMeta.setDisplayName("§fUHC Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
}
inv.setItem(getItemSlot("cobweb", "uhc", player), uhccobweb);
inv.setItem(getItemSlot("cobblestone", "uhc", player), uhccobblestone);
inv.setItem(getItemSlot("goldenapple", "uhc", player), uhcgoldenapple);
for (int slot : getItemSlotArray("water", "uhc", player)) {
inv.setItem(slot, uhcwater);
}
inv.setItem(getItemSlot("crossbow", "uhc", player), uhccrossbow);
inv.setItem(getItemSlot("bow", "uhc", player), uhcbow);
for (int slot : getItemSlotArray("shield", "uhc", player)) {
inv.setItem(slot, uhcshield);
}
inv.setItem(getItemSlot("arrow", "uhc", player), uhcarrow);
inv.setItem(getItemSlot("planks", "uhc", player), uhcplanks);
inv.setItem(getItemSlot("pickaxe", "uhc", player), uhcpickaxe);
break;
case "boxcart":
if (true) {
ItemStack axe = new ItemStack(Material.NETHERITE_AXE);
ItemStack sword = new ItemStack(Material.NETHERITE_SWORD);
ItemStack enderpearl = new ItemStack(Material.ENDER_PEARL, 16);
ItemStack rail = new ItemStack(Material.RAIL, 64);
ItemStack cart = new ItemStack(Material.TNT_MINECART);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 64);
ItemStack cobweb = new ItemStack(Material.COBWEB, 64);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack bow = new ItemStack(Material.BOW);
ItemStack arrow = new ItemStack(Material.ARROW, 64);
ItemStack fireresistance = new ItemStack(Material.SPLASH_POTION);
ItemStack strength = new ItemStack(Material.SPLASH_POTION);
ItemStack speed = new ItemStack(Material.SPLASH_POTION);
ItemStack cherrylog = new ItemStack(Material.CHERRY_LOG, 64);
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
ItemStack flintandsteel = new ItemStack(Material.FLINT_AND_STEEL);
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
infoMeta.setDisplayName("§fUHC Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
sword.addEnchantment(Enchantment.SHARPNESS, 5);
sword.addEnchantment(Enchantment.SWEEPING_EDGE, 3);
sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
sword.addEnchantment(Enchantment.KNOCKBACK, 1);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
sword.addEnchantment(Enchantment.MENDING, 1);
axe.addEnchantment(Enchantment.SHARPNESS, 5);
axe.addEnchantment(Enchantment.EFFICIENCY, 5);
axe.addEnchantment(Enchantment.UNBREAKING, 3);
axe.addEnchantment(Enchantment.MENDING, 1);
bow.addEnchantment(Enchantment.POWER, 5);
bow.addEnchantment(Enchantment.PUNCH, 2);
bow.addEnchantment(Enchantment.FLAME, 1);
bow.addEnchantment(Enchantment.UNBREAKING, 3);
bow.addEnchantment(Enchantment.MENDING, 1);
crossbow.addEnchantment(Enchantment.PIERCING, 4);
crossbow.addEnchantment(Enchantment.QUICK_CHARGE, 3);
crossbow.addEnchantment(Enchantment.UNBREAKING, 3);
crossbow.addEnchantment(Enchantment.MENDING, 1);
flintandsteel.addEnchantment(Enchantment.UNBREAKING, 3);
flintandsteel.addEnchantment(Enchantment.MENDING, 1);
shield.addEnchantment(Enchantment.UNBREAKING, 3);
shield.addEnchantment(Enchantment.MENDING, 1);
player.openInventory(gui);
PotionMeta fireresistancemeta = (PotionMeta) fireresistance.getItemMeta();
fireresistancemeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0), true);
fireresistancemeta.setDisplayName("§fSplash Potion of Fire Resistance");
fireresistance.setItemMeta(fireresistancemeta);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§fSplash Potion of Strength");
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1800, 1), true);
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
speed.setItemMeta(speedmeta);
inv.setItem(getItemSlot("axe", "boxcart", player), axe);
inv.setItem(getItemSlot("sword", "boxcart", player), sword);
for (int slot : getItemSlotArray("enderpearl", "boxcart", player)) {
inv.setItem(slot, enderpearl);
}
inv.setItem(getItemSlot("rail", "boxcart", player), rail);
for (int slot : getItemSlotArray("cart", "boxcart", player)) {
inv.setItem(slot, cart);
}
inv.setItem(getItemSlot("goldenapple", "boxcart", player), goldenapple);
inv.setItem(getItemSlot("cobweb", "boxcart", player), cobweb);
inv.setItem(getItemSlot("shield", "boxcart", player), shield);
inv.setItem(getItemSlot("bow", "boxcart", player), bow);
inv.setItem(getItemSlot("arrow", "boxcart", player), arrow);
for (int slot : getItemSlotArray("fireresistance", "boxcart", player)) {
inv.setItem(slot, fireresistance);
}
for (int slot : getItemSlotArray("strength", "boxcart", player)) {
inv.setItem(slot, strength);
}
for (int slot : getItemSlotArray("speed", "boxcart", player)) {
inv.setItem(slot, speed);
}
inv.setItem(getItemSlot("cherrylog", "boxcart", player), cherrylog);
inv.setItem(getItemSlot("crossbow", "boxcart", player), crossbow);
inv.setItem(getItemSlot("flintandsteel", "boxcart", player), flintandsteel);
inv.setItem(getItemSlot("totem", "boxcart", player), totem);
infoMeta.setDisplayName("§fBoxCart Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
}
break;
default:
player.sendMessage("§cNincs ilyen FFA típus!");
@@ -196,7 +304,7 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) {
return List.of("sword", "uhc");
return List.of("sword", "uhc", "boxcart");
}
return List.of();
}