类org.bukkit.generator.ChunkGenerator源码实例Demo

下面列出了怎么用org.bukkit.generator.ChunkGenerator的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: uSkyBlock   文件: WorldManager.java
/**
 * Gets the skyblock island {@link World}. Creates and/or imports the world if necessary.
 * @return Skyblock island world.
 */
@NotNull
public synchronized World getWorld() {
    if (skyBlockWorld == null) {
        skyBlockWorld = Bukkit.getWorld(Settings.general_worldName);
        ChunkGenerator skyGenerator = getOverworldGenerator();
        ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null;
        if (skyBlockWorld == null
                || skyBlockWorld.canGenerateStructures()
                || worldGenerator == null
                || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) {
            skyBlockWorld = WorldCreator
                    .name(Settings.general_worldName)
                    .type(WorldType.NORMAL)
                    .generateStructures(false)
                    .environment(World.Environment.NORMAL)
                    .generator(skyGenerator)
                    .createWorld();
            skyBlockWorld.save();
        }
        MultiverseCoreHandler.importWorld(skyBlockWorld);
        setupWorld(skyBlockWorld, island_height);
    }
    return skyBlockWorld;
}
 
源代码2 项目: uSkyBlock   文件: WorldManager.java
/**
 * Gets the skyblock nether island {@link World}. Creates and/or imports the world if necessary. Returns null if
 * the nether is not enabled in the plugin configuration.
 * @return Skyblock nether island world, or null if nether is disabled.
 */
@Nullable
public synchronized World getNetherWorld() {
    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())) {
            skyBlockNetherWorld = WorldCreator
                    .name(Settings.general_worldName + "_nether")
                    .type(WorldType.NORMAL)
                    .generateStructures(false)
                    .environment(World.Environment.NETHER)
                    .generator(skyGenerator)
                    .createWorld();
            skyBlockNetherWorld.save();
        }
        MultiverseCoreHandler.importNetherWorld(skyBlockNetherWorld);
        setupWorld(skyBlockNetherWorld, island_height / 2);
        MultiverseInventoriesHandler.linkWorlds(getWorld(), skyBlockNetherWorld);
    }
    return skyBlockNetherWorld;
}
 
源代码3 项目: Kettle   文件: WorldCreator.java
/**
 * 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;
}
 
源代码4 项目: Kettle   文件: CraftWorld.java
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);
    }
}
 
源代码5 项目: Kettle   文件: CraftServer.java
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;
}
 
源代码6 项目: Thermos   文件: CraftWorld.java
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);
    }
}
 
源代码7 项目: Thermos   文件: CraftServer.java
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;
}
 
源代码8 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码9 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码10 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.THE_VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码11 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码12 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码13 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ChunkGenerator getChunkGenerator() {
	return new ChunkGenerator() {
		@Override
		public final ChunkGenerator.ChunkData generateChunkData(final World world, final Random random, final int x, final int z, final ChunkGenerator.BiomeGrid chunkGererator) {
			final ChunkGenerator.ChunkData chunkData = this.createChunkData(world);
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					chunkGererator.setBiome(i, j, Biome.VOID);
				}
			}
			return chunkData;
		}
	};
}
 
源代码14 项目: uSkyBlock   文件: WorldManager.java
/**
 * Gets the {@link ChunkGenerator} responsible for generating chunks in the overworld skyworld.
 * @return ChunkGenerator for overworld skyworld.
 */
@NotNull
private ChunkGenerator getOverworldGenerator() {
    try {
        String clazz = plugin.getConfig().getString("options.advanced.chunk-generator",
                "us.talabrek.ultimateskyblock.world.SkyBlockChunkGenerator");
        Object generator = Class.forName(clazz).newInstance();
        if (generator instanceof ChunkGenerator) {
            return (ChunkGenerator) generator;
        }
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
        logger.log(Level.WARNING, "Invalid overworld chunk-generator configured: " + ex);
    }
    return new SkyBlockChunkGenerator();
}
 
源代码15 项目: uSkyBlock   文件: WorldManager.java
/**
 * Gets the {@link ChunkGenerator} responsible for generating chunks in the nether skyworld.
 * @return ChunkGenerator for nether skyworld.
 */
@NotNull
private ChunkGenerator getNetherGenerator() {
    try {
        String clazz = plugin.getConfig().getString("nether.chunk-generator",
                "us.talabrek.ultimateskyblock.world.SkyBlockNetherChunkGenerator");
        Object generator = Class.forName(clazz).newInstance();
        if (generator instanceof ChunkGenerator) {
            return (ChunkGenerator) generator;
        }
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
        logger.log(Level.WARNING, "Invalid nether chunk-generator configured: " + ex);
    }
    return new SkyBlockNetherChunkGenerator();
}
 
源代码16 项目: uSkyBlock   文件: WorldManager.java
/**
 * Gets a {@link ChunkGenerator} for use in a default world, as specified in the server configuration
 * @param worldName Name of the world that this will be applied to
 * @param id Unique ID, if any, that was specified to indicate which generator was requested
 * @return ChunkGenerator for use in the default world generation
 */
@Nullable
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
    Validate.notNull(worldName, "WorldName cannot be null");

    return ((id != null && id.endsWith("nether")) || (worldName.endsWith("nether")))
            && Settings.nether_enabled
            ? getNetherGenerator()
            : getOverworldGenerator();
}
 
源代码17 项目: IridiumSkyblock   文件: IridiumSkyblock.java
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    if (worldName.equals(configuration.worldName) || worldName.equals(configuration.netherWorldName))
        return generator;
    return super.getDefaultWorldGenerator(worldName, id);
}
 
源代码18 项目: Kettle   文件: JavaPlugin.java
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    return null;
}
 
源代码19 项目: Kettle   文件: CustomChunkGenerator.java
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) {
    this.world = (WorldServer) world;
    this.generator = generator;

    this.random = new Random(seed);
}
 
源代码20 项目: Kettle   文件: CraftWorld.java
public ChunkGenerator getGenerator() {
    return generator;
}
 
源代码21 项目: Kettle   文件: CraftServer.java
public World createWorld(String name, Environment environment, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).generator(generator).createWorld();
}
 
源代码22 项目: Kettle   文件: CraftServer.java
public World createWorld(String name, Environment environment, long seed, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).seed(seed).generator(generator).createWorld();
}
 
源代码23 项目: Kettle   文件: CraftServer.java
@Override
public World createWorld(WorldCreator creator) {
    Validate.notNull(creator, "Creator may not be null");

    String name = creator.name();
    ChunkGenerator generator = creator.generator();
    File folder = new File(getWorldContainer(), name);
    World world = getWorld(name);
    WorldType type = WorldType.parseWorldType(creator.type().getName());
    boolean generateStructures = creator.generateStructures();

    if ((folder.exists()) && (!folder.isDirectory())) {
        throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
    }

    if (world != null) {
        return world;
    }

    boolean hardcore = false;

    WorldSettings worldSettings = new WorldSettings(creator.seed(), WorldSettings.getGameTypeById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    WorldServer internal = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
    System.out.println("Preparing start region for level " + (console.worldServerList.size() - 1) + " (Seed: " + internal.getSeed() + ")");

    if (internal.getWorld().getKeepSpawnInMemory()) {
        short short1 = 196;
        long i = System.currentTimeMillis();
        for (int j = -short1; j <= short1; j += 16) {
            for (int k = -short1; k <= short1; k += 16) {
                long l = System.currentTimeMillis();

                if (l < i) {
                    i = l;
                }

                if (l > i + 1000L) {
                    int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                    int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

                    System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                BlockPos chunkcoordinates = internal.getSpawnPoint();
                internal.getChunkProvider().loadChunk(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
    return internal.getWorld();
}
 
源代码24 项目: Kettle   文件: CraftServer.java
@Override
public ChunkGenerator.ChunkData createChunkData(World world) {
    return new CraftChunkData(world);
}
 
源代码25 项目: TabooLib   文件: InternalPlugin.java
@Override
public ChunkGenerator getDefaultWorldGenerator(String s, String s1) {
    return null;
}
 
源代码26 项目: Civs   文件: WorldImpl.java
@Override
public ChunkGenerator getGenerator() {
    return null;
}
 
源代码27 项目: Chimera   文件: MockServer.java
@Override
public ChunkGenerator.ChunkData createChunkData(World world) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
源代码28 项目: SonarPet   文件: BootstrapedPlugin.java
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    return null;
}
 
源代码29 项目: SonarPet   文件: Bootstrap.java
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    return plugin.getDefaultWorldGenerator(worldName, id);
}
 
源代码30 项目: SaneEconomy   文件: MockServer.java
@Override
public ChunkGenerator.ChunkData createChunkData(World world) {
    return null;
}
 
 类所在包
 同包方法