use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class ToolCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
MinigamePlayer player = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
if (args == null) {
MinigameUtils.giveMinigameTool(player);
} else if (MinigameUtils.hasMinigameTool(player)) {
if (args[0].equalsIgnoreCase("minigame") && args.length == 2) {
if (Minigames.getPlugin().getMinigameManager().hasMinigame(args[1])) {
MinigameTool tool;
Minigame mg = Minigames.getPlugin().getMinigameManager().getMinigame(args[1]);
if (!MinigameUtils.hasMinigameTool(player))
tool = MinigameUtils.giveMinigameTool(player);
else
tool = MinigameUtils.getMinigameTool(player);
tool.setMinigame(mg);
} else {
sender.sendMessage(ChatColor.RED + "No Minigame found by the name \"" + args[1] + "\"");
}
} else if (args[0].equalsIgnoreCase("select")) {
MinigameTool tool;
if (!MinigameUtils.hasMinigameTool(player))
tool = MinigameUtils.giveMinigameTool(player);
else
tool = MinigameUtils.getMinigameTool(player);
if (tool.getMinigame() != null && tool.getMode() != null) {
tool.getMode().select(player, tool.getMinigame(), TeamsModule.getMinigameModule(tool.getMinigame()).getTeam(tool.getTeam()));
} else if (tool.getMode() == null)
sender.sendMessage(ChatColor.RED + "You must have a mode selected to select anything!");
else
sender.sendMessage(ChatColor.RED + "You must have a valid Minigame selected to use this tool!");
} else if (args[0].equalsIgnoreCase("deselect")) {
MinigameTool tool;
if (!MinigameUtils.hasMinigameTool(player))
tool = MinigameUtils.giveMinigameTool(player);
else
tool = MinigameUtils.getMinigameTool(player);
if (tool.getMinigame() != null && tool.getMode() != null) {
tool.getMode().deselect(player, tool.getMinigame(), TeamsModule.getMinigameModule(tool.getMinigame()).getTeam(tool.getTeam()));
} else if (tool.getMode() == null)
sender.sendMessage(ChatColor.RED + "You must have a mode selected to deselect anything!");
else
sender.sendMessage(ChatColor.RED + "You must have a valid Minigame selected to use this tool!");
} else if (args[0].equalsIgnoreCase("team") && args.length == 2) {
if (TeamColor.matchColor(args[1]) != null || args[1].equalsIgnoreCase("none")) {
MinigameTool tool;
if (!MinigameUtils.hasMinigameTool(player))
tool = MinigameUtils.giveMinigameTool(player);
else
tool = MinigameUtils.getMinigameTool(player);
if (args[1].equalsIgnoreCase("none"))
tool.setTeam(null);
else
tool.setTeam(TeamColor.matchColor(args[1]));
sender.sendMessage(ChatColor.GRAY + "Set the tools team to " + args[1]);
} else {
sender.sendMessage(ChatColor.RED + args[1] + " is not a valid team color!");
}
} else if (ToolModes.getToolMode(args[0]) != null) {
MinigameTool tool;
if (!MinigameUtils.hasMinigameTool(player))
tool = MinigameUtils.giveMinigameTool(player);
else
tool = MinigameUtils.getMinigameTool(player);
tool.setMode(ToolModes.getToolMode(args[0]));
sender.sendMessage(ChatColor.GRAY + "Set the tools mode to '" + tool.getMode().getName().toLowerCase().replace("_", " ") + "'");
} else {
return false;
}
} else {
sender.sendMessage(ChatColor.RED + "You must have a Minigame Tool! Type \"/minigame tool\" to recieve one.");
}
return true;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class InfoCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
minigame = plugin.getMinigameManager().getMinigame(args[0]);
}
if (minigame != null) {
List<String> output = new ArrayList<>();
output.add(ChatColor.GREEN + MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.header"), minigame.getName(true)));
output.add(ChatColor.GOLD + "<-------------------------------------->");
output.add(ChatColor.WHITE + MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.description"), minigame.getObjective()));
output.add(ChatColor.WHITE + MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.gameType"), minigame.getType().getName()));
if (minigame.isEnabled() && minigame.hasStarted()) {
if (minigame.getMinigameTimer() != null && minigame.getMinigameTimer().getTimeLeft() > 0) {
output.add(ChatColor.WHITE + MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.Timer"), minigame.getMinigameTimer().getTimeLeft()));
}
if (minigame.hasPlayers()) {
output.add(ChatColor.WHITE + MinigameUtils.formStr(MinigameUtils.getLang("command.info.out.playerHeader"), minigame.getPlayers().size(), minigame.getMaxPlayers()));
if (minigame.isTeamGame()) {
for (Team t : TeamsModule.getMinigameModule(minigame).getTeams()) {
String teamData = MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.teamData"), t.getDisplayName(), t.getScore(), t.getChatColor().name());
output.add(teamData);
output.add(ChatColor.GOLD + "~~~~~~~~~~~~~~~~~");
for (MinigamePlayer ply : t.getPlayers()) {
Integer score = ply.getScore();
Integer deaths = ply.getDeaths();
Integer reverts = ply.getReverts();
Integer kills = ply.getKills();
String name = ply.getTeam().getChatColor() + ply.getDisplayName(minigame.usePlayerDisplayNames()) + ChatColor.GRAY;
String playerData = MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.playerData"), name, score, deaths, reverts, kills);
output.add(playerData + ChatColor.GRAY);
}
}
} else {
for (MinigamePlayer ply : minigame.getPlayers()) {
Integer score = ply.getScore();
Integer deaths = ply.getDeaths();
Integer reverts = ply.getReverts();
Integer kills = ply.getKills();
String name = ply.getDisplayName(minigame.usePlayerDisplayNames());
if (minigame.isTeamGame()) {
name = ply.getTeam().getChatColor() + name;
}
String playerData = MinigameUtils.formStr(MinigameUtils.getLang("command.info.output.playerData"), name, score, deaths, reverts, kills);
output.add(ChatColor.GRAY + playerData + ChatColor.GRAY);
}
}
} else {
output.add(ChatColor.RED + MinigameUtils.getLang("command.info.output.noPlayer"));
}
} else {
if (minigame.isEnabled()) {
output.add(ChatColor.RED + MinigameUtils.getLang("command.info.output.notStarted"));
} else {
output.add(ChatColor.RED + MinigameUtils.getLang("minigame.error.notEnabled"));
}
}
for (String out : output) {
sender.sendMessage(out);
}
return true;
} else {
sender.sendMessage(ChatColor.RED + MinigameUtils.getLang("command.info.noMinigame"));
return false;
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class PlayerCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
if (args[0].equalsIgnoreCase("list")) {
List<MinigamePlayer> pls = new ArrayList<>();
for (MinigamePlayer pl : Minigames.getPlugin().getPlayerManager().getAllMinigamePlayers()) {
if (pl.isInMinigame()) {
pls.add(pl);
}
}
sender.sendMessage(ChatColor.AQUA + "-----------List of Players Playing Minigames-----------");
if (!pls.isEmpty()) {
for (MinigamePlayer pl : pls) {
sender.sendMessage(ChatColor.GREEN + pl.getName() + ChatColor.GRAY + " (Playing \"" + pl.getMinigame().getName(false) + "\")");
}
} else {
sender.sendMessage(ChatColor.RED + "None");
}
} else {
List<Player> plmatch = Minigames.getPlugin().getServer().matchPlayer(args[0]);
if (!plmatch.isEmpty()) {
MinigamePlayer pl = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(plmatch.get(0));
sender.sendMessage(ChatColor.AQUA + "--------Player info on " + pl.getName() + "--------");
if (pl.isInMinigame()) {
sender.sendMessage(ChatColor.GREEN + "Minigame: " + ChatColor.GRAY + pl.getMinigame().getName(false));
sender.sendMessage(ChatColor.GREEN + "Score: " + ChatColor.GRAY + pl.getScore());
sender.sendMessage(ChatColor.GREEN + "Kills: " + ChatColor.GRAY + pl.getKills());
sender.sendMessage(ChatColor.GREEN + "Deaths: " + ChatColor.GRAY + pl.getDeaths());
sender.sendMessage(ChatColor.GREEN + "Reverts: " + ChatColor.GRAY + pl.getReverts());
sender.sendMessage(ChatColor.GREEN + "Play Time: " + ChatColor.GRAY + MinigameUtils.convertTime((int) ((Calendar.getInstance().getTimeInMillis() - pl.getStartTime() + pl.getStoredTime()) / 1000)));
} else {
sender.sendMessage(ChatColor.GREEN + "Minigame: " + ChatColor.RED + "Not in Minigame");
}
} else {
sender.sendMessage(ChatColor.RED + "Could not find a player by the name \"" + args[0] + "\"");
}
}
return true;
}
return false;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class StopCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
Minigame mgm = plugin.getMinigameManager().getMinigame(args[0]);
if (mgm != null && mgm.isEnabled() && mgm.getType() == MinigameType.GLOBAL) {
MinigamePlayer caller = null;
if (sender instanceof Player)
caller = plugin.getPlayerManager().getMinigamePlayer((Player) sender);
plugin.getMinigameManager().stopGlobalMinigame(mgm, caller);
} else if (mgm == null || mgm.getType() != MinigameType.GLOBAL) {
sender.sendMessage(ChatColor.RED + "There is no Global Minigame by the name \"" + args[0] + "\"");
} else {
sender.sendMessage(ChatColor.RED + mgm.getName(false) + " is not running!");
}
return true;
}
return false;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class PlayerHasItemCondition method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
Menu m = new Menu(3, "Player Has Item", player);
m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), prev), m.getSize() - 9);
final MinigamePlayer fply = player;
Material display = type.getFlag();
if (display == null)
display = Material.STONE;
m.addItem(new MenuItemMaterial("Item", display, new Callback<Material>() {
@Override
public void setValue(Material value) {
type.setFlag(value);
}
@Override
public Material getValue() {
return type.getFlag();
}
}));
m.addItem(new MenuItemList("Search Where", Material.COMPASS, new Callback<String>() {
@Override
public void setValue(String value) {
where.setFlag(value.toUpperCase());
}
@Override
public String getValue() {
return WordUtils.capitalizeFully(where.getFlag());
}
}, Arrays.asList("Anywhere", "Hotbar", "Main", "Armor", "Slot")));
m.addItem(slot.getMenuItem("Slot", Material.DIAMOND, 0, 35));
m.addItem(new MenuItemNewLine());
m.addItem(matchName.getMenuItem("Match Display Name", Material.NAME_TAG));
MenuItemString menuItem = (MenuItemString) name.getMenuItem("Display Name", Material.NAME_TAG, MinigameUtils.stringToList("The name to match.;Use % to do a wildcard match"));
menuItem.setAllowNull(true);
m.addItem(menuItem);
m.addItem(matchLore.getMenuItem("Match Lore", Material.BOOK));
menuItem = (MenuItemString) lore.getMenuItem("Lore", Material.BOOK, MinigameUtils.stringToList("The lore to match. Separate;with semi-colons;for new lines.;Use % to do a wildcard match"));
menuItem.setAllowNull(true);
m.addItem(menuItem);
addInvertMenuItem(m);
m.displayMenu(player);
return true;
}
Aggregations