Skip to content

Commit

Permalink
WorldEdit incompatibility check (#638)
Browse files Browse the repository at this point in the history
* WorldEdit incompatibility check

* Peaches suggestion

* Spaced for @dlsf

Co-authored-by: boiscljo <boiscljo>
  • Loading branch information
boiscljo authored Mar 21, 2022
1 parent fcd68a3 commit 7146507
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public class SchematicManager {

public SchematicManager() {
File parent = new File(IridiumSkyblock.getInstance().getDataFolder(), "schematics");
this.schematicPaster = worldEdit || fawe ? new WorldEdit() : new Schematic();
SchematicPaster schematicPaster = worldEdit || fawe ? new WorldEdit() : new Schematic();

if ((worldEdit || fawe) && !WorldEdit.isWorking())
{
IridiumSkyblock.getInstance().getLogger().warning("WorldEdit version doesn't support minecraft version, falling back to default integration");
schematicPaster = new Schematic();
}

this.schematicPaster = schematicPaster;
this.schematicFiles = new HashMap<>();
for (File file : parent.listFiles()) {
schematicFiles.put(file.getName(), file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
Expand All @@ -23,6 +25,14 @@ public class WorldEdit implements SchematicPaster {

private static final HashMap<File, ClipboardFormat> cachedClipboardFormat = new HashMap<>();

public static boolean isWorking()
{
final Platform platform = com.sk89q.worldedit.WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
int liveDataVersion = platform.getDataVersion();

return liveDataVersion != -1;
}

@Override
public void paste(File file, Location location, Boolean ignoreAirBlock, CompletableFuture<Void> completableFuture) {
try {
Expand Down

0 comments on commit 7146507

Please sign in to comment.