diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 266fbecd1..776ab7218 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -48,6 +48,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import org.inventivetalent.mapmanager.MapManagerPlugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,6 +57,7 @@ public class FaweBukkit implements IFawe, Listener { private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class); private final Plugin plugin; + private final String separator = System.lineSeparator(); private VaultUtil vault; private ItemUtil itemUtil; @@ -73,11 +75,7 @@ public class FaweBukkit implements IFawe, Listener { Settings.IMP.TICK_LIMITER.ENABLED = !Bukkit.hasWhitelist(); Fawe.set(this); Fawe.setupInjector(); - try { - new BrushListener(plugin); - } catch (Throwable e) { - log.debug("Brush Listener Failed", e); - } + plugin.getServer().getPluginManager().registerEvents(this, plugin); if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { new RenderListener(plugin); } @@ -142,7 +140,7 @@ public class FaweBukkit implements IFawe, Listener { fos.write(jarData); } } - BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(player)); + ImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(player), ((MapManagerPlugin) manager.getPlugin("MapManager")).getMapManager()); if (imageListener == null) { this.imageListener = new BukkitImageListener(plugin); } @@ -210,11 +208,11 @@ public class FaweBukkit implements IFawe, Listener { @Override public String getDebugInfo() { StringBuilder msg = new StringBuilder(); - msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n"); - msg.append("Plugins: \n"); + msg.append("Server Version: ").append(Bukkit.getVersion()).append(separator); + msg.append("Plugins: " + separator); for (Plugin p : Bukkit.getPluginManager().getPlugins()) { msg.append(" - ").append(p.getName()).append(": ") - .append(p.getDescription().getVersion()).append("\n"); + .append(p.getDescription().getVersion()).append(separator); } return msg.toString(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitAdapter_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitAdapter_1_13.java index 775416f8f..4bf1b23e9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitAdapter_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_13/BukkitAdapter_1_13.java @@ -15,7 +15,6 @@ import io.papermc.lib.PaperLib; import net.jpountz.util.UnsafeUtils; import net.minecraft.server.v1_13_R2.Block; import net.minecraft.server.v1_13_R2.Chunk; -import net.minecraft.server.v1_13_R2.ChunkCoordIntPair; import net.minecraft.server.v1_13_R2.ChunkSection; import net.minecraft.server.v1_13_R2.DataBits; import net.minecraft.server.v1_13_R2.DataPalette; @@ -30,7 +29,6 @@ import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; import sun.misc.Unsafe; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.concurrent.locks.Lock; @@ -210,8 +208,8 @@ public final class BukkitAdapter_1_13 extends NMSAdapter { } final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + final long[] blockStates = FaweCache.INSTANCE.getBlockStates().get(); + final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get(); try { int[] num_palette_buffer = new int[1]; int air; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java index 64e2a12c5..06abc80ff 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java @@ -30,7 +30,6 @@ import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; import sun.misc.Unsafe; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.concurrent.locks.Lock; @@ -203,8 +202,8 @@ public final class BukkitAdapter_1_14 extends NMSAdapter { } final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + final long[] blockStates = FaweCache.INSTANCE.getBlockStates().get(); + final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get(); try { int[] num_palette_buffer = new int[1]; int air; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java index 7e89ec3a6..9fde9c90d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitAdapter_1_15.java @@ -181,8 +181,8 @@ public final class BukkitAdapter_1_15 extends NMSAdapter { } final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + final long[] blockStates = FaweCache.INSTANCE.getBlockStates().get(); + final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get(); try { int[] num_palette_buffer = new int[1]; int air; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java index 24102e985..6470812be 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java @@ -96,7 +96,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { BiomeStorage index = getChunk().getBiomeIndex(); BiomeBase base = null; if (y == -1) { - for (y = 0; y < FaweCache.WORLD_HEIGHT; y++) { + for (y = 0; y < FaweCache.worldHeight; y++) { base = index.getBiome(x, y, z); if (base != null) break; } @@ -324,7 +324,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { if (biome != null) { final Biome craftBiome = BukkitAdapter.adapt(biome); BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); - for (int y = 0; y < FaweCache.WORLD_HEIGHT; y++) { + for (int y = 0; y < FaweCache.worldHeight; y++) { currentBiomes.setBiome(x, y, z, nmsBiome); } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java index 345775726..a1435ffad 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java @@ -20,9 +20,6 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.plugin.Plugin; public class BrushListener implements Listener { - public BrushListener(Plugin plugin) { - Bukkit.getPluginManager().registerEvents(this, plugin); - } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) { @@ -37,7 +34,7 @@ public class BrushListener implements Listener { final int slot = event.getNewSlot(); final int oldSlot = event.getPreviousSlot(); final int ri; - if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) { + if (slot - oldSlot <= 4 && slot - oldSlot > 0 || slot - oldSlot < -4) { ri = 1; } else { ri = -1; @@ -53,7 +50,7 @@ public class BrushListener implements Listener { public void onPlayerMove(PlayerMoveEvent event) { Location from = event.getFrom(); Location to = event.getTo(); - if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ() || from.getBlockY() != to.getBlockY()) { + if (from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch() || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ() || from.getBlockY() != to.getBlockY()) { Player bukkitPlayer = event.getPlayer(); com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer); LocalSession session = player.getSession(); 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 ebbf41fb3..00d2bbb0f 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 @@ -286,7 +286,7 @@ public class BukkitImageListener implements Listener { EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer) .combineStages(false).autoQueue(false).blockBag(null).limitUnlimited() .build(); - ExtentTraverser last = new ExtentTraverser(es.getExtent()).last(); + ExtentTraverser last = new ExtentTraverser<>(es.getExtent()).last(); Extent extent = last.get(); if (extent instanceof IQueueExtent) { last = last.previous(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java index 0d37d4379..c1c526e7c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java @@ -54,6 +54,7 @@ public abstract class ChunkListener implements Listener { public ChunkListener() { if (Settings.IMP.TICK_LIMITER.ENABLED) { PluginManager plm = Bukkit.getPluginManager(); + assert Fawe.imp() != null; Plugin plugin = Fawe.imp().getPlugin(); plm.registerEvents(this, plugin); try { @@ -293,8 +294,8 @@ public abstract class ChunkListener implements Listener { if (elem != null) { String methodName = elem.getMethodName(); // setAir | setTypeAndData (hacky, but this needs to be efficient) - if (methodName.charAt(0) == 's' && methodName.length() == 6 - || methodName.length() == 14) { + if (methodName.charAt(0) == 's' && (methodName.length() == 6 + || methodName.length() == 14)) { return true; } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java index accc84b90..f76fb3fa9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java @@ -9,7 +9,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPhysicsEvent; -// public class ChunkListener_9 extends ChunkListener { private Exception exception; @@ -88,4 +87,4 @@ public class ChunkListener_9 extends ChunkListener { StackTraceElement[] elems = getElements(ex); return elems.length > i ? elems[i] : null; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java index e89b90745..5d5a24f51 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java @@ -9,6 +9,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -99,7 +100,7 @@ public class RenderListener implements Listener { player.setViewDistance(value); } - private int getViewDistance(Player player) { + private int getViewDistance(Entity player) { int[] value = views.get(player.getUniqueId()); return value == null ? Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING : value[0]; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java index 95a31d98e..02c9d69d7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java @@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.regions.FaweMaskManager; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permissible; public abstract class BukkitMaskManager extends FaweMaskManager { @@ -9,7 +10,7 @@ public abstract class BukkitMaskManager extends FaweMaskManager { super(plugin); } - public boolean hasMemberPermission(Player player) { + public boolean hasMemberPermission(Permissible player) { return player.hasPermission("fawe." + getKey() + ".member"); } } 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 43a1d5968..d62e54853 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 @@ -30,7 +30,7 @@ public class BukkitReflectionUtils { try { final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle"); final Object handle = getHandle.invoke(server); - final Class handleServerClass = handle.getClass(); + final Class handleServerClass = handle.getClass(); pas = handleServerClass.getName().split("\\."); if (pas.length == 5) { final String verM = pas[3]; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java index 2e709913c..e3f890537 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java @@ -26,7 +26,7 @@ public class ItemUtil { private final Field fieldHandle; private final BukkitImplAdapter adapter; - private SoftReference>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>()); + private SoftReference>> hashToNMSTag = new SoftReference<>(new Int2ObjectOpenHashMap<>()); public ItemUtil() throws Exception { this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java index b49a35b3f..9d6c211e8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/image/BukkitImageViewer.java @@ -15,6 +15,7 @@ import org.bukkit.Rotation; import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -32,12 +33,12 @@ public class BukkitImageViewer implements ImageViewer { private ItemFrame[][] frames; private boolean reverse; - public BukkitImageViewer(Player player) { - mapManager = ((MapManagerPlugin) Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager(); + public BukkitImageViewer(Player player, MapManager mapManager) { + this.mapManager = mapManager; this.player = player; } - public void selectFrame(ItemFrame start) { + public void selectFrame(Entity start) { Location pos1 = start.getLocation().clone(); Location pos2 = start.getLocation().clone(); @@ -108,7 +109,7 @@ public class BukkitImageViewer implements ImageViewer { Collection entities = world.getNearbyEntities(pos, 0.1, 0.1, 0.1); boolean contains = false; for (Entity ent : entities) { - if (ent instanceof ItemFrame && ((ItemFrame) ent).getFacing() == facing) { + if (ent instanceof ItemFrame && ent.getFacing() == facing) { ItemFrame itemFrame = (ItemFrame) ent; itemFrame.setRotation(Rotation.NONE); contains = true; @@ -137,7 +138,7 @@ public class BukkitImageViewer implements ImageViewer { boolean initializing = last == null; if (this.frames != null) { - if (image == null && drawable != null) image = drawable.draw(); + if (image == null) image = drawable.draw(); last = image; int width = frames.length; int height = frames[0].length; @@ -158,7 +159,7 @@ public class BukkitImageViewer implements ImageViewer { } else if (player.getInventory().getHeldItemSlot() != slot) { player.getInventory().setHeldItemSlot(slot); } - if (image == null && drawable != null) image = drawable.draw(); + if (image == null) image = drawable.draw(); last = image; BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false); MapWrapper mapWrapper = mapManager.wrapImage(scaled); @@ -169,7 +170,7 @@ public class BukkitImageViewer implements ImageViewer { } } - private int getMapSlot(Player player) { + private int getMapSlot(HumanEntity player) { PlayerInventory inventory = player.getInventory(); for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); @@ -188,4 +189,4 @@ public class BukkitImageViewer implements ImageViewer { public void close() throws IOException { last = null; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index dc2a46c9e..a0ea8f5f7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -376,7 +376,7 @@ public enum BukkitAdapter { * @param block The WorldEdit BlockStateHolder * @return The Bukkit BlockData */ - public static BlockData adapt(@NotNull BlockStateHolder block) { + public static > BlockData adapt(@NotNull T block) { return getAdapter().adapt(block); } @@ -409,4 +409,4 @@ public enum BukkitAdapter { public static ItemStack adapt(BaseItemStack item) { return getAdapter().adapt(item); } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index d26bb36df..82716c789 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -70,6 +70,9 @@ public class BukkitServerInterface implements MultiUserPlatform { dynamicCommands = new CommandRegistration(plugin); } + CommandRegistration getDynamicCommands() { + return dynamicCommands; + } boolean isHookingEvents() { return hookingEvents; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 4df8a7d61..758537b69 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -87,6 +87,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; +import org.bukkit.metadata.Metadatable; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; @@ -575,7 +576,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter return wePlayer; } - public BukkitPlayer getCachedPlayer(Player player) { + public BukkitPlayer getCachedPlayer(Metadatable player) { List meta = player.getMetadata("WE"); if (meta == null || meta.isEmpty()) { return null; @@ -648,15 +649,24 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter String buffer = event.getBuffer(); int firstSpace = buffer.indexOf(' '); if (firstSpace < 0) return; - final String label = buffer.substring(0, firstSpace); + String label = buffer.substring(1, firstSpace); + Plugin owner = server.getDynamicCommands().getCommandOwner(label); + if (owner != WorldEditPlugin.this) { + return; + } + int plSep = label.indexOf(":"); + if (plSep >= 0 && plSep < label.length() + 1) { + label = label.substring(plSep + 1); + buffer = "/" + buffer.substring(plSep + 2); + } final Optional command = WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label); if (!command.isPresent()) return; - CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), event.getBuffer()); + CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), buffer); getWorldEdit().getEventBus().post(suggestEvent); - event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions())); + event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions())); event.setHandled(true); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java index 43beef3b7..295f1b38f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java @@ -79,7 +79,7 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter { Material material = blockData.getMaterial(); BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]); List propList = type.getProperties(); - if (propList.size() == 0) return type.getDefaultState(); + if (propList.isEmpty()) return type.getDefaultState(); String properties = blockData.getAsString(); return BlockState.get(type, properties, type.getDefaultState()); } catch (NullPointerException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 0d692550f..1415eab06 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -28,10 +28,15 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryUsage; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.ZoneId; import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.Objects; +import java.util.TimeZone; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import javax.management.InstanceAlreadyExistsException; @@ -157,7 +162,7 @@ public class Fawe { * The platform specific implementation */ private final IFawe IMP; - private Thread thread; + private final Thread thread; private Fawe(final IFawe implementation) { INSTANCE = this; @@ -289,7 +294,11 @@ public class Fawe { String dateString = br.readLine(); br.close(); this.version = FaweVersion.tryParse(versionString, commitString, dateString); - Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString(); + //noinspection MagicConstant + GregorianCalendar gregorianCalendar = new GregorianCalendar(2000 + version.year, + version.month - 1, version.day); + gregorianCalendar.setTimeZone(TimeZone.getTimeZone("GMT")); + Settings.IMP.DATE = DateFormat.getDateInstance().format(gregorianCalendar.getTime()); Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-1.15/" + version.build; Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/commit/" + Integer.toHexString(version.hash); } catch (Throwable ignore) {} @@ -412,12 +421,4 @@ public class Fawe { return INSTANCE == null || INSTANCE.thread == Thread.currentThread(); } - /** - * Sets the main thread to the current thread - * - * @return - */ - public Thread setMainThread() { - return this.thread = Thread.currentThread(); - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt index 7c7d788ad..e56fc33cc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt @@ -31,9 +31,9 @@ import java.util.function.Supplier object FaweCache : Trimable { const val BLOCKS_PER_LAYER = 4096 - const val CHUNK_LAYERS = 16 - const val WORLD_HEIGHT = CHUNK_LAYERS shl 4 - const val WORLD_MAX_Y = WORLD_HEIGHT - 1 + const val chunkLayers = 16 + const val worldHeight = chunkLayers shl 4 + const val worldMaxY = 255 val EMPTY_CHAR_4096 = CharArray(4096) @@ -57,7 +57,7 @@ object FaweCache : Trimable { result } - val SECTION_BITS_TO_CHAR = CleanableThreadLocal { CharArray(4096) } + val sectionBitsToChar = CleanableThreadLocal { CharArray(4096) } val PALETTE_TO_BLOCK = CleanableThreadLocal { IntArray(Character.MAX_VALUE.toInt() + 1) } @@ -67,23 +67,23 @@ object FaweCache : Trimable { }, fun(a: CharArray): Unit = Arrays.fill(a, Char.MAX_VALUE) ) - val BLOCK_STATES = CleanableThreadLocal { LongArray(2048) } + val blockStates = CleanableThreadLocal { LongArray(2048) } - val SECTION_BLOCKS = CleanableThreadLocal { IntArray(4096) } + val sectionBlocks = CleanableThreadLocal { IntArray(4096) } - val INDEX_STORE = CleanableThreadLocal { IntArray(256) } + val indexStore = CleanableThreadLocal { IntArray(256) } - val HEIGHT_STORE = CleanableThreadLocal { IntArray(256) } + val heightStore = CleanableThreadLocal { IntArray(256) } - private val PALETTE_CACHE = CleanableThreadLocal(Supplier { Palette() }) + private val paletteCache = CleanableThreadLocal(Supplier { Palette() }) /* * Vector cache */ - var MUTABLE_BLOCKVECTOR3 = CleanableThreadLocal(Supplier { MutableBlockVector3() }) + var mutableBlockVector3 = CleanableThreadLocal(Supplier { MutableBlockVector3() }) - var MUTABLE_VECTOR3: CleanableThreadLocal = object : CleanableThreadLocal(Supplier { MutableVector3() }) { + var mutableVector3: CleanableThreadLocal = object : CleanableThreadLocal(Supplier { MutableVector3() }) { override fun init(): MutableVector3 { return MutableVector3() } @@ -102,15 +102,15 @@ object FaweCache : Trimable { BYTE_BUFFER_8192.clean() BLOCK_TO_PALETTE.clean() PALETTE_TO_BLOCK.clean() - BLOCK_STATES.clean() - SECTION_BLOCKS.clean() - PALETTE_CACHE.clean() + blockStates.clean() + sectionBlocks.clean() + paletteCache.clean() PALETTE_TO_BLOCK_CHAR.clean() - INDEX_STORE.clean() + indexStore.clean() - MUTABLE_VECTOR3.clean() - MUTABLE_BLOCKVECTOR3.clean() - SECTION_BITS_TO_CHAR.clean() + mutableVector3.clean() + mutableBlockVector3.clean() + sectionBitsToChar.clean() for ((_, value) in REGISTERED_SINGLETONS) { value.clean() } @@ -239,8 +239,8 @@ object FaweCache : Trimable { private fun toPalette(layerOffset: Int, blocksInts: IntArray?, blocksChars: CharArray?): Palette { val blockToPalette = BLOCK_TO_PALETTE.get() val paletteToBlock = PALETTE_TO_BLOCK.get() - val blockStates = BLOCK_STATES.get() - val blocksCopy = SECTION_BLOCKS.get() + val blockStates = blockStates.get() + val blocksCopy = sectionBlocks.get() val blockIndexStart = layerOffset shl 12 val blockIndexEnd = blockIndexStart + 4096 @@ -305,7 +305,7 @@ object FaweCache : Trimable { } // Construct palette - val palette = PALETTE_CACHE.get() + val palette = paletteCache.get() palette.bitsPerEntry = bitsPerEntry palette.paletteToBlockLength = num_palette palette.paletteToBlock = paletteToBlock @@ -419,7 +419,7 @@ object FaweCache : Trimable { return asTag((if (value) 1 else 0).toByte()) } else if (value == null) { println("Invalid nbt: " + value!!) - return null + return value } else { val clazz = value.javaClass if (clazz.name.startsWith("com.intellectualcrafters.jnbt")) { @@ -507,15 +507,15 @@ object FaweCache : Trimable { } } - val CHUNK = FaweChunkLoadException() - val BLOCK_BAG = FaweBlockBagException() - val MANUAL = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")) - val NO_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region")) - val OUTSIDE_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")) - val MAX_CHECKS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks")) - val MAX_CHANGES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes")) - val LOW_MEMORY = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")) - val MAX_ENTITIES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities")) - val MAX_TILES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles")) - val MAX_ITERATIONS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations")) + val chunk = FaweChunkLoadException() + val blockBag = FaweBlockBagException() + val manual = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")) + val noRegion = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region")) + val outsideRegion = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")) + val maxChecks = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks")) + val maxChanges = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes")) + val lowMemory = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")) + val maxEntities = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities")) + val maxTiles = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles")) + val maxIterations = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations")) } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java index 089533d96..28d97409d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java @@ -1,13 +1,10 @@ package com.boydti.fawe.beta; import com.boydti.fawe.FaweCache; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.HashMap; @@ -34,7 +31,7 @@ public class CombinedBlocks implements IBlocks { @Override public int getBitMask() { int bitMask = addMask; - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.chunkLayers; layer++) { if (primary.hasSection(layer)) { bitMask |= (1 << layer); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index 8bce0c6d0..910ed0e5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -56,7 +56,7 @@ public interface IBatchProcessor { } } int maxLayer = (maxY + 1) >> 4; - for (int layer = maxLayer; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = maxLayer; layer < FaweCache.chunkLayers; layer++) { if (set.hasSection(layer)) { if (layer == minLayer) { char[] arr = set.load(layer); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java index 220a165a9..b09e1202b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java @@ -36,7 +36,7 @@ public interface IBlocks extends Trimable { BiomeType getBiomeType(int x, int y, int z); default int getBitMask() { - return IntStream.range(0, FaweCache.CHUNK_LAYERS).filter(this::hasSection) + return IntStream.range(0, FaweCache.chunkLayers).filter(this::hasSection) .map(layer -> (1 << layer)).sum(); } @@ -56,7 +56,7 @@ public interface IBlocks extends Trimable { FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray); try { - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.chunkLayers; layer++) { if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue; char[] ids = this.load(layer); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index bdb431bae..8c6ded67f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -78,7 +78,7 @@ public interface IQueueExtent extends Flushable, Trimable, ICh @Override default BlockVector3 getMaximumPoint() { - return BlockVector3.at(30000000, FaweCache.WORLD_MAX_Y, 30000000); + return BlockVector3.at(30000000, FaweCache.worldMaxY, 30000000); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java index ab0c98ba9..63638352c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java @@ -84,7 +84,7 @@ public class BitSetBlocks implements IChunkSet { @Override public char[] load(int layer) { - char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] arr = FaweCache.INSTANCE.getSectionBitsToChar().get(); MemBlockSet.IRow nullRowY = row.getRow(layer); if (nullRowY instanceof MemBlockSet.RowY) { char value = blockState.getOrdinalChar(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java index a0e98f71c..83d94a99c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java @@ -142,7 +142,7 @@ public class FallbackChunkGet implements IChunkGet { @Override public char[] load(int layer) { - char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] arr = FaweCache.INSTANCE.getSectionBitsToChar().get(); int by = layer << 4; for (int y = 0, i = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java index c5dcc3bea..bbfd5db61 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java @@ -23,6 +23,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.Future; import javax.annotation.Nullable; +import org.jetbrains.annotations.Range; /** * An abstract {@link IChunk} class that implements basic get/set blocks @@ -39,7 +40,9 @@ public class ChunkHolder> implements IQueueChunk { private IChunkSet chunkSet; // The blocks to be set to the chunkExisting private IBlockDelegate delegate; // delegate handles the abstraction of the chunk layers private IQueueExtent extent; // the parent queue extent which has this chunk + @Range(from = 0, to = 15) private int chunkX; + @Range(from = 0, to = 15) private int chunkZ; public ChunkHolder() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java index 28982600c..507892358 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java @@ -29,22 +29,21 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; - -import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; public class LimitExtent extends PassthroughExtent { private final FaweLimit limit; /** - * Create a new instance. - * - * @param extent the extent - */ + * Create a new instance. + * + * @param extent the extent + */ public LimitExtent(Extent extent, FaweLimit limit) { super(extent); this.limit = limit; @@ -119,7 +118,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getHighestTerrainBlock(x, z, minY, maxY); } catch (FaweException e) { @@ -132,7 +131,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter); } catch (FaweException e) { @@ -145,7 +144,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY); } catch (FaweException e) { @@ -158,7 +157,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); } catch (FaweException e) { @@ -171,7 +170,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); } catch (FaweException e) { @@ -184,7 +183,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); } catch (FaweException e) { @@ -197,7 +196,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); } catch (FaweException e) { @@ -210,7 +209,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { - limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT); + limit.THROW_MAX_CHECKS(FaweCache.worldHeight); try { return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); } catch (FaweException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java index f6e0a2023..77f997dcb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java @@ -58,7 +58,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap @Override public boolean cancel() { if (super.cancel()) { - processor.setProcessor(new NullExtent(this, FaweCache.INSTANCE.getMANUAL())); + processor.setProcessor(new NullExtent(this, FaweCache.INSTANCE.getManual())); return true; } return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java deleted file mode 100644 index 2df358190..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java +++ /dev/null @@ -1,312 +0,0 @@ -package com.boydti.fawe.jnbt; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard; -import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; -import com.boydti.fawe.object.clipboard.LinearClipboard; -import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.math.BlockVector3; - -import java.io.BufferedInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.zip.GZIPInputStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CorruptSchematicStreamer { - - private final Logger log = LoggerFactory.getLogger(CorruptSchematicStreamer.class); - private final InputStream stream; - private final UUID uuid; - private LinearClipboard fc; - final AtomicInteger volume = new AtomicInteger(); - final AtomicInteger width = new AtomicInteger(); - final AtomicInteger height = new AtomicInteger(); - final AtomicInteger length = new AtomicInteger(); - final AtomicInteger offsetX = new AtomicInteger(); - final AtomicInteger offsetY = new AtomicInteger(); - final AtomicInteger offsetZ = new AtomicInteger(); - final AtomicInteger originX = new AtomicInteger(); - final AtomicInteger originY = new AtomicInteger(); - final AtomicInteger originZ = new AtomicInteger(); - - public CorruptSchematicStreamer(InputStream rootStream, UUID uuid) { - this.stream = rootStream; - this.uuid = uuid; - } - - public void match(String matchTag, CorruptReader reader) { - try { - stream.reset(); - stream.mark(Integer.MAX_VALUE); - DataInputStream dataInput = new DataInputStream(new BufferedInputStream(new GZIPInputStream(stream))); - byte[] match = matchTag.getBytes(); - int[] matchValue = new int[match.length]; - int matchIndex = 0; - int read; - while ((read = dataInput.read()) != -1) { - int expected = match[matchIndex]; - if (expected == -1) { - if (++matchIndex == match.length) { - break; - } - } else if (read == expected) { - if (++matchIndex == match.length) { - reader.run(dataInput); - break; - } - } else { - if (matchIndex == 2) - matchIndex = 0; - } - } - log.debug(" - Recover " + matchTag + " = success"); - } catch (Throwable e) { - log.error(" - Recover " + matchTag + " = partial failure", e); - } - } - - public LinearClipboard setupClipboard() { - if (fc != null) { - return fc; - } - BlockVector3 dimensions = guessDimensions(volume.get(), width.get(), height.get(), length.get()); - if (width.get() == 0 || height.get() == 0 || length.get() == 0) { - log.debug("No dimensions found! Estimating based on factors:" + dimensions); - } - if (Settings.IMP.CLIPBOARD.USE_DISK) { - fc = new DiskOptimizedClipboard(dimensions, uuid); - } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { - fc = new CPUOptimizedClipboard(dimensions); - } else { - fc = new MemoryOptimizedClipboard(dimensions); - } - return fc; - } - - public Clipboard recover() { - // TODO FIXME - throw new UnsupportedOperationException("TODO FIXME"); -// try { -// if (stream == null || !stream.markSupported()) { -// throw new IllegalArgumentException("Can only recover from a marked and resettable stream!"); -// } -// match("Width", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// width.set(in.readShort()); -// } -// }); -// match("Height", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// height.set(in.readShort()); -// } -// }); -// match("Length", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// length.set(in.readShort()); -// } -// }); -// match("WEOffsetX", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// offsetX.set(in.readInt()); -// } -// }); -// match("WEOffsetY", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// offsetY.set(in.readInt()); -// } -// }); -// match("WEOffsetZ", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// offsetZ.set(in.readInt()); -// } -// }); -// match("WEOriginX", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// originX.set(in.readInt()); -// } -// }); -// match("WEOriginY", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// originY.set(in.readInt()); -// } -// }); -// match("WEOriginZ", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// originZ.set(in.readInt()); -// } -// }); -// match("Blocks", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int length = in.readInt(); -// volume.set(length); -// setupClipboard(); -// for (int i = 0; i < length; i++) { -// fc.setId(i, in.read()); -// } -// } -// }); -// match("Data", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int length = in.readInt(); -// volume.set(length); -// setupClipboard(); -// for (int i = 0; i < length; i++) { -// fc.setData(i, in.read()); -// } -// } -// }); -// match("AddBlocks", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int length = in.readInt(); -// int expected = volume.get(); -// if (expected == 0) { -// expected = length * 2; -// volume.set(expected); -// } -// setupClipboard(); -// if (expected == length * 2) { -// for (int i = 0; i < length; i++) { -// int value = in.read(); -// int first = value & 0x0F; -// int second = (value & 0xF0) >> 4; -// int gIndex = i << 1; -// if (first != 0) fc.setAdd(gIndex, first); -// if (second != 0) fc.setAdd(gIndex + 1, second); -// } -// } else { -// for (int i = 0; i < length; i++) { -// int value = in.read(); -// if (value != 0) fc.setAdd(i, value); -// } -// } -// } -// }); -// match("Biomes", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int length = in.readInt(); -// for (int i = 0; i < length; i++) { -// fc.setBiome(i, in.read()); -// } -// } -// }); -// Vector dimensions = guessDimensions(volume.get(), width.get(), height.get(), length.get()); -// Vector min = new Vector(originX.get(), originY.get(), originZ.get()); -// Vector offset = new Vector(offsetX.get(), offsetY.get(), offsetZ.get()); -// Vector origin = min.subtract(offset); -// CuboidRegion region = new CuboidRegion(min, min.add(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()).subtract(Vector.ONE)); -// fc.setOrigin(offset); -// final BlockArrayClipboard clipboard = new BlockArrayClipboard(region, fc); -// match("TileEntities", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int childType = in.readByte(); -// int length = in.readInt(); -// NBTInputStream nis = new NBTInputStream(in); -// for (int i = 0; i < length; ++i) { -// CompoundTag tag = (CompoundTag) nis.readTagPayload(childType, 1); -// int x = tag.getInt("x"); -// int y = tag.getInt("y"); -// int z = tag.getInt("z"); -// fc.setTile(x, y, z, tag); -// } -// } -// }); -// match("Entities", new CorruptSchematicStreamer.CorruptReader() { -// @Override -// public void run(DataInputStream in) throws IOException { -// int childType = in.readByte(); -// int length = in.readInt(); -// NBTInputStream nis = new NBTInputStream(in); -// for (int i = 0; i < length; ++i) { -// CompoundTag tag = (CompoundTag) nis.readTagPayload(childType, 1); -// int x = tag.getInt("x"); -// int y = tag.getInt("y"); -// int z = tag.getInt("z"); -// String id = tag.getString("id"); -// if (id.isEmpty()) { -// return; -// } -// ListTag positionTag = tag.getListTag("Pos"); -// ListTag directionTag = tag.getListTag("Rotation"); -// BaseEntity state = new BaseEntity(id, tag); -// fc.createEntity(clipboard, positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2), (float) directionTag.asDouble(0), (float) directionTag.asDouble(1), state); -// } -// } -// }); -// return clipboard; -// } catch (Throwable e) { -// if (fc != null) fc.close(); -// throw e; -// } - } - - private BlockVector3 guessDimensions(int volume, int width, int height, int length) { - if (volume == 0) { - return BlockVector3.at(width, height, length); - } - if (volume == width * height * length) { - return BlockVector3.at(width, height, length); - } - if (width == 0 && height != 0 && length != 0 && volume % (height * length) == 0 && height * length <= volume) { - return BlockVector3.at(volume / (height * length), height, length); - } - if (height == 0 && width != 0 && length != 0 && volume % (width * length) == 0 && width * length <= volume) { - return BlockVector3.at(width, volume / (width * length), length); - } - if (length == 0 && height != 0 && width != 0 && volume % (height * width) == 0 && height * width <= volume) { - return BlockVector3.at(width, height, volume / (width * height)); - } - List factors = new ArrayList<>(); - for (int i = (int) Math.sqrt(volume); i > 0; i--) { - if (volume % i == 0) { - factors.add(i); - factors.add(volume / i); - } - } - int min = Integer.MAX_VALUE; - int vx = 0, vy = 0, vz = 0; - for (int x = 0; x < factors.size(); x++) { - int xValue = factors.get(x); - for (int yValue : factors) { - long area = xValue * yValue; - if (volume % area == 0) { - int z = (int) (volume / area); - int max = Math.max(Math.max(xValue, yValue), z); - if (max < min) { - min = max; - vx = xValue; - vz = z; - vy = yValue; - } - } - } - } - return BlockVector3.at(vx, vz, vy); - } - - public interface CorruptReader { - void run(DataInputStream in) throws IOException; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index 522b90e32..aef82ff33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -47,7 +47,7 @@ public class MCAChunk implements IChunk { public final boolean[] hasSections = new boolean[16]; public boolean hasBiomes = false; - public final BiomeType[] biomes = new BiomeType[256]; + public final BiomeType[] biomes = new BiomeType[1024]; public final char[] blocks = new char[65536]; @@ -72,7 +72,7 @@ public class MCAChunk implements IChunk { int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1); BitArray4096 bitArray = new BitArray4096(section.blocks, bitsPerEntry); - char[] buffer = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] buffer = FaweCache.INSTANCE.getSectionBitsToChar().get(); bitArray.toRaw(buffer); int offset = section.layer << 12; for (int i = 0; i < buffer.length; i++) { @@ -220,8 +220,8 @@ public class MCAChunk implements IChunk { public void write(NBTOutputStream nbtOut) throws IOException { int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get(); int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get(); - long[] blockstates = FaweCache.INSTANCE.getBLOCK_STATES().get(); - int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get(); + long[] blockstates = FaweCache.INSTANCE.getBlockStates().get(); + int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get(); nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND); nbtOut.writeNamedTag("DataVersion", 1631); @@ -243,7 +243,7 @@ public class MCAChunk implements IChunk { out.writeNamedTag("InhabitedTime", inhabitedTime); out.writeNamedTag("LastUpdate", lastUpdate); if (hasBiomes) { - int type = NBTConstants.TYPE_BYTE_ARRAY; + int type = NBTConstants.TYPE_INT_ARRAY; out.writeNamedTagName("Biomes", type); out.writeInt(biomes.length); for (BiomeType biome : biomes) { @@ -524,7 +524,7 @@ public class MCAChunk implements IChunk { @Override public char[] load(int layer) { - char[] tmp = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get(); + char[] tmp = FaweCache.INSTANCE.getSectionBitsToChar().get(); int offset = layer << 12; System.arraycopy(blocks, offset, tmp, 0, 4096); return tmp; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index 76c4050c4..9f3be6328 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -138,7 +138,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh @Override public BlockVector3 getMaximumPoint() { - return BlockVector3.at((this.X << 9) + 511, FaweCache.WORLD_MAX_Y, (this.Z << 9) + 511); + return BlockVector3.at((this.X << 9) + 511, FaweCache.worldMaxY, (this.Z << 9) + 511); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/BytePair.java b/worldedit-core/src/main/java/com/boydti/fawe/object/BytePair.java deleted file mode 100644 index ccb56666e..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/BytePair.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.boydti.fawe.object; - -import com.boydti.fawe.util.MathMan; - -public class BytePair { - public short pair; - - public BytePair(final byte x, final byte z) { - this.pair = MathMan.pairByte(x, z); - } - - public int get0x() { - return MathMan.unpair16x((byte) get0()); - } - - public int get0y() { - return MathMan.unpair16y((byte) get0()); - } - - public int get0() { - return MathMan.unpairShortX(pair); - } - - public int get1() { - return MathMan.unpairShortY(pair); - } - - @Override - public int hashCode() { - return pair; - } - - @Override - public String toString() { - return pair + ""; - } - - @Override - public boolean equals(final Object obj) { - return obj.hashCode() == pair; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java index 179403f20..7cf4a887b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java @@ -136,51 +136,51 @@ public class FaweLimit { } public void THROW_MAX_CHANGES() { - if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES(); + if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMaxChanges(); } public void THROW_MAX_FAILS() { - if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMaxChecks(); } public void THROW_MAX_CHECKS() { - if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMaxChecks(); } public void THROW_MAX_ITERATIONS() { - if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS(); + if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMaxIterations(); } public void THROW_MAX_BLOCKSTATES() { - if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMAX_TILES(); + if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMaxTiles(); } public void THROW_MAX_ENTITIES() { - if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES(); + if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMaxEntities(); } public void THROW_MAX_CHANGES(int amt) { - if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES(); + if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChanges(); } public void THROW_MAX_FAILS(int amt) { - if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChecks(); } public void THROW_MAX_CHECKS(int amt) { - if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS(); + if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChecks(); } public void THROW_MAX_ITERATIONS(int amt) { - if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS(); + if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxIterations(); } public void THROW_MAX_BLOCKSTATES(int amt) { - if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_TILES(); + if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxTiles(); } public void THROW_MAX_ENTITIES(int amt) { - if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES(); + if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxEntities(); } public boolean isUnlimited() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerPair.java b/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerPair.java deleted file mode 100644 index 902848f9c..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerPair.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.boydti.fawe.object; - -public class IntegerPair { - public int x; - public int z; - - public IntegerPair(final int x, final int z) { - this.x = x; - this.z = z; - } - - @Override - public int hashCode() { - return (x << 16) | (z & 0xFFFF); - } - - @Override - public String toString() { - return x + "," + z; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if ((obj == null) || (this.getClass() != obj.getClass())) { - return false; - } - final IntegerPair other = (IntegerPair) obj; - return ((this.x == other.x) && (this.z == other.z)); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerTrio.java b/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerTrio.java deleted file mode 100644 index b328836a0..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/IntegerTrio.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.boydti.fawe.object; - -public class IntegerTrio { - public int x, y, z; - - public IntegerTrio(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public IntegerTrio(IntegerTrio node) { - this.x = node.x; - this.y = node.y; - this.z = node.z; - } - - public IntegerTrio() { - } - - public final void set(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public final void set(IntegerTrio node) { - this.x = node.x; - this.y = node.y; - this.z = node.z; - } - - @Override - public final int hashCode() { - return (x ^ (z << 12)) ^ (y << 24); - } - - public final int getX() { - return x; - } - - public final int getY() { - return y; - } - - public final int getZ() { - return z; - } - - @Override - public String toString() { - return x + "," + y + "," + z; - } - - @Override - public boolean equals(Object obj) { - IntegerTrio other = (IntegerTrio) obj; - return other.x == x && other.z == z && other.y == y; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java index 1a8d166ec..e8c7cd1a3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; public class NullChangeSet extends AbstractChangeSet { @@ -58,7 +59,7 @@ public class NullChangeSet extends AbstractChangeSet { @Override public final Iterator getIterator(boolean undo) { - return new ArrayList().iterator(); + return Collections.emptyIterator(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/AbstractBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/AbstractBrush.java deleted file mode 100644 index 910450f34..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/AbstractBrush.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.boydti.fawe.object.brush; - -import com.sk89q.worldedit.command.tool.BrushTool; -import com.sk89q.worldedit.command.tool.brush.Brush; - -public abstract class AbstractBrush implements Brush { - private BrushTool tool; - - public AbstractBrush(BrushTool tool) { - this.tool = tool; - } - - public void setTool(BrushTool tool) { - this.tool = tool; - } - - public BrushTool getTool() { - return tool; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java index 4ae931884..dffcb29e3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java @@ -1,10 +1,5 @@ package com.boydti.fawe.object.brush; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.math.BlockVector3; - public class RaiseBrush extends ErodeBrush { public RaiseBrush() { this(6, 0, 1, 1); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java index 903d4f80e..50fcab3a5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java @@ -37,7 +37,7 @@ public class ShatterBrush extends ScatterBrush { LocalBlockVectorSet set = new LocalBlockVectorSet(); set.add(pos); frontiers[i] = set; - frontiersVisited[i] = set.clone(); + frontiersVisited[i] = new LocalBlockVectorSet(set); i++; } // Mask diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index fadad9001..8988a1839 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -1,7 +1,6 @@ package com.boydti.fawe.object.brush; import com.boydti.fawe.FaweCache; -import com.sk89q.worldedit.function.mask.DelegateExtentMask; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.mask.IdMask; @@ -63,7 +62,7 @@ public class SplineBrush implements Brush, ResettableTool { this.position = position; if (newPos) { if (positionSets.size() >= MAX_POINTS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.INSTANCE.getMaxChecks(); } final ArrayList points = new ArrayList<>(); if (size > 0) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index dae06fbf0..a831e4438 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.brush.heightmap; -import com.boydti.fawe.object.IntegerPair; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -12,6 +11,7 @@ import java.awt.image.Raster; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; +import kotlin.Pair; public class ScalableHeightMap implements HeightMap { public int size2; @@ -65,9 +65,9 @@ public class ScalableHeightMap implements HeightMap { int minY = clipboard.getMinimumPoint().getBlockY(); int maxY = clipboard.getMaximumPoint().getBlockY(); int clipHeight = maxY - minY + 1; - HashSet visited = new HashSet<>(); + HashSet> visited = new HashSet<>(); for (BlockVector3 pos : clipboard.getRegion()) { - IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ()); + Pair pair = new Pair<>(pos.getBlockX(), pos.getBlockZ()); if (visited.contains(pair)) { continue; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index c5cd08d7a..ec76dff40 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -7,13 +7,9 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.implementation.filter.block.AbstractFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.ArrayFilterBlock; -import com.boydti.fawe.beta.implementation.filter.block.MultiFilterBlock; -import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet; -import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.jnbt.anvil.MCAChunk; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; @@ -39,7 +35,6 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; @@ -59,7 +54,6 @@ import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -1563,12 +1557,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr char[] floor = this.floor.get(); char[] overlay = this.overlay != null ? this.overlay.get() : null; try { - int[] indexes = FaweCache.INSTANCE.getINDEX_STORE().get(); + int[] indexes = FaweCache.INSTANCE.getIndexStore().get(); int index; int maxY = 0; int minY = Integer.MAX_VALUE; - int[] heightMap = FaweCache.INSTANCE.getHEIGHT_STORE().get(); + int[] heightMap = FaweCache.INSTANCE.getHeightStore().get(); int globalIndex; for (int z = csz; z <= cez; z++) { globalIndex = z * getWidth() + csx; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java index db2b83226..b1c21356d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java @@ -8,7 +8,7 @@ import com.sk89q.worldedit.world.biome.BiomeTypes; public class MutableBiomeChange implements Change { - private MutableBlockVector2 mutable = new MutableBlockVector2(); + private final MutableBlockVector2 mutable = new MutableBlockVector2(); private int from; private int to; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java index c527c560f..6f2762831 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java @@ -87,10 +87,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet { try { blockBag.fetchPlacedBlock(typeTo.getDefaultState()); } catch (UnplaceableBlockException e) { - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.INSTANCE.getBlockBag(); } catch (BlockBagException e) { missingBlocks[typeTo.getInternalId()]++; - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.INSTANCE.getBlockBag(); } } if (mine) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java index 5c199c326..409ca481e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java @@ -6,8 +6,6 @@ import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; -import com.boydti.fawe.object.IntegerPair; -import com.boydti.fawe.object.change.MutableFullBlockChange; import com.boydti.fawe.util.MainUtil; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTOutputStream; @@ -16,12 +14,13 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.World; -import java.io.EOFException; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.UUID; +import kotlin.Pair; /** * Store the change on disk @@ -403,25 +402,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet { return null; } - public IntegerPair readHeader() { + public Pair readHeader() { int ox = getOriginX(); int oz = getOriginZ(); if (ox == 0 && oz == 0 && bdFile.exists()) { - try (FileInputStream fis = new FileInputStream(bdFile)) { - final FaweInputStream gis = MainUtil.getCompressedIS(fis); + try (FileInputStream fis = new FileInputStream(bdFile); FaweInputStream gis = MainUtil + .getCompressedIS(fis)) { // skip mode gis.skipFully(1); // origin ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read()); oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read()); setOrigin(ox, oz); - fis.close(); - gis.close(); } catch (IOException e) { e.printStackTrace(); } } - return new IntegerPair(ox, oz); + return new Pair<>(ox, oz); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java index d82a6f4c2..1635b625d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java @@ -456,7 +456,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { public Iterator getBiomeIterator(final boolean dir) throws IOException { final FaweInputStream is = getBiomeIS(); if (is == null) { - return new ArrayList().iterator(); + return Collections.emptyIterator(); } final MutableBiomeChange change = new MutableBiomeChange(); return new Iterator() { @@ -570,7 +570,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { public Iterator getEntityIterator(final NBTInputStream is, final boolean create) { if (is == null) { - return new ArrayList().iterator(); + return Collections.emptyIterator(); } final MutableEntityChange change = new MutableEntityChange(null, create); try { @@ -619,7 +619,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { public Iterator getTileIterator(final NBTInputStream is, final boolean create) { if (is == null) { - return new ArrayList().iterator(); + return Collections.emptyIterator(); } final MutableTileChange change = new MutableTileChange(null, create); try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index b47880573..68d80c9d7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -1,7 +1,6 @@ package com.boydti.fawe.object.clipboard; import com.boydti.fawe.jnbt.streamer.IntValueReader; -import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -16,23 +15,24 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import java.util.Map.Entry; import javax.annotation.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; +import kotlin.Triple; public class CPUOptimizedClipboard extends LinearClipboard { private BiomeType[] biomes = null; private char[] states; - private final HashMap nbtMapLoc; + private final HashMap, CompoundTag> nbtMapLoc; private final HashMap nbtMapIndex; @@ -95,9 +95,9 @@ public class CPUOptimizedClipboard extends LinearClipboard { if (nbtMapLoc.isEmpty()) { return; } - for (Map.Entry entry : nbtMapLoc.entrySet()) { - IntegerTrio key = entry.getKey(); - setTile(getIndex(key.x, key.y, key.z), entry.getValue()); + for (Entry, CompoundTag> entry : nbtMapLoc.entrySet()) { + Triple key = entry.getKey(); + setTile(getIndex(key.getFirst(), key.getSecond(), key.getThird()), entry.getValue()); } nbtMapLoc.clear(); } @@ -168,7 +168,7 @@ public class CPUOptimizedClipboard extends LinearClipboard { @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - nbtMapLoc.put(new IntegerTrio(x, y, z), tag); + nbtMapLoc.put(new Triple<>(x, y, z), tag); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index a3523e1df..01b32e76c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -3,7 +3,6 @@ package com.boydti.fawe.object.clipboard; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; import com.boydti.fawe.jnbt.streamer.IntValueReader; -import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; @@ -39,8 +38,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; import javax.annotation.Nullable; +import kotlin.Triple; /** * A clipboard with disk backed storage. (lower memory + loads on crash) @@ -51,7 +52,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable private static int HEADER_SIZE = 14; - private final HashMap nbtMap; + private final HashMap, CompoundTag> nbtMap; private final File file; private RandomAccessFile braf; @@ -60,45 +61,41 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable private FileChannel fileChannel; private boolean hasBiomes; - public DiskOptimizedClipboard(BlockVector3 dimensions, UUID uuid) { + public DiskOptimizedClipboard(BlockVector3 dimensions, UUID uuid) throws IOException { this(dimensions, MainUtil.getFile(Fawe.get() != null ? Fawe.imp().getDirectory() : new File("."), Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd")); } - public DiskOptimizedClipboard(BlockVector3 dimensions) { + public DiskOptimizedClipboard(BlockVector3 dimensions) throws IOException { this(dimensions, MainUtil.getFile(Fawe.imp() != null ? Fawe.imp().getDirectory() : new File("."), Settings.IMP.PATHS.CLIPBOARD + File.separator + UUID.randomUUID() + ".bd")); } - public DiskOptimizedClipboard(BlockVector3 dimensions, File file) { + public DiskOptimizedClipboard(BlockVector3 dimensions, File file) throws IOException { super(dimensions); if (getWidth() > Character.MAX_VALUE || getHeight() > Character.MAX_VALUE || getLength() > Character.MAX_VALUE) { throw new IllegalArgumentException("Too large"); } nbtMap = new HashMap<>(); + this.file = file; try { - this.file = file; - try { - if (!file.exists()) { - File parent = file.getParentFile(); - if (parent != null) { - file.getParentFile().mkdirs(); - } - file.createNewFile(); + if (!file.exists()) { + File parent = file.getParentFile(); + if (parent != null) { + file.getParentFile().mkdirs(); } - } catch (Exception e) { - e.printStackTrace(); + file.createNewFile(); } - this.braf = new RandomAccessFile(file, "rw"); - long fileLength = (long) getVolume() * 2L + (long) HEADER_SIZE; - braf.setLength(0); - braf.setLength(fileLength); - init(); - // write getLength() etc - byteBuffer.putChar(2, (char) getWidth()); - byteBuffer.putChar(4, (char) getHeight()); - byteBuffer.putChar(6, (char) getLength()); - } catch (IOException e) { - throw new RuntimeException(e); + } catch (Exception e) { + e.printStackTrace(); } + this.braf = new RandomAccessFile(file, "rw"); + long fileLength = (long) getVolume() * 2L + (long) HEADER_SIZE; + braf.setLength(0); + braf.setLength(fileLength); + init(); + // write getLength() etc + byteBuffer.putChar(2, (char) getWidth()); + byteBuffer.putChar(4, (char) getHeight()); + byteBuffer.putChar(6, (char) getLength()); } @Override @@ -310,9 +307,9 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable CompoundTag nbt; if (nbtMap.size() < 4) { nbt = null; - for (Map.Entry entry : nbtMap.entrySet()) { - IntegerTrio key = entry.getKey(); - int index = getIndex(key.x, key.y, key.z); + for (Entry, CompoundTag> entry : nbtMap.entrySet()) { + Triple key = entry.getKey(); + int index = getIndex(key.getFirst(), key.getSecond(), key.getThird()); if (index == i) { nbt = entry.getValue(); break; @@ -323,7 +320,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable int newI = i - y * getArea(); int z = newI / getWidth(); int x = newI - z * getWidth(); - nbt = nbtMap.get(new IntegerTrio(x, y, z)); + nbt = nbtMap.get(new Triple<>(x, y, z)); } return state.toBaseBlock(nbt); } @@ -332,7 +329,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable private BaseBlock toBaseBlock(BlockState state, int x, int y, int z) { if (state.getMaterial().hasContainer() && !nbtMap.isEmpty()) { - CompoundTag nbt = nbtMap.get(new IntegerTrio(x, y, z)); + CompoundTag nbt = nbtMap.get(new Triple<>(x, y, z)); return state.toBaseBlock(nbt); } return state.toBaseBlock(); @@ -363,7 +360,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - nbtMap.put(new IntegerTrio(x, y, z), tag); + nbtMap.put(new Triple<>(x, y, z), tag); Map values = ReflectionUtils.getMap(tag.getValue()); values.put("x", new IntTag(x)); values.put("y", new IntTag(y)); @@ -427,16 +424,4 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable this.entities.remove(entity); } - @Override - public void removeEntity(int x, int y, int z, UUID uuid) { - Iterator iter = this.entities.iterator(); - while (iter.hasNext()) { - BlockArrayClipboard.ClipboardEntity entity = iter.next(); - UUID entUUID = entity.getState().getNbtData().getUUID(); - if (uuid.equals(entUUID)) { - iter.remove(); - return; - } - } - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java index 4e97c9561..5dc7e1282 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.clipboard; import com.boydti.fawe.config.Settings; import com.boydti.fawe.jnbt.streamer.IntValueReader; -import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; @@ -20,17 +19,15 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; - -import javax.annotation.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.UUID; +import java.util.Map.Entry; +import javax.annotation.Nullable; +import kotlin.Triple; public class MemoryOptimizedClipboard extends LinearClipboard { @@ -43,7 +40,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { private byte[] buffer = new byte[MainUtil.getMaxCompressedLength(BLOCK_SIZE)]; private byte[] biomes = null; - private final HashMap nbtMapLoc; + private final HashMap, CompoundTag> nbtMapLoc; private final HashMap nbtMapIndex; @@ -71,9 +68,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard { if (nbtMapLoc.isEmpty()) { return; } - for (Map.Entry entry : nbtMapLoc.entrySet()) { - IntegerTrio key = entry.getKey(); - setTile(getIndex(key.x, key.y, key.z), entry.getValue()); + for (Entry, CompoundTag> entry : nbtMapLoc.entrySet()) { + Triple key = entry.getKey(); + setTile(getIndex(key.getFirst(), key.getSecond(), key.getThird()), entry.getValue()); } nbtMapLoc.clear(); } @@ -266,7 +263,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - nbtMapLoc.put(new IntegerTrio(x, y, z), tag); + nbtMapLoc.put(new Triple<>(x, y, z), tag); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java index 1fe4f1ef9..9597faa15 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java @@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.List; import java.util.function.Supplier; +import org.jetbrains.annotations.NotNull; public abstract class ReadOnlyClipboard extends SimpleClipboard { public final Region region; @@ -68,6 +69,8 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard { }; } + @NotNull + @Override public Region getRegion() { return region; } @@ -81,7 +84,7 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard { public abstract List getEntities(); @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) { + public > boolean setBlock(int x, int y, int z, B block) { throw new UnsupportedOperationException("Clipboard is immutable"); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/SimpleClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/SimpleClipboard.java index b614e5bef..507d74f74 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/SimpleClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/SimpleClipboard.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import java.io.Closeable; +import org.jetbrains.annotations.NotNull; public abstract class SimpleClipboard implements Clipboard, Closeable { private final BlockVector3 size; @@ -44,6 +45,7 @@ public abstract class SimpleClipboard implements Clipboard, Closeable { return size.subtract(BlockVector3.ONE); } + @NotNull @Override public Region getRegion() { return new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() - 1, getHeight() - 1, getLength() - 1)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCutClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCutClipboard.java deleted file mode 100644 index ed4287ef5..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCutClipboard.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.boydti.fawe.object.clipboard; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.io.Closeable; -import java.io.IOException; -import java.util.function.Supplier; - -public class WorldCutClipboard extends WorldCopyClipboard { - public WorldCutClipboard(Supplier supplier, Region region) { - super(supplier, region); - } - - public WorldCutClipboard(Supplier supplier, Region region, boolean hasEntities, boolean hasBiomes) { - super(supplier, region, hasEntities, hasBiomes); - } - - @Override - public BaseBlock getFullBlock(int x, int y, int z) { - Extent extent = getExtent(); - BaseBlock block = extent.getFullBlock(x, y, z); - extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); - return block; - } - - @Override - public BlockState getBlock(int x, int y, int z) { - Extent extent = getExtent(); - BlockState block = extent.getBlock(x, y, z); - extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); - return block; - } - - @Override - public void close() { - Extent extent = getExtent(); - if (extent instanceof EditSession) { - ((EditSession) extent).flushQueue(); - } else if (extent instanceof Closeable) { - try { - ((Closeable) extent).close(); - } catch (IOException e) { - e.printStackTrace(); - } - } else { - extent.commit(); - } - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java index 87c9a247a..7814daf50 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.collection; +import com.google.common.base.Functions; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -15,7 +16,7 @@ public class AdaptedMap implements IAdaptedMap { private final Function value; private final Function key; - private static final Function SAME = o -> o; + private static final Function SAME = Functions.identity(); private static final Function IMMUTABLE = o -> { throw new UnsupportedOperationException("Immutable"); }; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java index 0edf2c6bd..30dec1e54 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; import java.util.Iterator; import java.util.Set; +import org.jetbrains.annotations.NotNull; public abstract class BlockSet extends AbstractRegion { private final int chunkOffsetX; @@ -92,6 +93,7 @@ public abstract class BlockSet extends AbstractRegion { public abstract void set(int x, int y, int z); public abstract void clear(int x, int y, int z); public abstract boolean remove(int x, int y, int z); + @NotNull @Override public abstract Iterator iterator(); @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java index 74dc46802..e4e6c2274 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java @@ -180,7 +180,7 @@ public class BlockVectorSet extends AbstractCollection implements public boolean retainAll(@NotNull Collection c) { Objects.requireNonNull(c); boolean modified = false; - Iterator it = iterator(); + Iterator it = iterator(); while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); @@ -192,11 +192,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean removeAll(Collection c) { - boolean result = false; - for (Object o : c) { - result |= remove(o); - } - return result; + return c.stream().map(this::remove).reduce(false, (a, b) -> a || b); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/CleanableThreadLocal.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/CleanableThreadLocal.java index 87aef5b8d..99abe1afa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/CleanableThreadLocal.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/CleanableThreadLocal.java @@ -87,7 +87,7 @@ public class CleanableThreadLocal extends ThreadLocal implements Closeable return list; } - public static void iterate(ThreadLocal instance, Consumer withMap) { + public static void iterate(ThreadLocal instance, Consumer withMap) { try { Thread[] threads = MainUtil.getThreads(); Field tl = Thread.class.getDeclaredField("threadLocals"); @@ -105,7 +105,7 @@ public class CleanableThreadLocal extends ThreadLocal implements Closeable } } - public static void clean(ThreadLocal instance) { + public static void clean(ThreadLocal instance) { iterate(instance, new Consumer() { Method methodRemove; @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java index 47ea5c752..eeb859282 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java @@ -35,7 +35,7 @@ public final class DifferentialArray implements DifferentialCollection { public DifferentialArray(T array) { checkNotNull(array); - Class clazz = array.getClass(); + Class clazz = array.getClass(); checkArgument(clazz.isArray(), "Data must be an array"); checkArgument(clazz.getComponentType().isPrimitive(), "Data must be a primitive array"); this.data = array; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java index ce6efa400..2682aa8e0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java @@ -148,7 +148,7 @@ public final class DifferentialBlockBuffer implements DifferentialCollection { offsetX = offsetZ = Integer.MAX_VALUE; this.set = new SparseBitSet(); } + public LocalBlockVectorSet(LocalBlockVectorSet copy) { + this.offsetX = copy.offsetX; + this.offsetZ = copy.offsetZ; + this.set = copy.set.clone(); + } public LocalBlockVectorSet(int x, int z, SparseBitSet set) { this.offsetX = x; @@ -55,12 +60,7 @@ public class LocalBlockVectorSet implements Set { } return false; } - - @Override - public LocalBlockVectorSet clone() { - return new LocalBlockVectorSet(offsetX, offsetZ, set.clone()); - } - + public boolean containsRadius(int x, int y, int z, int radius) { if (radius <= 0) { return contains(x, y, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java index 2d9e37a1e..61c9ea1c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LongHashSet.java @@ -60,11 +60,11 @@ public class LongHashSet { public void add(long key) { int mainIdx = (int) (key & 255); - long outer[][] = this.values[mainIdx]; + long[][] outer = this.values[mainIdx]; if (outer == null) this.values[mainIdx] = outer = new long[256][]; int outerIdx = (int) ((key >> 32) & 255); - long inner[] = outer[outerIdx]; + long[] inner = outer[outerIdx]; if (inner == null) { synchronized (this) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java index 3a7735439..779b927ed 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java @@ -73,10 +73,12 @@ public final class MemBlockSet extends BlockSet { return rows[x >> 4].remove(this.rows, x, y, z - getBlockOffsetZ()); } + @Override public BlockVector3 getMinimumPoint() { return BlockVector3.at(getMinX(), getMinimumY(), getMinZ()); } + @Override public BlockVector3 getMaximumPoint() { return BlockVector3.at(getMaxX(), getMaximumY(), getMaxZ()); } @@ -173,8 +175,10 @@ public final class MemBlockSet extends BlockSet { }; } + @Override public Set getChunkCubes() { return new AbstractSet() { + @NotNull @Override public Iterator iterator() { return new Iterator() { @@ -279,7 +283,6 @@ public final class MemBlockSet extends BlockSet { }; } - @Override public int getMinimumY() { int maxY = 15; int maxy = 16; @@ -324,7 +327,6 @@ public final class MemBlockSet extends BlockSet { return by; } - @Override public int getMaximumY() { int maxY = 0; int maxy = 0; @@ -357,8 +359,8 @@ public final class MemBlockSet extends BlockSet { maxy = y + 1; } by = (Y << 4) + y; - if (by == FaweCache.WORLD_MAX_Y) - return FaweCache.WORLD_MAX_Y; + if (by == FaweCache.worldMaxY) + return FaweCache.worldMaxY; break outer; } } @@ -739,6 +741,7 @@ public final class MemBlockSet extends BlockSet { return total; } + @Override public void clear() { Arrays.fill(rows, NULL_ROW_X); } @@ -827,7 +830,7 @@ public final class MemBlockSet extends BlockSet { public final IRow[] rows; public RowZ() { - this.rows = new IRow[FaweCache.CHUNK_LAYERS]; + this.rows = new IRow[FaweCache.chunkLayers]; reset(); } @@ -861,12 +864,7 @@ public final class MemBlockSet extends BlockSet { } public boolean isEmpty() { - for (IRow row :rows) { - if (row instanceof RowY) { - return false; - } - } - return true; + return Arrays.stream(rows).noneMatch(row -> row instanceof RowY); } public void reset(int layer) { @@ -874,7 +872,7 @@ public final class MemBlockSet extends BlockSet { } public void reset() { - for (int i = 0; i < FaweCache.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y; + for (int i = 0; i < FaweCache.chunkLayers; i++) rows[i] = NULL_ROW_Y; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/PrimitiveList.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/PrimitiveList.java deleted file mode 100644 index 84b2ccd5e..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/PrimitiveList.java +++ /dev/null @@ -1,338 +0,0 @@ -package com.boydti.fawe.object.collection; - -import java.lang.reflect.Array; -import java.util.AbstractList; - -public class PrimitiveList extends AbstractList { - private final Class primitive; - private final Type type; - private int length; - private int totalLength; - private Object arr; - - private enum Type { - Byte, - Boolean, - Short, - Character, - Integer, - Float, - Long, - Double - } - - public PrimitiveList(Class type) { - try { - Class boxed; - if (type.isPrimitive()) { - this.primitive = type; - boxed = (Class) Array.get(Array.newInstance(primitive, 1), 0).getClass(); - } else { - this.primitive = (Class) type.getField("TYPE").get(null); - boxed = type; - } - this.type = Type.valueOf(boxed.getSimpleName()); - } catch (Throwable e) { - throw new RuntimeException(e); - } - length = 0; - totalLength = 0; - arr = Array.newInstance(primitive, 0); - } - - public PrimitiveList(T[] arr) { - try { - Class boxed = (Class) arr.getClass().getComponentType(); - this.primitive = (Class) boxed.getField("TYPE").get(null); - this.type = Type.valueOf(boxed.getSimpleName()); - } catch (Throwable e) { - throw new RuntimeException(e); - } - this.arr = Array.newInstance(primitive, arr.length); - for (int i = 0; i < arr.length; i++) { - T val = arr[i]; - if (val != null) setFast(i, val); - } - this.length = arr.length; - this.totalLength = length; - } - - public PrimitiveList(Object arr) { - if (!arr.getClass().isArray()) { - throw new IllegalArgumentException("Argument must be an array!"); - } - this.primitive = arr.getClass().getComponentType(); - Class boxed = (Class) Array.get(Array.newInstance(primitive, 1), 0).getClass(); - this.type = Type.valueOf(boxed.getSimpleName()); - this.arr = arr; - this.length = Array.getLength(arr); - this.totalLength = length; - } - - public Object getArray() { - return arr; - } - - @Override - public T get(int index) { - return (T) getFast(index); - } - - public byte getByte(int index) { - return type == Type.Double ? ((byte[]) arr)[index] : (byte) getFast(index); - } - - public boolean getBoolean(int index) { - return type == Type.Boolean ? ((boolean[]) arr)[index] : (boolean) getFast(index); - } - - public short getShort(int index) { - return type == Type.Short ? ((short[]) arr)[index] : (short) getFast(index); - } - - public char getCharacter(int index) { - return type == Type.Character ? ((char[]) arr)[index] : (char) getFast(index); - } - - public int getInt(int index) { - return type == Type.Integer ? ((int[]) arr)[index] : (int) getFast(index); - } - - public float getFloat(int index) { - return type == Type.Float ? ((float[]) arr)[index] : (float) getFast(index); - } - - public long getLong(int index) { - return type == Type.Long ? ((long[]) arr)[index] : (long) getFast(index); - } - - public double getDouble(int index) { - return type == Type.Double ? ((double[]) arr)[index] : (double) getFast(index); - } - - private final Object getFast(int index) { - switch (type) { - case Byte: - return ((byte[]) arr)[index]; - case Boolean: - return ((boolean[]) arr)[index]; - case Short: - return ((short[]) arr)[index]; - case Character: - return ((char[]) arr)[index]; - case Integer: - return ((int[]) arr)[index]; - case Float: - return ((float[]) arr)[index]; - case Long: - return ((long[]) arr)[index]; - case Double: - return ((double[]) arr)[index]; - } - return null; - } - - @Override - public T set(int index, T element) { - T value = get(index); - setFast(index, element); - return value; - } - - public void set(int index, char value) { - switch (type) { - case Character: - ((char[]) arr)[index] = value; - return; - default: - setFast(index, value); - return; - } - } - - public void set(int index, byte value) { - switch (type) { - case Byte: - ((byte[]) arr)[index] = value; - return; - default: - setFast(index, value); - return; - } - } - - public void set(int index, int value) { - switch (type) { - case Integer: - ((int[]) arr)[index] = value; - return; - case Long: - ((long[]) arr)[index] = (long) value; - return; - case Double: - ((double[]) arr)[index] = (double) value; - return; - default: - setFast(index, value); - return; - } - } - - public void set(int index, long value) { - switch (type) { - case Integer: - ((int[]) arr)[index] = (int) value; - return; - case Long: - ((long[]) arr)[index] = value; - return; - case Double: - ((double[]) arr)[index] = (double) value; - return; - default: - setFast(index, value); - return; - } - } - - public void set(int index, double value) { - switch (type) { - case Float: - ((float[]) arr)[index] = (float) value; - return; - case Long: - ((long[]) arr)[index] = (long) value; - return; - case Double: - ((double[]) arr)[index] = value; - return; - default: - setFast(index, value); - return; - } - } - - public final void setFast(int index, Object element) { - switch (type) { - case Byte: - ((byte[]) arr)[index] = (byte) element; - return; - case Boolean: - ((boolean[]) arr)[index] = (boolean) element; - return; - case Short: - ((short[]) arr)[index] = (short) element; - return; - case Character: - ((char[]) arr)[index] = (char) element; - return; - case Integer: - ((int[]) arr)[index] = (int) element; - return; - case Float: - ((float[]) arr)[index] = (float) element; - return; - case Long: - ((long[]) arr)[index] = (long) element; - return; - case Double: - ((double[]) arr)[index] = (double) element; - return; - } - } - - - @Override - public void add(int index, T element) { - if (index == length) { - if (totalLength == length) { - Object tmp = arr; - totalLength = (length << 1) + 16; - arr = Array.newInstance(primitive, totalLength); - System.arraycopy(tmp, 0, arr, 0, length); - } - setFast(length, element); - length++; - } else { - if (totalLength == length) { - Object tmp = arr; - totalLength = (length << 1) + 16; - arr = Array.newInstance(primitive, totalLength); - System.arraycopy(tmp, 0, arr, 0, index); - } - System.arraycopy(arr, index, arr, index + 1, length - index); - set(index, element); - length++; - } - } - - private void ensureAddCapacity() { - if (totalLength == length) { - Object tmp = arr; - totalLength = (length << 1) + 16; - arr = Array.newInstance(primitive, totalLength); - System.arraycopy(tmp, 0, arr, 0, length); - } - } - - @Override - public boolean add(T element) { - ensureAddCapacity(); - setFast(length++, element); - return true; - } - - public boolean add(int element) { - ensureAddCapacity(); - set(length++, element); - return true; - } - - public boolean add(long element) { - ensureAddCapacity(); - set(length++, element); - return true; - } - - public boolean add(double element) { - ensureAddCapacity(); - set(length++, element); - return true; - } - - public boolean add(byte element) { - ensureAddCapacity(); - set(length++, element); - return true; - } - - public boolean add(char element) { - ensureAddCapacity(); - set(length++, element); - return true; - } - - @Override - public T remove(int index) { - if (index < 0 || index > length) throw new IndexOutOfBoundsException(index + " not in [0, " + length + "]"); - T value = get(index); - if (index != length) { - System.arraycopy(arr, index + 1, arr, index, length - index - 1); - } - length--; - return value; - } - - @Override - public int size() { - return length; - } - - @Override - public void clear() { - if (length != 0) { - this.arr = Array.newInstance(primitive, 0); - } - length = 0; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java index 79055a77b..db03b1b6d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java @@ -1,47 +1,48 @@ // CHECKSTYLE:OFF package com.boydti.fawe.object.collection; -/*- This software is the work of Paladin Software International, Incorporated, +/* This software is the work of Paladin Software International, Incorporated, * based upon previous work done for and by Sun Microsystems, Inc. */ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import java.util.Arrays; /** * This class implements a set of bits that grows as needed. Each bit of the - * bit set represents a boolean value. The values of a - * SparseBitSet are indexed by non-negative integers. + * bit set represents a {@code boolean} value. The values of a + * {@code SparseBitSet} are indexed by non-negative integers. * Individual indexed values may be examined, set, cleared, or modified by - * logical operations. One SparseBitSet or logical value may be - * used to modify the contents of (another) SparseBitSet through + * logical operations. One {@code SparseBitSet} or logical value may be + * used to modify the contents of (another) {@code SparseBitSet} through * logical AND, logical inclusive OR, logical exclusive * OR, and And NOT operations over all or part of the bit sets. *

- * All values in a bit set initially have the value false. + * All values in a bit set initially have the value {@code false}. *

* Every bit set has a current size, which is the number of bits of space * nominally in use by the bit set from the first set bit to just after * the last set bit. The length of the bit set effectively tells the position * available after the last bit of the SparseBitSet. *

- * The maximum cardinality of a SparseBitSet is - * Integer.MAX_VALUE, which means the bits of a - * SparseBitSet are labelled - * 0 .. Integer.MAX_VALUE − 1. - * After the last set bit of a SparseBitSet, any attempt to find + * The maximum cardinality of a {@code SparseBitSet} is + * {@link Integer#MAX_VALUE}, which means the bits of a + * {@code SparseBitSet} are labelled {@code 0} ..  + * {@code Integer.MAX_VALUE − 1}. + * After the last set bit of a {@code SparseBitSet}, any attempt to find * a subsequent bit (nextSetBit()), will return an value of −1. * If an attempt is made to use nextClearBit(), and all the bits are * set from the starting position of the search to the bit labelled - * Integer.MAX_VALUE − 1, then similarly −1 + * {@code Integer.MAX_VALUE − 1}, then similarly −1 * will be returned. *

* Unless otherwise noted, passing a null parameter to any of the methods in - * a SparseBitSet will result in a - * NullPointerException. + * a {@code SparseBitSet} will result in a + * {@link NullPointerException}. *

- * A SparseBitSet is not safe for multi-threaded use without + * A {@code SparseBitSet} is not safe for multi-threaded use without * external synchronization. * * @author Bruce K. Haddon @@ -51,7 +52,6 @@ import java.io.Serializable; * @version 1.0, 2009-03-17 * @since 1.6 */ -@SuppressWarnings("ALL") public class SparseBitSet implements Cloneable, Serializable { /* My apologies for listing all the additional authors, but concepts, code, @@ -123,7 +123,7 @@ public class SparseBitSet implements Cloneable, Serializable /** * The storage for this SparseBitSet. The ith bit is stored in a word - * represented by a long value, and is at bit position i % 64 + * represented by a long value, and is at bit position {@code i % 64} * within that word (where bit position 0 refers to the least significant bit * and 63 refers to the most significant bit). *

@@ -334,7 +334,7 @@ public class SparseBitSet implements Cloneable, Serializable /** * Constructor for a new (sparse) bit set. All bits initially are effectively - * false. This is a internal constructor that collects all the + * {@code false}. This is a internal constructor that collects all the * needed actions to initialise the bit set. *

* The capacity is taken to be a suggestion for a size of the bit set, @@ -365,7 +365,7 @@ public class SparseBitSet implements Cloneable, Serializable /** * Constructs an empty bit set with the default initial size. - * Initially all bits are effectively false. + * Initially all bits are effectively {@code false}. * * @since 1.6 */ @@ -377,9 +377,9 @@ public class SparseBitSet implements Cloneable, Serializable /** * Creates a bit set whose initial size is large enough to efficiently - * represent bits with indices in the range 0 through - * at least nbits-1. Initially all bits are effectively - * false. + * represent bits with indices in the range {@code 0} through + * at least {@code nbits-1}. Initially all bits are effectively + * {@code false}. *

* No guarantees are given for how large or small the actual object will be. * The setting of bits above the given range is permitted (and will perhaps @@ -399,8 +399,8 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AND of the addressed target bit with the argument * value. This bit set is modified so that the addressed bit has the value - * true if and only if it both initially had the value - * true and the argument value is also true. + * {@code true} if and only if it both initially had the value + * {@code true} and the argument value is also {@code true}. * * @param i a bit index * @param value a boolean value to AND with that bit @@ -419,17 +419,17 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AND of this target bit set with the argument bit * set within the given range of bits. Within the range, this bit set is - * modified so that each bit in it has the value true if and only - * if it both initially had the value true and the corresponding - * bit in the bit set argument also had the value true. Outside + * modified so that each bit in it has the value {@code true} if and only + * if it both initially had the value {@code true} and the corresponding + * bit in the bit set argument also had the value {@code true}. Outside * the range, this set is not changed. * * @param i index of the first bit to be included in the operation * @param j index after the last bit to included in the operation * @param b a SparseBitSet - * @exception IndexOutOfBoundsException if i is negative or - * equal to Integer.MAX_VALUE, or j is negative, - * or i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or + * equal to Integer.MAX_VALUE, or {@code j} is negative, + * or {@code i} is larger than {@code j} * @since 1.6 */ public void and(int i, int j, SparseBitSet b) throws IndexOutOfBoundsException @@ -440,9 +440,9 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AND of this target bit set with the argument bit * set. This bit set is modified so that each bit in it has the value - * true if and only if it both initially had the value - * true and the corresponding bit in the bit set argument also - * had the value true. + * {@code true} if and only if it both initially had the value + * {@code true} and the corresponding bit in the bit set argument also + * had the value {@code true}. * * @param b a SparseBitSet * @since 1.6 @@ -454,11 +454,11 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Performs a logical AND of the two given SparseBitSets. - * The returned SparseBitSet is created so that each bit in it - * has the value true if and only if both the given sets - * initially had the corresponding bits true, otherwise - * false. + * Performs a logical AND of the two given {@code SparseBitSet}s. + * The returned {@code SparseBitSet} is created so that each bit in it + * has the value {@code true} if and only if both the given sets + * initially had the corresponding bits {@code true}, otherwise + * {@code false}. * * @param a a SparseBitSet * @param b another SparseBitSet @@ -475,8 +475,8 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AndNOT of the addressed target bit with the * argument value. This bit set is modified so that the addressed bit has the - * value true if and only if it both initially had the value - * true and the argument value is false. + * value {@code true} if and only if it both initially had the value + * {@code true} and the argument value is {@code false}. * * @param i a bit index * @param value a boolean value to AndNOT with that bit @@ -495,17 +495,17 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AndNOT of this target bit set with the argument * bit set within the given range of bits. Within the range, this bit set is - * modified so that each bit in it has the value true if and only - * if it both initially had the value true and the corresponding - * bit in the bit set argument has the value false. Outside + * modified so that each bit in it has the value {@code true} if and only + * if it both initially had the value {@code true} and the corresponding + * bit in the bit set argument has the value {@code false}. Outside * the range, this set is not changed. * * @param i index of the first bit to be included in the operation * @param j index after the last bit to included in the operation * @param b the SparseBitSet with which to mask this SparseBitSet - * @exception IndexOutOfBoundsException if i is negative or - * equal to Integer.MAX_VALUE, or j is negative, - * or i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or + * equal to Integer.MAX_VALUE, or {@code j} is negative, + * or {@code i} is larger than {@code j} * @since 1.6 */ public void andNot(int i, int j, SparseBitSet b) @@ -517,9 +517,9 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical AndNOT of this target bit set with the argument * bit set. This bit set is modified so that each bit in it has the value - * true if and only if it both initially had the value - * true and the corresponding bit in the bit set argument has - * the value false. + * {@code true} if and only if it both initially had the value + * {@code true} and the corresponding bit in the bit set argument has + * the value {@code false}. * * @param b the SparseBitSet with which to mask this SparseBitSet * @since 1.6 @@ -530,12 +530,12 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Creates a bit set from thie first SparseBitSet whose + * Creates a bit set from thie first {@code SparseBitSet} whose * corresponding bits are cleared by the set bits of the second - * SparseBitSet. The resulting bit set is created so that a bit - * in it has the value true if and only if the corresponding bit - * in the SparseBitSet of the first is set, and that same - * corresponding bit is not set in the SparseBitSet of the second + * {@code SparseBitSet}. The resulting bit set is created so that a bit + * in it has the value {@code true} if and only if the corresponding bit + * in the {@code SparseBitSet} of the first is set, and that same + * corresponding bit is not set in the {@code SparseBitSet} of the second * argument. * * @param a a SparseBitSet @@ -552,8 +552,8 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Returns the number of bits set to true in this - * SparseBitSet. + * Returns the number of bits set to {@code true} in this + * {@code SparseBitSet}. * * @return the number of bits set to true in this SparseBitSet * @since 1.6 @@ -565,7 +565,7 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Sets the bit at the specified index to false. + * Sets the bit at the specified index to {@code false}. * * @param i a bit index. * @exception IndexOutOfBoundsException if the specified index is negative @@ -593,14 +593,14 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Sets the bits from the specified i (inclusive) to the - * specified j (exclusive) to false. + * Sets the bits from the specified {@code i} (inclusive) to the + * specified {@code j} (exclusive) to {@code false}. * * @param i index of the first bit to be cleared * @param j index after the last bit to be cleared - * @exception IndexOutOfBoundsException if i is negative or - * equal to Integer.MAX_VALUE, or j is negative, - * or i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or + * equal to Integer.MAX_VALUE, or {@code j} is negative, + * or {@code i} is larger than {@code j} * @since 1.6 */ public void clear(int i, int j) throws IndexOutOfBoundsException @@ -609,8 +609,8 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Sets all of the bits in this SparseBitSet to - * false. + * Sets all of the bits in this {@code SparseBitSet} to + * {@code false}. * * @since 1.6 */ @@ -621,15 +621,15 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Cloning this SparseBitSet produces a new - * SparseBitSet that is equal() to it. The clone of the + * Cloning this {@code SparseBitSet} produces a new + * {@code SparseBitSet} that is equal() to it. The clone of the * bit set is another bit set that has exactly the same bits set to - * true as this bit set. + * {@code true} as this bit set. *

* Note: the actual space allocated to the clone tries to minimise the actual * amount of storage allocated to hold the bits, while still trying to * keep access to the bits being a rapid as possible. Since the space - * allocated to a SparseBitSet is not normally decreased, + * allocated to a {@code SparseBitSet} is not normally decreased, * replacing a bit set by its clone may be a way of both managing memory * consumption and improving the rapidity of access. * @@ -667,16 +667,16 @@ public class SparseBitSet implements Cloneable, Serializable /** * Compares this object against the specified object. The result is - * true if and only if the argument is not null - * and is a SparseBitSet object that has exactly the same bits - * set to true as this bit set. That is, for every nonnegative - * i indexing a bit in the set, + * {@code true} if and only if the argument is not {@code null} + * and is a {@code SparseBitSet} object that has exactly the same bits + * set to {@code true} as this bit set. That is, for every nonnegative + * {@code i} indexing a bit in the set, *

((SparseBitSet)obj).get(i) == this.get(i)
* must be true. * * @param obj the Object with which to compare - * @return true if the objects are equivalent; - * false otherwise. + * @return {@code true} if the objects are equivalent; + * {@code false} otherwise. * @since 1.6 */ @Override @@ -726,15 +726,15 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Sets each bit from the specified i (inclusive) to the - * specified j (exclusive) to the complement of its current + * Sets each bit from the specified {@code i} (inclusive) to the + * specified {@code j} (exclusive) to the complement of its current * value. * * @param i index of the first bit to flip * @param j index after the last bit to flip - * @exception IndexOutOfBoundsException if i is negative or is - * equal to Integer.MAX_VALUE, or j is negative, or - * i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or is + * equal to Integer.MAX_VALUE, or {@code j} is negative, or + * {@code i} is larger than {@code j} * @since 1.6 */ public void flip(int i, int j) throws IndexOutOfBoundsException @@ -744,9 +744,9 @@ public class SparseBitSet implements Cloneable, Serializable /** * Returns the value of the bit with the specified index. The value is - * true if the bit with the index i is currently set - * in this SparseBitSet; otherwise, the result is - * false. + * {@code true} if the bit with the index {@code i} is currently set + * in this {@code SparseBitSet}; otherwise, the result is + * {@code false}. * * @param i the bit index * @return the boolean value of the bit with the specified index. @@ -768,16 +768,16 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Returns a new SparseBitSet composed of bits from this - * SparseBitSet from i (inclusive) to j + * Returns a new {@code SparseBitSet} composed of bits from this + * {@code SparseBitSet} from {@code i} (inclusive) to {@code j} * (exclusive). * * @param i index of the first bit to include * @param j index after the last bit to include * @return a new SparseBitSet from a range of this SparseBitSet - * @exception IndexOutOfBoundsException if i is negative or is - * equal to Integer.MAX_VALUE, or j is negative, or - * i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or is + * equal to Integer.MAX_VALUE, or {@code j} is negative, or + * {@code i} is larger than {@code j} * @since 1.6 */ public SparseBitSet get(int i, int j) throws IndexOutOfBoundsException @@ -789,17 +789,17 @@ public class SparseBitSet implements Cloneable, Serializable /** * Returns a hash code value for this bit set. The hash code depends only on - * which bits have been set within this SparseBitSet. The + * which bits have been set within this {@code SparseBitSet}. The * algorithm used to compute it may be described as follows. *

- * Suppose the bits in the SparseBitSet were to be stored in an - * array of long integers called, say, bits, in such - * a manner that bit i is set in the SparseBitSet - * (for nonnegative values of i) if and only if the expression + * Suppose the bits in the {@code SparseBitSet} were to be stored in an + * array of {@code long} integers called, say, {@code bits}, in such + * a manner that bit {@code i} is set in the {@code SparseBitSet} + * (for nonnegative values of {@code i}) if and only if the expression *

      *  ((i>>6) < bits.length) && ((bits[i>>6] & (1L << (bit & 0x3F))) != 0)
      *  
- * is true. Then the following definition of the hashCode method + * is true. Then the following definition of the {@code hashCode} method * would be a correct implementation of the actual algorithm: *
      *  public int hashCode()
@@ -824,19 +824,19 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns true if the specified SparseBitSet has any bits
-     *  within the given range i (inclusive) to j
-     *  (exclusive) set to true that are also set to true
-     *  in the same range of this SparseBitSet.
+     *  Returns true if the specified {@code SparseBitSet} has any bits
+     *  within the given range {@code i} (inclusive) to {@code j}
+     *  (exclusive) set to {@code true} that are also set to {@code true}
+     *  in the same range of this {@code SparseBitSet}.
      *
      * @param       i index of the first bit to include
      * @param       j index after the last bit to include
      * @param       b the SparseBitSet with which to intersect
      * @return      the boolean indicating whether this SparseBitSet intersects the
      *              specified SparseBitSet
-     * @exception   IndexOutOfBoundsException if i is negative or
-     *              equal to Integer.MAX_VALUE, or j is negative,
-     *              or i is larger than j
+     * @exception   IndexOutOfBoundsException if {@code i} is negative or
+     *              equal to Integer.MAX_VALUE, or {@code j} is negative,
+     *              or {@code i} is larger than {@code j}
      * @since       1.6
      */
     public boolean intersects(int i, int j, SparseBitSet b)
@@ -847,9 +847,9 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns true if the specified SparseBitSet has any bits set to
-     *  true that are also set to true in this
-     *  SparseBitSet.
+     *  Returns true if the specified {@code SparseBitSet} has any bits set to
+     *  {@code true} that are also set to {@code true} in this
+     *  {@code SparseBitSet}.
      *
      * @param       b a SparseBitSet with which to intersect
      * @return      boolean indicating whether this SparseBitSet intersects the
@@ -863,8 +863,8 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns true if this SparseBitSet contains no bits that are
-     *  set to true.
+     *  Returns true if this {@code SparseBitSet} contains no bits that are
+     *  set to {@code true}.
      *
      * @return      the boolean indicating whether this SparseBitSet is empty
      * @since       1.6
@@ -876,9 +876,9 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns the "logical length" of this SparseBitSet: the index
-     *  of the highest set bit in the SparseBitSet plus one. Returns
-     *  zero if the SparseBitSet contains no set bits.
+     *  Returns the "logical length" of this {@code SparseBitSet}: the index
+     *  of the highest set bit in the {@code SparseBitSet} plus one. Returns
+     *  zero if the {@code SparseBitSet} contains no set bits.
      *
      * @return      the logical length of this SparseBitSet
      * @since       1.6
@@ -890,7 +890,7 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns the index of the first bit that is set to false that
+     *  Returns the index of the first bit that is set to {@code false} that
      *  occurs on or after the specified starting index.
      *
      * @param       i the index to start checking from (inclusive)
@@ -957,12 +957,12 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Returns the index of the first bit that is set to true that
+     *  Returns the index of the first bit that is set to {@code true} that
      *  occurs on or after the specified starting index. If no such it exists then
      *  -1 is returned.
      *  

- * To iterate over the true bits in a SparseBitSet - * sbs, use the following loop: + * To iterate over the {@code true} bits in a {@code SparseBitSet + * sbs}, use the following loop: * *

      *  for( int i = sbbits.nextSetBit(0); i >= 0; i = sbbits.nextSetBit(i+1) )
@@ -1168,8 +1168,8 @@ public class SparseBitSet implements Cloneable, Serializable
     /**
      *  Performs a logical OR of the addressed target bit with the
      *  argument value. This bit set is modified so that the addressed bit has the
-     *  value true if and only if it both initially had the value
-     *  true or the argument value is true.
+     *  value {@code true} if and only if it both initially had the value
+     *  {@code true} or the argument value is {@code true}.
      *
      * @param       i a bit index
      * @param       value a boolean value to OR with that bit
@@ -1188,18 +1188,18 @@ public class SparseBitSet implements Cloneable, Serializable
     /**
      *  Performs a logical OR of the addressed target bit with the
      *  argument value within the given range. This bit set is modified so that
-     *  within the range a bit in it has the value true if and only if
-     *  it either already had the value true or the corresponding bit
-     *  in the bit set argument has the value true. Outside the range
+     *  within the range a bit in it has the value {@code true} if and only if
+     *  it either already had the value {@code true} or the corresponding bit
+     *  in the bit set argument has the value {@code true}. Outside the range
      *  this set is not changed.
      *
      * @param       i index of the first bit to be included in the operation
      * @param       j index after the last bit to included in the operation
      * @param       b the SparseBitSet with which to perform the OR
      *              operation with this SparseBitSet
-     * @exception   IndexOutOfBoundsException if i is negative or
-     *              equal to Integer.MAX_VALUE, or j is negative,
-     *              or i is larger than j
+     * @exception   IndexOutOfBoundsException if {@code i} is negative or
+     *              equal to Integer.MAX_VALUE, or {@code j} is negative,
+     *              or {@code i} is larger than {@code j}
      * @since       1.6
      */
     public void or(int i, int j, SparseBitSet b) throws IndexOutOfBoundsException
@@ -1209,9 +1209,9 @@ public class SparseBitSet implements Cloneable, Serializable
 
     /**
      *  Performs a logical OR of this bit set with the bit set argument.
-     *  This bit set is modified so that a bit in it has the value true
-     *  if and only if it either already had the value true or the
-     *  corresponding bit in the bit set argument has the value true.
+     *  This bit set is modified so that a bit in it has the value {@code true}
+     *  if and only if it either already had the value {@code true} or the
+     *  corresponding bit in the bit set argument has the value {@code true}.
      *
      * @param       b the SparseBitSet with which to perform the OR
      *              operation with this SparseBitSet
@@ -1223,11 +1223,11 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Performs a logical OR of the two given SparseBitSets.
-     *  The returned SparseBitSet is created so that a bit in it has
-     *  the value true if and only if it either had the value
-     *  true in the set given by the first arguemetn or had the value
-     *  true in the second argument, otherwise false.
+     *  Performs a logical OR of the two given {@code SparseBitSet}s.
+     *  The returned {@code SparseBitSet} is created so that a bit in it has
+     *  the value {@code true} if and only if it either had the value
+     *  {@code true} in the set given by the first arguemetn or had the value
+     *  {@code true} in the second argument, otherwise {@code false}.
      *
      * @param       a a SparseBitSet
      * @param       b another SparseBitSet
@@ -1287,14 +1287,14 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Sets the bits from the specified i (inclusive) to the specified
-     *  j (exclusive) to true.
+     *  Sets the bits from the specified {@code i} (inclusive) to the specified
+     *  {@code j} (exclusive) to {@code true}.
      *
      * @param       i index of the first bit to be set
      * @param       j index after the last bit to be se
-     * @exception   IndexOutOfBoundsException if i is negative or is
-     *              equal to Integer.MAX_INT, or j is negative, or
-     *              i is larger than j.
+     * @exception   IndexOutOfBoundsException if {@code i} is negative or is
+     *              equal to Integer.MAX_INT, or {@code j} is negative, or
+     *              {@code i} is larger than {@code j}.
      * @since       1.6
      */
     public void set(int i, int j) throws IndexOutOfBoundsException
@@ -1303,15 +1303,15 @@ public class SparseBitSet implements Cloneable, Serializable
     }
 
     /**
-     *  Sets the bits from the specified i (inclusive) to the specified
-     *  j (exclusive) to the specified value.
+     *  Sets the bits from the specified {@code i} (inclusive) to the specified
+     *  {@code j} (exclusive) to the specified value.
      *
      * @param       i index of the first bit to be set
      * @param       j index after the last bit to be set
      * @param       value to which to set the selected bits
-     * @exception   IndexOutOfBoundsException if i is negative or is
-     *              equal to Integer.MAX_VALUE, or j is negative, or
-     *              i is larger than j
+     * @exception   IndexOutOfBoundsException if {@code i} is negative or is
+     *              equal to Integer.MAX_VALUE, or {@code j} is negative, or
+     *              {@code i} is larger than {@code j}
      * @since       1.6
      */
     public void set(int i, int j, boolean value)
@@ -1324,7 +1324,7 @@ public class SparseBitSet implements Cloneable, Serializable
 
     /**
      *  Returns the number of bits of space nominally in use by this
-     *  SparseBitSet to represent bit values. The count of bits in
+     *  {@code SparseBitSet} to represent bit values. The count of bits in
      *  the set is the (label of the last set bit) + 1 - (the label of the first
      *  set bit).
      *
@@ -1360,7 +1360,7 @@ public class SparseBitSet implements Cloneable, Serializable
      *  

* This method is intended for diagnostic use (as it is relatively expensive * in time), but can be useful in understanding an application's use of a - * SparseBitSet. + * {@code SparseBitSet}. * * @param values an array for the individual results (if not null) * @return a String detailing the statistics of the bit set @@ -1423,7 +1423,7 @@ public class SparseBitSet implements Cloneable, Serializable /** * Returns a string representation of this bit set. For every index for which - * this SparseBitSet contains a bit in the set state, the decimal + * this {@code SparseBitSet} contains a bit in the set state, the decimal * representation of that index is included in the result. Such indices are * listed in order from lowest to highest. If there is a subsequence of set * bits longer than the value given by toStringCompaction, the subsequence @@ -1437,22 +1437,22 @@ public class SparseBitSet implements Cloneable, Serializable *

      *      SparseBitSet drPepper = new SparseBitSet();
      *  
- * Now drPepper.toString() returns "{}". + * Now {@code drPepper.toString()} returns "{@code {}}". *
*
      *      drPepper.set(2);
      *  
- * Now drPepper.toString() returns "{2}". + * Now {@code drPepper.toString()} returns "{@code {2}}". *
*
      *      drPepper.set(3, 4);
      *      drPepper.set(10);
      *  
- * Now drPepper.toString() returns "{2..4, 10}". + * Now {@code drPepper.toString()} returns "{@code {2..4, 10}}". *
* This method is intended for diagnostic use (as it is relatively expensive * in time), but can be useful in interpreting problems in an application's use - * of a SparseBitSet. + * of a {@code SparseBitSet}. * * @return a String representation of this SparseBitSet * @see #toStringCompaction(int length) @@ -1504,18 +1504,18 @@ public class SparseBitSet implements Cloneable, Serializable } /** Sequences of set bits longer than this value are shown by - * {@link #toString()} as a "sub-sequence," in the form a..b. + * {@link #toString()} as a "sub-sequence," in the form {@code a..b}. * Setting this value to zero causes each set bit to be listed individually. * The default default value is 2 (which means sequences of three or more * bits set are shown as a subsequence, and all other set bits are listed * individually). *

- * Note: this value will be passed to SparseBitSets that + * Note: this value will be passed to {@code SparseBitSet}s that * may be created within or as a result of the operations on this bit set, * or, for static methods, from the value belonging to the first parameter. * * @param count the maximum count of a run of bits that are shown as - * individual entries in a toString() conversion. + * individual entries in a {@code toString}() conversion. * If 0, all bits are shown individually. * @since 1.6 * @see #toString() @@ -1526,9 +1526,9 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * If change is true, the current value of the + * If change is {@code true}, the current value of the * toStringCompaction() value is made the default value for all - * SparseBitSets created from this point onward in this JVM. + * {@code SparseBitSet}s created from this point onward in this JVM. * * @param change if true, change the default value * @since 1.6 @@ -1546,17 +1546,17 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical XOR of the addressed target bit with the * argument value. This bit set is modified so that the addressed bit has the - * value true if and only one of the following statements holds: + * value {@code true} if and only one of the following statements holds: *

    - *
  • The addressed bit initially had the value true, and the - * value of the argument is false. - *
  • The bit initially had the value false, and the - * value of the argument is true. + *
  • The addressed bit initially had the value {@code true}, and the + * value of the argument is {@code false}. + *
  • The bit initially had the value {@code false}, and the + * value of the argument is {@code true}. *
* * @param i a bit index * @param value a boolean value to XOR with that bit - * @exception java.lang.IndexOutOfBoundsException if the specified index + * @exception IndexOutOfBoundsException if the specified index * is negative * or equal to Integer.MAX_VALUE * @since 1.6 @@ -1572,13 +1572,13 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical XOR of this bit set with the bit set argument * within the given range. This resulting bit set is computed so that a bit - * within the range in it has the value true if and only if one + * within the range in it has the value {@code true} if and only if one * of the following statements holds: *
    - *
  • The bit initially had the value true, and the - * corresponding bit in the argument set has the value false. - *
  • The bit initially had the value false, and the - * corresponding bit in the argument set has the value true. + *
  • The bit initially had the value {@code true}, and the + * corresponding bit in the argument set has the value {@code false}. + *
  • The bit initially had the value {@code false}, and the + * corresponding bit in the argument set has the value {@code true}. *
* Outside the range this set is not changed. * @@ -1586,9 +1586,9 @@ public class SparseBitSet implements Cloneable, Serializable * @param j index after the last bit to included in the operation * @param b the SparseBitSet with which to perform the XOR * operation with this SparseBitSet - * @exception IndexOutOfBoundsException if i is negative or - * equal to Integer.MAX_VALUE, or j is negative, - * or i is larger than j + * @exception IndexOutOfBoundsException if {@code i} is negative or + * equal to Integer.MAX_VALUE, or {@code j} is negative, + * or {@code i} is larger than {@code j} * @since 1.6 */ public void xor(int i, int j, SparseBitSet b) throws IndexOutOfBoundsException @@ -1599,12 +1599,12 @@ public class SparseBitSet implements Cloneable, Serializable /** * Performs a logical XOR of this bit set with the bit set argument. * This resulting bit set is computed so that a bit in it has the value - * true if and only if one of the following statements holds: + * {@code true} if and only if one of the following statements holds: *
    - *
  • The bit initially had the value true, and the - * corresponding bit in the argument set has the value false. - *
  • The bit initially had the value false, and the - * corresponding bit in the argument set has the value true. + *
  • The bit initially had the value {@code true}, and the + * corresponding bit in the argument set has the value {@code false}. + *
  • The bit initially had the value {@code false}, and the + * corresponding bit in the argument set has the value {@code true}. *
* * @param b the SparseBitSet with which to perform the XOR @@ -1617,16 +1617,16 @@ public class SparseBitSet implements Cloneable, Serializable } /** - * Performs a logical XOR of the two given SparseBitSets. + * Performs a logical XOR of the two given {@code SparseBitSet}s. * The resulting bit set is created so that a bit in it has the value - * true if and only if one of the following statements holds: + * {@code true} if and only if one of the following statements holds: *
    - *
  • A bit in the first argument has the value true, and the + *
  • A bit in the first argument has the value {@code true}, and the * corresponding bit in the second argument has the value - * false.
  • - *
  • A bit in the first argument has the value false, and the + * {@code false}.
  • + *
  • A bit in the first argument has the value {@code false}, and the * corresponding bit in the second argument has the value - * true.
+ * {@code true}. * * @param a a SparseBitSet * @param b another SparseBitSet @@ -1645,7 +1645,7 @@ public class SparseBitSet implements Cloneable, Serializable //============================================================================== /** - * Throw the exception to indicate a range error. The String + * Throw the exception to indicate a range error. The {@code String} * constructed reports all the possible errors in one message. * * @param i lower bound for a operation @@ -1743,7 +1743,7 @@ public class SparseBitSet implements Cloneable, Serializable * Scans over the bit set (and a second bit set if part of the operation) are * all performed by this method. The properties and the operation executed * are defined by a given strategy, which must be derived from the - * AbstractStrategy. The strategy defines how to operate on a + * {@code AbstractStrategy}. The strategy defines how to operate on a * single word, and on whole words that may or may not constitute a full * block of words. * @@ -1993,7 +1993,7 @@ public class SparseBitSet implements Cloneable, Serializable //============================================================================== /** - * Save the state of the SparseBitSet instance to a stream + * Save the state of the {@code SparseBitSet} instance to a stream * (i.e., serialize it). * * @param s the ObjectOutputStream to which to write the serialized object @@ -2004,10 +2004,10 @@ public class SparseBitSet implements Cloneable, Serializable * @serialData The default data is emitted, followed by the current * compactionCount for the bit set, and then the * length of the set (the position of the last bit), - * followed by the cache.count value (an int, - * the number of int->long pairs needed to describe - * the set), followed by the index (int) and word - * (long) for each int->long pair. + * followed by the cache.count value (an {@code int}, + * the number of {@code int->long} pairs needed to describe + * the set), followed by the index ({@code int}) and word + * ({@code long}) for each {@code int->long} pair. * The mappings need not be emitted in any particular order. This * is followed by the hashCode for the set that can be used * as an integrity check when the bit set is read back. @@ -2056,7 +2056,7 @@ public class SparseBitSet implements Cloneable, Serializable private static final long serialVersionUID = -6663013367427929992L; /** - * Reconstitute the SparseBitSet instance from a stream + * Reconstitute the {@code SparseBitSet} instance from a stream * (i.e., deserialize it). * * @param s the ObjectInputStream to use @@ -2110,12 +2110,12 @@ public class SparseBitSet implements Cloneable, Serializable /** * These enumeration values are used as labels for the values in the String * created by the statistics() method. The values of the corresponding - * statistics are ints, except for the loadFactor and - * Average_chain_length values, which are floats. + * statistics are {@code int}s, except for the loadFactor and + * Average_chain_length values, which are {@code float}s. *

- * An array of Strings may be obtained containing a + * An array of {@code String}s may be obtained containing a * representation of each of these values. An element of such an array, say, - * values, may be accessed, for example, by: + * {@code values}, may be accessed, for example, by: *

      *      values[SparseBitSet.statistics.Buckets_available.ordinal()]
* @@ -2243,12 +2243,12 @@ public class SparseBitSet implements Cloneable, Serializable /** * This strategy class is used by the setScanner to carry out the a variety * of operations on this set, and usually a second set. The - * setScanner() method of the main SparseBitSet class + * setScanner() method of the main {@code SparseBitSet} class * essentially finds matching level3 blocks, and then calls the strategy to * do the appropriate operation on each of the elements of the block. *

* The symbolic constants control optimisation paths in the - * setScanner() method of the main SparseBitSet class. + * setScanner() method of the main {@code SparseBitSet} class. * * @see SparseBitSet#setScanner(int i, int j, * SparseBitSet b, AbstractStrategy op) @@ -2366,10 +2366,7 @@ public class SparseBitSet implements Cloneable, Serializable */ protected final boolean isZeroBlock(long[] a3) { - for (long word : a3) - if (word != 0L) - return false; - return true; + return Arrays.stream(a3).noneMatch(word -> word != 0L); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/YieldIterable.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/YieldIterable.java index 83025877e..f89147111 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/YieldIterable.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/YieldIterable.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.collection; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.Closeable; @@ -12,9 +13,9 @@ import java.util.function.Consumer; public class YieldIterable implements Iterable, Consumer, Closeable { private static final Object END_MARKER = new Object(); private final LinkedBlockingQueue queue; - private Future future; + private Future future; - public YieldIterable(@Nullable Future task) { + public YieldIterable(@Nullable Future task) { this.queue = new LinkedBlockingQueue<>(); this.future = task; } @@ -23,10 +24,11 @@ public class YieldIterable implements Iterable, Consumer, Closeable { this(null); } - public void setFuture(Future future) { + public void setFuture(Future future) { this.future = future; } + @NotNull @Override public Iterator iterator() { return new Iterator() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java index e4eeba80a..bc530b82f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java @@ -71,7 +71,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return false; } @@ -82,7 +82,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public boolean setBiome(int x, int y, int z, BiomeType biome) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return false; } @@ -93,7 +93,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiome(BlockVector2 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return null; } @@ -104,7 +104,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiomeType(int x, int y, int z) { if (!contains(x, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return null; } @@ -115,7 +115,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BaseBlock getFullBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return BlockTypes.AIR.getDefaultState().toBaseBlock(); } @@ -126,7 +126,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BlockState getBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return BlockTypes.AIR.getDefaultState(); } @@ -137,7 +137,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getBlockLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return 0; } @@ -148,7 +148,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getBrightness(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return 0; } @@ -159,7 +159,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return 0; } @@ -170,7 +170,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getOpacity(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return 0; } @@ -181,7 +181,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public int getSkyLight(int x, int y, int z) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return 0; } @@ -193,7 +193,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public Entity createEntity(Location location, BaseEntity entity) { if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOutsideRegion()); } return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java index cab4422f4..029efe52c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MemoryCheckingExtent.java @@ -26,7 +26,7 @@ public class MemoryCheckingExtent extends PassthroughExtent { this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin")); } } - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getLOW_MEMORY()); + WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getLowMemory()); } return super.getExtent(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index 670186c6e..a99e9c268 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -54,7 +54,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor { } public NullExtent() { - this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.INSTANCE.getMANUAL()); + this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.INSTANCE.getManual()); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java index 3586e4590..19f1af11e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.extent; import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.FaweLimit; -import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.util.WEManager; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; @@ -38,7 +37,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return null; } if (!limit.MAX_ENTITIES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_ENTITIES()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxEntities()); return null; } return super.createEntity(location, entity); @@ -47,7 +46,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BlockState getBlock(int x, int y, int z) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxChecks()); return BlockTypes.AIR.getDefaultState(); } else { return extent.getBlock(x, y, z); @@ -57,7 +56,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BaseBlock getFullBlock(BlockVector3 pos) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxChecks()); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } else { return extent.getFullBlock(pos); @@ -79,18 +78,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); if (hasNbt) { if (!limit.MAX_BLOCKSTATES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_TILES()); + WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMaxTiles()); return false; } else { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMaxChanges()); return false; } return extent.setBlock(x, y, z, block); } } if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMaxChanges()); return false; } else { return extent.setBlock(x, y, z, block); @@ -100,7 +99,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHANGES()); + WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxChanges()); return false; } return super.setBiome(position, biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java index 89f5634de..834662452 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; -import com.boydti.fawe.object.IntegerTrio; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.operation.Operation; @@ -20,6 +19,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import kotlin.Triple; public abstract class DFSVisitor implements Operation { @@ -57,11 +57,11 @@ public abstract class DFSVisitor implements Operation { return this.directions; } - private IntegerTrio[] getIntDirections() { - IntegerTrio[] array = new IntegerTrio[directions.size()]; + private Triple[] getIntDirections() { + Triple[] array = new Triple[directions.size()]; for (int i = 0; i < array.length; i++) { BlockVector3 dir = directions.get(i); - array[i] = new IntegerTrio(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ()); + array[i] = new Triple<>(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ()); } return array; } @@ -83,7 +83,7 @@ public abstract class DFSVisitor implements Operation { // MutableBlockVector3 mutable = new MutableBlockVector3(); // MutableBlockVector3 mutable2 = new MutableBlockVector3(); int countAdd, countAttempt; - IntegerTrio[] dirs = getIntDirections(); + Triple[] dirs = getIntDirections(); for (int layer = 0; !queue.isEmpty(); layer++) { current = queue.poll(); @@ -99,11 +99,11 @@ public abstract class DFSVisitor implements Operation { function.apply(bv); countAdd = 0; countAttempt = 0; - for (IntegerTrio direction : dirs) { + for (Triple direction : dirs) { // mutable2.mutX(from.getX() + direction.x); // mutable2.mutY(from.getY() + direction.y); // mutable2.mutZ(from.getZ() + direction.z); - BlockVector3 bv2 = BlockVector3.at(from.getX() + direction.x, from.getY() + direction.y, from.getZ() + direction.z); + BlockVector3 bv2 = BlockVector3.at(from.getX() + direction.getFirst(), from.getY() + direction.getSecond(), from.getZ() + direction.getThird()); if (isVisitable(bv, bv2)) { adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ()); if ((!adjacent.equals(current.from))) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index 7b2b52b79..8f9555061 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -232,11 +232,11 @@ public class EditSessionBuilder { event.setExtent(extent); eventBus.post(event); if (event.isCancelled()) { - return new NullExtent(extent, FaweCache.INSTANCE.getMANUAL()); + return new NullExtent(extent, FaweCache.INSTANCE.getManual()); } final Extent toReturn = event.getExtent(); if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) { - return new NullExtent(toReturn, FaweCache.INSTANCE.getMANUAL()); + return new NullExtent(toReturn, FaweCache.INSTANCE.getManual()); } // if (!(toReturn instanceof AbstractDelegateExtent)) { // Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent"); @@ -316,7 +316,7 @@ public class EditSessionBuilder { if (Permission.hasPermission(player, "worldedit.fast")) { player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin")); } - throw FaweCache.INSTANCE.getLOW_MEMORY(); + throw FaweCache.INSTANCE.getLowMemory(); } } // this.originalLimit = limit; @@ -420,7 +420,7 @@ public class EditSessionBuilder { FaweRegionExtent regionExtent = null; if (allowedRegions != null) { if (allowedRegions.length == 0) { - regionExtent = new NullExtent(this.extent, FaweCache.INSTANCE.getNO_REGION()); + regionExtent = new NullExtent(this.extent, FaweCache.INSTANCE.getNoRegion()); } else { // this.extent = new ProcessedWEExtent(this.extent, this.limit); if (allowedRegions.length == 1) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MathMan.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MathMan.java index b9cb2d22e..09055f5c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MathMan.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MathMan.java @@ -1,5 +1,7 @@ package com.boydti.fawe.util; +import kotlin.UInt; + public class MathMan { /** @@ -414,4 +416,10 @@ public class MathMan { public static boolean isPowerOfTwo(int x) { return (x & (x - 1)) == 0; } + + public static int floor(double value) { + int i = (int)value; + return value < (double)i ? i - 1 : i; + } + } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java index a1f71161c..4694a0146 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java @@ -58,7 +58,7 @@ public class SchemSync implements Runnable { private void close(Error error) throws IOException { this.clientSocket.getOutputStream().write(error.ordinal()); - throw FaweCache.INSTANCE.getMANUAL(); + throw FaweCache.INSTANCE.getManual(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java index 38298c5a0..791ee97ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java @@ -26,11 +26,6 @@ import java.util.Locale; */ public final class ByteArrayTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_BYTE_ARRAY; - } - private final byte[] value; /** diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java index b90b1acfb..6ea46c1b0 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java @@ -23,10 +23,6 @@ package com.sk89q.jnbt; * The {@code TAG_Byte} tag. */ public final class ByteTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_BYTE; - } private final byte value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java index faa23c1df..8768a3b39 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java @@ -33,11 +33,6 @@ import java.util.UUID; */ public class CompoundTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_COMPOUND; - } - private Map value; /** diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java index ca27de1e7..e571e8e76 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java @@ -24,10 +24,6 @@ package com.sk89q.jnbt; * */ public final class DoubleTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_DOUBLE; - } private final double value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java index 00e9d9da8..02da93f18 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java @@ -24,11 +24,6 @@ package com.sk89q.jnbt; */ public final class EndTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_END; - } - @Override public Object getValue() { return null; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java index eaf76c620..7a4895810 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java @@ -23,10 +23,6 @@ package com.sk89q.jnbt; * The {@code TAG_Float} tag. */ public final class FloatTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_FLOAT; - } private final float value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java index b4fa50a20..04ec07be8 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java @@ -28,11 +28,6 @@ import java.util.Locale; */ public final class IntArrayTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_INT_ARRAY; - } - private final int[] value; /** diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java index e1da41b01..1fa374cce 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java @@ -23,10 +23,6 @@ package com.sk89q.jnbt; * The {@code TAG_Int} tag. */ public final class IntTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_INT; - } private final int value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java index 205492f8c..1cef4ac8c 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java @@ -32,11 +32,6 @@ import javax.annotation.Nullable; */ public class ListTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_LIST; - } - private final Class type; private final List value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java index f5139cfc4..1771ed9a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java @@ -28,11 +28,6 @@ import java.util.Locale; */ public class LongArrayTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_LONG_ARRAY; - } - private final long[] value; /** diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java index c3fe1cb04..1a7f4d8f6 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java @@ -24,10 +24,6 @@ package com.sk89q.jnbt; * */ public final class LongTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_LONG; - } private final long value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java index 99b0acdf0..107cbaae6 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java @@ -311,7 +311,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da int size = tags.size(); if (!tags.isEmpty()) { Tag tag0 = tags.get(0); - os.writeByte(tag0.getTypeCode()); + os.writeByte(NBTUtils.getTypeCode(tag0.getClass())); } else { os.writeByte(NBTUtils.getTypeCode(clazz)); } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java index 3464254bf..212958ef4 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java @@ -23,10 +23,6 @@ package com.sk89q.jnbt; * The {@code TAG_Short} tag. */ public final class ShortTag extends NumberTag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_SHORT; - } private final short value; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java index 057ac8c64..5a2c504a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java @@ -26,11 +26,6 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public final class StringTag extends Tag { - @Override - public int getTypeCode() { - return NBTConstants.TYPE_STRING; - } - private final String value; /** diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java index adfc5147a..d7c273b17 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java @@ -35,6 +35,4 @@ public abstract class Tag { return getValue(); } - public abstract int getTypeCode(); - } diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java index cca293ddf..1129e5256 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -62,7 +62,7 @@ public class YAMLNode { /** * Gets a property at a location. This will either return an Object - * or null, with null meaning no configuration value exists at + * or null, with null meaning that no configuration value exists at * that location. This could potentially return a default value (not yet * implemented) as defined by a plugin, if this is a plugin-tied * configuration. @@ -197,7 +197,7 @@ public class YAMLNode { } /** - * Gets a string at a location. This will either return a String + * Gets a string at a location. This will either return an String * or null, with null meaning that no configuration value exists at * that location. If the object at the particular location is not actually * a string, it will be converted to its string representation. @@ -214,7 +214,7 @@ public class YAMLNode { } /** - * Gets a vector at a location. This will either return a Vector + * Gets a vector at a location. This will either return an Vector * or a null. If the object at the particular location is not * actually a string, it will be converted to its string representation. * @@ -239,7 +239,7 @@ public class YAMLNode { } /** - * Gets a 2D vector at a location. This will either return a Vector + * Gets a 2D vector at a location. This will either return an Vector * or a null. If the object at the particular location is not * actually a string, it will be converted to its string representation. * @@ -263,7 +263,7 @@ public class YAMLNode { } /** - * Gets a string at a location. This will either return a Vector + * Gets a string at a location. This will either return an Vector * or the default value. If the object at the particular location is not * actually a string, it will be converted to its string representation. * @@ -281,7 +281,7 @@ public class YAMLNode { } /** - * Gets a string at a location. This will either return a String + * Gets a string at a location. This will either return an String * or the default value. If the object at the particular location is not * actually a string, it will be converted to its string representation. * @@ -337,10 +337,10 @@ public class YAMLNode { } /** - * Gets a double at a location. This will either return a double + * Gets a double at a location. This will either return an double * or null. If the object at the particular location is not * actually a double, the default value will be returned. However, other - * number types will be casted to a double. + * number types will be casted to an double. * * @param path path to node (dot notation) * @return double or null @@ -355,10 +355,10 @@ public class YAMLNode { } /** - * Gets a double at a location. This will either return a double + * Gets a double at a location. This will either return an double * or the default value. If the object at the particular location is not * actually a double, the default value will be returned. However, other - * number types will be casted to a double. + * number types will be casted to an double. * * @param path path to node (dot notation) * @param def default value @@ -375,7 +375,7 @@ public class YAMLNode { } /** - * Gets a boolean at a location. This will either return a boolean + * Gets a boolean at a location. This will either return an boolean * or null. If the object at the particular location is not * actually a boolean, the default value will be returned. * @@ -392,7 +392,7 @@ public class YAMLNode { } /** - * Gets a boolean at a location. This will either return a boolean + * Gets a boolean at a location. This will either return an boolean * or the default value. If the object at the particular location is not * actually a boolean, the default value will be returned. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 170fc76e0..b89812547 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2802,7 +2802,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) { - throw FaweCache.INSTANCE.getOUTSIDE_REGION(); + throw FaweCache.INSTANCE.getOutsideRegion(); } } final Set chunks = region.getChunks(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 90150a27a..c374ce1ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -128,7 +128,7 @@ public class ClipboardCommands { ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.INSTANCE.getMaxChecks(); } session.setClipboard(null); @@ -246,10 +246,10 @@ public class ClipboardCommands { long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.INSTANCE.getMaxChecks(); } if (volume >= limit.MAX_CHANGES) { - throw FaweCache.INSTANCE.getMAX_CHANGES(); + throw FaweCache.INSTANCE.getMaxChanges(); } session.setClipboard(null); 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 8fae5e501..fd2aaffc8 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 @@ -422,7 +422,7 @@ public class RegionCommands { long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { - throw FaweCache.INSTANCE.getMAX_CHECKS(); + throw FaweCache.INSTANCE.getMaxChecks(); } int affected = 0; try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java index dc28b2751..f4215548d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java @@ -30,7 +30,7 @@ public class TransformCommands { aliases = {"#l"}, desc = "Sequentially pick from a list of transform" ) - public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent linear(Actor actor, LocalSession session, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { if (other instanceof RandomTransform) { Set extents = ((RandomTransform) other).getExtents(); return new LinearTransform(extents.toArray(new ResettableExtent[0])); @@ -43,7 +43,7 @@ public class TransformCommands { aliases = {"#l3d"}, desc = "Use the x,y,z coordinate to pick a transform from the list" ) - public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { if (other instanceof RandomTransform) { Set extents = ((RandomTransform) other).getExtents(); return new Linear3DTransform(extents.toArray(new ResettableExtent[0])); @@ -55,7 +55,7 @@ public class TransformCommands { name = "#pattern", desc = "Always use a specific pattern" ) - public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { return new PatternTransform(other, pattern); } @@ -63,7 +63,7 @@ public class TransformCommands { name = "#offset", desc = "Offset transform" ) - public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { return new OffsetExtent(other, (int) x, (int) y, (int) z); } @@ -72,7 +72,7 @@ public class TransformCommands { aliases = {"#randomoffset"}, desc = "Random offset transform" ) - public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { return new RandomOffsetTransform(other, (int) x, (int) y, (int) z); } @@ -80,7 +80,7 @@ public class TransformCommands { name = "#scale", desc = "All changes will be scaled" ) - public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { return new ScaleTransform(other, x, y, z); } @@ -88,7 +88,7 @@ public class TransformCommands { name = "#rotate", desc = "All changes will be rotate around the initial position" ) - public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { + public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(desc = "ResettableExtent", def = "#null") ResettableExtent other) { ExtentTraverser traverser = new ExtentTraverser<>(other).find(TransformExtent.class); BlockTransformExtent affine = traverser != null ? traverser.get() : null; if (affine == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 1666916ef..07432bc0d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -46,6 +46,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.TextStyle; import java.time.zone.ZoneRulesException; +import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; @@ -79,7 +80,9 @@ public class WorldEditCommands { if (fVer != null) { FaweVersion version = Fawe.get().getVersion(); - Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day) + //noinspection MagicConstant + Date date = new GregorianCalendar(2000 + version.year, + version.month - 1, version.day) .getTime(); TextComponent dateArg = TextComponent.of(date.toLocaleString()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java index fa09c8911..4c1797b52 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.command.factory; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.EditContext; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.pattern.Pattern; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class ReplaceFactory implements Contextual { private final Pattern fill; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/TreeGeneratorFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/TreeGeneratorFactory.java index a0b684539..76d875851 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/TreeGeneratorFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/TreeGeneratorFactory.java @@ -41,4 +41,4 @@ public final class TreeGeneratorFactory implements Contextual { public String toString() { return "tree of type " + type; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index ce02f08e3..f028cff5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -114,7 +114,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Construct the tool. - * + * * @param permission the permission to check before use is allowed */ public BrushTool(String permission) { @@ -275,7 +275,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the filter. - * + * * @return the filter */ public Mask getMask() { @@ -303,7 +303,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the block filter used for identifying blocks to replace. - * + * * @param filter the filter to set */ public void setMask(Mask filter) { @@ -342,7 +342,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the brush. - * + * * @param brush tbe brush * @param permission the permission */ @@ -356,7 +356,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the current brush. - * + * * @return the current brush */ public Brush getBrush() { @@ -365,7 +365,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the material. - * + * * @param material the material */ public void setFill(@Nullable Pattern material) { @@ -383,7 +383,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the set brush size. - * + * * @return a radius */ public double getSize() { @@ -392,7 +392,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the set brush size. - * + * * @param radius a radius */ public void setSize(double radius) { @@ -410,7 +410,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the set brush range. - * + * * @return the range of the brush in blocks */ public int getRange() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java index 642a8c4aa..2aef51e92 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; @@ -29,6 +28,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; /** * A wand that can be used at a distance. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 3d299f456..87ef84b39 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.sk89q.worldedit.EditSession; @@ -32,6 +31,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index 69b64a037..9ca71b7d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -24,13 +24,13 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.LocatedBlock; +import com.sk89q.worldedit.util.collection.LocatedBlockList; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockTypes; import java.util.LinkedHashSet; import java.util.Set; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.util.collection.LocatedBlockList; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; public class GravityBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java index fbd406865..03b50a7e9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java @@ -34,4 +34,4 @@ public class SphereBrush implements Brush { } editSession.makeSphere(position, pattern, size, size, size, true); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 8a7ce511c..769389180 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -129,12 +129,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent { new ExtentTraverser<>(this).setNext(new HistoryExtent(extent, changeSet)); } } - - @Override - public int getMaxY() { - return extent.getMaxY(); - } - + @Override public BlockState getBlock(int x, int y, int z) { return extent.getBlock(x, y, z); @@ -177,14 +172,12 @@ public class AbstractDelegateExtent implements Extent, LightingExtent { } @Override - public > boolean setBlock(BlockVector3 position, T block) - throws WorldEditException { + public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { return extent.setBlock(position.getX(), position.getY(), position.getZ(), block); } @Override - public > boolean setBlock(int x, int y, int z, T block) - throws WorldEditException { + public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { return extent.setBlock(x, y, z, block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 1f2f2b7f6..08ee007d8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -457,7 +457,7 @@ public interface Extent extends InputExtent, OutputExtent { default boolean cancel() { ExtentTraverser traverser = new ExtentTraverser<>(this); - NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getMANUAL()); + NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getManual()); ExtentTraverser next = traverser.next(); if (next != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index f05619fd5..ec1f5e15f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -54,6 +54,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, Closeable { + @NotNull private Region region; private BlockVector3 offset; @@ -85,6 +86,7 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, setRegion(region); } + @NotNull @Override public Region getRegion() { return region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index 21ddee061..b638f5646 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -77,12 +77,17 @@ public interface Clipboard extends Extent, Iterable, Closeable { static Clipboard create(BlockVector3 size, UUID uuid) { if (Settings.IMP.CLIPBOARD.USE_DISK) { - return new DiskOptimizedClipboard(size, uuid); + try { + return new DiskOptimizedClipboard(size, uuid); + } catch (IOException e) { + e.printStackTrace(); + } } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { return new CPUOptimizedClipboard(size); } else { return new MemoryOptimizedClipboard(size); } + return null; } /** @@ -116,11 +121,10 @@ public interface Clipboard extends Extent, Iterable, Closeable { void setOrigin(BlockVector3 origin); /** - * Returns true if the clipboard has biome data. This can be checked since {@link - * Extent#getBiome(BlockVector2)} strongly suggests returning {@link - * com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} if biomes aren't - * present. However, it might not be desired to set areas to ocean if the clipboard is - * defaulting to ocean, instead of having biomes explicitly set. + * Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)} + * strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} + * if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting + * to ocean, instead of having biomes explicitly set. * * @return true if the clipboard has biome data set */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 3ca0aefc2..6687cda38 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.extent.inventory; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.object.exception.FaweException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -107,10 +106,10 @@ public class BlockBagExtent extends AbstractDelegateExtent { try { blockBag.fetchPlacedBlock(block.toImmutableState()); } catch (UnplaceableBlockException e) { - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.INSTANCE.getBlockBag(); } catch (BlockBagException e) { missingBlocks[block.getBlockType().getInternalId()]++; - throw FaweCache.INSTANCE.getBLOCK_BAG(); + throw FaweCache.INSTANCE.getBlockBag(); } } if (mine) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index bb9448e8a..f97394f31 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -32,20 +32,22 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import java.util.Comparator; +import javax.annotation.concurrent.Immutable; /** * An immutable 3-dimensional vector. */ -public abstract class BlockVector3 { +@Immutable +public class BlockVector3 { - public static final BlockVector3 ZERO = BlockVector3.at(0, 0, 0); - public static final BlockVector3 UNIT_X = BlockVector3.at(1, 0, 0); - public static final BlockVector3 UNIT_Y = BlockVector3.at(0, 1, 0); - public static final BlockVector3 UNIT_Z = BlockVector3.at(0, 0, 1); - public static final BlockVector3 UNIT_MINUS_X = BlockVector3.at(-1, 0, 0); - public static final BlockVector3 UNIT_MINUS_Y = BlockVector3.at(0, -1, 0); - public static final BlockVector3 UNIT_MINUS_Z = BlockVector3.at(0, 0, -1); - public static final BlockVector3 ONE = BlockVector3.at(1, 1, 1); + public static final BlockVector3 ZERO = new BlockVector3(0, 0, 0); + public static final BlockVector3 UNIT_X = new BlockVector3(1, 0, 0); + public static final BlockVector3 UNIT_Y = new BlockVector3(0, 1, 0); + public static final BlockVector3 UNIT_Z = new BlockVector3(0, 0, 1); + public static final BlockVector3 UNIT_MINUS_X = new BlockVector3(-1, 0, 0); + public static final BlockVector3 UNIT_MINUS_Y = new BlockVector3(0, -1, 0); + public static final BlockVector3 UNIT_MINUS_Z = new BlockVector3(0, 0, -1); + public static final BlockVector3 ONE = new BlockVector3(1, 1, 1); public static BlockVector3 at(double x, double y, double z) { return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)); @@ -68,7 +70,7 @@ public abstract class BlockVector3 { break; } */ - return new BlockVector3Imp(x, y, z); + return new BlockVector3(x, y, z); } private static final int WORLD_XZ_MINMAX = 30_000_000; @@ -114,6 +116,21 @@ public abstract class BlockVector3 { return YzxOrderComparator.YZX_ORDER; } + private final int x, y, z; + + /** + * Construct an instance. + * + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate + */ + public BlockVector3(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + public MutableBlockVector3 setComponents(double x, double y, double z) { return new MutableBlockVector3((int) x, (int) y, (int) z); } @@ -124,35 +141,35 @@ public abstract class BlockVector3 { public long toLongPackedForm() { checkLongPackable(this); - return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & (long) BITS_12) << (26 + 26))); + return (x & BITS_26) | ((z & BITS_26) << 26) | (((y & (long) BITS_12) << (26 + 26))); } public MutableBlockVector3 mutX(double x) { - return new MutableBlockVector3((int) x, getY(), getZ()); + return new MutableBlockVector3((int) x, y, z); } public MutableBlockVector3 mutY(double y) { - return new MutableBlockVector3(getX(), (int) y, getZ()); + return new MutableBlockVector3(x, (int) y, z); } public MutableBlockVector3 mutZ(double z) { - return new MutableBlockVector3(getX(), getY(), (int) z); + return new MutableBlockVector3(x, y, (int) z); } public MutableBlockVector3 mutX(int x) { - return new MutableBlockVector3(x, getY(), getZ()); + return new MutableBlockVector3(x, y, z); } public MutableBlockVector3 mutY(int y) { - return new MutableBlockVector3(getX(), y, getZ()); + return new MutableBlockVector3(x, y, z); } public MutableBlockVector3 mutZ(int z) { - return new MutableBlockVector3(getX(), getY(), z); + return new MutableBlockVector3(x, y, z); } public BlockVector3 toImmutable() { - return BlockVector3.at(getX(), getY(), getZ()); + return BlockVector3.at(x, y, z); } /** @@ -160,7 +177,9 @@ public abstract class BlockVector3 { * * @return the x coordinate */ - public abstract int getX(); + public int getX() { + return x; + } /** * Get the X coordinate. @@ -168,7 +187,7 @@ public abstract class BlockVector3 { * @return the x coordinate */ public int getBlockX() { - return getX(); + return x; } /** @@ -178,7 +197,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 withX(int x) { - return BlockVector3.at(x, getY(), getZ()); + return BlockVector3.at(x, y, z); } /** @@ -186,7 +205,9 @@ public abstract class BlockVector3 { * * @return the y coordinate */ - public abstract int getY(); + public int getY() { + return y; + } /** * Get the Y coordinate. @@ -194,7 +215,7 @@ public abstract class BlockVector3 { * @return the y coordinate */ public int getBlockY() { - return getY(); + return y; } /** @@ -204,7 +225,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 withY(int y) { - return BlockVector3.at(getX(), y, getZ()); + return BlockVector3.at(x, y, z); } /** @@ -212,7 +233,9 @@ public abstract class BlockVector3 { * * @return the z coordinate */ - public abstract int getZ(); + public int getZ() { + return z; + } /** * Get the Z coordinate. @@ -220,7 +243,7 @@ public abstract class BlockVector3 { * @return the z coordinate */ public int getBlockZ() { - return getZ(); + return z; } /** @@ -230,7 +253,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 withZ(int z) { - return BlockVector3.at(getX(), getY(), z); + return BlockVector3.at(x, y, z); } /** @@ -240,7 +263,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 add(BlockVector3 other) { - return add(other.getX(), other.getY(), other.getZ()); + return add(other.x, other.y, other.z); } /** @@ -252,7 +275,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 add(int x, int y, int z) { - return BlockVector3.at(this.getX() + x, this.getY() + y, this.getZ() + z); + return BlockVector3.at(this.x + x, this.y + y, this.z + z); } /** @@ -263,12 +286,12 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 add(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = x, newY = y, newZ = z; for (BlockVector3 other : others) { - newX += other.getX(); - newY += other.getY(); - newZ += other.getZ(); + newX += other.x; + newY += other.y; + newZ += other.z; } return BlockVector3.at(newX, newY, newZ); @@ -282,7 +305,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 subtract(BlockVector3 other) { - return subtract(other.getX(), other.getY(), other.getZ()); + return subtract(other.x, other.y, other.z); } /** @@ -295,7 +318,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 subtract(int x, int y, int z) { - return BlockVector3.at(this.getX() - x, this.getY() - y, this.getZ() - z); + return BlockVector3.at(this.x - x, this.y - y, this.z - z); } /** @@ -306,12 +329,12 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 subtract(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = x, newY = y, newZ = z; for (BlockVector3 other : others) { - newX -= other.getX(); - newY -= other.getY(); - newZ -= other.getZ(); + newX -= other.x; + newY -= other.y; + newZ -= other.z; } return BlockVector3.at(newX, newY, newZ); @@ -324,7 +347,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 multiply(BlockVector3 other) { - return multiply(other.getX(), other.getY(), other.getZ()); + return multiply(other.x, other.y, other.z); } /** @@ -336,7 +359,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 multiply(int x, int y, int z) { - return BlockVector3.at(this.getX() * x, this.getY() * y, this.getZ() * z); + return BlockVector3.at(this.x * x, this.y * y, this.z * z); } /** @@ -346,12 +369,12 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 multiply(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = x, newY = y, newZ = z; for (BlockVector3 other : others) { - newX *= other.getX(); - newY *= other.getY(); - newZ *= other.getZ(); + newX *= other.x; + newY *= other.y; + newZ *= other.z; } return BlockVector3.at(newX, newY, newZ); @@ -374,7 +397,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 divide(BlockVector3 other) { - return divide(other.getX(), other.getY(), other.getZ()); + return divide(other.x, other.y, other.z); } /** @@ -386,7 +409,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 divide(int x, int y, int z) { - return BlockVector3.at(this.getX() / x, this.getY() / y, this.getZ() / z); + return BlockVector3.at(this.x / x, this.y / y, this.z / z); } /** @@ -408,7 +431,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 shr(int x, int y, int z) { - return at(this.getX() >> x, this.getY() >> y, this.getZ() >> z); + return at(this.x >> x, this.y >> y, this.z >> z); } /** @@ -430,7 +453,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 shl(int x, int y, int z) { - return at(this.getX() << x, this.getY() << y, this.getZ() << z); + return at(this.x << x, this.y << y, this.z << z); } /** @@ -458,7 +481,7 @@ public abstract class BlockVector3 { * @return length, squared */ public int lengthSq() { - return getX() * getX() + getY() * getY() + getZ() * getZ(); + return x * x + y * y + z * z; } /** @@ -478,9 +501,9 @@ public abstract class BlockVector3 { * @return distance */ public int distanceSq(BlockVector3 other) { - int dx = other.getX() - getX(); - int dy = other.getY() - getY(); - int dz = other.getZ() - getZ(); + int dx = other.x - x; + int dy = other.y - y; + int dz = other.z - z; return dx * dx + dy * dy + dz * dz; } @@ -492,9 +515,9 @@ public abstract class BlockVector3 { */ public BlockVector3 normalize() { double len = length(); - double x = this.getX() / len; - double y = this.getY() / len; - double z = this.getZ() / len; + double x = this.x / len; + double y = this.y / len; + double z = this.z / len; return BlockVector3.at(x, y, z); } @@ -505,7 +528,7 @@ public abstract class BlockVector3 { * @return the dot product of this and the other vector */ public double dot(BlockVector3 other) { - return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ(); + return x * other.x + y * other.y + z * other.z; } /** @@ -515,10 +538,10 @@ public abstract class BlockVector3 { * @return the cross product of this and the other vector */ public BlockVector3 cross(BlockVector3 other) { - return new BlockVector3Imp( - getY() * other.getZ() - getZ() * other.getY(), - getZ() * other.getX() - getX() * other.getZ(), - getX() * other.getY() - getY() * other.getX() + return new BlockVector3( + y * other.z - z * other.y, + z * other.x - x * other.z, + x * other.y - y * other.x ); } @@ -530,8 +553,7 @@ public abstract class BlockVector3 { * @return true if the vector is contained */ public boolean containedWithin(BlockVector3 min, BlockVector3 max) { - return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max - .getY() && getZ() >= min.getZ() && getZ() <= max.getZ(); + return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; } /** @@ -543,11 +565,11 @@ public abstract class BlockVector3 { */ public BlockVector3 clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (getY() < min) { - return BlockVector3.at(getX(), min, getZ()); + if (y < min) { + return BlockVector3.at(x, min, z); } - if (getY() > max) { - return BlockVector3.at(getX(), max, getZ()); + if (y > max) { + return BlockVector3.at(x, max, z); } return this; } @@ -591,7 +613,7 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 abs() { - return BlockVector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ())); + return BlockVector3.at(Math.abs(x), Math.abs(y), Math.abs(z)); } /** @@ -607,8 +629,8 @@ public abstract class BlockVector3 { */ public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { angle = Math.toRadians(angle); - double x = this.getX() - aboutX; - double z = this.getZ() - aboutZ; + double x = this.x - aboutX; + double z = this.z - aboutZ; double cos = Math.cos(angle); double sin = Math.sin(angle); double x2 = x * cos - z * sin; @@ -616,7 +638,7 @@ public abstract class BlockVector3 { return BlockVector3.at( x2 + aboutX + translateX, - getY(), + y, z2 + aboutZ + translateZ ); } @@ -662,10 +684,10 @@ public abstract class BlockVector3 { * @return minimum */ public BlockVector3 getMinimum(BlockVector3 v2) { - return new BlockVector3Imp( - Math.min(getX(), v2.getX()), - Math.min(getY(), v2.getY()), - Math.min(getZ(), v2.getZ()) + return new BlockVector3( + Math.min(x, v2.x), + Math.min(y, v2.y), + Math.min(z, v2.z) ); } @@ -676,10 +698,10 @@ public abstract class BlockVector3 { * @return maximum */ public BlockVector3 getMaximum(BlockVector3 v2) { - return new BlockVector3Imp( - Math.max(getX(), v2.getX()), - Math.max(getY(), v2.getY()), - Math.max(getZ(), v2.getZ()) + return new BlockVector3( + Math.max(x, v2.x), + Math.max(y, v2.y), + Math.max(z, v2.z) ); } @@ -706,7 +728,7 @@ public abstract class BlockVector3 { } public boolean setBiome(Extent orDefault, BiomeType biome) { - return orDefault.setBiome(getX(), getY(), getZ(), biome); + return orDefault.setBiome(x, y, z, biome); } public int getOrdinal(Extent orDefault) { @@ -726,19 +748,19 @@ public abstract class BlockVector3 { } public CompoundTag getNbtData(Extent orDefault) { - return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData(); + return orDefault.getFullBlock(x, y, z).getNbtData(); } public BlockState getOrdinalBelow(Extent orDefault) { - return orDefault.getBlock(getX(), getY() - 1, getZ()); + return orDefault.getBlock(x, y - 1, z); } public BlockState getStateAbove(Extent orDefault) { - return orDefault.getBlock(getX(), getY() + 1, getZ()); + return orDefault.getBlock(x, y + 1, z); } public BlockState getStateRelativeY(Extent orDefault, final int y) { - return orDefault.getBlock(getX(), getY() + y, getZ()); + return orDefault.getBlock(x, this.y + y, z); } /** @@ -747,11 +769,11 @@ public abstract class BlockVector3 { * @return a new {@link BlockVector2} */ public BlockVector2 toBlockVector2() { - return BlockVector2.at(getX(), getZ()); + return BlockVector2.at(x, z); } public Vector3 toVector3() { - return Vector3.at(getX(), getY(), getZ()); + return Vector3.at(x, y, z); } @Override @@ -761,7 +783,7 @@ public abstract class BlockVector3 { } BlockVector3 other = (BlockVector3) obj; - return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ(); + return other.x == this.x && other.y == this.y && other.z == this.z; } public final boolean equals(BlockVector3 other) { @@ -771,12 +793,12 @@ public abstract class BlockVector3 { @Override public int hashCode() { - return (getX() ^ (getZ() << 12)) ^ (getY() << 24); + return (x ^ (z << 12)) ^ (y << 24); } @Override public String toString() { - return "(" + getX() + ", " + getY() + ", " + getZ() + ")"; + return "(" + x + ", " + y + ", " + z + ")"; } //Used by VS fork diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java deleted file mode 100644 index dd7399c64..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 Lesser 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 Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.math; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.collect.ComparisonChain; -import com.sk89q.worldedit.math.transform.AffineTransform; - -import java.util.Comparator; - -/** - * An immutable 3-dimensional vector. - */ -public final class BlockVector3Imp extends BlockVector3 { - - public static final BlockVector3Imp ZERO = new BlockVector3Imp(0, 0, 0); - public static final BlockVector3Imp UNIT_X = new BlockVector3Imp(1, 0, 0); - public static final BlockVector3Imp UNIT_Y = new BlockVector3Imp(0, 1, 0); - public static final BlockVector3Imp UNIT_Z = new BlockVector3Imp(0, 0, 1); - public static final BlockVector3Imp ONE = new BlockVector3Imp(1, 1, 1); - - public static BlockVector3Imp at(double x, double y, double z) { - return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)); - } - - public static BlockVector3Imp at(int x, int y, int z) { - return new BlockVector3Imp(x, y, z); - } - - private final int x, y, z; - - /** - * Construct an instance. - * - * @param x the X coordinate - * @param y the Y coordinate - * @param z the Z coordinate - */ - protected BlockVector3Imp(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - @Override - public final int getX() { - return x; - } - - @Override - public final int getY() { - return y; - } - - @Override - public final int getZ() { - return z; - } - - @Override - public int hashCode() { - return (getX() ^ (getZ() << 12)) ^ (getY() << 24); - } - - @Override - public final BlockVector3 toImmutable() { - return this; - } - - @Override - public String toString() { - return "(" + getX() + ", " + getY() + ", " + getZ() + ")"; - } -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/DelegateBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/DelegateBlockVector3.java index eb4b1c3ec..af9ec50c2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/DelegateBlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/DelegateBlockVector3.java @@ -11,6 +11,11 @@ import java.util.Comparator; public class DelegateBlockVector3 extends BlockVector3 { private BlockVector3 parent; + public DelegateBlockVector3(BlockVector3 parent) { + super(parent.getX(), parent.getY(), parent.getZ()); + this.parent = parent; + } + public DelegateBlockVector3 init(BlockVector3 parent) { this.parent = parent; return this; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java index 012431c73..1a43f45da 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java @@ -1,6 +1,7 @@ package com.sk89q.worldedit.math; import com.boydti.fawe.FaweCache; +import com.boydti.fawe.util.MathMan; public class MutableBlockVector3 extends BlockVector3 { @@ -13,27 +14,34 @@ public class MutableBlockVector3 extends BlockVector3 { } public static MutableBlockVector3 get(int x, int y, int z) { - return FaweCache.INSTANCE.getMUTABLE_BLOCKVECTOR3().get().setComponents(x, y, z); + return FaweCache.INSTANCE.getMutableBlockVector3().get().setComponents(x, y, z); } - public MutableBlockVector3() {} + public MutableBlockVector3() { + this(0, 0, 0); + } - public MutableBlockVector3(BlockVector3 other) { - this(other.getX(), other.getY(), other.getZ()); + public MutableBlockVector3(BlockVector3 blockVector3) { + this(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); } public MutableBlockVector3 setComponents(BlockVector3 other) { return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); } - private int x,y,z; + private int x, y, z; public MutableBlockVector3(int x, int y, int z) { + super(0, 0, 0); this.x = x; this.y = y; this.z = z; } + public MutableBlockVector3(double x, double y, double z) { + this(MathMan.floor(x), MathMan.floor(y), MathMan.floor(z)); + } + @Override public MutableBlockVector3 setComponents(int x, int y, int z) { this.x = x; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java index e3ff705c1..e356b3662 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java @@ -10,11 +10,11 @@ public class MutableVector3 extends Vector3 { } public static MutableVector3 get(int x, int y, int z) { - return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z); + return FaweCache.INSTANCE.getMutableVector3().get().setComponents(x, y, z); } public static MutableVector3 get(double x, double y, double z) { - return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z); + return FaweCache.INSTANCE.getMutableVector3().get().setComponents(x, y, z); } public MutableVector3(double x, double y, double z) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/OffsetBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/OffsetBlockVector3.java index ea8253632..cf5650311 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/OffsetBlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/OffsetBlockVector3.java @@ -4,6 +4,7 @@ public class OffsetBlockVector3 extends DelegateBlockVector3 { private final BlockVector3 offset; public OffsetBlockVector3(BlockVector3 offset) { + super(offset); this.offset = offset; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 9c63c884a..4156d0781 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -172,10 +172,10 @@ public abstract class AbstractRegion extends AbstractSet implement final BlockVector3 min = getMinimumPoint().divide(16); final BlockVector3 max = getMaximumPoint().divide(16); - for (int X = min.getBlockX(); X <= max.getBlockX(); ++X) { - for (int Z = min.getBlockZ(); Z <= max.getBlockZ(); ++Z) { - if (containsChunk(X, Z)) { - chunks.add(BlockVector2.at(X, Z)); + for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { + for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { + if (containsChunk(x, z)) { + chunks.add(BlockVector2.at(x, z)); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 6552c948c..40259edb4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -124,8 +124,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { if (pos1 == null || pos2 == null) { return; } - pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY()); - pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY()); + pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.worldMaxY : world.getMaxY()); + pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.worldMaxY : world.getMaxY()); minX = Math.min(pos1.getX(), pos2.getX()); minY = Math.min(pos1.getY(), pos2.getY()); minZ = Math.min(pos1.getZ(), pos2.getZ()); @@ -730,7 +730,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { boolean trimZ = lowerZ != 0 || upperZ != 15; int indexY, index; - for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) { + for (int layer = 0; layer < FaweCache.chunkLayers; layer++) { if (set.hasSection(layer)) { char[] arr = set.load(layer); if (trimX || trimZ) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index f35860b01..a1babfc22 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -67,9 +67,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess * * @return center point */ - default Vector3 getCenter() { - return getMinimumPoint().add(getMaximumPoint()).toVector3().divide(2); - } + Vector3 getCenter(); /** * Get the number of blocks in the region. @@ -195,17 +193,9 @@ public interface Region extends Iterable, Cloneable, IBatchProcess */ List polygonize(int maxPoints); - default int getMinimumY() { - return getMinimumPoint().getY(); - } - - default int getMaximumY() { - return getMaximumPoint().getY(); - } - default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, boolean full) { - int minSection = Math.max(0, getMinimumY() >> 4); - int maxSection = Math.min(15, getMaximumY() >> 4); + int minSection = Math.max(0, getMinimumPoint().getBlockY() >> 4); + int maxSection = Math.min(15, getMaximumPoint().getBlockY() >> 4); for (int layer = minSection; layer <= maxSection; layer++) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return; block = block.initLayer(get, set, layer);