Search in sources :

Example 1 with PlayerLoadout

use of au.com.mineauz.minigames.PlayerLoadout in project Minigames by AddstarMC.

the class EquipLoadoutAction method executeRegionAction.

@Override
public void executeRegionAction(MinigamePlayer player, Region region) {
    debug(player, region);
    if (player == null || !player.isInMinigame())
        return;
    LoadoutModule lmod = LoadoutModule.getMinigameModule(player.getMinigame());
    if (lmod.hasLoadout(loadout.getFlag())) {
        PlayerLoadout pLoadOut = lmod.getLoadout(loadout.getFlag());
        player.setLoadout(pLoadOut);
        pLoadOut.equiptLoadout(player);
    }
}
Also used : PlayerLoadout(au.com.mineauz.minigames.PlayerLoadout) LoadoutModule(au.com.mineauz.minigames.minigame.modules.LoadoutModule)

Example 2 with PlayerLoadout

use of au.com.mineauz.minigames.PlayerLoadout in project Minigames by AddstarMC.

the class LoadoutModule method displaySelectionMenu.

public void displaySelectionMenu(MinigamePlayer player, final boolean equip) {
    Menu m = new Menu(6, "Select Loadout", player);
    final MinigamePlayer fply = player;
    for (PlayerLoadout loadout : extraLoadouts.values()) {
        if (loadout.isDisplayedInMenu()) {
            if (!loadout.getUsePermissions() || player.getPlayer().hasPermission("minigame.loadout." + loadout.getName(false).toLowerCase())) {
                if (!player.getMinigame().isTeamGame() || loadout.getTeamColor() == null || player.getTeam().getColor() == loadout.getTeamColor()) {
                    MenuItemCustom c = new MenuItemCustom(loadout.getName(true), Material.GLASS);
                    if (!loadout.getItems().isEmpty()) {
                        ItemStack item = loadout.getItem(new ArrayList<>(loadout.getItems()).get(0));
                        c.setItem(item);
                    }
                    final PlayerLoadout floadout2 = loadout;
                    c.setClick(object -> {
                        fply.setLoadout(floadout2);
                        fply.getPlayer().closeInventory();
                        if (!equip)
                            fply.sendMessage(MinigameUtils.getLang("player.loadout.nextSpawn"), MinigameMessageType.INFO);
                        else {
                            fply.sendMessage(MinigameUtils.formStr("player.loadout.equipped", floadout2.getName(true)), MinigameMessageType.INFO);
                            floadout2.equiptLoadout(fply);
                        }
                        return null;
                    });
                    m.addItem(c);
                }
            }
        }
    }
    m.displayMenu(player);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) PlayerLoadout(au.com.mineauz.minigames.PlayerLoadout) ArrayList(java.util.ArrayList) Menu(au.com.mineauz.minigames.menu.Menu) ItemStack(org.bukkit.inventory.ItemStack) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 3 with PlayerLoadout

use of au.com.mineauz.minigames.PlayerLoadout in project Minigames by AddstarMC.

the class MenuItemLoadoutAdd method checkValidEntry.

@Override
public void checkValidEntry(String entry) {
    entry = entry.replace(" ", "_");
    if (!loadouts.keySet().contains(entry)) {
        for (int i = 0; i < 45; i++) {
            if (!getContainer().hasMenuItem(i)) {
                PlayerLoadout loadout = new PlayerLoadout(entry);
                loadouts.put(entry, loadout);
                List<String> des = new ArrayList<>();
                des.add("Shift + Right Click to Delete");
                if (minigame != null)
                    getContainer().addItem(new MenuItemDisplayLoadout(entry, des, Material.DIAMOND_SWORD, loadout, minigame), i);
                else
                    getContainer().addItem(new MenuItemDisplayLoadout(entry, des, Material.DIAMOND_SWORD, loadout), i);
                break;
            }
        }
        getContainer().cancelReopenTimer();
        getContainer().displayMenu(getContainer().getViewer());
        return;
    }
    getContainer().cancelReopenTimer();
    getContainer().displayMenu(getContainer().getViewer());
    getContainer().getViewer().sendMessage("A Loadout already exists by the name \"" + entry + "\".", MinigameMessageType.ERROR);
}
Also used : PlayerLoadout(au.com.mineauz.minigames.PlayerLoadout) ArrayList(java.util.ArrayList)

Example 4 with PlayerLoadout

use of au.com.mineauz.minigames.PlayerLoadout in project Minigames by AddstarMC.

the class EquipLoadoutAction method executeNodeAction.

@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
    debug(player, node);
    if (player == null || !player.isInMinigame())
        return;
    LoadoutModule lmod = LoadoutModule.getMinigameModule(player.getMinigame());
    if (lmod.hasLoadout(loadout.getFlag())) {
        PlayerLoadout pLoadOut = lmod.getLoadout(loadout.getFlag());
        player.setLoadout(pLoadOut);
        pLoadOut.equiptLoadout(player);
    }
}
Also used : PlayerLoadout(au.com.mineauz.minigames.PlayerLoadout) LoadoutModule(au.com.mineauz.minigames.minigame.modules.LoadoutModule)

Aggregations

PlayerLoadout (au.com.mineauz.minigames.PlayerLoadout)4 LoadoutModule (au.com.mineauz.minigames.minigame.modules.LoadoutModule)2 ArrayList (java.util.ArrayList)2 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)1 ItemStack (org.bukkit.inventory.ItemStack)1