Update Upstream

d48530c Don't allow editing without a Bukkit Impl Adapter. (1920)
This commit is contained in:
NotMyFault 2021-10-24 12:21:23 +02:00
parent c55bc8c05f
commit ad640532dc
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
6 changed files with 53 additions and 8 deletions

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.YAMLConfiguration;
import com.sk89q.worldedit.util.report.Unreported;
import org.apache.logging.log4j.LogManager;
@ -32,10 +33,11 @@ import java.nio.file.Path;
*/
public class BukkitConfiguration extends YAMLConfiguration {
public boolean noOpPermissions = false;
public boolean commandBlockSupport = false;
@Unreported
private final WorldEditPlugin plugin;
public boolean noOpPermissions = false;
public boolean commandBlockSupport = false;
public boolean unsupportedVersionEditing = false;
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
super(config, LogManager.getLogger(plugin.getLogger().getName()));
@ -47,6 +49,12 @@ public class BukkitConfiguration extends YAMLConfiguration {
super.load();
noOpPermissions = config.getBoolean("no-op-permissions", false);
commandBlockSupport = config.getBoolean("command-block-support", false);
unsupportedVersionEditing = "I accept that I will receive no support with this flag enabled.".equals(
config.getString("allow-editing-on-unsupported-versions", "false"));
if (unsupportedVersionEditing) {
WorldEdit.logger.warn("Editing without a Bukkit adapter has been enabled. You will not receive support "
+ "for any issues that arise as a result.");
}
migrateLegacyFolders();
}

View File

@ -363,7 +363,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public void sendAnnouncements() {
if (WorldEditPlugin.getInstance().getLifecycledBukkitImplAdapter() == null) {
if (!WorldEditPlugin.getInstance().getLifecycledBukkitImplAdapter().isValid()) {
//FAWE start - swap out EH download url with ours
print(Caption.of(
"worldedit.version.bukkit.unsupported-adapter",

View File

@ -97,7 +97,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
@SuppressWarnings("deprecation")
@Override
public int getDataVersion() {
if (plugin.getLifecycledBukkitImplAdapter() != null) {
if (plugin.getLifecycledBukkitImplAdapter().isValid()) {
return Bukkit.getUnsafe().getDataVersion();
}
return -1;

View File

@ -33,6 +33,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.UnsupportedVersionEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -488,8 +489,12 @@ public class BukkitWorld extends AbstractWorld {
}
}
}
if (WorldEditPlugin.getInstance().getLocalConfiguration().unsupportedVersionEditing) {
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
} else {
throw new RuntimeException(new UnsupportedVersionEditException());
}
}
@Override

View File

@ -0,0 +1,31 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit.adapter;
import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.worldedit.WorldEditException;
public class UnsupportedVersionEditException extends WorldEditException {
public UnsupportedVersionEditException() {
super(Caption.of("worldedit.bukkit.no-edit-without-adapter"));
}
}

View File

@ -495,7 +495,6 @@
"worldedit.timezone.set": "Timezone set for this session to: {0}",
"worldedit.timezone.current": "The current time in that timezone is: {0}",
"worldedit.version.version": "FAWE version:\n - Date {0}\n - Commit {1}\n - Build {2}\n - Platform {3}",
"worldedit.version.bukkit.unsupported-adapter": "This FAWE version does not fully support your version of Bukkit. Block entities (e.g. chests) will be empty, block properties (e.g. rotation) will be missing, and other things may not work.\nUpdate FAWE and your server software to restore this functionality:\n{0}",
"worldedit.trace.no-tracing-extents": "Trace: No extent was used.",
"worldedit.trace.action-failed": "Trace: Action(s) {0} at {1} discarded by extent {2}",
"worldedit.trace.active.already": "Trace mode already active.",
@ -618,5 +617,7 @@
"worldedit.help.no-subcommands": "'{0}' has no sub-commands. (Maybe '{1}' is for a parameter?)",
"worldedit.help.subcommand-not-found": "The sub-command '{0}' under '{1}' could not be found.",
"worldedit.cli.stopping": "Stopping!",
"worldedit.cli.unknown-command": "Unknown command!"
"worldedit.cli.unknown-command": "Unknown command!",
"worldedit.version.bukkit.unsupported-adapter": "This FastAsyncWorldEdit version does not fully support your version of Bukkit. Block entities (e.g. chests) will be empty, block properties (e.g. rotation) will be missing, and other things may not work. Update FastAsyncWorldEdit to restore this functionality:\n{0}",
"worldedit.bukkit.no-edit-without-adapter": "Editing on unsupported versions is disabled."
}