use of au.com.mineauz.minigames.tool.MinigameTool 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.plugin.pdata.getMinigamePlayer((Player) sender);
if (args == null) {
MinigameUtils.giveMinigameTool(player);
} else if (MinigameUtils.hasMinigameTool(player)) {
if (args[0].equalsIgnoreCase("minigame") && args.length == 2) {
if (Minigames.plugin.mdata.hasMinigame(args[1])) {
MinigameTool tool;
Minigame mg = Minigames.plugin.mdata.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.tool.MinigameTool in project Minigames by AddstarMC.
the class MenuItemToolTeam method onRightClick.
@Override
public ItemStack onRightClick() {
super.onRightClick();
MinigamePlayer ply = getContainer().getViewer();
if (MinigameUtils.hasMinigameTool(ply)) {
MinigameTool tool = MinigameUtils.getMinigameTool(ply);
tool.setTeam(TeamColor.matchColor(value.getValue().replace(" ", "_")));
}
return getItem();
}
use of au.com.mineauz.minigames.tool.MinigameTool in project Minigames by AddstarMC.
the class RegionToolMode method onSetMode.
@Override
public void onSetMode(final MinigamePlayer player, MinigameTool tool) {
tool.addSetting("Region", "None");
final Menu m = new Menu(2, "Region Selection", player);
if (player.isInMenu()) {
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, player.getMenu()), m.getSize() - 9);
}
final MinigameTool ftool = tool;
m.addItem(new MenuItemString("Region Name", Material.PAPER, new Callback<String>() {
@Override
public void setValue(String value) {
ftool.changeSetting("Region", value);
}
@Override
public String getValue() {
return ftool.getSetting("Region");
}
}));
if (tool.getMinigame() != null) {
// Node selection menu
RegionModule module = RegionModule.getMinigameModule(tool.getMinigame());
Menu regionMenu = new Menu(6, "Regions", player);
List<MenuItem> items = new ArrayList<MenuItem>();
for (final Region region : module.getRegions()) {
MenuItemCustom item = new MenuItemCustom(region.getName(), Material.CHEST);
// Set the node and go back to the main menu
item.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
ftool.changeSetting("Region", region.getName());
m.displayMenu(player);
return object;
}
});
items.add(item);
}
regionMenu.addItems(items);
regionMenu.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), regionMenu.getSize() - 9);
m.addItem(new MenuItemPage("Edit Region", Material.CHEST, regionMenu));
}
m.displayMenu(player);
}
Aggregations