Search in sources :

Example 6 with MinigameTool

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;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 7 with MinigameTool

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();
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool)

Example 8 with MinigameTool

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);
}
Also used : MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)8 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)4 ArrayList (java.util.ArrayList)3 Callback (au.com.mineauz.minigames.menu.Callback)2 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)2 Menu (au.com.mineauz.minigames.menu.Menu)2 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)2 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)2 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)2 Minigame (au.com.mineauz.minigames.minigame.Minigame)2 ItemStack (org.bukkit.inventory.ItemStack)2 Team (au.com.mineauz.minigames.minigame.Team)1 Material (org.bukkit.Material)1 Block (org.bukkit.block.Block)1 Sign (org.bukkit.block.Sign)1 EventHandler (org.bukkit.event.EventHandler)1