mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Load default biomes into registry at earliest convenience, then load custom biomes later.
This commit is contained in:
parent
563ad7761a
commit
f412796f28
@ -236,18 +236,18 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
// datapacks aren't loaded until just before the world is, and bukkit has no event for this
|
||||
// so the earliest we can do this is in WorldInit
|
||||
setupTags();
|
||||
setupBiomes(); // FAWE - load biomes later
|
||||
setupBiomes(); // FAWE - load biomes later. Initialize biomes twice to allow for the registry to be present for
|
||||
// plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent(platform));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
private void initializeRegistries() {
|
||||
/* // FAWE start - move Biomes to their own method
|
||||
for (Biome biome : Biome.values()) {
|
||||
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
|
||||
BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
|
||||
}
|
||||
// FAWE start - move Biomes to their own method. Initialize biomes twice to allow for the registry to be present for
|
||||
// plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
|
||||
setupBiomes();
|
||||
// FAWE end
|
||||
/*
|
||||
|
||||
// Block & Item
|
||||
for (Material material : Material.values()) {
|
||||
@ -311,14 +311,11 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
// FAWE start
|
||||
private void setupBiomes() {
|
||||
if (this.adapter.value().isPresent()) {
|
||||
// We don't know which world is the one with the data packs
|
||||
// so we just loop over them. Doesn't hurt
|
||||
for (org.bukkit.World world : Bukkit.getWorlds()) {
|
||||
// cast is needed, thanks to raw types <3
|
||||
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes(world)) {
|
||||
if (BiomeType.REGISTRY.get(biome.toString()) == null) { // only register once
|
||||
BiomeType.REGISTRY.register(biome.toString(), new BiomeType(biome.toString()));
|
||||
}
|
||||
// Biomes are stored globally in the server. Registries are not kept per-world in Minecraft.
|
||||
// The WorldServer get-registries method simply delegates to the MinecraftServer method.
|
||||
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes()) {
|
||||
if (BiomeType.REGISTRY.get(biome.toString()) == null) { // only register once
|
||||
BiomeType.REGISTRY.register(biome.toString(), new BiomeType(biome.toString()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -311,10 +311,9 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
/**
|
||||
* Returns an iterable of all biomes known to the server.
|
||||
*
|
||||
* @param world the world to load the registered biomes from.
|
||||
* @return all biomes known to the server.
|
||||
*/
|
||||
default Iterable<NamespacedKey> getRegisteredBiomes(World world) {
|
||||
default Iterable<NamespacedKey> getRegisteredBiomes() {
|
||||
return Arrays.stream(Biome.values())
|
||||
.map(Keyed::getKey)
|
||||
.collect(Collectors.toList());
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user