Search in sources :

Example 11 with Minigame

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

the class ReloadCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (plugin.pdata.getMinigamePlayer(p).isInMinigame()) {
            plugin.pdata.quitMinigame(plugin.pdata.getMinigamePlayer(p), true);
        }
    }
    Minigames.plugin.mdata.getAllMinigames().clear();
    try {
        plugin.getConfig().load(plugin.getDataFolder() + "/config.yml");
    } catch (FileNotFoundException ex) {
        plugin.getLogger().info("Failed to load config, creating one.");
        try {
            plugin.getConfig().save(plugin.getDataFolder() + "/config.yml");
        } catch (IOException e) {
            plugin.getLogger().log(Level.SEVERE, "Could not save config.yml!");
            e.printStackTrace();
        }
    } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE, "Failed to load config!");
        e.printStackTrace();
    }
    List<String> mgs = new ArrayList<String>();
    if (Minigames.plugin.getConfig().contains("minigames")) {
        mgs = Minigames.plugin.getConfig().getStringList("minigames");
    }
    final List<String> allMGS = new ArrayList<String>();
    allMGS.addAll(mgs);
    if (!mgs.isEmpty()) {
        for (String mgm : allMGS) {
            Minigame game = new Minigame(mgm);
            game.loadMinigame();
            Minigames.plugin.mdata.addMinigame(game);
        }
    }
    sender.sendMessage(ChatColor.GREEN + "Reloaded Minigame configs");
    return true;
}
Also used : Player(org.bukkit.entity.Player) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Minigame(au.com.mineauz.minigames.minigame.Minigame) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 12 with Minigame

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

the class HintCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    MinigamePlayer player = plugin.pdata.getMinigamePlayer((Player) sender);
    if (args != null) {
        Minigame mgm = plugin.mdata.getMinigame(args[0]);
        if (mgm != null && mgm.getMinigameTimer() != null && mgm.getType() == MinigameType.GLOBAL && mgm.getMechanicName().equals("treasure_hunt")) {
            TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(mgm);
            if (thm.hasTreasureLocation() && !thm.isTreasureFound()) {
                thm.getHints(player);
            } else {
                player.sendMessage(ChatColor.GRAY + mgm.getName(false) + " is currently not running.");
            }
        } else if (mgm == null || mgm.getType() != MinigameType.GLOBAL) {
            player.sendMessage(ChatColor.RED + "There is no treasure hunt running by the name \"" + args[0] + "\"");
        }
    } else {
        List<Minigame> mgs = new ArrayList<Minigame>();
        for (Minigame mg : plugin.mdata.getAllMinigames().values()) {
            if (mg.getType() == MinigameType.GLOBAL && mg.getMechanicName().equals("treasure_hunt")) {
                mgs.add(mg);
            }
        }
        if (!mgs.isEmpty()) {
            if (mgs.size() > 1) {
                player.sendMessage(ChatColor.LIGHT_PURPLE + "Currently running Treasure Hunts:");
                String treasures = "";
                for (int i = 0; i < mgs.size(); i++) {
                    treasures += mgs.get(i).getName(false);
                    if (i != mgs.size() - 1) {
                        treasures += ", ";
                    }
                }
                player.sendMessage(ChatColor.GRAY + treasures);
            } else {
                TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(mgs.get(0));
                if (thm.hasTreasureLocation() && !thm.isTreasureFound()) {
                    thm.getHints(player);
                } else {
                    player.sendMessage(ChatColor.GRAY + mgs.get(0).getName(false) + " is currently not running.");
                }
            }
        } else if (mgs.isEmpty()) {
            player.sendMessage(ChatColor.LIGHT_PURPLE + "There are no Treasure Hunt minigames currently running.");
        }
    }
    return true;
}
Also used : TreasureHuntModule(au.com.mineauz.minigames.minigame.modules.TreasureHuntModule) MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 13 with Minigame

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

the class CreateCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        Player player = (Player) sender;
        if (!plugin.mdata.hasMinigame(args[0])) {
            String mgmName = args[0];
            MinigameType type = MinigameType.SINGLEPLAYER;
            if (args.length >= 2) {
                if (MinigameType.hasValue(args[1].toUpperCase())) {
                    type = MinigameType.valueOf(args[1].toUpperCase());
                } else {
                    player.sendMessage(ChatColor.RED + "There is no Minigame type by the name \"" + args[1] + "\"!");
                }
            }
            Minigame mgm = new Minigame(mgmName, type, player.getLocation());
            player.sendMessage(ChatColor.GRAY + "The Minigame " + args[0] + " has been created.");
            List<String> mgs = null;
            if (plugin.getConfig().contains("minigames")) {
                mgs = plugin.getConfig().getStringList("minigames");
            } else {
                mgs = new ArrayList<String>();
            }
            mgs.add(mgmName);
            plugin.getConfig().set("minigames", mgs);
            plugin.saveConfig();
            mgm.saveMinigame();
            plugin.mdata.addMinigame(mgm);
        } else {
            sender.sendMessage(ChatColor.RED + "This Minigame already exists!");
        }
        return true;
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) MinigameType(au.com.mineauz.minigames.gametypes.MinigameType) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 14 with Minigame

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

the class DisableAllCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    MinigameData mdata = Minigames.plugin.mdata;
    List<Minigame> minigames = new ArrayList<Minigame>(mdata.getAllMinigames().values());
    if (args != null) {
        for (String arg : args) {
            if (mdata.hasMinigame(arg))
                minigames.remove(mdata.getMinigame(arg));
            else
                sender.sendMessage(ChatColor.RED + "No Minigame found by the name \"" + arg + "\"; Ignoring...");
        }
    }
    for (Minigame mg : minigames) {
        mg.setEnabled(false);
    }
    sender.sendMessage(ChatColor.GRAY + String.valueOf(minigames.size()) + " Minigames disabled!");
    return true;
}
Also used : MinigameData(au.com.mineauz.minigames.MinigameData) ArrayList(java.util.ArrayList) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Example 15 with Minigame

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