@Override public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) { if (world.getEnvironment().equals(World.Environment.NETHER)) { return generateNetherChunks(world, random, chunkX, chunkZ, biomeGrid); } ChunkData result = createChunkData(world); if (Settings.seaHeight != 0) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < Settings.seaHeight; y++) { result.setBlock(x, y, z, Material.STATIONARY_WATER); } } } } return result; }
public void generate(byte[][] chunk, World world, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid grid) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { int realX = x + chunkX * 16; int realZ = z + chunkZ * 16; grid.setBiome(x, z, null); // Generate basic terrain double height = baseHeight + generateSea(realX, realZ, grid) + generateHugeMountain(realX, realZ) + terrainAmplitude1 * terrainGenerator1.noise(realX * terrainFreq1, realZ * terrainFreq1) + terrainAmplitude2 * terrainGenerator2.noise(realX * terrainFreq2, realZ * terrainFreq2); double humidity = 50D + 50D * humidityGenerator.noise(realX * humidityFreq, realZ * humidityFreq); double temperature = 8D + 24D * temperatureGenerator.noise(realX * temperatureFreq, realZ * temperatureFreq); if (height > baseHeight) grid.setBiome(x, z, null); for (int y = 1; y < 256; y++) { if (grid.getBiome(x, z) != null) { if (y < height) setBlock(x, y, z, chunk, Material.STONE); else if (y < baseHeight) setBlock(x, y, z, chunk, Material.WATER); else setBlock(x, y, z, chunk, Material.AIR); } else if (y <= height) setBlock(x, y, z, chunk, Material.STONE); } } } }
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 void displayGenerators(PlotPlayer plr) { StringBuffer message = new StringBuffer(); message.append("&6你想要生成什么类型地皮?"); for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) { if (entry.getKey().equals("PlotSquared")) { message.append("\n&8 - &2" + entry.getKey() + " (默认生成参数)"); } else if (entry.getValue() instanceof HybridGen) { message.append("\n&8 - &7" + entry.getKey() + " (混合生成参数)"); } else if (entry.getValue() instanceof PlotGenerator) { message.append("\n&8 - &7" + entry.getKey() + " (高级地皮生成参数)"); } else { message.append("\n&8 - &7" + entry.getKey() + " (其他生成参数)"); } } MainUtil.sendMessage(plr, message.toString()); }
@Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { WorldEvents.lastWorld = world; if (!PlotSquared.setupPlotWorld(world, id)) { return null; } HybridGen result = new HybridGen(world); TaskManager.runTaskLater(new Runnable() { @Override public void run() { if (WorldEvents.lastWorld != null && WorldEvents.lastWorld.equals(world)) { WorldEvents.lastWorld = null; } } }, 20); return result; }
@Override public void updateGenerators() { if (SetupUtils.generators.size() > 0) { return; } final String testWorld = "CheckingPlotSquaredGenerator"; for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (plugin.isEnabled()) { final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); if (generator != null) { PlotSquared.removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); // final PlotGenerator pgen = (PlotGenerator) generator; // if (pgen.getPlotManager() instanceof SquarePlotManager) { SetupUtils.generators.put(name, generator); // } // } } } } }
@Override public String getGenerator(PlotWorld plotworld) { if (SetupUtils.generators.size() == 0) { updateGenerators(); } World world = Bukkit.getWorld(plotworld.worldname); if (world == null) { return null; } ChunkGenerator generator = world.getGenerator(); if (!(generator instanceof PlotGenerator)) { return null; } for (Entry<String, ChunkGenerator> entry : generators.entrySet()) { if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) { return entry.getKey(); } } return null; }
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; }
@Override public final ChunkGenerator getDefaultWorldGenerator(String world, String id) { if (Settings.Enabled_Components.PLOTME_CONVERTER) { initPlotMeConverter(); Settings.Enabled_Components.PLOTME_CONVERTER = false; } IndependentPlotGenerator result; if (id != null && id.equalsIgnoreCase("single")) { result = new SingleWorldGenerator(); } else { result = PS.get().IMP.getDefaultGenerator(); if (!PS.get().setupPlotWorld(world, id, result)) { return null; } } return (ChunkGenerator) result.specify(world); }
@Override public GeneratorWrapper<?> getGenerator(String world, String name) { if (name == null) { return null; } Plugin genPlugin = Bukkit.getPluginManager().getPlugin(name); if (genPlugin != null && genPlugin.isEnabled()) { ChunkGenerator gen = genPlugin.getDefaultWorldGenerator(world, ""); if (gen instanceof GeneratorWrapper<?>) { return (GeneratorWrapper<?>) gen; } return new BukkitPlotGenerator(world, gen); } else { return new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator()); } }
@Override public String getGenerator(PlotArea plotArea) { if (SetupUtils.generators.isEmpty()) { updateGenerators(); } World world = Bukkit.getWorld(plotArea.worldname); if (world == null) { return null; } ChunkGenerator generator = world.getGenerator(); if (!(generator instanceof BukkitPlotGenerator)) { return null; } for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) { GeneratorWrapper<?> current = entry.getValue(); if (current.equals(generator)) { return entry.getKey(); } } return null; }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onWorldInit(WorldInitEvent event) { World world = event.getWorld(); String name = world.getName(); PlotAreaManager manager = PS.get().getPlotAreaManager(); if (manager instanceof SinglePlotAreaManager) { SinglePlotAreaManager single = (SinglePlotAreaManager) manager; if (single.isWorld(name)) { world.setKeepSpawnInMemory(false); return; } } ChunkGenerator gen = world.getGenerator(); if (gen instanceof GeneratorWrapper) { PS.get().loadWorld(name, (GeneratorWrapper<?>) gen); } else { PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen)); } }
public CraftWorld(net.minecraft.world.WorldServer world, ChunkGenerator gen, Environment env) { this.world = world; this.generator = gen; environment = env; if (server.chunkGCPeriod > 0) { chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); } }
public ChunkGenerator getGenerator(String world) { ConfigurationSection section = configuration.getConfigurationSection("worlds"); ChunkGenerator result = null; if (section != null) { section = section.getConfigurationSection(world); if (section != null) { String name = section.getString("generator"); if ((name != null) && (!name.equals(""))) { String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = pluginManager.getPlugin(split[0]); if (plugin == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' does not exist"); } else if (!plugin.isEnabled()) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)"); } else { try { result = plugin.getDefaultWorldGenerator(world, id); if (result == null) { getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator"); } } catch (Throwable t) { plugin.getLogger().log(Level.SEVERE, "Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName(), t); } } } } } return result; }
private double generateSea(int x, int z, ChunkGenerator.BiomeGrid grid) { double height = seaAmplitude * seaGenerator.noise(x * seaFreq, z * seaFreq); if (height < -0.05) { grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.OCEAN); if (height < -0.2) grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.DEEP_OCEAN); } return height > 0 ? 0 : height; }
@Override public ChunkData generateChunkData(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biome) { ChunkData chunkData = createChunkData(world); GeneratorEvent.Generation event = new GeneratorEvent.Generation(world, random, x, z, chunkData, biome); functionality.generation.ifPresent(triggerItem -> TriggerItem.walk(triggerItem, event)); return chunkData; }
public Generation(World world, Random random, Integer x, Integer z, ChunkGenerator.ChunkData chunkData, ChunkGenerator.BiomeGrid biomeGrid) { super(world, random); this.x = x; this.z = z; this.chunkData = chunkData; this.biomeGrid = biomeGrid; }
/** * Attempts to get the {@link ChunkGenerator} with the given name. * <p> * If the generator is not found, null will be returned and a message will * be printed to the specified {@link CommandSender} explaining why. * <p> * The name must be in the "plugin:id" notation, or optionally just * "plugin", where "plugin" is the safe-name of a plugin and "id" is an * optional unique identifier for the generator you wish to request from * the plugin. * * @param world Name of the world this will be used for * @param name Name of the generator to retrieve * @param output Where to output if errors are present * @return Resulting generator, or null */ public static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output) { ChunkGenerator result = null; if (world == null) { throw new IllegalArgumentException("World name must be specified"); } if (output == null) { output = Bukkit.getConsoleSender(); } if (name != null) { String[] split = name.split(":", 2); String id = (split.length > 1) ? split[1] : null; Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]); if (plugin == null) { output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + split[0] + "' does not exist"); } else if (!plugin.isEnabled()) { output.sendMessage("Could not set generator for world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled"); } else { result = plugin.getDefaultWorldGenerator(world, id); } } return result; }
public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) { this.world = world; this.generator = gen; environment = env; if (server.chunkGCPeriod > 0) { chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); } }
@Override public ChunkGenerator getGenerator(final String world, final String name) { final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); if ((gen_plugin != null) && gen_plugin.isEnabled()) { return gen_plugin.getDefaultWorldGenerator(world, ""); } else { return new HybridGen(world); } }