Add Trapper game class to the CTF system

Introduced the new "Trapper" class with unique armor, tools, and abilities to enhance gameplay. The Trapper specializes in utilizing powdered snow traps to hinder the enemy team. This includes creating necessary implementations and updating retrieval logic.
This commit is contained in:
Teriuihi 2025-02-28 23:12:13 +01:00
parent 3550d75634
commit d56e8eaea5
4 changed files with 87 additions and 0 deletions

View File

@ -25,6 +25,8 @@ import java.util.List;
@Slf4j
public abstract class GameClass {
//TODO simple class that does powedered snow
//TODO mage uses up more snowballs shot gun style immediately spawn them when thrown 5 sec or so cooldown? mayb 3
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
private final List<Material> armor;

View File

@ -4,6 +4,7 @@ import com.alttd.ctf.game.GameManager;
import com.alttd.ctf.game_class.creation.EngineerCreator;
import com.alttd.ctf.game_class.creation.FighterCreator;
import com.alttd.ctf.game_class.creation.TankCreator;
import com.alttd.ctf.game_class.creation.TrapperCreator;
import com.alttd.ctf.team.Team;
import java.util.ArrayList;
@ -24,6 +25,7 @@ public class GameClassRetrieval {
final List<GameClass> gameClasses = new ArrayList<>();
gameClasses.add(FighterCreator.createFighter(team.getColor()));
gameClasses.add(TankCreator.createTank(team.getColor()));
gameClasses.add(TrapperCreator.createTrapper(team.getColor()));
gameClasses.add(EngineerCreator.createEngineer(team.getColor()));
return gameClasses;
}

View File

@ -0,0 +1,68 @@
package com.alttd.ctf.game_class.creation;
import com.alttd.ctf.game_class.GameClass;
import com.alttd.ctf.game_class.implementations.Tank;
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.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;
@Slf4j
public class TrapperCreator {
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
@Contract("_ -> new")
public static @NotNull GameClass createTrapper(@NotNull TeamColor teamColor) {//TODO add ability to become temp invulnerable (with some particle effects mayb?)
return new Tank(getArmor(), getTools(teamColor), getDisplayItem(teamColor),
20, 7, 4);
}
@Contract(value = " -> new", pure = true)
private static @Unmodifiable List<Material> getArmor() {
return (List.of(Material.LEATHER_BOOTS, Material.LEATHER_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.AIR));
}
@Contract("_ -> new")
private static @NotNull @Unmodifiable List<ItemStack> getTools(TeamColor teamColor) {
return (List.of(getShovel(teamColor), getPowderedSnow(teamColor)));
}
private static @NotNull ItemStack getPowderedSnow(@NotNull TeamColor teamColor) {
ItemStack powderedSnow = new ItemStack(Material.POWDER_SNOW_BUCKET);
powderedSnow.setAmount(16);
ItemMeta itemMeta = powderedSnow.getItemMeta();
itemMeta.itemName(MiniMessage.miniMessage().deserialize(
String.format("<color:%s>Snow Trap</color>", teamColor.hex())));
powderedSnow.setItemMeta(itemMeta);
return powderedSnow;
}
private static @NotNull ItemStack getShovel(@NotNull TeamColor teamColor) {
ItemStack shovel = new ItemStack(Material.WOODEN_SHOVEL);
ItemMeta meta = shovel.getItemMeta();
meta.setUnbreakable(true);
meta.itemName(miniMessage.deserialize(String.format("<color:%s>Snow shovel</color>", teamColor.hex())));
shovel.setItemMeta(meta);
return shovel;
}
private static @NotNull ItemStack getDisplayItem(@NotNull TeamColor teamColor) {
ItemStack itemStack = new ItemStack(Material.POWDER_SNOW_BUCKET);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.displayName(miniMessage.deserialize(String.format("<color:%s>Trapper</color>", teamColor.hex())));
itemMeta.lore(List.of(
miniMessage.deserialize("<gold>The Trapper is a normal class, but it has a trick up it's sleeve</gold>"),
miniMessage.deserialize("<gold>They can place their powdered snow to trap the enemy team.</gold>")
));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}

View File

@ -0,0 +1,15 @@
package com.alttd.ctf.game_class.implementations;
import com.alttd.ctf.game_class.GameClass;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class Trapper extends GameClass {
protected Trapper(@NotNull List<Material> armor, @NotNull List<ItemStack> tools, @NotNull ItemStack displayItem,
double health, int throwTickSpeed, int damage) {
super(armor, tools, displayItem, health, throwTickSpeed, damage);
}
}