HOTfixes breaking world generation (Multiverse-Core) [SD-8519]

These are changes not meant for production. Please squash this commit as soon as an actual fix has been applied... I shouldn't even create such a commit...

Anyway:
Multiverse-Core is too forceful when applying it's own configurations. We have to load on `STARTUP` to allow MVC to find our plugin and generator.
But we can't generate worlds this early in server boot... That's why we are listening for the event before doing any actual initialization... That's not good... Or at least it can't stay like this...
This commit is contained in:
Christian Koop 2021-08-11 21:07:35 +02:00
parent aa1bfd1330
commit d8efa1bf6e
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 138 additions and 104 deletions

View File

@ -53,7 +53,10 @@ import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerLoadEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginManager;
@ -164,104 +167,114 @@ public class SkyBlock extends SongodaPlugin {
return;
}
permissionManager = new PermissionManager(this);
final SkyBlock plugin = this;
Bukkit.getPluginManager().registerEvents(new Listener() {
boolean alreadyRun = false;
@EventHandler
private void onServerLoaded(ServerLoadEvent e) {
if (!alreadyRun) {
alreadyRun = true;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
permissionManager = new PermissionManager(plugin);
localizationManager = new LocalizationManager();
worldManager.loadWorlds();
userCacheManager = new UserCacheManager(this);
visitManager = new VisitManager(this);
banManager = new BanManager(this);
islandManager = new IslandManager(this);
upgradeManager = new UpgradeManager(this);
playerDataManager = new PlayerDataManager(this);
cooldownManager = new CooldownManager(this);
userCacheManager = new UserCacheManager(plugin);
visitManager = new VisitManager(plugin);
banManager = new BanManager(plugin);
islandManager = new IslandManager(plugin);
upgradeManager = new UpgradeManager(plugin);
playerDataManager = new PlayerDataManager(plugin);
cooldownManager = new CooldownManager(plugin);
limitationHandler = new LimitationInstanceHandler();
fabledChallenge = new FabledChallenge(this);
scoreboardManager = new ScoreboardManager(this);
inviteManager = new InviteManager(this);
biomeManager = new BiomeManager(this);
levellingManager = new IslandLevelManager(this);
commandManager = new CommandManager(this);
structureManager = new StructureManager(this);
soundManager = new SoundManager(this);
fabledChallenge = new FabledChallenge(plugin);
scoreboardManager = new ScoreboardManager(plugin);
inviteManager = new InviteManager(plugin);
biomeManager = new BiomeManager(plugin);
levellingManager = new IslandLevelManager(plugin);
commandManager = new CommandManager(plugin);
structureManager = new StructureManager(plugin);
soundManager = new SoundManager(plugin);
if (this.config.getBoolean("Island.Generator.Enable")) {
generatorManager = new GeneratorManager(this);
if (plugin.config.getBoolean("Island.Generator.Enable")) {
generatorManager = new GeneratorManager(plugin);
}
if (this.config.getBoolean("Island.Stackable.Enable")) {
stackableManager = new StackableManager(this);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
if (plugin.config.getBoolean("Island.Stackable.Enable")) {
stackableManager = new StackableManager(plugin);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> stackableManager.loadSavedStackables(), 5L);
}
leaderboardManager = new LeaderboardManager(this);
leaderboardManager = new LeaderboardManager(plugin);
placeholderManager = new PlaceholderManager(this);
placeholderManager = new PlaceholderManager(plugin);
placeholderManager.registerPlaceholders();
messageManager = new MessageManager(this);
messageManager = new MessageManager(plugin);
rewardManager = new RewardManager(this);
rewardManager = new RewardManager(plugin);
rewardManager.loadRewards();
bankManager = new BankManager(this);
bankManager = new BankManager(plugin);
if (this.config.getBoolean("Island.Task.PlaytimeTask")) {
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
if (plugin.config.getBoolean("Island.Task.PlaytimeTask")) {
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(plugin, 0L, 20L);
}
if (this.config.getBoolean("Island.Task.VisitTask")) {
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
if (plugin.config.getBoolean("Island.Task.VisitTask")) {
new VisitTask(playerDataManager).runTaskTimerAsynchronously(plugin, 0L, 20L);
}
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(plugin, 0L, 20L);
// Start Tasks
hologramTask = HologramTask.startTask(this);
mobNetherWaterTask = MobNetherWaterTask.startTask(this);
hologramTask = HologramTask.startTask(plugin);
mobNetherWaterTask = MobNetherWaterTask.startTask(plugin);
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new JoinListeners(this), this);
pluginManager.registerEvents(new QuitListeners(this), this);
pluginManager.registerEvents(new BlockListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
pluginManager.registerEvents(new BucketListeners(this), this);
pluginManager.registerEvents(new ProjectileListeners(this), this);
pluginManager.registerEvents(new InventoryListeners(this), this);
pluginManager.registerEvents(new ItemListeners(this), this);
pluginManager.registerEvents(new TeleportListeners(this), this);
pluginManager.registerEvents(new PortalListeners(this), this);
pluginManager.registerEvents(new MoveListeners(this), this);
pluginManager.registerEvents(new DeathListeners(this), this);
pluginManager.registerEvents(new RespawnListeners(this), this);
pluginManager.registerEvents(new ChatListeners(this), this);
pluginManager.registerEvents(new SpawnerListeners(this), this);
pluginManager.registerEvents(new FoodListeners(this), this);
pluginManager.registerEvents(new GrowListeners(this), this);
pluginManager.registerEvents(new PistonListeners(this), this);
pluginManager.registerEvents(new FallBreakListeners(this), this);
pluginManager.registerEvents(new WorldListeners(this), this);
pluginManager.registerEvents(new JoinListeners(plugin), plugin);
pluginManager.registerEvents(new QuitListeners(plugin), plugin);
pluginManager.registerEvents(new BlockListeners(plugin), plugin);
pluginManager.registerEvents(new InteractListeners(plugin), plugin);
pluginManager.registerEvents(new EntityListeners(plugin), plugin);
pluginManager.registerEvents(new BucketListeners(plugin), plugin);
pluginManager.registerEvents(new ProjectileListeners(plugin), plugin);
pluginManager.registerEvents(new InventoryListeners(plugin), plugin);
pluginManager.registerEvents(new ItemListeners(plugin), plugin);
pluginManager.registerEvents(new TeleportListeners(plugin), plugin);
pluginManager.registerEvents(new PortalListeners(plugin), plugin);
pluginManager.registerEvents(new MoveListeners(plugin), plugin);
pluginManager.registerEvents(new DeathListeners(plugin), plugin);
pluginManager.registerEvents(new RespawnListeners(plugin), plugin);
pluginManager.registerEvents(new ChatListeners(plugin), plugin);
pluginManager.registerEvents(new SpawnerListeners(plugin), plugin);
pluginManager.registerEvents(new FoodListeners(plugin), plugin);
pluginManager.registerEvents(new GrowListeners(plugin), plugin);
pluginManager.registerEvents(new PistonListeners(plugin), plugin);
pluginManager.registerEvents(new FallBreakListeners(plugin), plugin);
pluginManager.registerEvents(new WorldListeners(plugin), plugin);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
pluginManager.registerEvents(new SpongeListeners(this), this);
pluginManager.registerEvents(new SpongeListeners(plugin), plugin);
}
if (pluginManager.isPluginEnabled("EpicSpawners"))
pluginManager.registerEvents(new EpicSpawners(this), this);
pluginManager.registerEvents(new EpicSpawners(plugin), plugin);
if (pluginManager.isPluginEnabled("UltimateStacker"))
pluginManager.registerEvents(new UltimateStacker(this), this);
pluginManager.registerEvents(new UltimateStacker(plugin), plugin);
pluginManager.registerEvents(new Levelling(), this);
pluginManager.registerEvents(new Generator(), this);
pluginManager.registerEvents(new Creator(), this);
pluginManager.registerEvents(new Levelling(), plugin);
pluginManager.registerEvents(new Generator(), plugin);
pluginManager.registerEvents(new Creator(), plugin);
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
plugin.getCommand("skyblock").setExecutor(new SkyBlockCommand());
if (pluginManager.isPluginEnabled("Vault")) {
this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
plugin.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
}
switch (this.config.getString("Economy.Manager", "Default")) {
switch (plugin.config.getString("Economy.Manager", "Default")) {
case "Vault":
getEconomyManager().setEconomy("Vault");
break;
@ -272,13 +285,17 @@ public class SkyBlock extends SongodaPlugin {
getEconomyManager().setEconomy("Reserve");
break;
default:
this.getLogger().warning("EconomyManager is default");
plugin.getLogger().warning("EconomyManager is default");
}
LogManager.load();
});
SkyBlockAPI.setImplementation(INSTANCE);
}
}
}, this);
}
@Override
public void onPluginDisable() {

View File

@ -1,15 +1,17 @@
package com.songoda.skyblock.world;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.limit.LimitationInstanceHandler;
import com.songoda.skyblock.world.generator.VoidGenerator;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.logging.Level;
public class WorldManager {
@ -55,19 +57,31 @@ public class WorldManager {
if (normalWorld == null) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Normal World '" + normalWorldName + "'.");
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment).generator(normalWorldWorldGenerator).createWorld();
normalWorld = WorldCreator.name(normalWorldName)
.type(WorldType.FLAT)
.environment(normalWorldEnvironment)
.generator(normalWorldWorldGenerator)
.createWorld();
registerMultiverse(normalWorldName, normalWorldEnvironment, normalWorldGeneratorName);
}
if (netherWorld == null && netherWorldEnabled) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Nether World '" + netherWorldName + "'.");
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment).generator(netherWorldWorldGenerator).createWorld();
netherWorld = WorldCreator.name(netherWorldName)
.type(WorldType.FLAT)
.environment(netherWorldEnvironment)
.generator(netherWorldWorldGenerator)
.createWorld();
registerMultiverse(netherWorldName, netherWorldEnvironment, netherWorldGeneratorName);
}
if (endWorld == null && endWorldEnabled) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Void World '" + endWorldName + "'.");
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment).generator(endWorldWorldGenerator).createWorld();
endWorld = WorldCreator.name(endWorldName)
.type(WorldType.FLAT)
.environment(endWorldEnvironment)
.generator(endWorldWorldGenerator)
.createWorld();
registerMultiverse(endWorldName, endWorldEnvironment, endWorldGeneratorName);
}
@ -85,9 +99,11 @@ public class WorldManager {
if (Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core") == null) {
return;
}
if (worldGeneratorName.toLowerCase().equals("default") || worldGeneratorName == null) {
if (worldGeneratorName == null || worldGeneratorName.equalsIgnoreCase("default")) {
worldGeneratorName = plugin.getName();
}
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldName + " " + environment.name().toLowerCase() + " -g " + plugin.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv modify set generator " + worldGeneratorName + " " + worldName);
}

View File

@ -2,12 +2,13 @@ name: FabledSkyBlock
main: com.songoda.skyblock.SkyBlock
version: maven-version-number
api-version: 1.13
load: STARTUP
description: A unique SkyBlock plugin
author: Songoda
authors: [ Fabrimat ]
softdepend: [ HolographicDisplays, Holograms, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, PlayerPoints,
LeaderHeads, EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector ]
loadbefore: [Multiverse-Core, ProtocolLib]
loadbefore: [ Multiverse-Core, ProtocolLib ]
commands:
island:
description: Island command