Search in sources :

Example 56 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame 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 57 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class DeleteCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        Minigame mgm = plugin.mdata.getMinigame(args[0]);
        if (mgm != null) {
            File save = new File(plugin.getDataFolder() + "/minigames/" + mgm.getName(false));
            if (save.exists() && save.isDirectory()) {
                if (save.list().length == 0) {
                    save.delete();
                } else {
                    for (String file : save.list()) {
                        File nfile = new File(save, file);
                        nfile.delete();
                    }
                    save.delete();
                }
                List<String> ls = plugin.getConfig().getStringList("minigames");
                ls.remove(mgm.getName(false));
                plugin.getConfig().set("minigames", ls);
                plugin.mdata.removeMinigame(mgm.getName(false));
                plugin.saveConfig();
                sender.sendMessage(ChatColor.RED + "The minigame " + mgm.getName(false) + " has been removed");
            }
        }
        return true;
    }
    return false;
}
Also used : Minigame(au.com.mineauz.minigames.minigame.Minigame) File(java.io.File)

Example 58 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class SaveCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        if (plugin.mdata.hasMinigame(args[0])) {
            Minigame mg = plugin.mdata.getMinigame(args[0]);
            mg.saveMinigame();
            sender.sendMessage(ChatColor.GRAY + mg.getName(false) + " has been saved.");
        } else {
            sender.sendMessage(ChatColor.RED + "There is no Minigame by the name: " + args[0]);
        }
        return true;
    }
    return false;
}
Also used : Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 59 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class JoinCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    Player player = (Player) sender;
    if (args != null) {
        Minigame mgm = plugin.mdata.getMinigame(args[0]);
        if (mgm != null && (!mgm.getUsePermissions() || player.hasPermission("minigame.join." + mgm.getName(false).toLowerCase()))) {
            if (!plugin.pdata.getMinigamePlayer(player).isInMinigame()) {
                sender.sendMessage(ChatColor.GREEN + MinigameUtils.formStr("command.join.joining", mgm.getName(false)));
                plugin.pdata.joinMinigame(plugin.pdata.getMinigamePlayer(player), mgm, false, 0.0);
            } else {
                player.sendMessage(ChatColor.RED + MinigameUtils.getLang("command.join.alreadyPlaying"));
            }
        } else if (mgm != null && mgm.getUsePermissions()) {
            player.sendMessage(ChatColor.RED + MinigameUtils.formStr("command.join.noMinigamePermission", "minigame.join." + mgm.getName(false).toLowerCase()));
        } else {
            player.sendMessage(ChatColor.RED + MinigameUtils.getLang("minigame.error.noMinigame"));
        }
        return true;
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 60 with Minigame

use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.

the class PlayerKillsMechanic method playerAttackPlayer.

@EventHandler
private void playerAttackPlayer(PlayerDeathEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getEntity());
    if (ply == null)
        return;
    Minigame mgm = ply.getMinigame();
    if (ply.isInMinigame() && mgm.getMechanicName().equals("kills")) {
        MinigamePlayer attacker = null;
        if (ply.getPlayer().getKiller() != null) {
            attacker = pdata.getMinigamePlayer(ply.getPlayer().getKiller());
            if (attacker == ply) {
                return;
            }
        } else {
            return;
        }
        if (!mgm.equals(attacker.getMinigame())) {
            return;
        }
        if (ply.getTeam() == null) {
            attacker.addScore();
            mgm.setScore(attacker, attacker.getScore());
            if (mgm.getMaxScore() != 0 && attacker.getScore() >= mgm.getMaxScorePerPlayer()) {
                List<MinigamePlayer> losers = new ArrayList<MinigamePlayer>(mgm.getPlayers().size() - 1);
                List<MinigamePlayer> winner = new ArrayList<MinigamePlayer>(1);
                winner.add(attacker);
                for (MinigamePlayer player : mgm.getPlayers()) {
                    if (player != attacker)
                        losers.add(player);
                }
                pdata.endMinigame(mgm, winner, losers);
            }
        } else {
            Team team = ply.getTeam();
            Team ateam = attacker.getTeam();
            if (team != ateam) {
                attacker.addScore();
                mgm.setScore(attacker, attacker.getScore());
                ateam.addScore();
                if (mgm.getMaxScore() != 0 && mgm.getMaxScorePerPlayer() <= ateam.getScore()) {
                    mdata.sendMinigameMessage(mgm, MinigameUtils.formStr("player.kills.finalKill", attacker.getName(), ply.getName()), null, null);
                    List<MinigamePlayer> w = new ArrayList<MinigamePlayer>(ateam.getPlayers());
                    List<MinigamePlayer> l = new ArrayList<MinigamePlayer>(mgm.getPlayers().size() - ateam.getPlayers().size());
                    for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
                        if (t != ateam)
                            l.addAll(t.getPlayers());
                    }
                    plugin.pdata.endMinigame(mgm, w, l);
                }
            }
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) Team(au.com.mineauz.minigames.minigame.Team) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Minigame (au.com.mineauz.minigames.minigame.Minigame)64 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)33 EventHandler (org.bukkit.event.EventHandler)29 ArrayList (java.util.ArrayList)19 Player (org.bukkit.entity.Player)16 Team (au.com.mineauz.minigames.minigame.Team)15 List (java.util.List)7 Location (org.bukkit.Location)7 TreasureHuntModule (au.com.mineauz.minigames.minigame.modules.TreasureHuntModule)4 Sign (org.bukkit.block.Sign)4 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)3 Block (org.bukkit.block.Block)3 ItemStack (org.bukkit.inventory.ItemStack)3 PotionEffect (org.bukkit.potion.PotionEffect)3 CTFFlag (au.com.mineauz.minigames.CTFFlag)2 MinigameData (au.com.mineauz.minigames.MinigameData)2 MultiplayerTimer (au.com.mineauz.minigames.MultiplayerTimer)2 ICommand (au.com.mineauz.minigames.commands.ICommand)2 TakeFlagEvent (au.com.mineauz.minigames.events.TakeFlagEvent)2 ScoreboardDisplay (au.com.mineauz.minigames.minigame.ScoreboardDisplay)2