Search in sources :

Example 1 with FlagHolder

use of com.ebicep.warlords.game.option.marker.FlagHolder 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)

Aggregations

PlayerFlagLocation (com.ebicep.warlords.game.flags.PlayerFlagLocation)1 SpawnFlagLocation (com.ebicep.warlords.game.flags.SpawnFlagLocation)1 FlagHolder (com.ebicep.warlords.game.option.marker.FlagHolder)1 Menu (com.ebicep.warlords.menu.Menu)1 ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)1 ItemStack (org.bukkit.inventory.ItemStack)1