Add Tank class and update Fighter tools in CTF game
Introduced a new Tank game class with specialized attributes and equipment, and added it to the class selection setup. Enhanced the Fighter class by introducing a healing potion tool to improve gameplay utility. These changes enhance gameplay diversity and team strategies.
This commit is contained in:
parent
4aa6a0d512
commit
9eccb130e5
|
|
@ -5,6 +5,7 @@ import com.alttd.ctf.config.Messages;
|
|||
import com.alttd.ctf.game.GameManager;
|
||||
import com.alttd.ctf.game_class.GameClass;
|
||||
import com.alttd.ctf.game_class.creation.FighterCreator;
|
||||
import com.alttd.ctf.game_class.creation.TankCreator;
|
||||
import com.alttd.ctf.gui.ClassSelectionGUI;
|
||||
import com.alttd.ctf.team.TeamPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
|
@ -25,6 +26,7 @@ public class SelectClass extends SubCommand {
|
|||
this.gameClasses = new HashMap<>();
|
||||
gameManager.getTeams().forEach(team -> {
|
||||
gameClasses.computeIfAbsent(team.getId(), teamId -> new ArrayList<>()).add(FighterCreator.createFighter(team.getColor()));
|
||||
gameClasses.computeIfAbsent(team.getId(), teamId -> new ArrayList<>()).add(TankCreator.createTank(team.getColor()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,27 +3,40 @@ package com.alttd.ctf.game_class.creation;
|
|||
import com.alttd.ctf.game_class.GameClass;
|
||||
import com.alttd.ctf.game_class.implementations.Fighter;
|
||||
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.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class FighterCreator {
|
||||
|
||||
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
public static GameClass createFighter(TeamColor teamColor) {
|
||||
return new Fighter(getArmor(), getTools(), getDisplayItem(teamColor), 15, 3, 5);
|
||||
return new Fighter(getArmor(), getTools(teamColor), getDisplayItem(teamColor), 15, 3, 5);
|
||||
}
|
||||
|
||||
private static List<Material> getArmor() {
|
||||
return (List.of(Material.AIR, Material.AIR, Material.LEATHER_CHESTPLATE, Material.AIR));
|
||||
}
|
||||
|
||||
private static List<ItemStack> getTools() {
|
||||
return (List.of());
|
||||
private static List<ItemStack> getTools(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(
|
||||
String.format("<color:%s>Emergency AOE med kit</color>", teamColor.hex())));
|
||||
healthPot.setItemMeta(potionMeta);
|
||||
healthPot.setAmount(3);
|
||||
return (List.of(healthPot));
|
||||
}
|
||||
|
||||
private static ItemStack getDisplayItem(TeamColor teamColor) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.alttd.ctf.game_class.creation;
|
||||
|
||||
import com.alttd.ctf.game_class.GameClass;
|
||||
import com.alttd.ctf.game_class.implementations.Fighter;
|
||||
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.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
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?)
|
||||
return new Fighter(getArmor(), getTools(teamColor), getDisplayItem(teamColor), 30, 7, 4);
|
||||
}
|
||||
|
||||
private static List<Material> getArmor() {
|
||||
return (List.of(Material.CHAINMAIL_BOOTS, Material.CHAINMAIL_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_HELMET));
|
||||
}
|
||||
|
||||
private static List<ItemStack> getTools(TeamColor teamColor) {
|
||||
ItemStack shield = new ItemStack(Material.SHIELD);
|
||||
ItemMeta itemMeta = shield.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
itemMeta.itemName(MiniMessage.miniMessage().deserialize(
|
||||
String.format("<color:%s>Shield</color>", teamColor.hex())));
|
||||
shield.setItemMeta(itemMeta);
|
||||
return (List.of(shield));
|
||||
}
|
||||
|
||||
private static ItemStack getDisplayItem(TeamColor teamColor) {
|
||||
ItemStack itemStack = new ItemStack(Material.SHIELD);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.displayName(miniMessage.deserialize(String.format("<color:%s>Tank</color>", teamColor.hex())));
|
||||
itemMeta.lore(List.of(
|
||||
miniMessage.deserialize("<gold>The Tank is slow but has a lot of health</gold>"),
|
||||
miniMessage.deserialize("<gold>They can protect themselves and their team with their shield.</gold>")
|
||||
));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 Tank extends GameClass {
|
||||
|
||||
protected Tank(@NotNull List<Material> armor, @NotNull List<ItemStack> tools, @NotNull ItemStack displayItem, double health, int throwTickSpeed, int damage) {
|
||||
super(armor, tools, displayItem, health, throwTickSpeed, damage);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user