mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-16 05:43:54 +00:00
Merge branch 'commanding' of https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13 into commanding
# Conflicts: # worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java # worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java # worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java # worldedit-libs/core/build.gradle.kts
This commit is contained in:
@ -29,8 +29,12 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -149,14 +153,20 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return sender.getBlock().getType() == Material.COMMAND_BLOCK
|
||||
|| sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK
|
||||
|| sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK;
|
||||
@NotNull Block block = sender.getBlock();
|
||||
@NotNull World world = block.getWorld();
|
||||
if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4)) {
|
||||
@NotNull Material type = block.getType();
|
||||
return type == Material.COMMAND_BLOCK
|
||||
|| type == Material.CHAIN_COMMAND_BLOCK
|
||||
|| type == Material.REPEATING_COMMAND_BLOCK;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +32,8 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
@ -42,14 +44,12 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
||||
|
||||
private CommandSender sender;
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||
checkNotNull(plugin);
|
||||
checkNotNull(sender);
|
||||
checkArgument(!(sender instanceof Player), "Cannot wrap a player");
|
||||
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@ -152,6 +152,10 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
if (sender instanceof Entity) {
|
||||
Entity entity = (Entity) sender;
|
||||
return (entity.isValid() && !entity.isDead());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.message;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_14.Spigot_v1_14_R1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_14.Spigot_v1_14_R4;
|
||||
import com.google.common.base.Joiner;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
@ -37,19 +38,13 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.command.CommandUtil;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemCategory;
|
||||
@ -305,7 +300,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
try {
|
||||
Bukkit.getPluginManager().loadPlugin(dummy);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (Bukkit.getUpdateFolderFile().mkdirs()) {
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, Bukkit.getUpdateFolder() + File.separator + "DummyFawe.jar");
|
||||
} else {
|
||||
getLogger().info("Please delete DummyFawe.jar and restart");
|
||||
}
|
||||
}
|
||||
getLogger().info("Please restart the server if you have any plugins which depend on FAWE.");
|
||||
} else if (dummy == null) {
|
||||
@ -343,7 +342,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
// Attempt to load a Bukkit adapter
|
||||
BukkitImplLoader adapterLoader = new BukkitImplLoader();
|
||||
try {
|
||||
adapterLoader.addClass(Spigot_v1_14_R1.class);
|
||||
adapterLoader.addClass(Spigot_v1_14_R4.class);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
@ -439,7 +438,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = "/" + commandLabel;
|
||||
split[0] = commandLabel;
|
||||
|
||||
CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
|
||||
getWorldEdit().getEventBus().post(event);
|
||||
|
@ -24,6 +24,7 @@ import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
@ -42,8 +43,10 @@ import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -75,9 +78,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
*/
|
||||
BaseBlock getBlock(Location location);
|
||||
|
||||
boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder<?> state, boolean update);
|
||||
|
||||
boolean isChunkInUse(Chunk chunk);
|
||||
/**
|
||||
* Set the block at the given location.
|
||||
*
|
||||
@ -86,7 +86,11 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
* @param notifyAndLight notify and light if set
|
||||
* @return true if a block was likely changed
|
||||
*/
|
||||
boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight);
|
||||
default boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight) {
|
||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||
}
|
||||
|
||||
boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder<?> state, boolean update);
|
||||
|
||||
/**
|
||||
* Notifies the simulation that the block at the given location has
|
||||
@ -124,22 +128,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
*/
|
||||
Map<String, ? extends Property<?>> getProperties(BlockType blockType);
|
||||
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default BlockMaterial getMaterial(BlockState blockState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Tag toNative(T foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default T fromNative(Tag foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given NBT data to the player.
|
||||
*
|
||||
@ -170,7 +158,52 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
default @org.jetbrains.annotations.Nullable World createWorld(WorldCreator creator) {
|
||||
/**
|
||||
* Create a Bukkit ItemStack with NBT, if available.
|
||||
*
|
||||
* @param item the WorldEdit BaseItemStack to adapt
|
||||
* @return the Bukkit ItemStack
|
||||
*/
|
||||
ItemStack adapt(BaseItemStack item);
|
||||
|
||||
/**
|
||||
* Create a WorldEdit ItemStack with NBT, if available.
|
||||
*
|
||||
* @param itemStack the Bukkit ItemStack to adapt
|
||||
* @return the WorldEdit BaseItemStack
|
||||
*/
|
||||
BaseItemStack adapt(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the internal ID for a given state, if possible.
|
||||
*
|
||||
* @param state The block state
|
||||
* @return the internal ID of the state
|
||||
*/
|
||||
default OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
boolean isChunkInUse(Chunk chunk);
|
||||
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default BlockMaterial getMaterial(BlockState blockState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Tag toNative(T foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default T fromNative(Tag foreign) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default @Nullable World createWorld(WorldCreator creator) {
|
||||
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user