From 8c9090a21d23c65391ab6e64dd93674ae503e4de Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Sun, 23 Jun 2019 13:27:34 -0400 Subject: [PATCH] I changed stuff. That's all I remember --- .../adapter/v1_13_1/Spigot_v1_13_R2.java | 44 ++++++++++--------- .../bukkit/listener/ATabCompleteListener.java | 2 +- .../bukkit/listener/BukkitImageListener.java | 22 +++++----- .../bukkit/util/BukkitReflectionUtils.java | 15 +------ .../boydti/fawe/bukkit/v0/BukkitQueue_0.java | 23 ++++------ .../fawe/bukkit/wrapper/AsyncChunk.java | 6 +-- .../bukkit/adapter/IBukkitAdapter.java | 7 +-- .../worldedit/command/RegionCommands.java | 2 +- .../function/visitor/LayerVisitor.java | 35 +++++++-------- 9 files changed, 67 insertions(+), 89 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java index 7c1821ce1..d16684bcd 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java @@ -20,7 +20,6 @@ package com.boydti.fawe.bukkit.adapter.v1_13_1; import com.boydti.fawe.Fawe; -import com.boydti.fawe.object.collection.ObjObjMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; 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.internal.Constants; 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.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; 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.registry.BlockMaterial; import net.minecraft.server.v1_13_R2.*; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.bukkit.craftbukkit.v1_13_R2.CraftServer; 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.entity.CraftEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.lang.reflect.Field; 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.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkNotNull; public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter{ - private final Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = Logger.getLogger(getClass().getCanonicalName()); private final Field nbtListTagListField; 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())); } - // ------------------------------------------------------------------------ - // Code that is less likely to break - // ------------------------------------------------------------------------ - - @SuppressWarnings("deprecation") @Override public BaseBlock getBlock(Location 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 - CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null; + CompoundTag nativeTag = state instanceof BaseBlock ? state.getNbtData() : null; if (nativeTag != null || existing instanceof TileEntityBlock) { nmsWorld.setTypeAndData(pos, blockData, 0); // remove tile @@ -352,7 +354,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit return Collections.emptyMap(); } if (block == null) { - logger.warn("Failed to find properties for " + blockType.getId()); + logger.warning("Failed to find properties for " + blockType.getId()); return Collections.emptyMap(); } Map> properties = Maps.newLinkedHashMap(); @@ -418,7 +420,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit try { return toNativeList((NBTTagList) foreign); } 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()); } } 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 IllegalAccessException on error */ - public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + private ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { List values = new ArrayList<>(); int type = foreign.d(); @@ -545,7 +547,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) { // TODO Auto-generated method stub - + } @Override @@ -561,6 +563,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public void sendFakeOP(Player player) { // TODO Auto-generated method stub - + } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java index 53c0a9b70..48a79232e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java @@ -29,7 +29,7 @@ public class ATabCompleteListener implements Listener { Dispatcher dispatcher = CommandManager.getInstance().getDispatcher(); CommandMapping weCommand = dispatcher.get(label); 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); List suggestions = event.getSuggestions(); if (suggestions != null && !suggestions.isEmpty()) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java index a0d3d80ec..8d995846c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java @@ -10,22 +10,15 @@ import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.TaskManager; 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.InvalidToolBindException; import com.sk89q.worldedit.command.tool.brush.Brush; 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.Location; -import org.bukkit.Material; import org.bukkit.Rotation; import org.bukkit.World; import org.bukkit.block.Block; @@ -48,6 +41,13 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; 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 { 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; BlockFace facing = itemFrame.getFacing(); - double thickness = 1/32d + 1/128d; + double thickness = 1/32D + 1/128D; double modX = facing.getModX(); double modZ = facing.getModZ(); double dx = source.getX() - target.getX() - modX * thickness; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java index 69f960507..6122ab99f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java @@ -2,10 +2,11 @@ package com.boydti.fawe.bukkit.util; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.ReflectionUtils; -import java.lang.reflect.Method; import org.bukkit.Bukkit; import org.bukkit.Server; +import java.lang.reflect.Method; + public class BukkitReflectionUtils { /** * prefix of bukkit classes @@ -74,18 +75,6 @@ public class BukkitReflectionUtils { 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() { final String packageName = Bukkit.getServer().getClass().getPackage().getName(); return packageName.substring(packageName.lastIndexOf('.') + 1); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index bcb83b6cd..3ea479f8e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.BukkitPlayer; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; -import com.boydti.fawe.example.IntFaweChunk; import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.object.FaweChunk; 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.adapter.BukkitImplAdapter; 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 org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -46,6 +35,12 @@ import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.WorldInitEvent; 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 extends NMSMappedFaweQueue implements Listener { protected static boolean PAPER = true; @@ -259,7 +254,7 @@ public abstract class BukkitQueue_0 extends NMSMa } public World createWorld(final WorldCreator creator) { - World world = TaskManager.IMP.sync(new RunnableVal() { + return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(World value) { disableChunkLoad = true; @@ -267,7 +262,6 @@ public abstract class BukkitQueue_0 extends NMSMa disableChunkLoad = false; } }); - return world; } @Override @@ -289,8 +283,7 @@ public abstract class BukkitQueue_0 extends NMSMa @Override public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) { if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z)); - boolean result = world.regenerateChunk(x, z); - return result; + return world.regenerateChunk(x, z); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java index c536f9f8a..69e9f069c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java @@ -9,7 +9,6 @@ import com.boydti.fawe.util.TaskManager; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; @@ -163,12 +162,11 @@ public class AsyncChunk implements Chunk { 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) { - return world.unloadChunk(x, z, save, safe); + return world.unloadChunk(x, z, save); } - @Override public boolean unload(boolean save) { return unload(true, false); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java index 885c3fe38..b3e7adc07 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack; import static com.google.common.base.Preconditions.checkNotNull; public interface IBukkitAdapter { + /** * Checks equality between a WorldEdit BlockType and a Bukkit Material * @@ -101,7 +102,7 @@ public interface IBukkitAdapter { default Location adapt(org.bukkit.Location location) { checkNotNull(location); Vector3 position = asVector(location); - return new com.sk89q.worldedit.util.Location( + return new Location( adapt(location.getWorld()), position, location.getYaw(), @@ -138,7 +139,7 @@ public interface IBukkitAdapter { world, position.getX(), position.getY(), position.getZ()); } - + default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position){ return adapt(world, position.toVector3()); } @@ -170,7 +171,7 @@ public interface IBukkitAdapter { checkNotNull(location); return Vector3.at(location.getX(), location.getY(), location.getZ()); } - + /** * Create a WorldEdit BlockVector from a Bukkit location. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 2a91c05fc..c1cc532f0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -564,7 +564,7 @@ public class RegionCommands extends MethodCommands { desc = "Have the blocks in the selection fall", help = "Make the blocks in the selection fall\n" + - "The -m flag will only fall within the vertical selection.", + "The -m flag will only fall within the vertical selection.", min = 0, max = 2 ) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index 586d27d0f..8ba8b67d2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -19,41 +19,36 @@ 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.function.LayerFunction; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.mask.Masks; 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.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; 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.checkNotNull; /** * Visits the layers within a region. - *

+ * *

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 * maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to * each layer.

*/ -@Deprecated public class LayerVisitor implements Operation { + private final FlatRegion flatRegion; private final LayerFunction function; private Mask2D mask = Masks.alwaysTrue2D(); - private final int minY; - private final int maxY; - private final Iterable iterator; + private int minY; + private int maxY; /** * Create a new visitor. @@ -63,14 +58,14 @@ public class LayerVisitor implements Operation { * @param maxY the maximum Y to begin the search at * @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); checkArgument(minY <= maxY, "minY <= maxY required"); checkNotNull(function); + this.flatRegion = flatRegion; this.minY = minY; this.maxY = maxY; this.function = function; - this.iterator = flatRegion.asFlatRegion(); } /** @@ -80,7 +75,7 @@ public class LayerVisitor implements Operation { * @return a 2D mask */ public Mask2D getMask() { - return this.mask; + return mask; } /** @@ -89,15 +84,15 @@ public class LayerVisitor implements Operation { * * @param mask a 2D mask */ - public void setMask(final Mask2D mask) { + public void setMask(Mask2D mask) { checkNotNull(mask); this.mask = mask; } @Override - public Operation resume(final RunContext run) throws WorldEditException { - for (final BlockVector2 column : this.iterator) { - if (!this.mask.test(column)) { + public Operation resume(RunContext run) throws WorldEditException { + for (BlockVector2 column : flatRegion.asFlatRegion()) { + if (!mask.test(column)) { continue; } @@ -111,14 +106,14 @@ public class LayerVisitor implements Operation { for (int y = maxY; y >= minY; --y) { BlockVector3 test = column.toBlockVector3(y); if (!found) { - if (this.function.isGround(test)) { + if (function.isGround(test)) { found = true; groundY = y; } } if (found) { - if (!this.function.apply(test, groundY - y)) { + if (!function.apply(test, groundY - y)) { break; } } @@ -132,7 +127,7 @@ public class LayerVisitor implements Operation { } @Override - public void addStatusMessages(final List messages) { + public void addStatusMessages(List messages) { }