Search in sources :

Example 31 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class RewardSign method signUse.

@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
    Location loc = sign.getLocation();
    if (!MinigameUtils.isMinigameTool(player.getPlayer().getInventory().getItemInMainHand())) {
        String label = sign.getLine(2).toLowerCase();
        if (player.isInMinigame()) {
            if (!player.hasTempClaimedReward(label)) {
                if (mdata.hasRewardSign(loc)) {
                    Rewards rew = mdata.getRewardSign(loc);
                    for (RewardType r : rew.getReward()) {
                        r.giveReward(player);
                    }
                }
                player.addTempClaimedReward(label);
            }
        } else {
            if (!player.hasClaimedReward(label)) {
                if (mdata.hasRewardSign(loc)) {
                    Rewards rew = mdata.getRewardSign(loc);
                    for (RewardType r : rew.getReward()) {
                        r.giveReward(player);
                    }
                    player.updateInventory();
                }
                player.addClaimedReward(label);
            }
        }
    } else if (player.getPlayer().hasPermission("minigame.tool")) {
        Rewards rew = null;
        if (!mdata.hasRewardSign(loc)) {
            mdata.addRewardSign(loc);
        }
        rew = mdata.getRewardSign(loc);
        Menu rewardMenu = new Menu(5, getName(), player);
        rewardMenu.addItem(new MenuItemRewardGroupAdd("Add Group", MenuUtility.getCreateMaterial(), rew), 42);
        rewardMenu.addItem(new MenuItemRewardAdd("Add Item", MenuUtility.getCreateMaterial(), rew), 43);
        final MenuItemCustom mic = new MenuItemCustom("Save Rewards", MenuUtility.getSaveMaterial());
        final Location floc = loc;
        mic.setClick(object -> {
            mdata.saveRewardSign(MinigameUtils.createLocationID(floc), true);
            mic.getContainer().getViewer().sendInfoMessage("Saved rewards for this sign.");
            mic.getContainer().getViewer().getPlayer().closeInventory();
            return null;
        });
        rewardMenu.addItem(mic, 44);
        // List<String> list = new ArrayList<String>();
        // for(RewardRarity r : RewardRarity.values()){
        // list.add(r.toString());
        // }
        List<MenuItem> mi = new ArrayList<>();
        for (RewardType item : rew.getRewards()) {
            mi.add(item.getMenuItem());
        }
        List<String> des = new ArrayList<>();
        des.add("Double Click to edit");
        for (RewardGroup group : rew.getGroups()) {
            MenuItemRewardGroup rwg = new MenuItemRewardGroup(group.getName() + " Group", des, Material.CHEST, group, rew);
            mi.add(rwg);
        }
        rewardMenu.addItems(mi);
        rewardMenu.displayMenu(player);
    }
    return true;
}
Also used : Sign(org.bukkit.block.Sign) RewardType(au.com.mineauz.minigames.minigame.reward.RewardType) RewardGroup(au.com.mineauz.minigames.minigame.reward.RewardGroup) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigameManager(au.com.mineauz.minigames.managers.MinigameManager) au.com.mineauz.minigames(au.com.mineauz.minigames) SignChangeEvent(org.bukkit.event.block.SignChangeEvent) ArrayList(java.util.ArrayList) List(java.util.List) Rewards(au.com.mineauz.minigames.minigame.reward.Rewards) Location(org.bukkit.Location) au.com.mineauz.minigames.menu(au.com.mineauz.minigames.menu) ChatColor(org.bukkit.ChatColor) Material(org.bukkit.Material) RewardGroup(au.com.mineauz.minigames.minigame.reward.RewardGroup) RewardType(au.com.mineauz.minigames.minigame.reward.RewardType) Rewards(au.com.mineauz.minigames.minigame.reward.Rewards) ArrayList(java.util.ArrayList) List(java.util.List) Location(org.bukkit.Location)

Example 32 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class SetRegionCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        MinigamePlayer ply = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
        RegionModule rmod = RegionModule.getMinigameModule(minigame);
        if (args.length == 2) {
            if (args[0].equalsIgnoreCase("select")) {
                Location ploc = ply.getLocation();
                ploc.setY(ploc.getY() - 1);
                if (args[1].equals("1")) {
                    Location p2 = ply.getSelectionPoints()[1];
                    ply.clearSelection();
                    ply.setSelection(ploc, p2);
                    ply.sendInfoMessage(ChatColor.GRAY + "Point 1 selected");
                } else {
                    Location p2 = ply.getSelectionPoints()[0];
                    ply.clearSelection();
                    ply.setSelection(p2, ploc);
                    ply.sendInfoMessage(ChatColor.GRAY + "Point 2 selected");
                }
                return true;
            } else if (args[0].equalsIgnoreCase("create")) {
                if (ply.hasSelection()) {
                    String name = args[1];
                    rmod.addRegion(name, new Region(name, ply.getSelectionPoints()[0], ply.getSelectionPoints()[1]));
                    ply.clearSelection();
                    ply.sendInfoMessage(ChatColor.GRAY + "Created new region for " + minigame.getName(false) + " named " + name);
                } else {
                    ply.sendInfoMessage(ChatColor.RED + "You have not made a selection!");
                }
                return true;
            } else if (args[0].equalsIgnoreCase("delete")) {
                if (rmod.hasRegion(args[1])) {
                    rmod.removeRegion(args[1]);
                    ply.sendInfoMessage(ChatColor.GRAY + "Removed the region named " + args[1] + " from " + minigame.getName(false));
                } else {
                    ply.sendInfoMessage(ChatColor.GRAY + "No region by the name " + args[1] + " was found in " + minigame.getName(false));
                }
                return true;
            }
        } else if (args.length == 1) {
            if (args[0].equalsIgnoreCase("modify")) {
                rmod.displayMenu(ply, null);
                return true;
            }
        }
    }
    return false;
}
Also used : RegionModule(au.com.mineauz.minigamesregions.RegionModule) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Region(au.com.mineauz.minigamesregions.Region) Location(org.bukkit.Location)

Example 33 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class SetBlockAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Set Block", player);
    final MinigamePlayer fply = player;
    m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), previous), m.getSize() - 9);
    m.addItem(new MenuItemBlockData("Type", Material.STONE, new Callback<BlockData>() {

        @Override
        public void setValue(BlockData value) {
            type.setFlag(value);
        }

        @Override
        public BlockData getValue() {
            return type.getFlag();
        }
    }));
    m.addItem(useBlockData.getMenuItem("Use Specific BlockData", Material.ENDER_PEARL));
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) BlockData(org.bukkit.block.data.BlockData)

Example 34 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class SwapBlockAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Swap Block", player);
    m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), previous), m.getSize() - 9);
    final MinigamePlayer fply = player;
    m.addItem(new MenuItemBlockData("Match Block", Material.COBBLESTONE, new Callback<BlockData>() {

        @Override
        public void setValue(BlockData value) {
            matchType.setFlag(value);
        }

        @Override
        public BlockData getValue() {
            return matchType.getFlag();
        }
    }));
    m.addItem(matchData.getMenuItem("Match Block Use Data?", Material.ENDER_PEARL));
    m.addItem(new MenuItemNewLine());
    m.addItem(new MenuItemBlockData("To Block", Material.STONE, new Callback<BlockData>() {

        @Override
        public void setValue(BlockData value) {
            toType.setFlag(value);
        }

        @Override
        public BlockData getValue() {
            return toType.getFlag();
        }
    }));
    m.addItem(toData.getMenuItem("To Block Use Data?", Material.ENDER_PEARL));
    m.addItem(keepAttachment.getMenuItem("Keep Attachment", Material.PISTON, MinigameUtils.stringToList("When on, and To Block Use Data is off;If the source and target block;types are both blocks that;attach to surfaces, this;attachment will be preserved")));
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) BlockData(org.bukkit.block.data.BlockData)

Example 35 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class SetNodeCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        MinigamePlayer ply = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
        RegionModule rmod = RegionModule.getMinigameModule(minigame);
        if (args[0].equalsIgnoreCase("create") && args.length >= 2) {
            if (!rmod.hasNode(args[1])) {
                rmod.addNode(args[1], new Node(args[1], ply.getLocation()));
                sender.sendMessage(ChatColor.GRAY + Main.getPlugin().getMessage("command.node.addedNode", args[1], minigame.getName(true)));
            } else
                sender.sendMessage(ChatColor.RED + Main.getPlugin().getMessage("command.node.nodeExists", args[1], minigame.getName(true)));
            return true;
        } else if (args[0].equalsIgnoreCase("modify")) {
            rmod.displayMenu(ply, null);
            return true;
        } else if (args[0].equalsIgnoreCase("delete") && args.length >= 2) {
            if (rmod.hasNode(args[1])) {
                rmod.removeNode(args[1]);
                sender.sendMessage(ChatColor.GRAY + "Removed a node called " + args[1] + " from " + minigame);
            } else
                sender.sendMessage(ChatColor.RED + "A node by the name " + args[1] + " doesn't exists in " + minigame);
            return true;
        }
    }
    return false;
}
Also used : RegionModule(au.com.mineauz.minigamesregions.RegionModule) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Node(au.com.mineauz.minigamesregions.Node)

Aggregations

MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)134 EventHandler (org.bukkit.event.EventHandler)46 Minigame (au.com.mineauz.minigames.minigame.Minigame)40 ArrayList (java.util.ArrayList)25 Team (au.com.mineauz.minigames.minigame.Team)24 OfflineMinigamePlayer (au.com.mineauz.minigames.objects.OfflineMinigamePlayer)15 Player (org.bukkit.entity.Player)15 Location (org.bukkit.Location)11 ItemStack (org.bukkit.inventory.ItemStack)8 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)7 Menu (au.com.mineauz.minigames.menu.Menu)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 List (java.util.List)5 PotionEffect (org.bukkit.potion.PotionEffect)5 ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)4 Material (org.bukkit.Material)4 Sign (org.bukkit.block.Sign)4 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)3 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)2