mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
QueryCapability is effectively a "dumb" method
This commit is contained in:
parent
366c26dc15
commit
320363e5ff
@ -37,8 +37,6 @@ import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -135,9 +133,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
|
||||
private synchronized void checkLoaded(@NonNull World world) {
|
||||
// Do not attempt to load configurations until WorldEdit has a platform ready.
|
||||
try {
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||
} catch (Throwable t) {
|
||||
if (!PlotSquared.get().isWeInitialised()) {
|
||||
return;
|
||||
}
|
||||
if (!this.loaded) {
|
||||
|
@ -72,7 +72,10 @@ import com.plotsquared.core.util.ReflectionUtils;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -153,6 +156,8 @@ public class PlotSquared {
|
||||
private EventDispatcher eventDispatcher;
|
||||
private PlotListener plotListener;
|
||||
|
||||
private boolean weInitialised;
|
||||
|
||||
/**
|
||||
* Initialize PlotSquared with the desired Implementation class.
|
||||
*
|
||||
@ -223,6 +228,7 @@ public class PlotSquared {
|
||||
}
|
||||
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WEPlatformReadyListener());
|
||||
|
||||
// Create Event utility class
|
||||
this.eventDispatcher = new EventDispatcher(this.worldedit);
|
||||
@ -1574,6 +1580,13 @@ public class PlotSquared {
|
||||
return this.plotListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the {@link PlatformReadyEvent} has been sent by WE. There is no way to query this within WE itself.
|
||||
*/
|
||||
public boolean isWeInitialised() {
|
||||
return weInitialised;
|
||||
}
|
||||
|
||||
/**
|
||||
* Different ways of sorting {@link Plot plots}
|
||||
*/
|
||||
@ -1596,4 +1609,14 @@ public class PlotSquared {
|
||||
DISTANCE_FROM_ORIGIN
|
||||
}
|
||||
|
||||
private final class WEPlatformReadyListener {
|
||||
|
||||
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
|
||||
public void onPlatformReady(PlatformReadyEvent event) {
|
||||
weInitialised = true;
|
||||
WorldEdit.getInstance().getEventBus().unregister(WEPlatformReadyListener.this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user