geforkt von Mirrors/FastAsyncWorldEdit
I changed stuff. That's all I remember
Dieser Commit ist enthalten in:
Ursprung
1e02560039
Commit
8c9090a21d
@ -20,7 +20,6 @@
|
|||||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.object.collection.ObjObjMap;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -33,42 +32,50 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
|||||||
import com.sk89q.worldedit.entity.LazyBaseEntity;
|
import com.sk89q.worldedit.entity.LazyBaseEntity;
|
||||||
import com.sk89q.worldedit.internal.Constants;
|
import com.sk89q.worldedit.internal.Constants;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.*;
|
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||||
|
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||||
|
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||||
|
import com.sk89q.worldedit.registry.state.IntegerProperty;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.*;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_13_R2.*;
|
import net.minecraft.server.v1_13_R2.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{
|
public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||||
|
|
||||||
private final Field nbtListTagListField;
|
private final Field nbtListTagListField;
|
||||||
private final Method nbtCreateTagMethod;
|
private final Method nbtCreateTagMethod;
|
||||||
@ -193,11 +200,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
return IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
return IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Code that is less likely to break
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Location location) {
|
public BaseBlock getBlock(Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
@ -251,7 +253,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
|
|
||||||
nmsChunk.d(pos); // Force delete the old tile entity
|
nmsChunk.d(pos); // Force delete the old tile entity
|
||||||
|
|
||||||
CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null;
|
CompoundTag nativeTag = state instanceof BaseBlock ? state.getNbtData() : null;
|
||||||
if (nativeTag != null || existing instanceof TileEntityBlock) {
|
if (nativeTag != null || existing instanceof TileEntityBlock) {
|
||||||
nmsWorld.setTypeAndData(pos, blockData, 0);
|
nmsWorld.setTypeAndData(pos, blockData, 0);
|
||||||
// remove tile
|
// remove tile
|
||||||
@ -352,7 +354,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
logger.warn("Failed to find properties for " + blockType.getId());
|
logger.warning("Failed to find properties for " + blockType.getId());
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
Map<String, Property<?>> properties = Maps.newLinkedHashMap();
|
Map<String, Property<?>> properties = Maps.newLinkedHashMap();
|
||||||
@ -418,7 +420,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
try {
|
try {
|
||||||
return toNativeList((NBTTagList) foreign);
|
return toNativeList((NBTTagList) foreign);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to convert NBTTagList", e);
|
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||||
}
|
}
|
||||||
} else if (foreign instanceof NBTTagLong) {
|
} else if (foreign instanceof NBTTagLong) {
|
||||||
@ -444,7 +446,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
* @throws IllegalArgumentException on error
|
* @throws IllegalArgumentException on error
|
||||||
* @throws IllegalAccessException on error
|
* @throws IllegalAccessException on error
|
||||||
*/
|
*/
|
||||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
private ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||||
List<Tag> values = new ArrayList<>();
|
List<Tag> values = new ArrayList<>();
|
||||||
int type = foreign.d();
|
int type = foreign.d();
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class ATabCompleteListener implements Listener {
|
|||||||
Dispatcher dispatcher = CommandManager.getInstance().getDispatcher();
|
Dispatcher dispatcher = CommandManager.getInstance().getDispatcher();
|
||||||
CommandMapping weCommand = dispatcher.get(label);
|
CommandMapping weCommand = dispatcher.get(label);
|
||||||
if (weCommand != null) {
|
if (weCommand != null) {
|
||||||
CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index, buffer.length()));
|
CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index));
|
||||||
worldEdit.getWorldEdit().getEventBus().post(event);
|
worldEdit.getWorldEdit().getEventBus().post(event);
|
||||||
List<String> suggestions = event.getSuggestions();
|
List<String> suggestions = event.getSuggestions();
|
||||||
if (suggestions != null && !suggestions.isEmpty()) {
|
if (suggestions != null && !suggestions.isEmpty()) {
|
||||||
|
@ -10,22 +10,15 @@ import com.boydti.fawe.util.EditSessionBuilder;
|
|||||||
import com.boydti.fawe.util.ExtentTraverser;
|
import com.boydti.fawe.util.ExtentTraverser;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Rotation;
|
import org.bukkit.Rotation;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -48,6 +41,13 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BukkitImageListener implements Listener {
|
public class BukkitImageListener implements Listener {
|
||||||
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ public class BukkitImageListener implements Listener {
|
|||||||
double zRat = Math.sin(yawRad) * a;
|
double zRat = Math.sin(yawRad) * a;
|
||||||
|
|
||||||
BlockFace facing = itemFrame.getFacing();
|
BlockFace facing = itemFrame.getFacing();
|
||||||
double thickness = 1/32d + 1/128d;
|
double thickness = 1/32D + 1/128D;
|
||||||
double modX = facing.getModX();
|
double modX = facing.getModX();
|
||||||
double modZ = facing.getModZ();
|
double modZ = facing.getModZ();
|
||||||
double dx = source.getX() - target.getX() - modX * thickness;
|
double dx = source.getX() - target.getX() - modX * thickness;
|
||||||
|
@ -2,10 +2,11 @@ package com.boydti.fawe.bukkit.util;
|
|||||||
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class BukkitReflectionUtils {
|
public class BukkitReflectionUtils {
|
||||||
/**
|
/**
|
||||||
* prefix of bukkit classes
|
* prefix of bukkit classes
|
||||||
@ -74,18 +75,6 @@ public class BukkitReflectionUtils {
|
|||||||
return ReflectionUtils.getClass(className);
|
return ReflectionUtils.getClass(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getUtilClass(final String name) {
|
|
||||||
try {
|
|
||||||
return Class.forName(name); //Try before 1.8 first
|
|
||||||
} catch (final ClassNotFoundException ex) {
|
|
||||||
try {
|
|
||||||
return Class.forName("net.minecraft.util." + name); //Not 1.8
|
|
||||||
} catch (final ClassNotFoundException ex2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.bukkit.BukkitPlayer;
|
import com.boydti.fawe.bukkit.BukkitPlayer;
|
||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
|
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
|
||||||
import com.boydti.fawe.example.IntFaweChunk;
|
|
||||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
@ -22,16 +21,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -46,6 +35,12 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
|||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener {
|
public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener {
|
||||||
|
|
||||||
protected static boolean PAPER = true;
|
protected static boolean PAPER = true;
|
||||||
@ -259,7 +254,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public World createWorld(final WorldCreator creator) {
|
public World createWorld(final WorldCreator creator) {
|
||||||
World world = TaskManager.IMP.sync(new RunnableVal<World>() {
|
return TaskManager.IMP.sync(new RunnableVal<World>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(World value) {
|
public void run(World value) {
|
||||||
disableChunkLoad = true;
|
disableChunkLoad = true;
|
||||||
@ -267,7 +262,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
|||||||
disableChunkLoad = false;
|
disableChunkLoad = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return world;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -289,8 +283,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
|||||||
@Override
|
@Override
|
||||||
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) {
|
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) {
|
||||||
if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z));
|
if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z));
|
||||||
boolean result = world.regenerateChunk(x, z);
|
return world.regenerateChunk(x, z);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,7 +9,6 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.ChunkSnapshot;
|
import org.bukkit.ChunkSnapshot;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
@ -163,12 +162,11 @@ public class AsyncChunk implements Chunk {
|
|||||||
return load(false);
|
return load(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
//Do not use the safe variable in this method for compatibility with 1.14+
|
||||||
public boolean unload(boolean save, boolean safe) {
|
public boolean unload(boolean save, boolean safe) {
|
||||||
return world.unloadChunk(x, z, save, safe);
|
return world.unloadChunk(x, z, save);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean unload(boolean save) {
|
public boolean unload(boolean save) {
|
||||||
return unload(true, false);
|
return unload(true, false);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public interface IBukkitAdapter {
|
public interface IBukkitAdapter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
||||||
*
|
*
|
||||||
@ -101,7 +102,7 @@ public interface IBukkitAdapter {
|
|||||||
default Location adapt(org.bukkit.Location location) {
|
default Location adapt(org.bukkit.Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
Vector3 position = asVector(location);
|
Vector3 position = asVector(location);
|
||||||
return new com.sk89q.worldedit.util.Location(
|
return new Location(
|
||||||
adapt(location.getWorld()),
|
adapt(location.getWorld()),
|
||||||
position,
|
position,
|
||||||
location.getYaw(),
|
location.getYaw(),
|
||||||
|
@ -19,41 +19,36 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.visitor;
|
package com.sk89q.worldedit.function.visitor;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.LayerFunction;
|
import com.sk89q.worldedit.function.LayerFunction;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.FlatRegion;
|
import com.sk89q.worldedit.regions.FlatRegion;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visits the layers within a region.
|
* Visits the layers within a region.
|
||||||
* <p>
|
*
|
||||||
* <p>This class works by iterating over all the columns in a {@link FlatRegion},
|
* <p>This class works by iterating over all the columns in a {@link FlatRegion},
|
||||||
* finding the first ground block in each column (searching from a given
|
* finding the first ground block in each column (searching from a given
|
||||||
* maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to
|
* maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to
|
||||||
* each layer.</p>
|
* each layer.</p>
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public class LayerVisitor implements Operation {
|
public class LayerVisitor implements Operation {
|
||||||
|
|
||||||
|
private final FlatRegion flatRegion;
|
||||||
private final LayerFunction function;
|
private final LayerFunction function;
|
||||||
private Mask2D mask = Masks.alwaysTrue2D();
|
private Mask2D mask = Masks.alwaysTrue2D();
|
||||||
private final int minY;
|
private int minY;
|
||||||
private final int maxY;
|
private int maxY;
|
||||||
private final Iterable<BlockVector2> iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new visitor.
|
* Create a new visitor.
|
||||||
@ -63,14 +58,14 @@ public class LayerVisitor implements Operation {
|
|||||||
* @param maxY the maximum Y to begin the search at
|
* @param maxY the maximum Y to begin the search at
|
||||||
* @param function the layer function to apply t blocks
|
* @param function the layer function to apply t blocks
|
||||||
*/
|
*/
|
||||||
public LayerVisitor(final FlatRegion flatRegion, final int minY, final int maxY, final LayerFunction function) {
|
public LayerVisitor(FlatRegion flatRegion, int minY, int maxY, LayerFunction function) {
|
||||||
checkNotNull(flatRegion);
|
checkNotNull(flatRegion);
|
||||||
checkArgument(minY <= maxY, "minY <= maxY required");
|
checkArgument(minY <= maxY, "minY <= maxY required");
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
|
this.flatRegion = flatRegion;
|
||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
this.maxY = maxY;
|
this.maxY = maxY;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.iterator = flatRegion.asFlatRegion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +75,7 @@ public class LayerVisitor implements Operation {
|
|||||||
* @return a 2D mask
|
* @return a 2D mask
|
||||||
*/
|
*/
|
||||||
public Mask2D getMask() {
|
public Mask2D getMask() {
|
||||||
return this.mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,15 +84,15 @@ public class LayerVisitor implements Operation {
|
|||||||
*
|
*
|
||||||
* @param mask a 2D mask
|
* @param mask a 2D mask
|
||||||
*/
|
*/
|
||||||
public void setMask(final Mask2D mask) {
|
public void setMask(Mask2D mask) {
|
||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
for (final BlockVector2 column : this.iterator) {
|
for (BlockVector2 column : flatRegion.asFlatRegion()) {
|
||||||
if (!this.mask.test(column)) {
|
if (!mask.test(column)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,14 +106,14 @@ public class LayerVisitor implements Operation {
|
|||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
BlockVector3 test = column.toBlockVector3(y);
|
BlockVector3 test = column.toBlockVector3(y);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (this.function.isGround(test)) {
|
if (function.isGround(test)) {
|
||||||
found = true;
|
found = true;
|
||||||
groundY = y;
|
groundY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!this.function.apply(test, groundY - y)) {
|
if (!function.apply(test, groundY - y)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +127,7 @@ public class LayerVisitor implements Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(final List<String> messages) {
|
public void addStatusMessages(List<String> messages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren