mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Only load world cofigurations if WorldEdit has fully enabled (safe to do) (#3666)
* Only load world cofigurations if WorldEdit has fully enabled (safe to do) - Fixes #3664 (cherry picked from commit f2e1e99be3b4f1fd5ce00e32ea7773dd4d1855aa) * Fix imports * QueryCapability is effectively a "dumb" method * Update Core/src/main/java/com/plotsquared/core/PlotSquared.java Co-authored-by: Alexander Brandes <mc.cache@web.de>
This commit is contained in:
@ -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,15 @@ public class PlotSquared {
|
||||
DISTANCE_FROM_ORIGIN
|
||||
}
|
||||
|
||||
private final class WEPlatformReadyListener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
|
||||
public void onPlatformReady(PlatformReadyEvent event) {
|
||||
weInitialised = true;
|
||||
WorldEdit.getInstance().getEventBus().unregister(WEPlatformReadyListener.this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user