Search in sources :

Example 11 with TeamColor

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

the class TeamSign method signCreate.

@Override
public boolean signCreate(SignChangeEvent event) {
    event.setLine(1, ChatColor.GREEN + "Team");
    if (TeamColor.matchColor(event.getLine(2)) != null || event.getLine(2).equalsIgnoreCase("neutral")) {
        if (event.getLine(2).equalsIgnoreCase("neutral")) {
            event.setLine(2, ChatColor.GRAY + "Neutral");
        } else {
            TeamColor col = TeamColor.matchColor(event.getLine(2));
            event.setLine(2, col.getColor() + MinigameUtils.capitalize(col.toString().replace("_", " ")));
        }
        return true;
    }
    event.getPlayer().sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.formStr("sign.team.invalidFormat", "\"red\", \"blue\" or \"neutral\""));
    return false;
}
Also used : TeamColor(au.com.mineauz.minigames.minigame.TeamColor)

Example 12 with TeamColor

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

the class TeamScoreRangeCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Team Score Range", player);
    m.addItem(min.getMenuItem("Minimum Score", Material.STEP, 0, null));
    m.addItem(max.getMenuItem("Maximum Score", Material.STONE, 0, null));
    List<String> teams = new ArrayList<String>();
    for (TeamColor t : TeamColor.values()) teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    m.addItem(new MenuItemList("Team Color", Material.WOOL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            team.setFlag(value.toUpperCase().replace(" ", "_"));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(team.getFlag().replace("_", " "));
        }
    }, teams));
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Menu(au.com.mineauz.minigames.menu.Menu)

Example 13 with TeamColor

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

the class TeamsModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(Menu menu) {
    Menu m = new Menu(6, "Teams", menu.getViewer());
    m.setPreviousPage(menu);
    List<MenuItem> items = new ArrayList<MenuItem>();
    List<String> teams = new ArrayList<String>(this.teams.size() + 1);
    for (TeamColor t : this.teams.keySet()) {
        teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    }
    teams.add("None");
    items.add(new MenuItemList("Default Winning Team", Material.PAPER, getDefaultWinnerCallback(), teams));
    items.add(new MenuItemNewLine());
    for (Team t : this.teams.values()) {
        items.add(new MenuItemTeam(t.getChatColor() + t.getDisplayName(), t));
    }
    m.addItem(new MenuItemAddTeam("Add Team", getMinigame()), m.getSize() - 1);
    m.addItems(items);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, menu), m.getSize() - 9);
    MenuItemPage p = new MenuItemPage("Team Options", Material.CHEST, m);
    menu.addItem(p);
}
Also used : MenuItemTeam(au.com.mineauz.minigames.menu.MenuItemTeam) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItem(au.com.mineauz.minigames.menu.MenuItem) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) MenuItemAddTeam(au.com.mineauz.minigames.menu.MenuItemAddTeam) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemAddTeam(au.com.mineauz.minigames.menu.MenuItemAddTeam) MenuItemTeam(au.com.mineauz.minigames.menu.MenuItemTeam) Team(au.com.mineauz.minigames.minigame.Team) Menu(au.com.mineauz.minigames.menu.Menu)

Example 14 with TeamColor

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

the class MatchTeamCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Match Team", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    List<String> teams = new ArrayList<String>();
    for (TeamColor t : TeamColor.values()) teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    m.addItem(new MenuItemList("Team Color", Material.WOOL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            team.setFlag(value.toUpperCase().replace(" ", "_"));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(team.getFlag().replace("_", " "));
        }
    }, teams));
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Menu(au.com.mineauz.minigames.menu.Menu)

Example 15 with TeamColor

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

the class EndCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args == null && sender instanceof Player) {
        MinigamePlayer ply = plugin.pdata.getMinigamePlayer((Player) sender);
        if (ply.isInMinigame()) {
            if (ply.getMinigame().getType() != MinigameType.SINGLEPLAYER) {
                List<MinigamePlayer> w = new ArrayList<MinigamePlayer>(1);
                List<MinigamePlayer> l = new ArrayList<MinigamePlayer>(ply.getMinigame().getPlayers().size());
                w.add(ply);
                l.addAll(ply.getMinigame().getPlayers());
                l.remove(ply);
                plugin.pdata.endMinigame(ply.getMinigame(), w, l);
                sender.sendMessage(ChatColor.GRAY + "You forced " + ply.getName() + " to win the Minigame.");
            } else {
                plugin.pdata.endMinigame(ply);
                sender.sendMessage(ChatColor.GRAY + "You forced " + ply.getName() + " to win the Minigame.");
            }
        } else {
            sender.sendMessage(ChatColor.RED + "Error: You are not in a minigame!");
        }
        return true;
    } else if (args != null) {
        Player player = null;
        if (sender instanceof Player) {
            player = (Player) sender;
        }
        if (player == null || player.hasPermission("minigame.end.other")) {
            List<Player> players = plugin.getServer().matchPlayer(args[0]);
            MinigamePlayer ply = null;
            Team team = null;
            Minigame mgm = null;
            if (args.length == 2 && plugin.mdata.hasMinigame(args[1])) {
                TeamColor color = TeamColor.matchColor(args[0]);
                mgm = plugin.mdata.getMinigame(args[1]);
                if (mgm == null) {
                    sender.sendMessage(ChatColor.RED + "No minigme found by the name " + args[1]);
                    return true;
                }
                if (TeamsModule.getMinigameModule(mgm).hasTeam(color)) {
                    team = TeamsModule.getMinigameModule(mgm).getTeam(color);
                } else {
                    sender.sendMessage(ChatColor.RED + "No team found by the name " + args[0] + " in " + mgm.getName(false));
                    return true;
                }
            } else if (args.length == 2 && !plugin.mdata.hasMinigame(args[1])) {
                sender.sendMessage(ChatColor.RED + "No Minigame found by the name " + args[1]);
                return true;
            } else if (!players.isEmpty()) {
                ply = plugin.pdata.getMinigamePlayer(players.get(0));
            } else {
                sender.sendMessage(ChatColor.RED + "No player found by the name " + args[0]);
                return true;
            }
            if (ply != null && ply.isInMinigame()) {
                if (ply.getMinigame().getType() != MinigameType.SINGLEPLAYER) {
                    List<MinigamePlayer> w = new ArrayList<MinigamePlayer>(1);
                    List<MinigamePlayer> l = new ArrayList<MinigamePlayer>(ply.getMinigame().getPlayers().size());
                    w.add(ply);
                    l.addAll(ply.getMinigame().getPlayers());
                    l.remove(ply);
                    plugin.pdata.endMinigame(ply.getMinigame(), w, l);
                    sender.sendMessage(ChatColor.GRAY + "You forced " + ply.getName() + " to win the Minigame.");
                } else {
                    plugin.pdata.endMinigame(ply);
                    sender.sendMessage(ChatColor.GRAY + "You forced " + ply.getName() + " to win the Minigame.");
                }
            } else if (args.length >= 2 && team != null && mgm != null) {
                if (mgm.hasPlayers()) {
                    List<MinigamePlayer> w = new ArrayList<MinigamePlayer>(team.getPlayers());
                    int lcount = 0;
                    for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
                        if (t != team) {
                            lcount += t.getPlayers().size();
                        }
                    }
                    List<MinigamePlayer> l = new ArrayList<MinigamePlayer>(lcount);
                    for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
                        if (t != team) {
                            l.addAll(t.getPlayers());
                        }
                    }
                    plugin.pdata.endMinigame(mgm, w, l);
                    sender.sendMessage(ChatColor.GRAY + "You forced " + team.getChatColor() + team.getDisplayName() + ChatColor.GRAY + " to win the Minigame.");
                } else {
                    sender.sendMessage(ChatColor.RED + "This Minigame has no players!");
                }
            } else {
                sender.sendMessage(ChatColor.RED + "This player is not playing a Minigame.");
            }
        } else if (player != null) {
            sender.sendMessage(ChatColor.RED + "Error: You don't have permission to force end another players Minigame!");
            sender.sendMessage(ChatColor.RED + "minigame.end.other");
        }
        return true;
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Team(au.com.mineauz.minigames.minigame.Team) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Aggregations

TeamColor (au.com.mineauz.minigames.minigame.TeamColor)16 ArrayList (java.util.ArrayList)13 Menu (au.com.mineauz.minigames.menu.Menu)6 Team (au.com.mineauz.minigames.minigame.Team)6 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)5 Callback (au.com.mineauz.minigames.menu.Callback)5 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)5 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)5 Minigame (au.com.mineauz.minigames.minigame.Minigame)3 List (java.util.List)3 TeamsModule (au.com.mineauz.minigames.minigame.modules.TeamsModule)2 Player (org.bukkit.entity.Player)2 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemAddTeam (au.com.mineauz.minigames.menu.MenuItemAddTeam)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)1 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)1 MenuItemTeam (au.com.mineauz.minigames.menu.MenuItemTeam)1 MenuItemToolMode (au.com.mineauz.minigames.menu.MenuItemToolMode)1