public WorldCreatorData( Optional<String> name, @Nullable Dimension dimension, Optional<Long> seed, @Nullable WorldType type, Optional<ChunkGenerator> generator, @Nullable String generatorSettings, @Nullable Boolean structures ) { if (name == null) { throw new IllegalArgumentException("The name of a creator cannot be null!"); } this.name = name; this.dimension = Optional.ofNullable(dimension).orElse(Dimension.NORMAL); this.type = Optional.ofNullable(type).orElse(WorldType.NORMAL); this.seed = seed; this.generator = generator; this.generatorSettings = Optional.ofNullable(generatorSettings).orElse(""); this.structures = Optional.ofNullable(structures).orElse(true); }
public static WorldCreatorData withGeneratorID( Optional<String> name, @Nullable Dimension dimension, Optional<Long> seed, @Nullable WorldType type, String generatorID, @Nullable String generatorSettings, @Nullable Boolean structures ) { return new WorldCreatorData( name, dimension, seed, type, Optional.ofNullable(generatorID).map(ChunkGeneratorWithID::getGenerator), generatorSettings, structures ); }
/** * Get the world that Beaconz runs in and if it doesn't exist, make it * @return */ public World getBeaconzWorld() { // Check to see if the world exists, and if not, make it if (beaconzWorld == null) { // World doesn't exist, so make it getLogger().info("World is '" + Settings.worldName + "'"); try { beaconzWorld = WorldCreator.name(Settings.worldName).type(WorldType.NORMAL).environment(World.Environment.NORMAL).createWorld(); } catch (Exception e) { getLogger().info("Could not make world yet.."); return null; } if (!beaconzWorld.getPopulators().contains(getBp())) { beaconzWorld.getPopulators().add(getBp()); } } // This is not allowed in this function as it can be called async //beaconzWorld.setSpawnLocation(Settings.xCenter, beaconzWorld.getHighestBlockYAt(Settings.xCenter, Settings.zCenter), Settings.zCenter); return beaconzWorld; }
public void createWorld(String name, long seed, String generator, Environment env, WorldType type, boolean genStructures, boolean providedSeed) { name = name.toLowerCase(); World w = this.createBukkitWorld(name, seed, generator, env, type, genStructures, providedSeed); this.database.setValue("worlds." + name + ".seed", seed); if(generator != null) { this.database.setValue("worlds." + name + ".generator", generator); } this.database.setValue("worlds." + name + ".environment", env.name()); this.database.setValue("worlds." + name + ".type", type.name()); this.database.setValue("worlds." + name + ".generateStructures", genStructures); this.database.setValue("worlds." + name + ".pvp", false); this.database.setValue("worlds." + name + ".difficulty", Difficulty.EASY.name()); this.database.setValue("worlds." + name + ".gamemode", GameMode.SURVIVAL.name()); WorldData world = new WorldData(this.module, this, name); world.setWorld(w); this.worlds.put(name, world); }
public World getWorld() { if (uSkyBlock.skyBlockWorld == null) { skyBlockWorld = Bukkit.getWorld(Settings.general_worldName); ChunkGenerator skyGenerator = getGenerator(); ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null; if (skyBlockWorld == null || skyBlockWorld.canGenerateStructures() || worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) { uSkyBlock.skyBlockWorld = WorldCreator .name(Settings.general_worldName) .type(WorldType.NORMAL) .generateStructures(false) .environment(World.Environment.NORMAL) .generator(skyGenerator) .createWorld(); uSkyBlock.skyBlockWorld.save(); } MultiverseCoreHandler.importWorld(skyBlockWorld); setupWorld(skyBlockWorld, island_height); } return uSkyBlock.skyBlockWorld; }
public World getSkyBlockNetherWorld() { if (skyBlockNetherWorld == null && Settings.nether_enabled) { skyBlockNetherWorld = Bukkit.getWorld(Settings.general_worldName + "_nether"); ChunkGenerator skyGenerator = getNetherGenerator(); ChunkGenerator worldGenerator = skyBlockNetherWorld != null ? skyBlockNetherWorld.getGenerator() : null; if (skyBlockNetherWorld == null || skyBlockNetherWorld.canGenerateStructures() || worldGenerator == null || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) { uSkyBlock.skyBlockNetherWorld = WorldCreator .name(Settings.general_worldName + "_nether") .type(WorldType.NORMAL) .generateStructures(false) .environment(World.Environment.NETHER) .generator(skyGenerator) .createWorld(); uSkyBlock.skyBlockNetherWorld.save(); } MultiverseCoreHandler.importNetherWorld(skyBlockNetherWorld); setupWorld(skyBlockNetherWorld, island_height / 2); MultiverseInventoriesHandler.linkWorlds(getWorld(), skyBlockNetherWorld); } return skyBlockNetherWorld; }
private static World createArenaWorld(ConfigArena arena, String name) { World world; world = Bukkit.getServer().getWorld(name); if (world == null) { WorldCreator wc = new WorldCreator(name); wc.environment(Environment.NORMAL); wc.type(WorldType.FLAT); wc.generateStructures(false); world = Bukkit.getServer().createWorld(wc); world.setAutoSave(false); world.setSpawnFlags(false, false); world.setKeepSpawnInMemory(false); ChunkCoord.addWorld(world); } return world; }
/** * @return the netherWorld */ public static World getNetherWorld() { if (netherWorld == null && Settings.createNether) { if (Settings.useOwnGenerator) { return Bukkit.getServer().getWorld(Settings.worldName +"_nether"); } if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether..."); } if (!Settings.newNether) { netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld(); } else { netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld()) .environment(World.Environment.NETHER).createWorld(); } netherWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit); netherWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit); } return netherWorld; }
public void create() { arenaWorld = plugin.getServer().getWorld(Statics.ARENA_WORLD_NAME); if (arenaWorld == null) { plugin.getLogger().info("Loading world '" + Statics.ARENA_WORLD_NAME + "'."); WorldCreator arenaWorldCreator = new WorldCreator(Statics.ARENA_WORLD_NAME); arenaWorldCreator.generateStructures(false); arenaWorldCreator.generator(new VoidGenerator()); arenaWorldCreator.type(WorldType.FLAT); arenaWorldCreator.seed(0); arenaWorld = arenaWorldCreator.createWorld(); plugin.getLogger().info("Done loading world '" + Statics.ARENA_WORLD_NAME + "'."); } else { plugin.getLogger().info("The world '" + Statics.ARENA_WORLD_NAME + "' was already loaded."); } arenaWorld.setAutoSave(false); arenaWorld.getBlockAt(-5000, 45, -5000).setType(Material.STONE); arenaWorld.setSpawnLocation(-5000, 50, -5000); for (Map.Entry<String, String> entry : plugin.getConfiguration().getArenaGamerules().entrySet()) { arenaWorld.setGameRuleValue(entry.getKey(), entry.getValue()); } arenaWorld.setTime(4000); }
/** * Generates the Skyblock worlds. */ public IslandWorld(BSkyBlock plugin) { if (Settings.useOwnGenerator) { // Do nothing return; } if (plugin.getServer().getWorld(Settings.worldName) == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Island World..."); } // Create the world if it does not exist islandWorld = WorldCreator.name(Settings.worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld()) .createWorld(); // Make the nether if it does not exist if (Settings.netherGenerate) { if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether..."); } if (!Settings.netherIslands) { netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld(); } else { netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld()) .environment(World.Environment.NETHER).createWorld(); } } // Make the end if it does not exist if (Settings.endGenerate) { if (plugin.getServer().getWorld(Settings.worldName + "_the_end") == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s End World..."); } if (!Settings.endIslands) { endWorld = WorldCreator.name(Settings.worldName + "_the_end").type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld(); } else { endWorld = WorldCreator.name(Settings.worldName + "_the_end").type(WorldType.FLAT).generator(new ChunkGeneratorWorld()) .environment(World.Environment.THE_END).createWorld(); } } fixMultiverse(plugin); }
/** * Loads a local world * * @param name the world to load * @return the loaded world * @throws WorldException if the world is not found or something else goes wrong */ @Nonnull public World loadLocalWorld(@Nonnull String name) { org.bukkit.WorldCreator wc = new WorldCreator(name); wc.environment(World.Environment.NORMAL); //TODO do we need support for environment in maps? wc.generateStructures(false); wc.type(WorldType.NORMAL); wc.generator(new CleanRoomChunkGenerator()); wc.generatorSettings(""); World world = wc.createWorld(); world.setAutoSave(false); return world; }
@Override public void loadLocalWorld(@Nonnull String name) { WorldCreator wc = new WorldCreator(name); wc.environment(World.Environment.NORMAL); //TODO do we need support for environment in maps? wc.generateStructures(false); wc.type(WorldType.NORMAL); wc.generator(new CleanRoomChunkGenerator()); wc.generatorSettings(""); World world = wc.createWorld(); world.setAutoSave(false); }
@Override protected WorldCreatorData[] get(Event event) { Optional<String> name = Optional.ofNullable(nameExpr).map(expr -> expr.getSingle(event)); Logging.debug(this, "Creator Name: " + name); Dimension dimension = Optional.ofNullable(dimensionExpr).map(expr -> expr.getSingle(event)).orElse(null); Optional<Long> seed = Optional.ofNullable(seedExpr).map(expr -> Long.parseLong(expr.getSingle(event))); WorldType type = Optional.ofNullable(typeExpr).map(expr -> expr.getSingle(event)).orElse(null); String generator = Optional.ofNullable(generatorExpr).map(expr -> expr.getSingle(event)).orElse(null); String generatorSettings = Optional.ofNullable(generatorSettingsExpr).map(expr -> expr.getSingle(event)).orElse(null); Boolean structures = Optional.ofNullable(structuresExpr).map(expr -> expr.getSingle(event)).orElse(null); return new WorldCreatorData[]{WorldCreatorData.withGeneratorID(name, dimension, seed, type, generator, generatorSettings, structures)}; }
@Override public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) { nameExpr = (Expression<String>) expressions[0]; dimensionExpr = (Expression<Dimension>) expressions[1]; seedExpr = (Expression<String>) expressions[2]; typeExpr = (Expression<WorldType>) expressions[3]; generatorExpr = (Expression<String>) expressions[4]; generatorSettingsExpr = (Expression<String>) expressions[5]; structuresExpr = (Expression<Boolean>) expressions[6]; return true; }
public static Optional<WorldCreatorData> fromJSON(Optional<String> worldName, JSONObject jsonObject) { try { Dimension dimension = Dimension.valueOf((String) jsonObject.get("environment")); Optional<Long> seed = Optional.ofNullable((String) jsonObject.get("seed")).map(Long::parseLong); WorldType type = WorldType.valueOf((String) jsonObject.get("worldtype")); String generatorID = (String) jsonObject.get("generator"); String generatorSettings = (String) jsonObject.get("generatorsettings"); Boolean structures = (Boolean) jsonObject.get("structures"); return Optional.of(withGeneratorID(worldName, dimension, seed, type, generatorID, generatorSettings, structures)); } catch (ClassCastException e) { return Optional.empty(); } }
@Override protected void execute(Event event) { String name = nameExpr.getSingle(event); Logging.debug(this, "World Creation Name: " + name); Dimension dimension = Optional.ofNullable(dimensionExpr).map(expr -> expr.getSingle(event)).orElse(null); Optional<Long> seed = Optional.ofNullable(seedExpr).map(expr -> Long.parseLong(expr.getSingle(event))); WorldType type = Optional.ofNullable(typeExpr).map(expr -> expr.getSingle(event)).orElse(null); String generator = Optional.ofNullable(generatorExpr).map(expr -> expr.getSingle(event)).orElse(null); String generatorSettings = Optional.ofNullable(generatorSettingsExpr).map(expr -> expr.getSingle(event)).orElse(null); Boolean structures = Optional.ofNullable(structuresExpr).map(expr -> expr.getSingle(event)).orElse(null); WorldCreatorData.withGeneratorID(Optional.of(name), dimension, seed, type, generator, generatorSettings, structures).createWorld(); }
@Override public void onLoad() { add(WorldType.NORMAL, "Normal", "Default", "Def", "Norm", "DE", "D", "NO", "N"); add(WorldType.FLAT, "Flat", "Super Flat", "SFlat", "Creative", "FL", "F"); add(WorldType.VERSION_1_1, "Version 1.1", "Old", "Old Version", "Beta", "1.1", "1_1", "V1.1", "V1_1"); add(WorldType.LARGE_BIOMES, "Large Biomes", "LBiomes", "Large", "LB", "Big Biomes", "Big", "BB"); add(WorldType.AMPLIFIED, "Amplified", "Amp", "AM", "A"); add(WorldType.CUSTOMIZED, "Customized", "Custom", "CU", "C"); }
public static Object createRespawnPacket(int dimId, Difficulty difficulty, WorldType worldType, NativeGameMode gamemode) { PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.RESPAWN); container.getIntegers().write(0, dimId); container.getDifficulties().write(0, difficulty); container.getWorldTypeModifier().write(0, worldType); container.getGameModes().write(0, gamemode); return container.getHandle(); }
public static Object createJoinGamePacket(int playerId, int maxPlayers) { PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.LOGIN); container.getIntegers().write(0, playerId); container.getIntegers().write(2, maxPlayers); container.getGameModes().write(0, NativeGameMode.SURVIVAL); container.getWorldTypeModifier().write(0, WorldType.NORMAL); container.getDifficulties().write(0, Difficulty.EASY); return container.getHandle(); }
public static TestWorld create(String name, Environment env, WorldType type) { TestWorld world = mock(TestWorld.class, Mockito.CALLS_REAL_METHODS); world.name = name; world.uid = UUID.randomUUID(); world.env = env; world.worldType = type; world.blocks = new HashMap<Location, Block>(); world.loadedChunks = new HashSet<TestChunk>(); return world; }
/** * Converts the world type. * * @param worldType * The Bukkit world type. * @return The Nukkit world type. * @throws IllegalArgumentException * When the Bukkit world type cannot be translated. */ public static Class<? extends Generator> toNukkit(WorldType worldType) throws IllegalArgumentException { switch (worldType) { case FLAT: return Generator.getGenerator(Generator.TYPE_FLAT); case NORMAL: return Generator.getGenerator(Generator.TYPE_INFINITE); case VERSION_1_1: return Generator.getGenerator(Generator.TYPE_OLD); default: throw new IllegalArgumentException("World type does not exist on Pocket Edition: " + worldType); } }
@Override protected void initializeParameters(List<CommandParameter<?>> params) { //<World Name> <Seed> <World Type> <World Environment> <Generate Structures> params.add(new StringParameter("World Name")); params.add(new StringParameter("Seed")); params.add(new EnumParameter<WorldType>("World Type", WorldType.class)); params.add(new EnumParameter<Environment>("World Environment", Environment.class)); params.add(new BooleanParameter("Generate Structures")); }
private World createBukkitWorld(String name, long seed, String generator, Environment env, WorldType type, boolean genStructures, boolean providedSeed) { WorldCreator c = new WorldCreator(name); if(providedSeed) { c.seed(seed); } if(generator != null) { c.generator(generator); } c.environment(env); c.type(type); c.generateStructures(genStructures); return c.createWorld(); }
/** * @return the netherWorld */ public static World getNetherWorld() { if (netherWorld == null && Settings.createNether) { if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether..."); } netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).generator(new SkyGridGen()).createWorld(); netherWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit); netherWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit); } return netherWorld; }
/** * @return the endWorld */ public static World getEndWorld() { if (endWorld == null && Settings.createEnd) { if (plugin.getServer().getWorld(Settings.worldName + "_the_end") == null) { Bukkit.getLogger().info("Creating " + plugin.getName() + "'s End..."); } endWorld = WorldCreator.name(Settings.worldName + "_the_end").type(WorldType.NORMAL).environment(World.Environment.THE_END).generator(new SkyGridGen()).createWorld(); endWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit); endWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit); } return endWorld; }
public void create_cmd() throws CivException { String name = getNamedString(1, "enter a world name"); WorldCreator wc = new WorldCreator(name); wc.environment(Environment.NORMAL); wc.type(WorldType.FLAT); wc.generateStructures(false); World world = Bukkit.getServer().createWorld(wc); world.setSpawnFlags(false, false); ChunkCoord.addWorld(world); CivMessage.sendSuccess(sender, "World "+name+" created."); }
private void createWorld() { isGenerating = true; world = WorldCreator.name("5min2live").type(WorldType.NORMAL) .environment(World.Environment.NORMAL).generateStructures(false).createWorld(); world.setDifficulty(Difficulty.HARD); final boolean pvpEnabled = fmtl.getConfig().getBoolean("pvp", false); world.setPVP(pvpEnabled); logInfo("PVP Enabled: " + pvpEnabled); eventNotifier.callEvent(new WorldReadyEvent(world)); isGenerating = false; }
public boolean commandUse(CommandSender sender, String[] args) { Variables var = Necessities.getVar(); if (args.length == 0) { sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You must enter a world name."); return true; } WorldManager wm = Necessities.getWM(); if (wm.worldExists(args[0])) { sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "That world already exists."); return true; } if (wm.worldUnloaded(args[0])) { sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "That world already exists just use /loadworld."); return true; } World.Environment environment = World.Environment.NORMAL; if (args.length > 1) wm.getEnvironment(args[1]);//would check if valid... but it auto changes to normal if not so that works fine I guess String generator = null; if (args.length > 2 && !args[2].equalsIgnoreCase("null")) generator = args[2];//TODO: Check if valid generator somehow WorldType type = WorldType.NORMAL; if (args.length > 3) type = wm.getType(args[3]); wm.createWorld(args[0], environment, generator, type); sender.sendMessage(var.getMessages() + "Created world named " + var.getObj() + args[0] + var.getMessages() + '.'); return true; }
public static WorldType addBukkitWorldType(String name) { if (!isSetup) { setup(); } WorldType worldType = addEnum(WorldType.class, name, new Class [] { String.class }, new Object[] { name }); Map<String, WorldType> BY_NAME = ReflectionHelper.getPrivateValue(WorldType.class, null, "BY_NAME"); BY_NAME.put(name.toUpperCase(), worldType); return worldType; }
public SGWorld(String name, String map) { this.name = name; displayName = map; wc = new WorldCreator(name); wc.environment(World.Environment.NORMAL); wc.type(WorldType.NORMAL); }
@Override protected World generateWorld() { if (!TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean()) { return null; } wipeFlatlandsIfFlagged(); WorldCreator worldCreator = new WorldCreator(WORLD_NAME); worldCreator.generateStructures(false); worldCreator.type(WorldType.NORMAL); worldCreator.environment(World.Environment.NORMAL); worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS)); World world = Bukkit.getServer().createWorld(worldCreator); world.setSpawnFlags(false, false); world.setSpawnLocation(0, 50, 0); Block welcomeSignBlock = world.getBlockAt(0, 50, 0); welcomeSignBlock.setType(Material.SIGN_POST); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); signData.setFacingDirection(BlockFace.NORTH); welcomeSign.setLine(0, ChatColor.GREEN + "Flatlands"); welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---"); welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point"); welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---"); welcomeSign.update(); TFM_GameRuleHandler.commitGameRules(); return world; }
public static World makeNewMockWorld(String world, World.Environment env, WorldType type, long seed, ChunkGenerator generator) { World mockWorld = basics(world, env, type); when(mockWorld.getGenerator()).thenReturn(generator); when(mockWorld.getSeed()).thenReturn(seed); registerWorld(mockWorld); return mockWorld; }
@Override public void loadWorld(String world, int flags) { WorldCreator create = new WorldCreator(world); switch (flags & ENV_FLAGS) { case NETHER_FLAG: create.environment(Environment.NETHER); break; case END_FLAG: create.environment(Environment.THE_END); break; case 0: create.environment(Environment.NORMAL); break; default: throw new IllegalArgumentException("Illegal env flag passed"); } switch (flags & TYPE_FLAGS) { case FLAT_FLAG: create.type(WorldType.FLAT); break; case LARGE_BIOME_FLAG: create.type(WorldType.LARGE_BIOMES); break; case 0: create.type(WorldType.NORMAL); break; default: throw new IllegalArgumentException("Illegal type flag passed"); } create.createWorld(); }
@Override public WorldType getWorldType() { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
public WorldCreatorData setType(WorldType type) { return new WorldCreatorData(name, dimension, seed, type, generator, generatorSettings, structures); }
@Override public WorldCreatorData set(WorldCreatorData worldCreatorData, WorldType worldType) { return worldCreatorData.setType(worldType); }
@Override public WorldType convert(WorldCreatorData worldCreatorData) { return worldCreatorData.type; }
public static WorldType get(String string) { return instance()._get(string); }