org.bukkit.event.world.WorldLoadEvent Java Examples

The following examples show how to use org.bukkit.event.world.WorldLoadEvent. 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: CarbonWorldGenerator.java    From Carbon with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler()
public void onWorldLoad(WorldLoadEvent evt) {
    //Add populator on world load
    World world = evt.getWorld();
    if (
        plugin.getConfig().getStringList("options.worlds").contains(world.getName()) && (
            !world.getPopulators().contains(dioritePopulator)
            && !world.getPopulators().contains(andesitePopulator)
            && !world.getPopulators().contains(granitePopulator)
        )
    ) {
        Carbon.log.log(Level.INFO, "[Carbon] Editing world: {0}", world.getName());
        Carbon.log.log(Level.INFO, "[Carbon] Adding populator for world: {0}", world.getName());
        world.getPopulators().add(dioritePopulator);
        world.getPopulators().add(andesitePopulator);
        world.getPopulators().add(granitePopulator);
        Carbon.log.log(Level.INFO, "[Carbon] Done editing world: {0}", world.getName());
	}
}
 
Example #2
Source File: BrokeLocationsControl.java    From Crazy-Crates with MIT License 6 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent e) {
    if (!cc.getBrokeCrateLocations().isEmpty()) {
        int fixedAmount = 0;
        List<BrokeLocation> fixedWorlds = new ArrayList<>();
        for (BrokeLocation brokeLocation : cc.getBrokeCrateLocations()) {
            Location location = brokeLocation.getLocation();
            if (location.getWorld() != null) {
                cc.getCrateLocations().add(new CrateLocation(brokeLocation.getLocationName(), brokeLocation.getCrate(), location));
                fixedWorlds.add(brokeLocation);
                fixedAmount++;
            }
        }
        cc.getBrokeCrateLocations().removeAll(fixedWorlds);
        if (fileManager.isLogging()) {
            System.out.println(fileManager.getPrefix() + "Fixed " + fixedAmount + " broken crate locations.");
            if (cc.getBrokeCrateLocations().isEmpty()) {
                System.out.println(fileManager.getPrefix() + "All broken crate locations have been fixed.");
            }
        }
    }
}
 
Example #3
Source File: WorldProblemListener.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void warnRandomTickRate(WorldLoadEvent event) {
  String str = event.getWorld().getGameRuleValue("randomTickSpeed");
  if (str != null) {
    int value = Integer.parseInt(str);
    if (value > RANDOM_TICK_SPEED_LIMIT) {
      broadcastDeveloperWarning(
          "Gamerule 'randomTickSpeed' is set to "
              + value
              + " for this world (normal value is 3). This may overload the server.");
    }
  }
}
 
Example #4
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldLoad(WorldLoadEvent e) {
    if (!UChat.get().getConfig().contains("general.default-channels.worlds." + e.getWorld().getName())) {
        UChat.get().getConfig().set("general.default-channels.worlds." + e.getWorld().getName() + ".channel", UChat.get().getConfig().contains("general.default-channels.default-channel"));
        UChat.get().getConfig().set("general.default-channels.worlds." + e.getWorld().getName() + ".force", false);
    }
}
 
Example #5
Source File: WorldListener.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent event) {
    for (Map.Entry<String, String> entry : new HashMap<>(UNLOADED_HOLOGRAMS).entrySet()) {
        if (entry.getValue().equals(event.getWorld().getName())) {
            HoloAPI.LOG.info("Loading hologram " + entry.getKey() + " into world " + entry.getValue() + ".");
            if (((SimpleHoloManager) HoloAPI.getManager()).loadFromFile(entry.getKey()) != null) {
                UNLOADED_HOLOGRAMS.remove(entry.getKey());
            }
        }
    }
}
 
Example #6
Source File: WorldListener.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldLoadEvent(WorldLoadEvent event)
{
	World world = event.getWorld();
	
	this.plugin.getWorldGuardCommunicator().doUnloadChunkFlagCheck(world);
}
 
Example #7
Source File: FindNewWorlds.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {

    ValidWorldsConfig validWorldsConfig = new ValidWorldsConfig();
    validWorldsConfig.initializeConfig();
    ConfigValues.validWorldsConfig = validWorldsConfig.configuration;

    if (event.getWorld().getName().equals(ConfigValues.adventurersGuildConfig.getString(AdventurersGuildConfig.GUILD_WORLD_NAME))) {
        NPCInitializer npcInitializer = new NPCInitializer();
    }

}
 
Example #8
Source File: GlobalProtectionListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
    World world = event.getWorld();
    for (Entry<UnloadedProtection, String> entry : new HashSet<>(plugin.getGlobalProtectionCache().getUnloadedProtections().entrySet())) {
        if (world.getName().equals(entry.getValue())) {
            entry.getKey().load(world);
        }
    }
}
 
Example #9
Source File: WorldListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onWorldLoad(WorldLoadEvent e) {
    World w = e.getWorld();
    try {
        RedProtect.get().rm.load(w.getName());
        // RedProtect.get().config.addWorldProperties(w);

        RedProtect.get().reloadConfigs();
        RedProtect.get().logger.warning("World loaded: " + w.getName());
    } catch (Exception ex) {
        RedProtect.get().logger.severe("RedProtect problem on load world:");
        ex.printStackTrace();
    }
}
 
Example #10
Source File: GlobalPVPModule.java    From UHC with MIT License 5 votes vote down vote up
@EventHandler
public void on(WorldLoadEvent event) {
    final World world = event.getWorld();

    if (worlds.worldMatches(world)) {
        world.setPVP(isEnabled());
    }
}
 
Example #11
Source File: DifficultyModule.java    From UHC with MIT License 5 votes vote down vote up
@EventHandler
public void on(WorldLoadEvent event) {
    if (isEnabled()) {
        if (worlds.worldMatches(event.getWorld())) {
            event.getWorld().setDifficulty(Difficulty.HARD);
        }
    }
}
 
Example #12
Source File: WorldListener.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
void onWorldLoad(WorldLoadEvent event) {
	plugin.loadShopkeepersInWorld(event.getWorld());
}
 
Example #13
Source File: WorldListener.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent e) {
    SlimefunPlugin.getWorldSettingsService().load(e.getWorld());
    BlockStorage.getForcedStorage(e.getWorld());
}
 
Example #14
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent worldLoadEvent) {
    checkSafety(worldLoadEvent);
}
 
Example #15
Source File: HealthRegenerationModule.java    From UHC with MIT License 4 votes vote down vote up
@EventHandler
public void on(WorldLoadEvent event) {
    event.getWorld().setGameRuleValue(GAME_RULE, isEnabled() ? "true" : "false");
}
 
Example #16
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 #17
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onWorldLoad(WorldLoadEvent worldLoadEvent) {
    checkSafety(worldLoadEvent);
}
 
Example #18
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onCreateWorld(WorldLoadEvent e) {
    UChat.get().reload();
}
 
Example #19
Source File: WorldListener.java    From GlobalWarming with GNU Lesser General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent loadEvent) {
    gw.getLogger().info("Detected world load after GW enabled, triggering automatic climate engine load.");
    ClimateEngine.getInstance().loadWorldClimateEngine(loadEvent.getWorld());
}
 
Example #20
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();
}