Search in sources :

Example 6 with TeamColor

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

the class AddTeamScoreAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Add Team Score", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
    m.addItem(new MenuItemInteger("Add Score Amount", Material.STONE, new Callback<Integer>() {

        @Override
        public void setValue(Integer value) {
            score.setFlag(value);
        }

        @Override
        public Integer getValue() {
            return score.getFlag();
        }
    }, null, null));
    List<String> teams = new ArrayList<>();
    teams.add("None");
    for (TeamColor team : TeamColor.values()) {
        teams.add(MinigameUtils.capitalize(team.toString()));
    }
    m.addItem(new MenuItemList("Specific Team", MinigameUtils.stringToList("If 'None', the players;team will be used"), Material.PAPER, new Callback<String>() {

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

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(team.getFlag());
        }
    }, teams));
    m.displayMenu(player);
    return true;
}
Also used : MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) 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 7 with TeamColor

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

the class FlagSign method signCreate.

@Override
public boolean signCreate(SignChangeEvent event) {
    event.setLine(1, ChatColor.GREEN + "Flag");
    if (TeamColor.matchColor(event.getLine(2)) != null) {
        TeamColor col = TeamColor.matchColor(event.getLine(2));
        event.setLine(2, col.getColor() + MinigameUtils.capitalize(col.toString()));
    } else if (event.getLine(2).equalsIgnoreCase("neutral")) {
        event.setLine(2, ChatColor.GRAY + "Neutral");
    } else if (event.getLine(2).equalsIgnoreCase("capture") && !event.getLine(3).isEmpty()) {
        event.setLine(2, ChatColor.GREEN + "Capture");
        if (TeamColor.matchColor(event.getLine(3)) != null) {
            TeamColor col = TeamColor.matchColor(event.getLine(3));
            event.setLine(3, col.getColor() + MinigameUtils.capitalize(col.toString()));
        } else if (event.getLine(3).equalsIgnoreCase("neutral")) {
            event.setLine(3, ChatColor.GRAY + "Neutral");
        } else {
            event.getBlock().breakNaturally();
            event.getPlayer().sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.flag.invalidSyntax") + " red, blue and neutral.");
            return false;
        }
    }
    //		}
    return true;
}
Also used : TeamColor(au.com.mineauz.minigames.minigame.TeamColor)

Example 8 with TeamColor

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

the class ScoreSign method signUse.

@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
    if (player.isInMinigame() && player.getPlayer().isOnGround()) {
        Minigame mg = player.getMinigame();
        int score = Integer.parseInt(sign.getLine(2));
        if (!mg.isTeamGame()) {
            if (player.hasClaimedScore(sign.getLocation())) {
                player.sendMessage(MinigameUtils.getLang("sign.score.alreadyUsed"), "error");
                return true;
            }
            player.addScore(score);
            mg.setScore(player, player.getScore());
            player.sendMessage(MinigameUtils.formStr("sign.score.addScore", score, player.getScore()), null);
            if (mg.getMaxScore() != 0 && mg.getMaxScorePerPlayer() <= player.getScore()) {
                Minigames.plugin.pdata.endMinigame(player);
            }
            player.addClaimedScore(sign.getLocation());
        } else {
            TeamColor steam = TeamColor.matchColor(ChatColor.stripColor(sign.getLine(3)));
            Team pteam = player.getTeam();
            if (steam == null || !TeamsModule.getMinigameModule(mg).hasTeam(steam) || pteam.getColor() == steam) {
                if (Minigames.plugin.mdata.hasClaimedScore(mg, sign.getLocation(), 0)) {
                    player.sendMessage(MinigameUtils.getLang("sign.score.alreadyUsedTeam"), "error");
                    return true;
                }
                player.addScore(score);
                mg.setScore(player, player.getScore());
                pteam.addScore(score);
                player.sendMessage(MinigameUtils.formStr("sign.score.addScoreTeam", score, pteam.getChatColor().toString() + pteam.getScore()), null);
                Minigames.plugin.mdata.addClaimedScore(mg, sign.getLocation(), 0);
                if (mg.getMaxScore() != 0 && mg.getMaxScorePerPlayer() <= pteam.getScore()) {
                    List<MinigamePlayer> winners = new ArrayList<MinigamePlayer>(pteam.getPlayers());
                    List<MinigamePlayer> losers = new ArrayList<MinigamePlayer>(mg.getPlayers().size() - pteam.getPlayers().size());
                    for (Team t : TeamsModule.getMinigameModule(mg).getTeams()) {
                        if (t != pteam)
                            losers.addAll(t.getPlayers());
                    }
                    Minigames.plugin.pdata.endMinigame(mg, winners, losers);
                }
            }
        }
    } else if (player.isInMinigame() && !player.getPlayer().isOnGround()) {
        player.sendMessage(MinigameUtils.getLang("sign.onGround"), "error");
    }
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Team(au.com.mineauz.minigames.minigame.Team) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 9 with TeamColor

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

the class ScoreSign method signCreate.

@Override
public boolean signCreate(SignChangeEvent event) {
    if (event.getLine(2).matches("[0-9]+")) {
        event.setLine(1, ChatColor.GREEN + "Score");
        if (TeamColor.matchColor(event.getLine(3)) != null) {
            TeamColor col = TeamColor.matchColor(event.getLine(3));
            event.setLine(3, col.getColor() + MinigameUtils.capitalize(col.toString()));
        } else
            event.setLine(3, "");
        return true;
    }
    return false;
}
Also used : TeamColor(au.com.mineauz.minigames.minigame.TeamColor)

Example 10 with TeamColor

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

the class MinigameTool method openMenu.

public void openMenu(MinigamePlayer player) {
    Menu men = new Menu(2, "Set Tool Mode", player);
    final MenuItemCustom miselect = new MenuItemCustom("Select", MinigameUtils.stringToList("Selects and area;or points visually"), Material.DIAMOND_BLOCK);
    final MenuItemCustom mideselect = new MenuItemCustom("Deselect", MinigameUtils.stringToList("Deselects an;area or points"), Material.GLASS);
    final MinigamePlayer fply = player;
    miselect.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (mode != null) {
                mode.select(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
            }
            return miselect.getItem();
        }
    });
    mideselect.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (mode != null) {
                mode.deselect(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
            }
            return mideselect.getItem();
        }
    });
    men.addItem(mideselect, men.getSize() - 1);
    men.addItem(miselect, men.getSize() - 2);
    List<String> teams = new ArrayList<String>(TeamColor.values().length + 1);
    for (TeamColor col : TeamColor.values()) teams.add(MinigameUtils.capitalize(col.toString().replace("_", " ")));
    teams.add("None");
    men.addItem(new MenuItemToolTeam("Team", Material.PAPER, new Callback<String>() {

        @Override
        public void setValue(String value) {
            setTeam(TeamColor.matchColor(value.replace(" ", "_")));
        }

        @Override
        public String getValue() {
            if (getTeam() != null)
                return MinigameUtils.capitalize(getTeam().toString().replace("_", " "));
            return "None";
        }
    }, teams), men.getSize() - 3);
    for (ToolMode m : ToolModes.getToolModes()) {
        men.addItem(new MenuItemToolMode(m.getDisplayName(), MinigameUtils.stringToList(m.getDescription()), m.getIcon(), m));
    }
    men.displayMenu(player);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemToolMode(au.com.mineauz.minigames.menu.MenuItemToolMode) MenuItemToolMode(au.com.mineauz.minigames.menu.MenuItemToolMode) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemToolTeam(au.com.mineauz.minigames.menu.MenuItemToolTeam) Menu(au.com.mineauz.minigames.menu.Menu)

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