Search in sources :

Example 36 with MinigamePlayer

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

the class PlayerXPRangeCondition method checkCondition.

private boolean checkCondition(MinigamePlayer player) {
    if (player == null || !player.isInMinigame()) {
        return false;
    }
    Player p = player.getPlayer();
    float xp = p.getLevel() + p.getExp();
    if (xp >= min.getFlag() && xp <= max.getFlag()) {
        return true;
    } else {
        return true;
    }
}
Also used : Player(org.bukkit.entity.Player) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer)

Example 37 with MinigamePlayer

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

the class TeamPlayerCountCondition method checkRegionCondition.

@Override
public boolean checkRegionCondition(MinigamePlayer player, Region region) {
    if (player.getTeam() != null) {
        Integer count = 0;
        Team t = player.getTeam();
        for (MinigamePlayer user : region.getPlayers()) {
            if (user.getTeam().equals(t)) {
                count++;
            }
        }
        return (count >= min.getFlag() && count <= max.getFlag());
    }
    return false;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Team(au.com.mineauz.minigames.minigame.Team)

Example 38 with MinigamePlayer

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

the class BasicRecorder method bucketFill.

@EventHandler(ignoreCancelled = true)
private void bucketFill(PlayerBucketFillEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockBreak()) {
            d.addBlock(event.getBlockClicked(), pdata.getMinigamePlayer(event.getPlayer()));
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 39 with MinigamePlayer

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

the class ResourcePackCommand method onCommand.

@Override
public boolean onCommand(final CommandSender sender, Minigame minigame, String label, String[] args) {
    ResourcePack pack;
    switch(args[0]) {
        case "apply":
            if (args.length < 3) {
                sender.sendMessage(getUsage());
                return false;
            }
            pack = plugin.getResourceManager().getResourcePack(args[1]);
            if (pack != null && pack.isValid()) {
                MinigamePlayer player = plugin.getPlayerManager().getMinigamePlayer(args[2]);
                player.applyResourcePack(pack);
                player.sendInfoMessage(MinigameUtils.getLang("minigame.resourcepack.apply"));
                return true;
            }
        case "remove":
            if (args.length < 2) {
                return false;
            }
            pack = plugin.getResourceManager().getResourcePack(args[1]);
            plugin.getResourceManager().removeResourcePack(pack);
            sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.remove"));
            return sendList(sender);
        case "addnew":
            if (args.length < 3) {
                sender.sendMessage(getUsage());
                return false;
            }
            String name = args[1];
            String u = args[2];
            try {
                URL url = new URL(u);
                final ResourcePack newPack = new ResourcePack(name, url);
                plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
                    if (newPack.isValid()) {
                        plugin.getResourceManager().addResourcePack(newPack);
                        sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.addresource"));
                        sendList(sender);
                    } else {
                        sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.invalidpack"));
                    }
                }, 100);
                return true;
            } catch (MalformedURLException e) {
                sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.badurl"));
                return false;
            }
        case "list":
            return sendList(sender);
        case "clear":
            for (MinigamePlayer p : plugin.getPlayerManager().getAllMinigamePlayers()) {
                p.applyResourcePack(plugin.getResourceManager().getResourcePack("empty"));
            }
            return true;
    }
    return false;
}
Also used : MalformedURLException(java.net.MalformedURLException) MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ResourcePack(au.com.mineauz.minigames.objects.ResourcePack) URL(java.net.URL)

Example 40 with MinigamePlayer

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

the class LoadoutCommand method onCommand.

public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    MinigamePlayer ply = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
    if (ply.isInMinigame()) {
        if (args == null) {
            LoadoutModule.getMinigameModule(ply.getMinigame()).displaySelectionMenu(ply, false);
        } else {
            String ln = args[0];
            if (LoadoutModule.getMinigameModule(ply.getMinigame()).hasLoadout(ln)) {
                ply.setLoadout(LoadoutModule.getMinigameModule(ply.getMinigame()).getLoadout(ln));
                ply.sendInfoMessage(MinigameUtils.formStr("player.loadout.nextSpawnName", ln));
            } else {
                ply.sendMessage(MinigameUtils.formStr("player.loadout.noLoadout", ln), MinigameMessageType.ERROR);
            }
        }
    } else {
        ply.sendMessage(MinigameUtils.getLang("command.loadout.noMinigame"), MinigameMessageType.ERROR);
    }
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer)

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