private boolean newWorld(CommandSender sender, String[] args) { if (args.length < 3) { return false; } String worldName = args[0]; if (!worldName.matches("^[A-Za-z0-9_]+$")) { return false; } String seed = args[1]; if (!seed.matches("[0-9]+")) { return false; } String worldDesc = args[2]; for (int i = 3; i < args.length; i++) { worldDesc += " " + args[i]; } sender.sendMessage("Creating new world base..."); Configuration config = plugin.getConfig(); ConfigurationSection section = config.createSection("worlds." + worldName); section.set("folder", worldName); section.set("description", worldDesc); section.set("seed", Long.parseLong(seed)); plugin.saveConfig(); WorldBase base = new WorldBase(worldName, section); plugin.worldBases.put(worldName, base); WorldInstance instance = new WorldInstance(base, true, true); plugin.loadedWorlds.put(instance.getWorldName(), instance); if (sender instanceof Player) { instance.teleport((Player) sender); } sender.sendMessage("New world base created!"); return true; }
private void setConfigValue(WorldInstance instance, String key, Object value) { ConfigurationSection section = plugin.getConfig().getConfigurationSection("worlds." + instance.getBase().getName()); section.set(key, value); plugin.saveConfig(); }