3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 19:10:07 +01:00

More code quality fixes

Dieser Commit ist enthalten in:
MattBDev 2020-01-22 16:56:24 -05:00
Ursprung 88359f0215
Commit 2d6957ce1c
115 geänderte Dateien mit 686 neuen und 1688 gelöschten Zeilen

Datei anzeigen

@ -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();
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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();

Datei anzeigen

@ -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<Extent> last = new ExtentTraverser<>(es.getExtent()).last();
Extent extent = last.get();
if (extent instanceof IQueueExtent) {
last = last.previous();

Datei anzeigen

@ -54,6 +54,7 @@ public abstract class ChunkListener implements Listener {
public ChunkListener() {
if (Settings.IMP.TICK_LIMITER.ENABLED) {
PluginManager plm = Bukkit.getPluginManager();
assert Fawe.<FaweBukkit>imp() != null;
Plugin plugin = Fawe.<FaweBukkit>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;
}
}

Datei anzeigen

@ -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;
}
}
}

Datei anzeigen

@ -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];
}

Datei anzeigen

@ -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");
}
}

Datei anzeigen

@ -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];

Datei anzeigen

@ -26,7 +26,7 @@ public class ItemUtil {
private final Field fieldHandle;
private final BukkitImplAdapter adapter;
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference<>(new Int2ObjectOpenHashMap<>());
public ItemUtil() throws Exception {
this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();

Datei anzeigen

@ -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<Entity> 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;
}
}
}

Datei anzeigen

@ -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 <T extends BlockStateHolder<T>> 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);
}
}
}

Datei anzeigen

@ -70,6 +70,9 @@ public class BukkitServerInterface implements MultiUserPlatform {
dynamicCommands = new CommandRegistration(plugin);
}
CommandRegistration getDynamicCommands() {
return dynamicCommands;
}
boolean isHookingEvents() {
return hookingEvents;
}

Datei anzeigen

@ -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<MetadataValue> 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<org.enginehub.piston.Command> 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);
}
}

Datei anzeigen

@ -79,7 +79,7 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
Material material = blockData.getMaterial();
BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
List<? extends Property> 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) {

Datei anzeigen

@ -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();
}
}

Datei anzeigen

@ -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<MutableVector3> = object : CleanableThreadLocal<MutableVector3>(Supplier { MutableVector3() }) {
var mutableVector3: CleanableThreadLocal<MutableVector3> = object : CleanableThreadLocal<MutableVector3>(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"))
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);

Datei anzeigen

@ -78,7 +78,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
@Override
default BlockVector3 getMaximumPoint() {
return BlockVector3.at(30000000, FaweCache.WORLD_MAX_Y, 30000000);
return BlockVector3.at(30000000, FaweCache.worldMaxY, 30000000);
}
/**

Datei anzeigen

@ -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();

Datei anzeigen

@ -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++) {

Datei anzeigen

@ -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<T extends Future<T>> implements IQueueChunk<T> {
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() {

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;

Datei anzeigen

@ -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<Integer> 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;
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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() {

Datei anzeigen

@ -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));
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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<Change> getIterator(boolean undo) {
return new ArrayList<Change>().iterator();
return Collections.emptyIterator();
}
@Override

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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);

Datei anzeigen

@ -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

Datei anzeigen

@ -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<BlockVector3> points = new ArrayList<>();
if (size > 0) {

Datei anzeigen

@ -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<IntegerPair> visited = new HashSet<>();
HashSet<Pair<Integer, Integer>> visited = new HashSet<>();
for (BlockVector3 pos : clipboard.getRegion()) {
IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
Pair<Integer, Integer> pair = new Pair<>(pos.getBlockX(), pos.getBlockZ());
if (visited.contains(pair)) {
continue;
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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<Integer, Integer> 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

Datei anzeigen

@ -456,7 +456,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
public Iterator<MutableBiomeChange> getBiomeIterator(final boolean dir) throws IOException {
final FaweInputStream is = getBiomeIS();
if (is == null) {
return new ArrayList<MutableBiomeChange>().iterator();
return Collections.emptyIterator();
}
final MutableBiomeChange change = new MutableBiomeChange();
return new Iterator<MutableBiomeChange>() {
@ -570,7 +570,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
public Iterator<MutableEntityChange> getEntityIterator(final NBTInputStream is, final boolean create) {
if (is == null) {
return new ArrayList<MutableEntityChange>().iterator();
return Collections.emptyIterator();
}
final MutableEntityChange change = new MutableEntityChange(null, create);
try {
@ -619,7 +619,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
public Iterator<MutableTileChange> getTileIterator(final NBTInputStream is, final boolean create) {
if (is == null) {
return new ArrayList<MutableTileChange>().iterator();
return Collections.emptyIterator();
}
final MutableTileChange change = new MutableTileChange(null, create);
try {

Datei anzeigen

@ -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<IntegerTrio, CompoundTag> nbtMapLoc;
private final HashMap<Triple<Integer,Integer,Integer>, CompoundTag> nbtMapLoc;
private final HashMap<Integer, CompoundTag> nbtMapIndex;
@ -95,9 +95,9 @@ public class CPUOptimizedClipboard extends LinearClipboard {
if (nbtMapLoc.isEmpty()) {
return;
}
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntegerTrio key = entry.getKey();
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
for (Entry<Triple<Integer, Integer, Integer>, CompoundTag> entry : nbtMapLoc.entrySet()) {
Triple<Integer, Integer, Integer> 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;
}

Datei anzeigen

@ -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<IntegerTrio, CompoundTag> nbtMap;
private final HashMap<Triple<Integer,Integer,Integer>, 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<IntegerTrio, CompoundTag> entry : nbtMap.entrySet()) {
IntegerTrio key = entry.getKey();
int index = getIndex(key.x, key.y, key.z);
for (Entry<Triple<Integer, Integer, Integer>, CompoundTag> entry : nbtMap.entrySet()) {
Triple<Integer, Integer, Integer> 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<String, Tag> 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<BlockArrayClipboard.ClipboardEntity> 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;
}
}
}
}

Datei anzeigen

@ -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<IntegerTrio, CompoundTag> nbtMapLoc;
private final HashMap<Triple<Integer,Integer,Integer>, CompoundTag> nbtMapLoc;
private final HashMap<Integer, CompoundTag> nbtMapIndex;
@ -71,9 +68,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
if (nbtMapLoc.isEmpty()) {
return;
}
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntegerTrio key = entry.getKey();
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
for (Entry<Triple<Integer, Integer, Integer>, CompoundTag> entry : nbtMapLoc.entrySet()) {
Triple<Integer, Integer, Integer> 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;
}

Datei anzeigen

@ -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<? extends Entity> getEntities();
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
throw new UnsupportedOperationException("Clipboard is immutable");
}

Datei anzeigen

@ -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));

Datei anzeigen

@ -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<Extent> supplier, Region region) {
super(supplier, region);
}
public WorldCutClipboard(Supplier<Extent> 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();
}
}
}

Datei anzeigen

@ -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<K, V, K2, V2> implements IAdaptedMap<K, V, K2, V2> {
private final Function<V, V2> value;
private final Function<K, K2> 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"); };

Datei anzeigen

@ -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<BlockVector3> iterator();
@Override

Datei anzeigen

@ -180,7 +180,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
public boolean retainAll(@NotNull Collection<?> c) {
Objects.requireNonNull(c);
boolean modified = false;
Iterator it = iterator();
Iterator<BlockVector3> it = iterator();
while (it.hasNext()) {
if (!c.contains(it.next())) {
it.remove();
@ -192,11 +192,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> 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);
}

Datei anzeigen

@ -87,7 +87,7 @@ public class CleanableThreadLocal<T> extends ThreadLocal<T> implements Closeable
return list;
}
public static void iterate(ThreadLocal instance, Consumer<Object> withMap) {
public static <R> void iterate(ThreadLocal<R> instance, Consumer<Object> withMap) {
try {
Thread[] threads = MainUtil.getThreads();
Field tl = Thread.class.getDeclaredField("threadLocals");
@ -105,7 +105,7 @@ public class CleanableThreadLocal<T> extends ThreadLocal<T> implements Closeable
}
}
public static void clean(ThreadLocal instance) {
public static <R> void clean(ThreadLocal<R> instance) {
iterate(instance, new Consumer<Object>() {
Method methodRemove;
@Override

Datei anzeigen

@ -35,7 +35,7 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
public DifferentialArray(T array) {
checkNotNull(array);
Class<? extends Object> 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;

Datei anzeigen

@ -148,7 +148,7 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
if (changes == null) {
changes = new char[t1][][][][];
} else if (changes != null && changes.length != 0) {
} else if (changes.length != 0) {
initialChange(changes, chunkX, chunkZ, localX, localZ, y, (char) -combined);
}

Datei anzeigen

@ -22,6 +22,11 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
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<BlockVector3> {
}
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);

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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<BlockVector3> getChunkCubes() {
return new AbstractSet<BlockVector3>() {
@NotNull
@Override
public Iterator<BlockVector3> iterator() {
return new Iterator<BlockVector3>() {
@ -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;
}
}

Datei anzeigen

@ -1,338 +0,0 @@
package com.boydti.fawe.object.collection;
import java.lang.reflect.Array;
import java.util.AbstractList;
public class PrimitiveList<T> extends AbstractList<T> {
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<T> type) {
try {
Class<T> boxed;
if (type.isPrimitive()) {
this.primitive = type;
boxed = (Class<T>) 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<T> boxed = (Class<T>) 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<T> boxed = (Class<T>) 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;
}
}

Datei anzeigen

@ -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 <code>boolean</code> value. The values of a
* <code>SparseBitSet</code> 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 <code>SparseBitSet</code> or logical value may be
* used to modify the contents of (another) <code>SparseBitSet</code> through
* logical operations. One {@code SparseBitSet} or logical value may be
* used to modify the contents of (another) {@code SparseBitSet} through
* logical <b>AND</b>, logical <b>inclusive OR</b>, logical <b>exclusive
* OR</b>, and <b>And NOT</b> operations over all or part of the bit sets.
* <p>
* All values in a bit set initially have the value <code>false</code>.
* All values in a bit set initially have the value {@code false}.
* <p>
* Every bit set has a current size, which is the number of bits of space
* <i>nominally</i> 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.
* <p>
* The maximum cardinality of a <code>SparseBitSet</code> is
* <code>Integer.MAX_VALUE</code>, which means the bits of a
* <code>SparseBitSet</code> are labelled <code>
* 0</code>&nbsp;..&nbsp;<code>Integer.MAX_VALUE&nbsp;&minus;&nbsp;1</code>.
* After the last set bit of a <code>SparseBitSet</code>, 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}&nbsp;..&nbsp;
* {@code Integer.MAX_VALUE&nbsp;&minus;&nbsp;1}.
* After the last set bit of a {@code SparseBitSet}, any attempt to find
* a subsequent bit (<i>nextSetBit</i>()), will return an value of &minus;1.
* If an attempt is made to use <i>nextClearBit</i>(), and all the bits are
* set from the starting position of the search to the bit labelled
* <code>Integer.MAX_VALUE&nbsp;&minus;&nbsp;1</code>, then similarly &minus;1
* {@code Integer.MAX_VALUE&nbsp;&minus;&nbsp;1}, then similarly &minus;1
* will be returned.
* <p>
* Unless otherwise noted, passing a null parameter to any of the methods in
* a <code>SparseBitSet</code> will result in a
* <code>NullPointerException</code>.
* a {@code SparseBitSet} will result in a
* {@link NullPointerException}.
* <p>
* A <code>SparseBitSet</code> 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 <i>i</i>th bit is stored in a word
* represented by a long value, and is at bit position <code>i % 64</code>
* 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).
* <p>
@ -334,7 +334,7 @@ public class SparseBitSet implements Cloneable, Serializable
/**
* Constructor for a new (sparse) bit set. All bits initially are effectively
* <code>false</code>. 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.
* <p>
* The capacity is taken to be a <i>suggestion</i> 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 <code>false</code>.
* 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 <code>0</code> through
* at least <code>nbits-1</code>. Initially all bits are effectively
* <code>false</code>.
* represent bits with indices in the range {@code 0} through
* at least {@code nbits-1}. Initially all bits are effectively
* {@code false}.
* <p>
* 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 <b>AND</b> of the addressed target bit with the argument
* value. This bit set is modified so that the addressed bit has the value
* <code>true</code> if and only if it both initially had the value
* <code>true</code> and the argument value is also <code>true</code>.
* {@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 <b>AND</b> with that bit
@ -419,17 +419,17 @@ public class SparseBitSet implements Cloneable, Serializable
/**
* Performs a logical <b>AND</b> 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 <code>true</code> if and only
* if it both initially had the value <code>true</code> and the corresponding
* bit in the bit set argument also had the value <code>true</code>. 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 <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <b>AND</b> of this target bit set with the argument bit
* set. This bit set is modified so that each bit in it has the value
* <code>true</code> if and only if it both initially had the value
* <code>true</code> and the corresponding bit in the bit set argument also
* had the value <code>true</code>.
* {@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 <b>AND</b> of the two given <code>SparseBitSet</code>s.
* The returned <code>SparseBitSet</code> is created so that each bit in it
* has the value <code>true</code> if and only if both the given sets
* initially had the corresponding bits <code>true</code>, otherwise
* <code>false</code>.
* Performs a logical <b>AND</b> 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 <b>AndNOT</b> of the addressed target bit with the
* argument value. This bit set is modified so that the addressed bit has the
* value <code>true</code> if and only if it both initially had the value
* <code>true</code> and the argument value is <code>false</code>.
* 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 <b>AndNOT</b> 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 <code>true</code> if and only
* if it both initially had the value <code>true</code> and the corresponding
* bit in the bit set argument has the value <code>false</code>. 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 <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <b>AndNOT</b> of this target bit set with the argument
* bit set. This bit set is modified so that each bit in it has the value
* <code>true</code> if and only if it both initially had the value
* <code>true</code> and the corresponding bit in the bit set argument has
* the value <code>false</code>.
* {@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 <code>SparseBitSet</code> whose
* Creates a bit set from thie first {@code SparseBitSet} whose
* corresponding bits are cleared by the set bits of the second
* <code>SparseBitSet</code>. The resulting bit set is created so that a bit
* in it has the value <code>true</code> if and only if the corresponding bit
* in the <code>SparseBitSet</code> of the first is set, and that same
* corresponding bit is not set in the <code>SparseBitSet</code> 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 <code>true</code> in this
* <code>SparseBitSet</code>.
* 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 <code>false</code>.
* 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 <code>i</code> (inclusive) to the
* specified <code>j</code> (exclusive) to <code>false</code>.
* 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 <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <code>SparseBitSet</code> to
* <code>false</code>.
* 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 <code>SparseBitSet</code> produces a new
* <code>SparseBitSet</code> that is <i>equal</i>() to it. The clone of the
* Cloning this {@code SparseBitSet} produces a new
* {@code SparseBitSet} that is <i>equal</i>() to it. The clone of the
* bit set is another bit set that has exactly the same bits set to
* <code>true</code> as this bit set.
* {@code true} as this bit set.
* <p>
* 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 <code>SparseBitSet</code> 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
* <code>true</code> if and only if the argument is not <code>null</code>
* and is a <code>SparseBitSet</code> object that has exactly the same bits
* set to <code>true</code> as this bit set. That is, for every nonnegative
* <code>i</code> 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,
* <pre>((SparseBitSet)obj).get(i) == this.get(i)</pre>
* must be true.
*
* @param obj the Object with which to compare
* @return <code>true</code> if the objects are equivalent;
* <code>false</code> 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 <code>i</code> (inclusive) to the
* specified <code>j</code> (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 <code>i</code> is negative or is
* equal to Integer.MAX_VALUE, or <code>j</code> is negative, or
* <code>i</code> is larger than <code>j</code>
* @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
* <code>true</code> if the bit with the index <code>i</code> is currently set
* in this <code>SparseBitSet</code>; otherwise, the result is
* <code>false</code>.
* {@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 <code>SparseBitSet</code> composed of bits from this
* <code>SparseBitSet</code> from <code>i</code> (inclusive) to <code>j</code>
* 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 <code>i</code> is negative or is
* equal to Integer.MAX_VALUE, or <code>j</code> is negative, or
* <code>i</code> is larger than <code>j</code>
* @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 <code>SparseBitSet</code>. The
* which bits have been set within this {@code SparseBitSet}. The
* algorithm used to compute it may be described as follows.
* <p>
* Suppose the bits in the <code>SparseBitSet</code> were to be stored in an
* array of <code>long</code> integers called, say, <code>bits</code>, in such
* a manner that bit <code>i</code> is set in the <code>SparseBitSet</code>
* (for nonnegative values of <code>i</code>) 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
* <pre>
* ((i&gt;&gt;6) &lt; bits.length) &amp;&amp; ((bits[i&gt;&gt;6] &amp; (1L &lt;&lt; (bit &amp; 0x3F))) != 0)
* </pre>
* is true. Then the following definition of the <code>hashCode</code> method
* is true. Then the following definition of the {@code hashCode} method
* would be a correct implementation of the actual algorithm:
* <pre>
* public int hashCode()
@ -824,19 +824,19 @@ public class SparseBitSet implements Cloneable, Serializable
}
/**
* Returns true if the specified <code>SparseBitSet</code> has any bits
* within the given range <code>i</code> (inclusive) to <code>j</code>
* (exclusive) set to <code>true</code> that are also set to <code>true</code>
* in the same range of this <code>SparseBitSet</code>.
* 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 <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <code>SparseBitSet</code> has any bits set to
* <code>true</code> that are also set to <code>true</code> in this
* <code>SparseBitSet</code>.
* 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 <code>SparseBitSet</code> contains no bits that are
* set to <code>true</code>.
* 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 <code>SparseBitSet</code>: the index
* of the highest set bit in the <code>SparseBitSet</code> plus one. Returns
* zero if the <code>SparseBitSet</code> 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 <code>false</code> 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 <code>true</code> 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.
* <p>
* To iterate over the <code>true</code> bits in a <code>SparseBitSet
* sbs</code>, use the following loop:
* To iterate over the {@code true} bits in a {@code SparseBitSet
* sbs}, use the following loop:
*
* <pre>
* for( int i = sbbits.nextSetBit(0); i &gt;= 0; i = sbbits.nextSetBit(i+1) )
@ -1168,8 +1168,8 @@ public class SparseBitSet implements Cloneable, Serializable
/**
* Performs a logical <b>OR</b> of the addressed target bit with the
* argument value. This bit set is modified so that the addressed bit has the
* value <code>true</code> if and only if it both initially had the value
* <code>true</code> or the argument value is <code>true</code>.
* 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 <b>OR</b> 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 <code>true</code> if and only if
* it either already had the value <code>true</code> or the corresponding bit
* in the bit set argument has the value <code>true</code>. 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 <b>OR</b>
* operation with this SparseBitSet
* @exception IndexOutOfBoundsException if <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <b>OR</b> of this bit set with the bit set argument.
* This bit set is modified so that a bit in it has the value <code>true</code>
* if and only if it either already had the value <code>true</code> or the
* corresponding bit in the bit set argument has the value <code>true</code>.
* 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 <b>OR</b>
* operation with this SparseBitSet
@ -1223,11 +1223,11 @@ public class SparseBitSet implements Cloneable, Serializable
}
/**
* Performs a logical <b>OR</b> of the two given <code>SparseBitSet</code>s.
* The returned <code>SparseBitSet</code> is created so that a bit in it has
* the value <code>true</code> if and only if it either had the value
* <code>true</code> in the set given by the first arguemetn or had the value
* <code>true</code> in the second argument, otherwise <code>false</code>.
* Performs a logical <b>OR</b> 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 <code>i</code> (inclusive) to the specified
* <code>j</code> (exclusive) to <code>true</code>.
* 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 <code>i</code> is negative or is
* equal to Integer.MAX_INT, or <code>j</code> is negative, or
* <code>i</code> is larger than <code>j</code>.
* @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 <code>i</code> (inclusive) to the specified
* <code>j</code> (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 <code>i</code> is negative or is
* equal to Integer.MAX_VALUE, or <code>j</code> is negative, or
* <code>i</code> is larger than <code>j</code>
* @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
* <code>SparseBitSet</code> 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
* <p>
* 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
* <code>SparseBitSet</code>.
* {@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 <code>SparseBitSet</code> 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
* <pre>
* SparseBitSet drPepper = new SparseBitSet();
* </pre>
* Now <code>drPepper.toString()</code> returns "<code>{}</code>".
* Now {@code drPepper.toString()} returns "{@code {}}".
* <br>
* <pre>
* drPepper.set(2);
* </pre>
* Now <code>drPepper.toString()</code> returns "<code>{2}</code>".
* Now {@code drPepper.toString()} returns "{@code {2}}".
* <br>
* <pre>
* drPepper.set(3, 4);
* drPepper.set(10);
* </pre>
* Now <code>drPepper.toString()</code> returns "<code>{2..4, 10}</code>".
* Now {@code drPepper.toString()} returns "{@code {2..4, 10}}".
* <br>
* 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 <code>SparseBitSet</code>.
* 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 <code>a..b</code>.
* {@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).
* <p>
* Note: this value will be passed to <code>SparseBitSet</code>s 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 <code>toString</code>() 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 <i>change</i> is <code>true</code>, the current value of the
* If <i>change</i> is {@code true}, the current value of the
* <i>toStringCompaction</i>() value is made the default value for all
* <code>SparseBitSet</code>s 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 <b>XOR</b> of the addressed target bit with the
* argument value. This bit set is modified so that the addressed bit has the
* value <code>true</code> if and only one of the following statements holds:
* value {@code true} if and only one of the following statements holds:
* <ul>
* <li>The addressed bit initially had the value <code>true</code>, and the
* value of the argument is <code>false</code>.
* <li>The bit initially had the value <code>false</code>, and the
* value of the argument is <code>true</code>.
* <li>The addressed bit initially had the value {@code true}, and the
* value of the argument is {@code false}.
* <li>The bit initially had the value {@code false}, and the
* value of the argument is {@code true}.
* </ul>
*
* @param i a bit index
* @param value a boolean value to <b>XOR</b> 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 <b>XOR</b> 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 <code>true</code> 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:
* <ul>
* <li>The bit initially had the value <code>true</code>, and the
* corresponding bit in the argument set has the value <code>false</code>.
* <li>The bit initially had the value <code>false</code>, and the
* corresponding bit in the argument set has the value <code>true</code>.
* <li>The bit initially had the value {@code true}, and the
* corresponding bit in the argument set has the value {@code false}.
* <li>The bit initially had the value {@code false}, and the
* corresponding bit in the argument set has the value {@code true}.
* </ul>
* 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 <b>XOR</b>
* operation with this SparseBitSet
* @exception IndexOutOfBoundsException if <code>i</code> is negative or
* equal to Integer.MAX_VALUE, or <code>j</code> is negative,
* or <code>i</code> is larger than <code>j</code>
* @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 <b>XOR</b> of this bit set with the bit set argument.
* This resulting bit set is computed so that a bit in it has the value
* <code>true</code> if and only if one of the following statements holds:
* {@code true} if and only if one of the following statements holds:
* <ul>
* <li>The bit initially had the value <code>true</code>, and the
* corresponding bit in the argument set has the value <code>false</code>.
* <li>The bit initially had the value <code>false</code>, and the
* corresponding bit in the argument set has the value <code>true</code>.
* <li>The bit initially had the value {@code true}, and the
* corresponding bit in the argument set has the value {@code false}.
* <li>The bit initially had the value {@code false}, and the
* corresponding bit in the argument set has the value {@code true}.
* </ul>
*
* @param b the SparseBitSet with which to perform the <b>XOR</b>
@ -1617,16 +1617,16 @@ public class SparseBitSet implements Cloneable, Serializable
}
/**
* Performs a logical <b>XOR</b> of the two given <code>SparseBitSet</code>s.
* Performs a logical <b>XOR</b> of the two given {@code SparseBitSet}s.
* The resulting bit set is created so that a bit in it has the value
* <code>true</code> if and only if one of the following statements holds:
* {@code true} if and only if one of the following statements holds:
* <ul>
* <li>A bit in the first argument has the value <code>true</code>, and the
* <li>A bit in the first argument has the value {@code true}, and the
* corresponding bit in the second argument has the value
* <code>false</code>.</li>
* <li>A bit in the first argument has the value <code>false</code>, and the
* {@code false}.</li>
* <li>A bit in the first argument has the value {@code false}, and the
* corresponding bit in the second argument has the value
* <code>true</code>.</li></ul>
* {@code true}.</li></ul>
*
* @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 <code>String</code>
* 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
* <code>AbstractStrategy</code>. 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 <code>SparseBitSet</code> instance to a stream
* Save the state of the {@code SparseBitSet} instance to a stream
* (<i>i.e.</i>, 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
* <i>compactionCount</i> for the bit set, and then the
* <i>length</i> of the set (the position of the last bit),
* followed by the <i>cache.count</i> value (an <code>int</code>,
* the number of <code>int-&gt;long</code> pairs needed to describe
* the set), followed by the index (<code>int</code>) and word
* (<code>long</code>) for each <code>int-&gt;long</code> pair.
* followed by the <i>cache.count</i> 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 <i>hashCode</i> 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 <code>SparseBitSet</code> instance from a stream
* Reconstitute the {@code SparseBitSet} instance from a stream
* (<i>i.e.</i>, 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 <i>statistics</i>() method. The values of the corresponding
* statistics are <code>int</code>s, except for the loadFactor and
* Average_chain_length values, which are <code>float</code>s.
* statistics are {@code int}s, except for the loadFactor and
* Average_chain_length values, which are {@code float}s.
* <p>
* An array of <code>String</code>s 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,
* <code>values</code>, may be accessed, for example, by:
* {@code values}, may be accessed, for example, by:
* <pre>
* values[SparseBitSet.statistics.Buckets_available.ordinal()]</pre>
*
@ -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
* <i>setScanner</i>() method of the main <code>SparseBitSet</code> class
* <i>setScanner</i>() 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.
* <p>
* The symbolic constants control optimisation paths in the
* <i>setScanner</i>() method of the main <code>SparseBitSet</code> class.
* <i>setScanner</i>() 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);
}
}

Datei anzeigen

@ -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<T> implements Iterable<T>, Consumer<T>, Closeable {
private static final Object END_MARKER = new Object();
private final LinkedBlockingQueue<T> queue;
private Future future;
private Future<Integer> future;
public YieldIterable(@Nullable Future task) {
public YieldIterable(@Nullable Future<Integer> task) {
this.queue = new LinkedBlockingQueue<>();
this.future = task;
}
@ -23,10 +24,11 @@ public class YieldIterable<T> implements Iterable<T>, Consumer<T>, Closeable {
this(null);
}
public void setFuture(Future future) {
public void setFuture(Future<Integer> future) {
this.future = future;
}
@NotNull
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {

Datei anzeigen

@ -71,7 +71,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
public <B extends BlockStateHolder<B>> 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;
}

Datei anzeigen

@ -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();
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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);

Datei anzeigen

@ -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<Integer,Integer,Integer> 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))) {

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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;
/**

Datei anzeigen

@ -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;

Datei anzeigen

@ -33,11 +33,6 @@ import java.util.UUID;
*/
public class CompoundTag extends Tag {
@Override
public int getTypeCode() {
return NBTConstants.TYPE_COMPOUND;
}
private Map<String, Tag> value;
/**

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;
/**

Datei anzeigen

@ -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;

Datei anzeigen

@ -32,11 +32,6 @@ import javax.annotation.Nullable;
*/
public class ListTag extends Tag {
@Override
public int getTypeCode() {
return NBTConstants.TYPE_LIST;
}
private final Class<? extends Tag> type;
private final List<Tag> value;

Datei anzeigen

@ -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;
/**

Datei anzeigen

@ -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;

Datei anzeigen

@ -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));
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;
/**

Datei anzeigen

@ -35,6 +35,4 @@ public abstract class Tag {
return getValue();
}
public abstract int getTypeCode();
}

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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<BlockVector2> chunks = region.getChunks();

Datei anzeigen

@ -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);

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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<ResettableExtent> 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<ResettableExtent> 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<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
BlockTransformExtent affine = traverser != null ? traverser.get() : null;
if (affine == null) {

Datei anzeigen

@ -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());

Datei anzeigen

@ -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<RegionFunction> {
private final Pattern fill;

Datei anzeigen

@ -41,4 +41,4 @@ public final class TreeGeneratorFactory implements Contextual<ForestGenerator> {
public String toString() {
return "tree of type " + type;
}
}
}

Datei anzeigen

@ -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() {

Datei anzeigen

@ -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.

Datei anzeigen

@ -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;

Datei anzeigen

@ -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 {

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen