diff --git a/src/main/java/com/alttd/ctf/game_class/creation/FighterCreator.java b/src/main/java/com/alttd/ctf/game_class/creation/FighterCreator.java index a8f7015..7173110 100644 --- a/src/main/java/com/alttd/ctf/game_class/creation/FighterCreator.java +++ b/src/main/java/com/alttd/ctf/game_class/creation/FighterCreator.java @@ -6,10 +6,14 @@ import com.alttd.ctf.team.TeamColor; import lombok.extern.slf4j.Slf4j; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionType; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; import java.util.List; @@ -18,28 +22,44 @@ public class FighterCreator { private static final MiniMessage miniMessage = MiniMessage.miniMessage(); - public static GameClass createFighter(TeamColor teamColor) { + @Contract("_ -> new") + public static @NotNull GameClass createFighter(@NotNull TeamColor teamColor) { return new Fighter(getArmor(), getTools(teamColor), getDisplayItem(teamColor), 15, 3, 5); } - private static List getArmor() { + @Contract(value = " -> new", pure = true) + private static @NotNull @Unmodifiable List getArmor() { return (List.of(Material.AIR, Material.AIR, Material.LEATHER_CHESTPLATE, Material.AIR)); } - private static List getTools(TeamColor teamColor) { + @Contract("_ -> new") + private static @NotNull @Unmodifiable List getTools(@NotNull TeamColor teamColor) { + return (List.of(getShovel(teamColor), getPotion(teamColor))); + } + + private static @NotNull ItemStack getPotion(@NotNull TeamColor teamColor) { ItemStack healthPot = new ItemStack(Material.SPLASH_POTION); if (!(healthPot.getItemMeta() instanceof PotionMeta potionMeta)) { throw new IllegalStateException("No potion meta from a splash potion"); } potionMeta.setBasePotionType(PotionType.STRONG_HEALING); - potionMeta.itemName(MiniMessage.miniMessage().deserialize( + potionMeta.itemName(miniMessage.deserialize( String.format("Emergency AOE med kit", teamColor.hex()))); healthPot.setItemMeta(potionMeta); healthPot.setAmount(3); - return (List.of(healthPot)); + return healthPot; } - private static ItemStack getDisplayItem(TeamColor teamColor) { + private static @NotNull ItemStack getShovel(@NotNull TeamColor teamColor) { + ItemStack shovel = new ItemStack(Material.WOODEN_SHOVEL); + ItemMeta meta = shovel.getItemMeta(); + meta.itemName(miniMessage.deserialize(String.format("Snow shovel", teamColor.hex()))); + meta.addEnchant(Enchantment.EFFICIENCY, 1, false); + shovel.setItemMeta(meta); + return shovel; + } + + private static @NotNull ItemStack getDisplayItem(@NotNull TeamColor teamColor) { ItemStack itemStack = new ItemStack(Material.IRON_SWORD); ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.displayName(miniMessage.deserialize(String.format("Fighter", teamColor.hex()))); diff --git a/src/main/java/com/alttd/ctf/game_class/creation/TankCreator.java b/src/main/java/com/alttd/ctf/game_class/creation/TankCreator.java index f48ca09..d2b7d89 100644 --- a/src/main/java/com/alttd/ctf/game_class/creation/TankCreator.java +++ b/src/main/java/com/alttd/ctf/game_class/creation/TankCreator.java @@ -9,6 +9,9 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; import java.util.List; @@ -17,25 +20,40 @@ public class TankCreator { private static final MiniMessage miniMessage = MiniMessage.miniMessage(); - public static GameClass createTank(TeamColor teamColor) {//TODO add ability to become temp invulnerable (with some particle effects mayb?) + @Contract("_ -> new") + public static @NotNull GameClass createTank(@NotNull TeamColor teamColor) {//TODO add ability to become temp invulnerable (with some particle effects mayb?) return new Fighter(getArmor(), getTools(teamColor), getDisplayItem(teamColor), 30, 7, 4); } - private static List getArmor() { + @Contract(value = " -> new", pure = true) + private static @Unmodifiable List getArmor() { return (List.of(Material.CHAINMAIL_BOOTS, Material.CHAINMAIL_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_HELMET)); } - private static List getTools(TeamColor teamColor) { + @Contract("_ -> new") + private static @NotNull @Unmodifiable List getTools(TeamColor teamColor) { + return (List.of(getShovel(teamColor), getShield(teamColor))); + } + + private static @NotNull ItemStack getShield(@NotNull TeamColor teamColor) { ItemStack shield = new ItemStack(Material.SHIELD); ItemMeta itemMeta = shield.getItemMeta(); itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); itemMeta.itemName(MiniMessage.miniMessage().deserialize( String.format("Shield", teamColor.hex()))); shield.setItemMeta(itemMeta); - return (List.of(shield)); + return shield; } - private static ItemStack getDisplayItem(TeamColor teamColor) { + private static @NotNull ItemStack getShovel(@NotNull TeamColor teamColor) { + ItemStack shovel = new ItemStack(Material.WOODEN_SHOVEL); + ItemMeta meta = shovel.getItemMeta(); + meta.itemName(miniMessage.deserialize(String.format("Snow shovel", teamColor.hex()))); + shovel.setItemMeta(meta); + return shovel; + } + + private static @NotNull ItemStack getDisplayItem(@NotNull TeamColor teamColor) { ItemStack itemStack = new ItemStack(Material.SHIELD); ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.displayName(miniMessage.deserialize(String.format("Tank", teamColor.hex())));