private boolean setMonsters(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { return true; } Player player = (Player) sender; if (args.length != 1) { return false; } boolean val = false; if (args[0].equalsIgnoreCase("on")) { val = true; } else if (args[0].equalsIgnoreCase("off")) { val = false; } else { return false; } WorldInstance instance = plugin.getWorldInstance(player); if (instance == null) { player.sendMessage("You are not in an instance."); return true; } instance.getBase().setMonstersEnabled(val); setConfigValue(instance, "monsters", val); return true; }
private boolean setPlaceables(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { return true; } Player player = (Player) sender; if (args.length != 1 || !args[0].matches("^[0-9]+(,[0-9]+)*$")) { return false; } String[] s = args[0].split(","); int[] types = new int[s.length]; for (int i = 0; i < s.length; i++) { types[i] = Integer.parseInt(s[i]); } WorldInstance instance = plugin.getWorldInstance(player); if (instance == null) { player.sendMessage("You are not in an instance."); return true; } instance.getBase().setPlaceable(types); setConfigValue(instance, "placeable", types); return true; }
private boolean start(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { return true; } Player player = (Player) sender; WorldInstance instance = plugin.getWorldInstance(player); if (instance == null) { player.sendMessage("You are not in an instance."); return true; } Location loc = player.getLocation(); String location = loc.getX() + "," + loc.getY() + "," + loc.getZ() + "," + loc.getYaw() + "," + loc.getPitch(); instance.getBase().setStartLocationString(location); setConfigValue(instance, "start", location); return true; }
private boolean listWorlds(CommandSender sender, String[] args) { int i = 1; for (World world : plugin.getServer().getWorlds()) { WorldInstance instance = plugin.getWorldInstance(world); String s = "World " + i + ": " + world.getName(); if (instance != null) { s += " instance of " + instance.getBase().getName(); } sender.sendMessage(s); i++; } return true; }
private boolean saveWorld(CommandSender sender, String[] args) { final Player player = (Player) sender; final WorldInstance instance = plugin.getWorldInstance(player); if (instance == null) { player.sendMessage("You must be in an instance to do this."); } else { instance.getInstanceWorld().save(); Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { public void run() { instance.overwriteBase(); player.sendMessage("World base saved."); } }, 40); } return true; }
private boolean leave(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { return true; } Player player = (Player) sender; boolean warn = true; final WorldInstance instance = plugin.getWorldInstance(player); if (instance != null) { instance.eject(player); warn = false; Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { public void run() { if (instance.worldLoaded() && instance.getInstanceWorld().getPlayers().size() == 0) { plugin.killInstance(instance, false); } } }, 600); } Party party = plugin.parties.get(player.getName().toLowerCase()); if (party == null) { if (warn) { player.sendMessage("You are not in a party."); } } else { party.remove(player); plugin.parties.remove(player.getName().toLowerCase()); } return true; }
private boolean setMax(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { return true; } Player player = (Player) sender; if (args.length != 1 || !args[0].matches("^[0-9]+$")) { return false; } int min = Integer.parseInt(args[0]); WorldInstance instance = plugin.getWorldInstance(player); if (instance == null) { player.sendMessage("You are not in an instance."); return true; } instance.getBase().setMaxPlayers(min); setConfigValue(instance, "max-players", min); return true; }