use of com.ebicep.warlords.player.Classes in project Warlords by ebicep.
the class ClassCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (!sender.hasPermission("warlords.game.changeclass")) {
return true;
}
Player player = BaseCommand.requirePlayerOutsideGame(sender);
if (player != null) {
PlayerSettings settings = Warlords.getPlayerSettings(player.getUniqueId());
if (args.length != 0) {
try {
Classes selectedClass = Classes.valueOf(args[0].toUpperCase(Locale.ROOT));
settings.setSelectedClass(selectedClass);
} catch (IllegalArgumentException e) {
sender.sendMessage(ChatColor.RED + args[0] + " was not found, valid classes: " + Arrays.toString(Classes.values()));
return true;
}
}
Classes selected = settings.getSelectedClass();
player.sendMessage(ChatColor.BLUE + "Your selected spec: §7" + selected);
}
return true;
}
use of com.ebicep.warlords.player.Classes in project Warlords by ebicep.
the class GameMenu method openClassMenu.
public static void openClassMenu(Player player, ClassesGroup selectedGroup) {
Classes selectedClass = getSelected(player);
Menu menu = new Menu(selectedGroup.name, 9 * 4);
List<Classes> values = selectedGroup.subclasses;
for (int i = 0; i < values.size(); i++) {
Classes subClass = values.get(i);
ItemBuilder builder = new ItemBuilder(subClass.specType.itemStack).name(ChatColor.GREEN + "Specialization: " + subClass.name + " " + ChatColor.DARK_GRAY + "[" + ChatColor.GRAY + "Lv" + ExperienceManager.getLevelString(ExperienceManager.getLevelForSpec(player.getUniqueId(), subClass)) + ChatColor.DARK_GRAY + "]").flags(ItemFlag.HIDE_ENCHANTS);
List<String> lore = new ArrayList<>();
lore.add(subClass.description);
lore.add("");
long experience = ExperienceManager.getExperienceForSpec(player.getUniqueId(), subClass);
int level = (int) ExperienceManager.calculateLevelFromExp(experience);
lore.add(ExperienceManager.getProgressString(experience, level + 1));
lore.add("");
if (subClass == selectedClass) {
lore.add(ChatColor.GREEN + ">>> ACTIVE <<<");
builder.enchant(Enchantment.OXYGEN, 1);
} else {
lore.add(ChatColor.YELLOW + "> Click to activate <");
}
builder.lore(lore);
menu.setItem(9 / 2 - values.size() / 2 + i * 2 - 1, 1, builder.get(), (m, e) -> {
player.sendMessage(ChatColor.WHITE + "Spec: §6" + subClass);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 2);
ArmorManager.resetArmor(player, subClass, Warlords.getPlayerSettings(player.getUniqueId()).getWantedTeam());
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
playerSettings.setSelectedClass(subClass);
AbstractPlayerClass apc = subClass.create.get();
player.getInventory().setItem(1, new ItemBuilder(apc.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(subClass, Weapons.FELFLAME_BLADE).item)).name("§aWeapon Skin Preview").lore("").get());
openClassMenu(player, selectedGroup);
if (DatabaseManager.playerService == null)
return;
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
databasePlayer.setLastSpec(subClass);
DatabaseManager.updatePlayerAsync(databasePlayer);
});
}
menu.setItem(4, 3, MENU_BACK_PREGAME, (m, e) -> openMainMenu(player));
menu.openForPlayer(player);
}
use of com.ebicep.warlords.player.Classes in project Warlords by ebicep.
the class ArmorManager method resetArmor.
public static void resetArmor(Player player, Classes selectedClass, Team team) {
boolean onBlueTeam = team == Team.BLUE;
ItemStack[] armor = new ItemStack[4];
if (selectedClass == PYROMANCER || selectedClass == CRYOMANCER || selectedClass == AQUAMANCER) {
armor[2] = new ItemBuilder(onBlueTeam ? ArmorSets.getSelected(player).get(0).itemBlue : ArmorSets.getSelected(player).get(0).itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.getSelected(player).get(0).name : ChatColor.RED + ArmorSets.getSelected(player).get(0).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? Helmets.getSelected(player).get(0).itemBlue : Helmets.getSelected(player).get(0).itemRed).name(onBlueTeam ? ChatColor.BLUE + Helmets.getSelected(player).get(0).name : ChatColor.RED + Helmets.getSelected(player).get(0).name).lore(helmetDescription).get();
} else if (selectedClass == BERSERKER || selectedClass == DEFENDER || selectedClass == REVENANT) {
armor[2] = new ItemBuilder(onBlueTeam ? ArmorSets.getSelected(player).get(1).itemBlue : ArmorSets.getSelected(player).get(1).itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.getSelected(player).get(1).name : ChatColor.RED + ArmorSets.getSelected(player).get(1).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? Helmets.getSelected(player).get(1).itemBlue : Helmets.getSelected(player).get(1).itemRed).name(onBlueTeam ? ChatColor.BLUE + Helmets.getSelected(player).get(1).name : ChatColor.RED + Helmets.getSelected(player).get(1).name).lore(helmetDescription).get();
} else if (selectedClass == AVENGER || selectedClass == CRUSADER || selectedClass == PROTECTOR) {
armor[2] = new ItemBuilder(onBlueTeam ? ArmorSets.getSelected(player).get(2).itemBlue : ArmorSets.getSelected(player).get(2).itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.getSelected(player).get(2).name : ChatColor.RED + ArmorSets.getSelected(player).get(2).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? Helmets.getSelected(player).get(2).itemBlue : Helmets.getSelected(player).get(2).itemRed).name(onBlueTeam ? ChatColor.BLUE + Helmets.getSelected(player).get(2).name : ChatColor.RED + Helmets.getSelected(player).get(2).name).lore(helmetDescription).get();
} else if (selectedClass == THUNDERLORD || selectedClass == SPIRITGUARD || selectedClass == EARTHWARDEN) {
armor[2] = new ItemBuilder(onBlueTeam ? ArmorSets.getSelected(player).get(3).itemBlue : ArmorSets.getSelected(player).get(3).itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.getSelected(player).get(3).name : ChatColor.RED + ArmorSets.getSelected(player).get(3).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? Helmets.getSelected(player).get(3).itemBlue : Helmets.getSelected(player).get(3).itemRed).name(onBlueTeam ? ChatColor.BLUE + Helmets.getSelected(player).get(3).name : ChatColor.RED + Helmets.getSelected(player).get(3).name).lore(helmetDescription).get();
} else if (selectedClass == ASSASSIN || selectedClass == VINDICATOR || selectedClass == APOTHECARY) {
armor[2] = new ItemBuilder(onBlueTeam ? ArmorSets.getSelected(player).get(4).itemBlue : ArmorSets.getSelected(player).get(4).itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.getSelected(player).get(4).name : ChatColor.RED + ArmorSets.getSelected(player).get(4).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? Helmets.getSelected(player).get(4).itemBlue : Helmets.getSelected(player).get(4).itemRed).name(onBlueTeam ? ChatColor.BLUE + Helmets.getSelected(player).get(4).name : ChatColor.RED + Helmets.getSelected(player).get(4).name).lore(helmetDescription).get();
}
String name = Arrays.stream(ArmorSets.values()).filter(o -> o.name.equals(ChatColor.stripColor(armor[2].getItemMeta().getDisplayName()))).collect(Collectors.toList()).get(0).name;
if (name.contains("Simple")) {
armor[2] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_CHESTPLATE.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_CHESTPLATE.name : ChatColor.RED + ArmorSets.SIMPLE_CHESTPLATE.name).lore(armorDescription).get();
armor[1] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_LEGGINGS.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_LEGGINGS.name : ChatColor.RED + ArmorSets.SIMPLE_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_BOOTS.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_BOOTS.name : ChatColor.RED + ArmorSets.SIMPLE_BOOTS.name).lore(armorDescription).get();
} else if (name.contains("Greater")) {
armor[1] = new ItemBuilder(onBlueTeam ? ArmorSets.GREATER_LEGGINGS.itemBlue : ArmorSets.GREATER_LEGGINGS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.GREATER_LEGGINGS.name : ChatColor.RED + ArmorSets.GREATER_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(onBlueTeam ? ArmorSets.GREATER_BOOTS.itemBlue : ArmorSets.GREATER_BOOTS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.GREATER_BOOTS.name : ChatColor.RED + ArmorSets.GREATER_BOOTS.name).lore(armorDescription).get();
} else if (name.contains("Masterwork")) {
armor[1] = new ItemBuilder(onBlueTeam ? ArmorSets.MASTERWORK_LEGGINGS.itemBlue : ArmorSets.MASTERWORK_LEGGINGS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.MASTERWORK_LEGGINGS.name : ChatColor.RED + ArmorSets.MASTERWORK_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(onBlueTeam ? ArmorSets.MASTERWORK_BOOTS.itemBlue : ArmorSets.MASTERWORK_BOOTS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.MASTERWORK_BOOTS.name : ChatColor.RED + ArmorSets.MASTERWORK_BOOTS.name).lore(armorDescription).get();
}
player.getInventory().setArmorContents(armor);
}
use of com.ebicep.warlords.player.Classes in project Warlords by ebicep.
the class ArmorManager method resetArmor.
public static void resetArmor(UUID uuid, LivingEntity livingEntity, Classes selectedClass, Team team) {
List<Helmets> helmets = Helmets.getSelected(uuid);
List<ArmorSets> armorSets = ArmorSets.getSelected(uuid);
boolean onBlueTeam = team == Team.BLUE;
ItemStack[] armor = new ItemStack[4];
if (selectedClass == PYROMANCER || selectedClass == CRYOMANCER || selectedClass == AQUAMANCER) {
armor[2] = new ItemBuilder(onBlueTeam ? armorSets.get(0).itemBlue : armorSets.get(0).itemRed).name(onBlueTeam ? ChatColor.BLUE + armorSets.get(0).name : ChatColor.RED + armorSets.get(0).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? helmets.get(0).itemBlue : helmets.get(0).itemRed).name(onBlueTeam ? ChatColor.BLUE + helmets.get(0).name : ChatColor.RED + helmets.get(0).name).lore(helmetDescription).get();
} else if (selectedClass == BERSERKER || selectedClass == DEFENDER || selectedClass == REVENANT) {
armor[2] = new ItemBuilder(onBlueTeam ? armorSets.get(1).itemBlue : armorSets.get(1).itemRed).name(onBlueTeam ? ChatColor.BLUE + armorSets.get(1).name : ChatColor.RED + armorSets.get(1).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? helmets.get(1).itemBlue : helmets.get(1).itemRed).name(onBlueTeam ? ChatColor.BLUE + helmets.get(1).name : ChatColor.RED + helmets.get(1).name).lore(helmetDescription).get();
} else if (selectedClass == AVENGER || selectedClass == CRUSADER || selectedClass == PROTECTOR) {
armor[2] = new ItemBuilder(onBlueTeam ? armorSets.get(2).itemBlue : armorSets.get(2).itemRed).name(onBlueTeam ? ChatColor.BLUE + armorSets.get(2).name : ChatColor.RED + armorSets.get(2).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? helmets.get(2).itemBlue : helmets.get(2).itemRed).name(onBlueTeam ? ChatColor.BLUE + helmets.get(2).name : ChatColor.RED + helmets.get(2).name).lore(helmetDescription).get();
} else if (selectedClass == THUNDERLORD || selectedClass == SPIRITGUARD || selectedClass == EARTHWARDEN) {
armor[2] = new ItemBuilder(onBlueTeam ? armorSets.get(3).itemBlue : armorSets.get(3).itemRed).name(onBlueTeam ? ChatColor.BLUE + armorSets.get(3).name : ChatColor.RED + armorSets.get(3).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? helmets.get(3).itemBlue : helmets.get(3).itemRed).name(onBlueTeam ? ChatColor.BLUE + helmets.get(3).name : ChatColor.RED + helmets.get(3).name).lore(helmetDescription).get();
} else if (selectedClass == ASSASSIN || selectedClass == VINDICATOR || selectedClass == APOTHECARY) {
armor[2] = new ItemBuilder(onBlueTeam ? armorSets.get(4).itemBlue : armorSets.get(4).itemRed).name(onBlueTeam ? ChatColor.BLUE + armorSets.get(4).name : ChatColor.RED + armorSets.get(4).name).lore(armorDescription).get();
armor[3] = new ItemBuilder(onBlueTeam ? helmets.get(4).itemBlue : helmets.get(4).itemRed).name(onBlueTeam ? ChatColor.BLUE + helmets.get(4).name : ChatColor.RED + helmets.get(4).name).lore(helmetDescription).get();
}
String name = Arrays.stream(ArmorSets.values()).filter(o -> o.name.equals(ChatColor.stripColor(armor[2].getItemMeta().getDisplayName()))).collect(Collectors.toList()).get(0).name;
if (name.contains("Simple")) {
armor[2] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_CHESTPLATE.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_CHESTPLATE.name : ChatColor.RED + ArmorSets.SIMPLE_CHESTPLATE.name).lore(armorDescription).get();
armor[1] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_LEGGINGS.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_LEGGINGS.name : ChatColor.RED + ArmorSets.SIMPLE_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(ArmorSets.applyColor(ArmorSets.SIMPLE_BOOTS.itemBlue, onBlueTeam)).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.SIMPLE_BOOTS.name : ChatColor.RED + ArmorSets.SIMPLE_BOOTS.name).lore(armorDescription).get();
} else if (name.contains("Greater")) {
armor[1] = new ItemBuilder(onBlueTeam ? ArmorSets.GREATER_LEGGINGS.itemBlue : ArmorSets.GREATER_LEGGINGS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.GREATER_LEGGINGS.name : ChatColor.RED + ArmorSets.GREATER_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(onBlueTeam ? ArmorSets.GREATER_BOOTS.itemBlue : ArmorSets.GREATER_BOOTS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.GREATER_BOOTS.name : ChatColor.RED + ArmorSets.GREATER_BOOTS.name).lore(armorDescription).get();
} else if (name.contains("Masterwork")) {
armor[1] = new ItemBuilder(onBlueTeam ? ArmorSets.MASTERWORK_LEGGINGS.itemBlue : ArmorSets.MASTERWORK_LEGGINGS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.MASTERWORK_LEGGINGS.name : ChatColor.RED + ArmorSets.MASTERWORK_LEGGINGS.name).lore(armorDescription).get();
armor[0] = new ItemBuilder(onBlueTeam ? ArmorSets.MASTERWORK_BOOTS.itemBlue : ArmorSets.MASTERWORK_BOOTS.itemRed).name(onBlueTeam ? ChatColor.BLUE + ArmorSets.MASTERWORK_BOOTS.name : ChatColor.RED + ArmorSets.MASTERWORK_BOOTS.name).lore(armorDescription).get();
}
livingEntity.getEquipment().setArmorContents(armor);
}
use of com.ebicep.warlords.player.Classes in project Warlords by ebicep.
the class GameMenu method openSkillBoostMenu.
public static void openSkillBoostMenu(Player player, Classes selectedGroup) {
Classes selectedClass = getSelected(player);
ClassesSkillBoosts selectedBoost = getSelectedBoost(player);
Menu menu = new Menu("Skill Boost", 9 * 6);
List<ClassesSkillBoosts> values = selectedGroup.skillBoosts;
for (int i = 0; i < values.size(); i++) {
ClassesSkillBoosts skillBoost = values.get(i);
ItemBuilder builder = new ItemBuilder(getSelected(player).specType.itemStack).name(skillBoost == selectedBoost ? ChatColor.GREEN + skillBoost.name + " (" + selectedClass.name + ")" : ChatColor.RED + skillBoost.name + " (" + selectedClass.name + ")").flags(ItemFlag.HIDE_ENCHANTS);
List<String> lore = new ArrayList<>();
lore.add(skillBoost == selectedBoost ? skillBoost.selectedDescription : skillBoost.description);
lore.add("");
if (skillBoost == selectedBoost) {
lore.add(ChatColor.GREEN + "Currently selected!");
builder.enchant(Enchantment.OXYGEN, 1);
} else {
lore.add(ChatColor.YELLOW + "Click to select!");
}
builder.lore(lore);
menu.setItem(i + 2, 3, builder.get(), (m, e) -> {
player.sendMessage(ChatColor.GREEN + "You have changed your weapon boost to: §b" + skillBoost.name + "!");
setSelectedBoost(player, skillBoost);
openSkillBoostMenu(player, selectedGroup);
if (DatabaseManager.playerService == null)
return;
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
databasePlayer.getSpec(selectedClass).setSkillBoost(skillBoost);
DatabaseManager.updatePlayerAsync(databasePlayer);
});
}
// showing change of ability
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
AbstractPlayerClass apc = selectedClass.create.get();
AbstractPlayerClass apc2 = selectedClass.create.get();
if (apc2.getWeapon().getClass() == selectedBoost.ability) {
apc2.getWeapon().boostSkill(selectedBoost, apc2);
apc.getWeapon().updateDescription(player);
apc2.getWeapon().updateDescription(player);
menu.setItem(3, 1, apc.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(selectedClass, Weapons.FELFLAME_BLADE).item), ACTION_DO_NOTHING);
menu.setItem(5, 1, apc2.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(selectedClass, Weapons.FELFLAME_BLADE).item), ACTION_DO_NOTHING);
} else if (apc2.getRed().getClass() == selectedBoost.ability) {
apc2.getRed().boostSkill(selectedBoost, apc2);
apc.getRed().updateDescription(player);
apc2.getRed().updateDescription(player);
menu.setItem(3, 1, apc.getRed().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 1)), ACTION_DO_NOTHING);
menu.setItem(5, 1, apc2.getRed().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 1)), ACTION_DO_NOTHING);
} else if (apc2.getPurple().getClass() == selectedBoost.ability) {
apc2.getPurple().boostSkill(selectedBoost, apc2);
apc.getPurple().updateDescription(player);
apc2.getPurple().updateDescription(player);
menu.setItem(3, 1, apc.getPurple().getItem(new ItemStack(Material.GLOWSTONE_DUST)), ACTION_DO_NOTHING);
menu.setItem(5, 1, apc2.getPurple().getItem(new ItemStack(Material.GLOWSTONE_DUST)), ACTION_DO_NOTHING);
} else if (apc2.getBlue().getClass() == selectedBoost.ability) {
apc2.getBlue().boostSkill(selectedBoost, apc2);
apc.getBlue().updateDescription(player);
apc2.getBlue().updateDescription(player);
menu.setItem(3, 1, apc.getBlue().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 10)), ACTION_DO_NOTHING);
menu.setItem(5, 1, apc2.getBlue().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 10)), ACTION_DO_NOTHING);
} else if (apc2.getOrange().getClass() == selectedBoost.ability) {
apc2.getOrange().boostSkill(selectedBoost, apc2);
apc.getOrange().updateDescription(player);
apc2.getOrange().updateDescription(player);
menu.setItem(3, 1, apc.getOrange().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 14)), ACTION_DO_NOTHING);
menu.setItem(5, 1, apc2.getOrange().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 14)), ACTION_DO_NOTHING);
}
menu.setItem(4, 5, MENU_BACK_PREGAME, (m, e) -> openMainMenu(player));
menu.openForPlayer(player);
}
Aggregations