org.bukkit.event.world.WorldInitEvent Java Examples

The following examples show how to use org.bukkit.event.world.WorldInitEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent e){
    World world = e.getWorld();
    MainConfiguration cfg = GameManager.getGameManager().getConfiguration();
    if (world.getName().equals(cfg.getOverworldUuid()) && cfg.getEnableGenerateSugarcane()){
        world.getPopulators().add(new SurgarCanePopulator(cfg.getGenerateSugarcanePercentage()));
    }
    if (world.getName().equals(cfg.getOverworldUuid()) && cfg.getReplaceOceanBiomes() && UhcCore.getVersion() >= 14){
        world.getPopulators().add(new BiomeTypePopulator());
    }
    if (world.getName().equals(cfg.getOverworldUuid()) && cfg.getCaveOresOnly()){
        world.getPopulators().add(new CaveOresOnlyPopulator());
    }
}
 
Example #2
Source File: WorldGeneratorInjector.java    From Carbon-2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
    WorldServer nmsworld = ((CraftWorld) event.getWorld()).getHandle();
    IChunkProvider genprovider = nmsworld.chunkProviderServer.chunkProvider;
    if (genprovider instanceof SkyLandsChunkGenerator) {
        ReflectionUtils.setFieldValue(NormalChunkGenerator.class, "provider", genprovider, new NewChunkProviderTheEnd(nmsworld, nmsworld.getSeed()));
    }
}
 
Example #3
Source File: BukkitQueue_0.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public static void onWorldLoad(WorldInitEvent event) {
    if (disableChunkLoad) {
        World world = event.getWorld();
        world.setKeepSpawnInMemory(false);
    }
}
 
Example #4
Source File: DWorldListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onInit(WorldInitEvent event) {
    World world = event.getWorld();
    if (plugin.isInstance(world)) {
        world.setKeepSpawnInMemory(false);
    }
}
 
Example #5
Source File: WorldGeneratorInjector.java    From Carbon-2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
    WorldServer nmsworld = ((CraftWorld) event.getWorld()).getHandle();
    IChunkProvider genprovider = nmsworld.chunkProviderServer.chunkProvider;
    if (genprovider instanceof SkyLandsChunkGenerator) {
        ReflectionUtils.setFieldValue(NormalChunkGenerator.class, "provider", genprovider, new NewChunkProviderTheEnd(nmsworld, nmsworld.getSeed()));
    }
}
 
Example #6
Source File: CarbonWorldGenerator.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
	//Add new chunkprovidergenerate
	if (plugin.getConfig().getStringList("options.worlds").contains(event.getWorld().getName()) && event.getWorld().getEnvironment() == Environment.NORMAL) {
 	WorldServer nmsWorld = ((CraftWorld) event.getWorld()).getHandle();
 	nmsWorld.chunkProviderServer.chunkProvider = new ChunkProviderGenerate(nmsWorld, nmsWorld.getSeed(), nmsWorld.getWorldData().shouldGenerateMapFeatures());
	}
}
 
Example #7
Source File: WorldBlacklistUpdater.java    From Minepacks with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(final WorldInitEvent event)
{
	String worldName = event.getWorld().getName().toLowerCase(Locale.ROOT);
	if(!plugin.getConfiguration().getWorldFilteredList().contains(worldName))
	{
		plugin.getWorldBlacklist().add(worldName);
	}
}
 
Example #8
Source File: TreePlugin.java    From GiantTrees with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(final WorldInitEvent event) {
  for (final String worldName : TreePlugin.this.getConfig()
                                               .getStringList("worlds")) {
    if (worldName.equals(event.getWorld().getName())) {
      TreePlugin.this.getLogger()
                     .info("Attaching giant tree populator to world \""
                               + event.getWorld().getName() + "\"");
      event.getWorld().getPopulators()
           .add(new TreePopulator(TreePlugin.this));
      return;
    }
  }
}
 
Example #9
Source File: CraftServer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@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();
}
 
Example #10
Source File: DisableKeepSpawnInMemoryListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
    event.getWorld().setKeepSpawnInMemory(false);
}
 
Example #11
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@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);
    net.minecraft.world.WorldType type = net.minecraft.world.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(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true;
    System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension

    if (worldserver.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 " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
                worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false;
    return worldserver.getWorld();
}
 
Example #12
Source File: WorldTileEntityListInjectorListener.java    From Carbon with GNU Lesser General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
	WorldServer nmsWorld = ((CraftWorld) event.getWorld()).getHandle();
	nmsWorld.tileEntityList = new OptimizedTileEntityList();
}