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