Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Fix some load-order issues probably.
Edge cases might still exist around plugins which use WE for initial world-gen, or in general plugins that try to access the platform before it's ready.
Dieser Commit ist enthalten in:
Ursprung
8f33e0d550
Commit
0f420f02ff
@ -96,7 +96,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class);
|
||||
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
|
||||
private static WorldEditPlugin INSTANCE;
|
||||
private static WorldInitListener worldInitListener = null;
|
||||
|
||||
private BukkitImplAdapter bukkitAdapter;
|
||||
private BukkitServerInterface server;
|
||||
@ -139,22 +138,19 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
getServer().getPluginManager().registerEvents(new AsyncTabCompleteListener(), this);
|
||||
}
|
||||
|
||||
// register this so we can load world-dependent data right as the first world is loading
|
||||
if (worldInitListener != null) {
|
||||
initializeRegistries(); // this creates the objects matching Bukkit's enums - but doesn't fill them with data yet
|
||||
if (Bukkit.getWorlds().isEmpty()) {
|
||||
setupPreWorldData();
|
||||
// register this so we can load world-dependent data right as the first world is loading
|
||||
getServer().getPluginManager().registerEvents(new WorldInitListener(), this);
|
||||
} else {
|
||||
getLogger().warning("Server reload detected. This may cause various issues with WorldEdit and dependent plugins.");
|
||||
try {
|
||||
// these don't stick around between reload
|
||||
loadAdapter();
|
||||
loadConfig();
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
setupPreWorldData();
|
||||
// since worlds are loaded already, we can do this now
|
||||
setupWorldData();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
} else {
|
||||
getServer().getPluginManager().registerEvents((worldInitListener = new WorldInitListener()), this);
|
||||
loadAdapter(); // Need an adapter to work with special blocks with NBT data
|
||||
setupRegistries();
|
||||
WorldEdit.getInstance().loadMappings();
|
||||
loadConfig(); // Load configuration
|
||||
}
|
||||
|
||||
// Enable metrics
|
||||
@ -162,12 +158,19 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
PaperLib.suggestPaper(this);
|
||||
}
|
||||
|
||||
private void setupPreWorldData() {
|
||||
loadAdapter();
|
||||
loadConfig();
|
||||
WorldEdit.getInstance().loadMappings();
|
||||
}
|
||||
|
||||
private void setupWorldData() {
|
||||
setupTags();
|
||||
setupTags(); // 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
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
}
|
||||
|
||||
private void setupRegistries() {
|
||||
private void initializeRegistries() {
|
||||
// Biome
|
||||
for (Biome biome : Biome.values()) {
|
||||
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
|
||||
@ -487,9 +490,9 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
if (!event.isCommand()) return;
|
||||
|
||||
String buffer = event.getBuffer();
|
||||
final String[] parts = buffer.split(" ");
|
||||
if (parts.length < 1) return;
|
||||
final String label = parts[0];
|
||||
int firstSpace = buffer.indexOf(' ');
|
||||
if (firstSpace < 0) return;
|
||||
final String label = buffer.substring(0, firstSpace);
|
||||
final Optional<org.enginehub.piston.Command> command
|
||||
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label);
|
||||
if (!command.isPresent()) return;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren