use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.
the class GameMenu method openLobbyAbilityMenu.
public static void openLobbyAbilityMenu(Player player) {
Menu menu = new Menu("Class Information", 9);
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
Classes selectedClass = playerSettings.getSelectedClass();
AbstractPlayerClass apc = selectedClass.create.get();
ItemBuilder icon = new ItemBuilder(selectedClass.specType.itemStack);
icon.name(ChatColor.GREEN + selectedClass.name);
icon.lore(selectedClass.description, "", "§6Specialization Stats:", "", "§7Health: §a" + apc.getMaxHealth(), "§7Energy: §a" + apc.getMaxEnergy() + " §7/ §a+" + apc.getEnergyPerSec() + " §7per sec §7/ §a+" + apc.getEnergyOnHit() + " §7per hit", "", selectedClass == APOTHECARY ? "§7Speed: §e10%" : null, apc.getDamageResistance() == 0 ? "§7Damage Reduction: §cNone" : "§7Damage Reduction: §e" + apc.getDamageResistance() + "%");
ClassesSkillBoosts selectedBoost = playerSettings.getSkillBoostForClass();
if (selectedBoost != null) {
if (apc.getWeapon().getClass() == selectedBoost.ability) {
apc.getWeapon().boostSkill(selectedBoost, apc);
} else if (apc.getRed().getClass() == selectedBoost.ability) {
apc.getRed().boostSkill(selectedBoost, apc);
} else if (apc.getPurple().getClass() == selectedBoost.ability) {
apc.getPurple().boostSkill(selectedBoost, apc);
} else if (apc.getBlue().getClass() == selectedBoost.ability) {
apc.getBlue().boostSkill(selectedBoost, apc);
} else if (apc.getOrange().getClass() == selectedBoost.ability) {
apc.getOrange().boostSkill(selectedBoost, apc);
}
}
apc.getWeapon().updateDescription(player);
apc.getRed().updateDescription(player);
apc.getPurple().updateDescription(player);
apc.getBlue().updateDescription(player);
apc.getOrange().updateDescription(player);
menu.setItem(0, icon.get(), ACTION_DO_NOTHING);
menu.setItem(2, apc.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(selectedClass, Weapons.FELFLAME_BLADE).item), ACTION_DO_NOTHING);
menu.setItem(3, apc.getRed().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 1)), ACTION_DO_NOTHING);
menu.setItem(4, apc.getPurple().getItem(new ItemStack(Material.GLOWSTONE_DUST)), ACTION_DO_NOTHING);
menu.setItem(5, apc.getBlue().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 10)), ACTION_DO_NOTHING);
menu.setItem(6, apc.getOrange().getItem(new ItemStack(Material.INK_SACK, 1, (byte) 14)), ACTION_DO_NOTHING);
menu.setItem(8, MENU_BACK_PREGAME, (m, e) -> openMainMenu(player));
menu.openForPlayer(player);
}
use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.
the class GameMenu method openWeaponMenu.
public static void openWeaponMenu(Player player, int pageNumber) {
Classes selectedClass = getSelected(player);
Weapons selectedWeapon = Weapons.getSelected(player, selectedClass);
Menu menu = new Menu("Weapon Skin Selector", 9 * 6);
List<Weapons> values = new ArrayList<>(Arrays.asList(Weapons.values()));
for (int i = (pageNumber - 1) * 21; i < pageNumber * 21 && i < values.size(); i++) {
Weapons weapon = values.get(i);
ItemBuilder builder;
if (weapon.isUnlocked) {
builder = new ItemBuilder(weapon.item).name(ChatColor.GREEN + weapon.name).flags(ItemFlag.HIDE_ENCHANTS);
List<String> lore = new ArrayList<>();
if (weapon == selectedWeapon) {
lore.add(ChatColor.GREEN + "Currently selected!");
builder.enchant(Enchantment.OXYGEN, 1);
} else {
lore.add(ChatColor.YELLOW + "Click to select!");
}
builder.lore(lore);
} else {
builder = new ItemBuilder(Material.BARRIER).name(ChatColor.RED + "Locked Weapon Skin");
}
menu.setItem((i - (pageNumber - 1) * 21) % 7 + 1, (i - (pageNumber - 1) * 21) / 7 + 1, builder.get(), (m, e) -> {
if (weapon.isUnlocked) {
player.sendMessage(ChatColor.GREEN + "You have changed your " + ChatColor.AQUA + selectedClass.name + ChatColor.GREEN + "'s weapon skin to: §b" + weapon.name + "!");
Weapons.setSelected(player, selectedClass, weapon);
openWeaponMenu(player, pageNumber);
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
AbstractPlayerClass apc = selectedClass.create.get();
player.getInventory().setItem(1, new ItemBuilder(apc.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(selectedClass, Weapons.FELFLAME_BLADE).item)).name("§aWeapon Skin Preview").lore("").get());
if (DatabaseManager.playerService == null)
return;
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
databasePlayer.getSpec(selectedClass).setWeapon(weapon);
DatabaseManager.updatePlayerAsync(databasePlayer);
} else {
player.sendMessage(ChatColor.RED + "This weapon skin has not been unlocked yet!");
}
});
}
if (pageNumber == 1) {
menu.setItem(8, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Next Page").lore(ChatColor.YELLOW + "Page " + (pageNumber + 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber + 1));
} else if (pageNumber == 2) {
menu.setItem(0, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Previous Page").lore(ChatColor.YELLOW + "Page " + (pageNumber - 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber - 1));
menu.setItem(8, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Next Page").lore(ChatColor.YELLOW + "Page " + (pageNumber + 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber + 1));
} else if (pageNumber == 3) {
menu.setItem(0, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Previous Page").lore(ChatColor.YELLOW + "Page " + (pageNumber - 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber - 1));
menu.setItem(8, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Next Page").lore(ChatColor.YELLOW + "Page " + (pageNumber + 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber + 1));
} else if (pageNumber == 4) {
menu.setItem(0, 5, new ItemBuilder(Material.ARROW).name(ChatColor.GREEN + "Previous Page").lore(ChatColor.YELLOW + "Page " + (pageNumber - 1)).get(), (m, e) -> openWeaponMenu(player, pageNumber - 1));
}
menu.setItem(4, 5, MENU_BACK_PREGAME, (m, e) -> openMainMenu(player));
menu.openForPlayer(player);
}
use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.
the class GameMenu method openTeamMenu.
public static void openTeamMenu(Player player) {
Team selectedTeam = Warlords.getPlayerSettings(player.getUniqueId()).getWantedTeam();
Menu menu = new Menu("Team Selector", 9 * 4);
List<Team> values = new ArrayList<>(Arrays.asList(Team.values()));
for (int i = 0; i < values.size(); i++) {
Team team = values.get(i);
ItemBuilder builder = new ItemBuilder(team.getItem()).name(team.teamColor() + team.getName()).flags(ItemFlag.HIDE_ENCHANTS);
List<String> lore = new ArrayList<>();
if (team == selectedTeam) {
lore.add(ChatColor.GREEN + "Currently selected!");
builder.enchant(Enchantment.OXYGEN, 1);
} else {
lore.add(ChatColor.YELLOW + "Click to select!");
}
builder.lore(lore);
menu.setItem(9 / 2 - values.size() % 2 + i * 2 - 1, 1, builder.get(), (m, e) -> {
if (selectedTeam != team) {
player.sendMessage(ChatColor.GREEN + "You have joined the " + team.teamColor() + team.getName() + ChatColor.GREEN + " team!");
Optional<Game> playerGame = Warlords.getGameManager().getPlayerGame(player.getUniqueId());
if (playerGame.isPresent()) {
Game game = playerGame.get();
Team oldTeam = game.getPlayerTeam(player.getUniqueId());
game.setPlayerTeam(player, team);
LobbyLocationMarker randomLobbyLocation = LobbyLocationMarker.getRandomLobbyLocation(game, team);
if (randomLobbyLocation != null) {
Location teleportDestination = MapSymmetryMarker.getSymmetry(game).getOppositeLocation(game, oldTeam, team, player.getLocation(), randomLobbyLocation.getLocation());
player.teleport(teleportDestination);
Warlords.setRejoinPoint(player.getUniqueId(), teleportDestination);
}
}
ArmorManager.resetArmor(player, Warlords.getPlayerSettings(player.getUniqueId()).getSelectedClass(), team);
Warlords.getPlayerSettings(player.getUniqueId()).setWantedTeam(team);
}
openTeamMenu(player);
});
}
menu.setItem(4, 3, Menu.MENU_CLOSE, ACTION_CLOSE_MENU);
menu.openForPlayer(player);
}
use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.
the class GameMenu method openArcadeMenu.
public static void openArcadeMenu(Player player) {
Menu menu = new Menu("Mini Games", 9 * 4);
ItemBuilder icon = new ItemBuilder(Material.GOLD_INGOT);
icon.name(ChatColor.GREEN + "Weapon Roller");
icon.lore("§7Is RNG with you today?");
menu.setItem(3, 1, icon.get(), (m, e) -> {
double difficulty = 1;
double base = random.nextDouble() * (1 - difficulty);
double meleeDamageMin = random.nextDouble() * difficulty + base;
double meleeDamageMax = random.nextDouble() * difficulty + base;
double critChance = random.nextDouble() * difficulty + base;
double critMultiplier = random.nextDouble() * difficulty + base;
double skillBoost = random.nextDouble() * difficulty + base;
double health = random.nextDouble() * difficulty + base;
double energy = random.nextDouble() * difficulty + base;
double cooldown = random.nextDouble() * difficulty + base;
double speed = random.nextDouble() * difficulty + base;
double score = (meleeDamageMin + meleeDamageMax + critChance + critMultiplier + skillBoost + health + energy + cooldown + speed) / 9;
meleeDamageMin = map(meleeDamageMin, 122, 132);
meleeDamageMax = map(meleeDamageMax, 166, 179);
critChance = map(critChance, 15, 25);
critMultiplier = map(critMultiplier, 180, 200);
skillBoost = map(skillBoost, 13, 20);
health = map(health, 500, 800);
energy = map(energy, 30, 35);
cooldown = map(cooldown, 7, 13);
speed = map(speed, 7, 13);
if (meleeDamageMin > meleeDamageMax) {
double temp = meleeDamageMin;
meleeDamageMin = meleeDamageMax;
meleeDamageMax = temp;
}
String displayScore = "§7Your weapon score is §a" + NumberFormat.formatOptionalTenths(score * 100);
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
Classes selectedClass = playerSettings.getSelectedClass();
AbstractPlayerClass apc = selectedClass.create.get();
ItemStack weapon = new ItemStack(Weapons.FELFLAME_BLADE.item);
ItemMeta weaponMeta = weapon.getItemMeta();
weaponMeta.setDisplayName("§6Warlord's Felflame of the " + apc.getWeapon().getName());
ArrayList<String> weaponLore = new ArrayList<>();
weaponLore.add("§7Damage: §c" + round(meleeDamageMin) + "§7-§c" + round(meleeDamageMax));
weaponLore.add("§7Crit Chance: §c" + round(critChance) + "%");
weaponLore.add("§7Crit Multiplier: §c" + round(critMultiplier) + "%");
weaponLore.add("");
String classNamePath = apc.getClass().getGenericSuperclass().getTypeName();
weaponLore.add("§a" + classNamePath.substring(classNamePath.indexOf("Abstract") + 8) + " (" + apc.getClass().getSimpleName() + "):");
weaponLore.add("§aIncreases the damage you");
weaponLore.add("§adeal with " + apc.getWeapon().getName() + " by §c" + round(skillBoost) + "%");
weaponLore.add("");
weaponLore.add("§7Health: §a+" + round(health));
weaponLore.add("§7Max Energy: §a+" + round(energy));
weaponLore.add("§7Cooldown Reduction: §a+" + round(cooldown) + "%");
weaponLore.add("§7Speed: §a+" + round(speed) + "%");
weaponLore.add("");
weaponLore.add("§3CRAFTED");
weaponLore.add("");
weaponLore.add(displayScore);
weaponLore.add("");
weaponLore.add("§7Left-click to roll again!");
weaponMeta.setLore(weaponLore);
weapon.setItemMeta(weaponMeta);
m.getInventory().setItem(e.getRawSlot(), weapon);
if (score > 0.85) {
Bukkit.broadcastMessage("§6" + player.getDisplayName() + " §frolled a weapon with a total score of §6" + NumberFormat.formatOptionalTenths(score * 100) + "§f!");
}
if (score < 0.15) {
Bukkit.broadcastMessage("§6" + player.getDisplayName() + " §frolled a weapon with a total score of §c" + NumberFormat.formatOptionalTenths(score * 100) + "§f!");
}
});
ItemBuilder icon2 = new ItemBuilder(Material.SULPHUR);
icon2.name(ChatColor.GREEN + "Skin Shard Roller");
icon2.lore("§7Is RNG with you to give everyone a new awesome skin?", "", "§7Left-click to roll 10 skin shards!");
menu.setItem(5, 1, icon2.get(), (m, e) -> {
Long weaponCooldown = openWeaponCooldown.get(player.getUniqueId());
Map<WeaponsRarity, Integer> foundWeaponCount = new EnumMap<>(WeaponsRarity.class);
for (WeaponsRarity rarity : WeaponsRarity.values()) {
foundWeaponCount.put(rarity, 0);
}
if (Bukkit.getOnlinePlayers().size() >= 16) {
if (weaponCooldown == null || weaponCooldown < System.currentTimeMillis()) {
openWeaponCooldown.put(player.getUniqueId(), System.currentTimeMillis() + 8 * 60 * 1000);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 2);
for (int i = 0; i < 10; i++) {
String legendaryName = legendaryNames[random.nextInt(legendaryNames.length)];
String mythicName = mythicNames[random.nextInt(mythicNames.length)];
double chance = random.nextDouble() * 100;
WeaponsRarity rarity;
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
Classes selectedClass = playerSettings.getSelectedClass();
if (chance < 96.38) {
rarity = WeaponsRarity.RARE;
} else if (chance < 96.38 + 3) {
rarity = WeaponsRarity.EPIC;
} else if (chance < 96.38 + 3 + 0.6) {
rarity = WeaponsRarity.LEGENDARY;
} else {
rarity = WeaponsRarity.MYTHIC;
}
foundWeaponCount.compute(rarity, (key, value) -> value == null ? 1 : value + 1);
List<Weapons> weapons = weaponByRarity.get(rarity);
Weapons weapon = weapons.get(random.nextInt(weapons.size()));
String message = rarity.getWeaponChatColor() + legendaryName + "'s " + weapon.getName() + " of the " + selectedClass.name;
String mythicMessage = rarity.getWeaponChatColor() + "§l" + mythicName + " " + weapon.getName() + " of the " + selectedClass.name;
if (rarity == WeaponsRarity.EPIC) {
Bukkit.broadcastMessage(ChatColor.AQUA + player.getDisplayName() + " §fgot lucky and found " + message);
}
if (rarity == WeaponsRarity.LEGENDARY) {
Utils.playGlobalSound(player.getLocation(), "legendaryfind", 1, 1);
Bukkit.broadcastMessage(ChatColor.AQUA + player.getDisplayName() + " §fgot lucky and found " + message);
player.getWorld().spigot().strikeLightningEffect(player.getLocation(), false);
}
if (rarity == WeaponsRarity.MYTHIC) {
Utils.playGlobalSound(player.getLocation(), "legendaryfind", 500, 0.8f);
Utils.playGlobalSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 500, 0.8f);
Bukkit.broadcastMessage(ChatColor.AQUA + player.getDisplayName() + " §fgot lucky and found " + mythicMessage);
for (int j = 0; j < 10; j++) {
player.getWorld().spigot().strikeLightningEffect(player.getLocation(), false);
}
}
if (!weapon.isUnlocked) {
weapon.isUnlocked = true;
Warlords.getInstance().saveWeaponConfig();
Bukkit.broadcastMessage("");
Bukkit.broadcastMessage("§l" + rarity.getWeaponChatColor() + weapon.getName() + " §l§fis now unlocked for everyone!");
Bukkit.broadcastMessage("");
} else {
if (rarity == WeaponsRarity.MYTHIC) {
Bukkit.broadcastMessage("");
Bukkit.broadcastMessage("§l" + rarity.getWeaponChatColor() + weapon.getName() + " §fwas already found! Unlucky!");
Bukkit.broadcastMessage("");
}
}
}
player.sendMessage("");
player.sendMessage("§7You found:");
player.sendMessage("§7Rare: §9" + foundWeaponCount.get(WeaponsRarity.RARE));
player.sendMessage("§7Epic: §5" + foundWeaponCount.get(WeaponsRarity.EPIC));
player.sendMessage("§7Legendary: §6" + foundWeaponCount.get(WeaponsRarity.LEGENDARY));
player.sendMessage("§7Mythic: §c" + foundWeaponCount.get(WeaponsRarity.MYTHIC));
} else {
long remainingTime = (weaponCooldown - System.currentTimeMillis()) / 1000;
long remainingTimeinMinutes = remainingTime / 60;
player.sendMessage(ChatColor.RED + "Please wait " + (remainingTime > 60 ? remainingTimeinMinutes + " minutes" : remainingTime + " seconds") + " before opening skin shards again!");
}
} else {
player.sendMessage(ChatColor.RED + "There must be at least 16 players online to roll skin shards!");
}
});
menu.setItem(4, 3, MENU_BACK_PREGAME, (m, e) -> openMainMenu(player));
menu.openForPlayer(player);
}
use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.
the class GameMenu method openMainMenu.
public static void openMainMenu(Player player) {
Classes selectedClass = getSelected(player);
Menu menu = new Menu("Warlords Shop", 9 * 6);
ClassesGroup[] values = ClassesGroup.values();
for (int i = 0; i < values.length; i++) {
ClassesGroup group = values[i];
List<String> lore = new ArrayList<>();
lore.add(group.description);
lore.add("");
lore.add(ChatColor.GOLD + "Specializations:");
for (Classes subClass : group.subclasses) {
lore.add((subClass == selectedClass ? ChatColor.GREEN : ChatColor.GRAY) + subClass.name);
}
lore.add("");
long experience = ExperienceManager.getExperienceForClass(player.getUniqueId(), group);
int level = (int) ExperienceManager.calculateLevelFromExp(experience);
lore.add(ExperienceManager.getProgressString(experience, level + 1));
lore.add("");
lore.add(ChatColor.YELLOW + "Click here to select a " + group.name + "\n" + ChatColor.YELLOW + "specialization");
ItemStack item = new ItemBuilder(group.item).name(ChatColor.GOLD + group.name + ChatColor.DARK_GRAY + " [" + ChatColor.GRAY + "Lv" + ExperienceManager.getLevelString(level) + ChatColor.DARK_GRAY + "]").lore(lore).get();
menu.setItem(9 / 2 - values.length / 2 + i * 2 - 2, 1, item, (m, e) -> {
openClassMenu(player, group);
});
}
menu.setItem(1, 3, MENU_SKINS, (m, e) -> openWeaponMenu(player, 1));
menu.setItem(3, 3, MENU_ARMOR_SETS, (m, e) -> openArmorMenu(player, 1));
menu.setItem(5, 3, MENU_BOOSTS, (m, e) -> openSkillBoostMenu(player, selectedClass));
menu.setItem(7, 3, MENU_SETTINGS, (m, e) -> openSettingsMenu(player));
menu.setItem(4, 5, Menu.MENU_CLOSE, ACTION_CLOSE_MENU);
menu.setItem(4, 2, MENU_ABILITY_DESCRIPTION, (m, e) -> openLobbyAbilityMenu(player));
menu.setItem(4, 4, MENU_ARCADE, (m, e) -> openArcadeMenu(player));
menu.openForPlayer(player);
}
Aggregations