geforkt von Mirrors/FastAsyncWorldEdit
Add Console/CommandBlock support to Fabric/Forge/Sponge (2317)
Dieser Commit ist enthalten in:
Ursprung
e7876c4eba
Commit
bb14d93a8d
@ -21,11 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
|
import com.sk89q.worldedit.extension.platform.AbstractCommandBlockActor;
|
||||||
import com.sk89q.worldedit.extension.platform.Locatable;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
@ -43,22 +40,20 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
|
public class BukkitBlockCommandSender extends AbstractCommandBlockActor {
|
||||||
|
|
||||||
private static final String UUID_PREFIX = "CMD";
|
private static final String UUID_PREFIX = "CMD";
|
||||||
|
|
||||||
private final BlockCommandSender sender;
|
private final BlockCommandSender sender;
|
||||||
private final WorldEditPlugin plugin;
|
private final WorldEditPlugin plugin;
|
||||||
private final Location location;
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public BukkitBlockCommandSender(WorldEditPlugin plugin, BlockCommandSender sender) {
|
public BukkitBlockCommandSender(WorldEditPlugin plugin, BlockCommandSender sender) {
|
||||||
|
super(BukkitAdapter.adapt(checkNotNull(sender).getBlock().getLocation()));
|
||||||
checkNotNull(plugin);
|
checkNotNull(plugin);
|
||||||
checkNotNull(sender);
|
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.location = BukkitAdapter.adapt(sender.getBlock().getLocation());
|
|
||||||
this.uuid = UUID.nameUUIDFromBytes((UUID_PREFIX + sender.getName()).getBytes(StandardCharsets.UTF_8));
|
this.uuid = UUID.nameUUIDFromBytes((UUID_PREFIX + sender.getName()).getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,21 +129,6 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
|||||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getLocation() {
|
|
||||||
return this.location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setLocation(Location location) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Extent getExtent() {
|
|
||||||
return this.location.getExtent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUniqueId() {
|
public UUID getUniqueId() {
|
||||||
return uuid;
|
return uuid;
|
||||||
|
@ -36,7 +36,6 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
|||||||
@Unreported
|
@Unreported
|
||||||
private final WorldEditPlugin plugin;
|
private final WorldEditPlugin plugin;
|
||||||
public boolean noOpPermissions = false;
|
public boolean noOpPermissions = false;
|
||||||
public boolean commandBlockSupport = false;
|
|
||||||
public boolean unsupportedVersionEditing = false;
|
public boolean unsupportedVersionEditing = false;
|
||||||
|
|
||||||
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||||
@ -48,7 +47,6 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
|||||||
public void load() {
|
public void load() {
|
||||||
super.load();
|
super.load();
|
||||||
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
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(
|
unsupportedVersionEditing = "I accept that I will receive no support with this flag enabled.".equals(
|
||||||
config.getString("allow-editing-on-unsupported-versions", "false"));
|
config.getString("allow-editing-on-unsupported-versions", "false"));
|
||||||
if (unsupportedVersionEditing) {
|
if (unsupportedVersionEditing) {
|
||||||
|
@ -96,6 +96,7 @@ public abstract class LocalConfiguration {
|
|||||||
public boolean allowSymlinks = false;
|
public boolean allowSymlinks = false;
|
||||||
public boolean serverSideCUI = true;
|
public boolean serverSideCUI = true;
|
||||||
public boolean extendedYLimit = false;
|
public boolean extendedYLimit = false;
|
||||||
|
public boolean commandBlockSupport = false;
|
||||||
public String defaultLocaleName = "default";
|
public String defaultLocaleName = "default";
|
||||||
public Locale defaultLocale = Locale.getDefault();
|
public Locale defaultLocale = Locale.getDefault();
|
||||||
|
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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.extension.platform;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
|
public abstract class AbstractCommandBlockActor extends AbstractNonPlayerActor implements Locatable {
|
||||||
|
protected static final String UUID_PREFIX = "CMD";
|
||||||
|
|
||||||
|
private final Location location;
|
||||||
|
|
||||||
|
public AbstractCommandBlockActor(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setLocation(Location location) {
|
||||||
|
// Can't move a CommandBlock
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent getExtent() {
|
||||||
|
return this.location.getExtent();
|
||||||
|
}
|
||||||
|
}
|
@ -140,6 +140,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
|||||||
serverSideCUI = getBool("server-side-cui", serverSideCUI);
|
serverSideCUI = getBool("server-side-cui", serverSideCUI);
|
||||||
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
|
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
|
||||||
setDefaultLocaleName(getString("default-locale", defaultLocaleName));
|
setDefaultLocaleName(getString("default-locale", defaultLocaleName));
|
||||||
|
commandBlockSupport = getBool("command-block-support", commandBlockSupport);
|
||||||
|
|
||||||
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
|
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ public class YAMLConfiguration extends LocalConfiguration {
|
|||||||
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
|
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
|
||||||
|
|
||||||
setDefaultLocaleName(config.getString("default-locale", defaultLocaleName));
|
setDefaultLocaleName(config.getString("default-locale", defaultLocaleName));
|
||||||
|
|
||||||
|
commandBlockSupport = config.getBoolean("command-block-support", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unload() {
|
public void unload() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren