Search in sources :

Example 21 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class DebugMenuPlayerOptions method openCooldownsMenu.

public static void openCooldownsMenu(Player player, WarlordsPlayer target) {
    int menuY = Math.min(5 + StatusEffectCooldowns.values().length / 7, 6);
    Menu menu = new Menu("Cooldowns: " + target.getName(), 9 * menuY);
    // general options
    ItemStack[] generalOptionItems = { new ItemBuilder(Material.BEACON).name(ChatColor.AQUA + "Manage Cooldowns").get(), new ItemBuilder(Material.MILK_BUCKET).name(ChatColor.AQUA + "Clear All Cooldowns").get(), new ItemBuilder(Material.MILK_BUCKET).name(ChatColor.AQUA + "Clear All Buffs").get(), new ItemBuilder(Material.MILK_BUCKET).name(ChatColor.AQUA + "Clear All Debuffs").get(), new ItemBuilder(Material.MILK_BUCKET).name(ChatColor.AQUA + "Clear All Abilities").get() };
    for (int i = 0; i < generalOptionItems.length; i++) {
        int finalI = i;
        menu.setItem(i + 1, 1, generalOptionItems[i], (m, e) -> {
            switch(finalI) {
                case 0:
                    openCooldownManagerMenu(player, target);
                    new BukkitRunnable() {

                        @Override
                        public void run() {
                            if (player.getOpenInventory().getTopInventory().getName().equals("Cooldown Manager: " + target.getName())) {
                                openCooldownManagerMenu(player, target);
                            } else {
                                this.cancel();
                            }
                        }
                    }.runTaskTimer(Warlords.getInstance(), 20, 20);
                    break;
                case 1:
                    target.getCooldownManager().clearCooldowns();
                    player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §aCooldowns were cleared");
                    break;
                case 2:
                    target.getCooldownManager().removeBuffCooldowns();
                    player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §aBuffs were cleared");
                    break;
                case 3:
                    target.getCooldownManager().removeDebuffCooldowns();
                    player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §aDebuffs were cleared");
                    break;
                case 4:
                    target.getCooldownManager().removeAbilityCooldowns();
                    player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §aAbility Cooldowns were cleared");
                    break;
            }
        });
    }
    // effects
    int yLevel = 1;
    for (int i = 0; i < StatusEffectCooldowns.values().length; i++) {
        if (i % 7 == 0) {
            yLevel++;
        }
        StatusEffectCooldowns cooldown = StatusEffectCooldowns.values()[i];
        menu.setItem((i % 7) + 1, yLevel, new ItemBuilder(cooldown.itemStack).name(cooldown.color + cooldown.name).flags(ItemFlag.HIDE_ATTRIBUTES).get(), (m, e) -> openStatusEffectTimeMenu(player, target, cooldown));
    }
    menu.setItem(3, menuY - 1, MENU_BACK, (m, e) -> openPlayerMenu(player, target));
    menu.setItem(4, menuY - 1, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Menu(com.ebicep.warlords.menu.Menu) ItemStack(org.bukkit.inventory.ItemStack)

Example 22 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class DebugMenuPlayerOptions method openStatusEffectTimeMenu.

public static void openStatusEffectTimeMenu(Player player, WarlordsPlayer target, StatusEffectCooldowns cooldown) {
    Menu menu = new Menu("Cooldown Time: " + target.getName(), 9 * 4);
    int[] durations = { 5, 15, 30, 60, 120, 300, 600 };
    for (int i = 0; i < durations.length; i++) {
        int finalI = i;
        menu.setItem(i + 1, 1, new ItemBuilder(woolSortedByColor[i + 5]).name(ChatColor.GREEN.toString() + durations[i] + "s").get(), (m, e) -> {
            target.getCooldownManager().addRegularCooldown(cooldown.name, cooldown.actionBarName, cooldown.cooldownClass, cooldown.cooldownObject, target, cooldown.cooldownType, cooldownManager -> {
            }, durations[finalI] * 20);
            if (cooldown == StatusEffectCooldowns.SPEED) {
                target.getSpeed().addSpeedModifier("Speed Powerup", 40, durations[finalI] * 20, "BASE");
            }
            player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §aRecieved " + durations[finalI] + " seconds of " + cooldown.name);
        });
    }
    menu.setItem(3, 3, MENU_BACK, (m, e) -> openCooldownsMenu(player, target));
    menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) Menu(com.ebicep.warlords.menu.Menu)

Example 23 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class DebugMenuPlayerOptions method openCooldownMenu.

public static void openCooldownMenu(Player player, WarlordsPlayer target, AbstractCooldown abstractCooldown) {
    Menu menu = new Menu(abstractCooldown.getName() + ": " + target.getName(), 9 * 4);
    ItemStack[] cooldownOptions = { new ItemBuilder(Material.MILK_BUCKET).name(ChatColor.AQUA + "Remove").get(), new ItemBuilder(Material.REDSTONE).name(ChatColor.AQUA + "Add duration").get() };
    for (int i = 0; i < cooldownOptions.length; i++) {
        int finalI = i;
        menu.setItem(i + 1, 1, cooldownOptions[i], (m, e) -> {
            if (target.getCooldownManager().getCooldowns().contains(abstractCooldown)) {
                switch(finalI + 1) {
                    case 1:
                        target.getCooldownManager().getCooldowns().remove(abstractCooldown);
                        player.sendMessage(ChatColor.RED + "DEV: " + target.getColoredName() + "'s §a" + abstractCooldown.getName() + " was removed");
                        openCooldownManagerMenu(player, target);
                        new BukkitRunnable() {

                            @Override
                            public void run() {
                                if (player.getOpenInventory().getTopInventory().getName().equals("Cooldown Manager: " + target.getName())) {
                                    openCooldownManagerMenu(player, target);
                                } else {
                                    this.cancel();
                                }
                            }
                        }.runTaskTimer(Warlords.getInstance(), 20, 20);
                        break;
                    case 2:
                        openCooldownTimerMenu(player, target, abstractCooldown);
                        break;
                }
            } else {
                openCooldownsMenu(player, target);
                player.sendMessage(ChatColor.RED + "DEV: §aThat cooldown no longer exists");
            }
        });
    }
    menu.setItem(3, 3, MENU_BACK, (m, e) -> openCooldownsMenu(player, target));
    menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Menu(com.ebicep.warlords.menu.Menu) ItemStack(org.bukkit.inventory.ItemStack)

Example 24 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class DebugMenuPlayerOptions method openFlagOptionMenu.

public static void openFlagOptionMenu(Player player, WarlordsPlayer target) {
    Menu menu = new Menu("Flag Options: " + target.getName(), 9 * 4);
    ItemStack[] flagOptions = { new ItemBuilder(Material.BANNER).name(ChatColor.GREEN + "Pick Up Flag").get(), new ItemBuilder(Material.BED).name(ChatColor.GREEN + "Return the Flag").get(), new ItemBuilder(Material.GRASS).name(ChatColor.GREEN + "Drop Flag").get(), new ItemBuilder(Material.REDSTONE_COMPARATOR).name(ChatColor.GREEN + "Set Multiplier").get() };
    int row = 0;
    for (FlagHolder holder : target.getGame().getMarkers(FlagHolder.class)) {
        if (holder.getTeam() == target.getTeam()) {
            continue;
        }
        row++;
        for (int i = 0; i < flagOptions.length; i++) {
            int finalI = i;
            menu.setItem(i + 1, row, flagOptions[i], (m, e) -> {
                switch(finalI) {
                    case 0:
                        if (target.getCarriedFlag() == holder.getInfo()) {
                            player.sendMessage(ChatColor.RED + "DEV: §aThat player already has the flag");
                        } else {
                            FlagHolder.update(target.getGame(), info -> info.getFlag() instanceof PlayerFlagLocation && ((PlayerFlagLocation) info.getFlag()).getPlayer() == target ? GroundFlagLocation.of(info.getFlag()) : info == holder.getInfo() ? PlayerFlagLocation.of(info.getFlag(), target) : null);
                        }
                        break;
                    case 1:
                        if (target.getCarriedFlag() == holder.getInfo()) {
                            holder.getInfo().setFlag(new SpawnFlagLocation(holder.getInfo().getSpawnLocation(), null));
                        } else {
                            player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
                        }
                        break;
                    case 2:
                        if (target.getCarriedFlag() == holder.getInfo()) {
                            holder.getInfo().setFlag(GroundFlagLocation.of(holder.getFlag()));
                        } else {
                            player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
                        }
                        break;
                    case 3:
                        if (target.getCarriedFlag() == holder.getInfo()) {
                            openFlagMultiplierMenu(player, target);
                        } else {
                            player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
                        }
                        break;
                }
            });
        }
    }
    menu.setItem(3, 3, MENU_BACK, (m, e) -> openPlayerMenu(player, target));
    menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) Menu(com.ebicep.warlords.menu.Menu) FlagHolder(com.ebicep.warlords.game.option.marker.FlagHolder) PlayerFlagLocation(com.ebicep.warlords.game.flags.PlayerFlagLocation) ItemStack(org.bukkit.inventory.ItemStack) SpawnFlagLocation(com.ebicep.warlords.game.flags.SpawnFlagLocation)

Example 25 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder 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);
}
Also used : Arrays(java.util.Arrays) Team(com.ebicep.warlords.game.Team) Warlords(com.ebicep.warlords.Warlords) Player(org.bukkit.entity.Player) UUID(java.util.UUID) LivingEntity(org.bukkit.entity.LivingEntity) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) Classes(com.ebicep.warlords.player.Classes) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ChatColor(org.bukkit.ChatColor) Color(org.bukkit.Color) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)49 Menu (com.ebicep.warlords.menu.Menu)31 ItemStack (org.bukkit.inventory.ItemStack)22 Warlords (com.ebicep.warlords.Warlords)12 Player (org.bukkit.entity.Player)12 Classes (com.ebicep.warlords.player.Classes)11 DatabasePlayer (com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)10 Collectors (java.util.stream.Collectors)10 DatabaseManager (com.ebicep.warlords.database.DatabaseManager)8 Team (com.ebicep.warlords.game.Team)8 ChatColor (org.bukkit.ChatColor)8 AbstractPlayerClass (com.ebicep.warlords.classes.AbstractPlayerClass)7 List (java.util.List)7 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 ItemFlag (org.bukkit.inventory.ItemFlag)7 ArrayList (java.util.ArrayList)6 Arrays (java.util.Arrays)6 UUID (java.util.UUID)6 Game (com.ebicep.warlords.game.Game)5