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;
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations