Search in sources :

Example 1 with LoadoutModule

use of au.com.mineauz.minigames.minigame.modules.LoadoutModule 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 LoadoutModule

use of au.com.mineauz.minigames.minigame.modules.LoadoutModule in project Minigames by AddstarMC.

the class LoadoutSign method signUse.

@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
    if (player.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR && player.isInMinigame()) {
        Minigame mgm = player.getMinigame();
        LoadoutModule loadout = LoadoutModule.getMinigameModule(mgm);
        if (mgm == null || mgm.isSpectator(player)) {
            return false;
        }
        if (sign.getLine(2).equals(ChatColor.GREEN + "Menu")) {
            boolean nores = true;
            if (sign.getLine(3).equalsIgnoreCase("respawn"))
                nores = false;
            LoadoutModule.getMinigameModule(mgm).displaySelectionMenu(player, nores);
        } else if (loadout.hasLoadout(sign.getLine(2))) {
            if (!loadout.getLoadout(sign.getLine(2)).getUsePermissions() || player.getPlayer().hasPermission("minigame.loadout." + sign.getLine(2).toLowerCase())) {
                if (player.setLoadout(loadout.getLoadout(sign.getLine(2)))) {
                    player.sendInfoMessage(MinigameUtils.formStr("sign.loadout.equipped", sign.getLine(2)));
                    if (mgm.getType() == MinigameType.SINGLEPLAYER || mgm.hasStarted()) {
                        if (sign.getLine(3).equalsIgnoreCase("respawn")) {
                            player.sendInfoMessage(MinigameUtils.getLang("sign.loadout.nextRespawn"));
                        } else {
                            loadout.getLoadout(sign.getLine(2)).equiptLoadout(player);
                        }
                    }
                }
                return true;
            } else {
                player.sendMessage(MinigameUtils.formStr("sign.loadout.noPermisson", sign.getLine(2)), MinigameMessageType.ERROR);
            }
        } else if (plugin.getMinigameManager().hasLoadout(sign.getLine(2))) {
            if (!plugin.getMinigameManager().getLoadout(sign.getLine(2)).getUsePermissions() || player.getPlayer().hasPermission("minigame.loadout." + sign.getLine(2).toLowerCase())) {
                if (player.setLoadout(plugin.getMinigameManager().getLoadout(sign.getLine(2)))) {
                    player.sendInfoMessage(MinigameUtils.formStr("sign.loadout.equipped", sign.getLine(2)));
                    if (mgm.getType() == MinigameType.SINGLEPLAYER || mgm.hasStarted()) {
                        if (sign.getLine(3).equalsIgnoreCase("respawn")) {
                            player.sendInfoMessage(MinigameUtils.getLang("sign.loadout.nextRespawn"));
                        } else {
                            plugin.getMinigameManager().getLoadout(sign.getLine(2)).equiptLoadout(player);
                        }
                    }
                }
                return true;
            } else {
                player.sendMessage(MinigameUtils.formStr("sign.loadout.noPermission", sign.getLine(2)), MinigameMessageType.ERROR);
            }
        } else {
            player.sendMessage(MinigameUtils.getLang("sign.loadout.noLoadout"), MinigameMessageType.ERROR);
        }
    } else if (player.getPlayer().getInventory().getItemInMainHand().getType() != Material.AIR)
        player.sendMessage(MinigameUtils.getLang("sign.emptyHand"), MinigameMessageType.ERROR);
    return false;
}
Also used : LoadoutModule(au.com.mineauz.minigames.minigame.modules.LoadoutModule) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 3 with LoadoutModule

use of au.com.mineauz.minigames.minigame.modules.LoadoutModule 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)

Example 4 with LoadoutModule

use of au.com.mineauz.minigames.minigame.modules.LoadoutModule in project Minigames by AddstarMC.

the class SetLoadoutCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    MinigamePlayer player = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
    Menu loadouts = new Menu(6, getName(), player);
    List<MenuItem> mi = new ArrayList<>();
    LoadoutModule mod = LoadoutModule.getMinigameModule(minigame);
    List<String> des = new ArrayList<>();
    des.add("Shift + Right Click to Delete");
    Material item = Material.WHITE_STAINED_GLASS_PANE;
    for (String ld : mod.getLoadouts()) {
        item = Material.WHITE_STAINED_GLASS_PANE;
        if (mod.getLoadout(ld).getItems().size() != 0) {
            item = mod.getLoadout(ld).getItem((Integer) mod.getLoadout(ld).getItems().toArray()[0]).getType();
        }
        MenuItemDisplayLoadout mil = new MenuItemDisplayLoadout(ld, des, item, mod.getLoadout(ld), minigame);
        mil.setAllowDelete(mod.getLoadout(ld).isDeleteable());
        mi.add(mil);
    }
    loadouts.addItem(new MenuItemLoadoutAdd("Add Loadout", Material.ITEM_FRAME, mod.getLoadoutMap(), minigame), 53);
    loadouts.addItems(mi);
    loadouts.displayMenu(player);
    return true;
}
Also used : MenuItemDisplayLoadout(au.com.mineauz.minigames.menu.MenuItemDisplayLoadout) MenuItemLoadoutAdd(au.com.mineauz.minigames.menu.MenuItemLoadoutAdd) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ArrayList(java.util.ArrayList) LoadoutModule(au.com.mineauz.minigames.minigame.modules.LoadoutModule) MenuItem(au.com.mineauz.minigames.menu.MenuItem) Material(org.bukkit.Material) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

LoadoutModule (au.com.mineauz.minigames.minigame.modules.LoadoutModule)4 PlayerLoadout (au.com.mineauz.minigames.PlayerLoadout)2 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemDisplayLoadout (au.com.mineauz.minigames.menu.MenuItemDisplayLoadout)1 MenuItemLoadoutAdd (au.com.mineauz.minigames.menu.MenuItemLoadoutAdd)1 Minigame (au.com.mineauz.minigames.minigame.Minigame)1 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)1 ArrayList (java.util.ArrayList)1 Material (org.bukkit.Material)1