This commit is contained in:
Luca
2021-11-24 20:29:53 +01:00
parent 980743ef62
commit e076e76c57
13 changed files with 223 additions and 434 deletions

View File

@ -10,17 +10,16 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.game.*;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.events.GameEndEvent;
import rip.tilly.bedwars.events.GameStartEvent;
import rip.tilly.bedwars.game.*;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.managers.hotbar.impl.HotbarItem;
import rip.tilly.bedwars.playerdata.currentgame.PlayerCurrentGameData;
import rip.tilly.bedwars.playerdata.PlayerData;
import rip.tilly.bedwars.playerdata.PlayerState;
import rip.tilly.bedwars.playerdata.currentgame.PlayerCurrentGameData;
import rip.tilly.bedwars.playerdata.currentgame.TeamUpgrades;
import rip.tilly.bedwars.utils.ItemBuilder;
import rip.tilly.bedwars.utils.ItemUtil;
import rip.tilly.bedwars.utils.PlayerUtil;
import rip.tilly.bedwars.utils.TtlHashMap;
@ -217,9 +216,6 @@ public class GameManager {
List<ItemStack> allItems = new ArrayList<>();
ItemStack sword = new ItemBuilder(Material.WOOD_SWORD).addUnbreakable().build();
if (teamUpgrades.isSharpenedSwords()) {
sword = new ItemBuilder(Material.WOOD_SWORD).enchantment(Enchantment.DAMAGE_ALL, 1).addUnbreakable().build();
}
allItems.add(sword);
if (currentGameData.isShears()) {
@ -278,217 +274,20 @@ public class GameManager {
return allItems;
}
public ItemStack[] getGameArmor(PlayerData playerData, TeamUpgrades teamUpgrades) {
public ItemStack[] getGameArmor(PlayerData playerData) {
Color color = playerData.getPlayerTeam().getColor();
PlayerCurrentGameData currentGameData = playerData.getCurrentGameData();
ItemStack leatherBoots = new ItemBuilder(Material.LEATHER_BOOTS).color(color).addUnbreakable().build();
ItemStack leatherLeggings = new ItemBuilder(Material.LEATHER_LEGGINGS).color(color).addUnbreakable().build();
ItemStack leatherChestplate = new ItemBuilder(Material.LEATHER_CHESTPLATE).color(color).addUnbreakable().build();
ItemStack leatherHelmet = new ItemBuilder(Material.LEATHER_HELMET).color(color).addUnbreakable().build();
ItemStack chainBoots = new ItemBuilder(Material.CHAINMAIL_BOOTS).addUnbreakable().build();
ItemStack chainLeggings = new ItemBuilder(Material.CHAINMAIL_LEGGINGS).addUnbreakable().build();
ItemStack ironBoots = new ItemBuilder(Material.IRON_BOOTS).addUnbreakable().build();
ItemStack ironLeggings = new ItemBuilder(Material.IRON_LEGGINGS).addUnbreakable().build();
ItemStack diamondBoots = new ItemBuilder(Material.DIAMOND_BOOTS).addUnbreakable().build();
ItemStack diamondLeggings = new ItemBuilder(Material.DIAMOND_LEGGINGS).addUnbreakable().build();
switch (teamUpgrades.getArmorLevel()) {
case 0:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
leatherBoots,
leatherLeggings,
leatherChestplate,
leatherHelmet
};
case CHAIN:
return new ItemStack[]{
chainBoots,
chainLeggings,
leatherChestplate,
leatherHelmet
};
case IRON:
return new ItemStack[]{
ironBoots,
ironLeggings,
leatherChestplate,
leatherHelmet
};
case DIAMOND:
return new ItemStack[]{
diamondBoots,
diamondLeggings,
leatherChestplate,
leatherHelmet
};
}
break;
case 1:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
ItemUtil.reEnchantItem(leatherBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
};
case CHAIN:
return new ItemStack[]{
ItemUtil.reEnchantItem(chainBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(chainLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
};
case IRON:
return new ItemStack[]{
ItemUtil.reEnchantItem(ironBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(ironLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
};
case DIAMOND:
return new ItemStack[]{
ItemUtil.reEnchantItem(diamondBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(diamondLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 1, true),
};
}
break;
case 2:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
ItemUtil.reEnchantItem(leatherBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
};
case CHAIN:
return new ItemStack[]{
ItemUtil.reEnchantItem(chainBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(chainLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
};
case IRON:
return new ItemStack[]{
ItemUtil.reEnchantItem(ironBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(ironLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
};
case DIAMOND:
return new ItemStack[]{
ItemUtil.reEnchantItem(diamondBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(diamondLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 2, true),
};
}
break;
case 3:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
ItemUtil.reEnchantItem(leatherBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
};
case CHAIN:
return new ItemStack[]{
ItemUtil.reEnchantItem(chainBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(chainLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
};
case IRON:
return new ItemStack[]{
ItemUtil.reEnchantItem(ironBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(ironLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
};
case DIAMOND:
return new ItemStack[]{
ItemUtil.reEnchantItem(diamondBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(diamondLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 3, true),
};
}
break;
case 4:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
ItemUtil.reEnchantItem(leatherBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
};
case CHAIN:
return new ItemStack[]{
ItemUtil.reEnchantItem(chainBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(chainLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
};
case IRON:
return new ItemStack[]{
ItemUtil.reEnchantItem(ironBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(ironLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
};
case DIAMOND:
return new ItemStack[]{
ItemUtil.reEnchantItem(diamondBoots, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(diamondLeggings, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherChestplate, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
ItemUtil.reEnchantItem(leatherHelmet, Enchantment.PROTECTION_ENVIRONMENTAL, 4, true),
};
}
break;
default:
switch (currentGameData.getArmorType()) {
case LEATHER:
return new ItemStack[]{
leatherBoots,
leatherLeggings,
leatherChestplate,
leatherHelmet
};
case CHAIN:
return new ItemStack[]{
chainBoots,
chainLeggings,
leatherChestplate,
leatherHelmet
};
case IRON:
return new ItemStack[]{
ironBoots,
ironLeggings,
leatherChestplate,
leatherHelmet
};
case DIAMOND:
return new ItemStack[]{
diamondBoots,
diamondLeggings,
leatherChestplate,
leatherHelmet
};
}
break;
}
return null;
return new ItemStack[] {
leatherBoots,
leatherLeggings,
leatherChestplate,
leatherHelmet
};
}
public void clearBlocks(Game game) {