Remove data versions from the Bukkit adapters (#1507)

* Remove data versions from the Bukkit adapters

* Don't allow saving schematics without an adapter in place on Bukkit.

* Removed confusing line
This commit is contained in:
Matthew Miller 2020-09-19 18:00:43 +10:00 committed by GitHub
parent deb5e44064
commit 2056218b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View File

@ -89,10 +89,11 @@ public Registries getRegistries() {
return BukkitRegistries.getInstance();
}
@SuppressWarnings("deprecation")
@Override
public int getDataVersion() {
if (plugin.getBukkitImplAdapter() != null) {
return plugin.getBukkitImplAdapter().getDataVersion();
return Bukkit.getUnsafe().getDataVersion();
}
return -1;
}

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.bukkit.adapter;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
@ -55,13 +54,6 @@
*/
public interface BukkitImplAdapter {
/**
* Get the Minecraft data version for the current world data.
*
* @return the data version
*/
int getDataVersion();
/**
* Get a data fixer, or null if not supported.
*

View File

@ -30,6 +30,7 @@
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
@ -155,6 +156,11 @@ public void save(Actor actor, LocalSession session,
String formatName,
@Switch(name = 'f', desc = "Overwrite an existing file.")
boolean allowOverwrite) throws WorldEditException {
if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) {
actor.printError(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version"));
return;
}
LocalConfiguration config = worldEdit.getConfiguration();
File dir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();

View File

@ -108,6 +108,7 @@
"worldedit.schematic.delete.failed": "Deletion of {0} failed! Is it read-only?",
"worldedit.schematic.delete.deleted": "{0} has been deleted.",
"worldedit.schematic.formats.title": "Available clipboard formats (Name: Lookup names)",
"worldedit.schematic.unsupported-minecraft-version": "This version of WorldEdit does not support your Minecraft version. Schematics will not work until this is resolved.",
"worldedit.pos.already-set": "Position already set.",
"worldedit.pos.console-require-coords": "You must provide coordinates as console.",