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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations