mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
parent
37003ec089
commit
e0f6869573
@ -48,7 +48,6 @@ 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;
|
||||
|
||||
@ -57,7 +56,6 @@ 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;
|
||||
|
||||
@ -75,7 +73,11 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
Settings.IMP.TICK_LIMITER.ENABLED = !Bukkit.hasWhitelist();
|
||||
Fawe.set(this);
|
||||
Fawe.setupInjector();
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
try {
|
||||
new BrushListener(plugin);
|
||||
} catch (Throwable e) {
|
||||
log.debug("Brush Listener Failed", e);
|
||||
}
|
||||
if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
|
||||
new RenderListener(plugin);
|
||||
}
|
||||
@ -140,7 +142,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
fos.write(jarData);
|
||||
}
|
||||
}
|
||||
ImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(player), ((MapManagerPlugin) manager.getPlugin("MapManager")).getMapManager());
|
||||
BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(player));
|
||||
if (imageListener == null) {
|
||||
this.imageListener = new BukkitImageListener(plugin);
|
||||
}
|
||||
@ -208,11 +210,11 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
@Override
|
||||
public String getDebugInfo() {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Server Version: ").append(Bukkit.getVersion()).append(separator);
|
||||
msg.append("Plugins: " + separator);
|
||||
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
|
||||
msg.append("Plugins: \n");
|
||||
for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
|
||||
msg.append(" - ").append(p.getName()).append(": ")
|
||||
.append(p.getDescription().getVersion()).append(separator);
|
||||
.append(p.getDescription().getVersion()).append("\n");
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ 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;
|
||||
@ -29,6 +30,7 @@ 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;
|
||||
@ -208,8 +210,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.getBlockStates().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get();
|
||||
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||
try {
|
||||
int[] num_palette_buffer = new int[1];
|
||||
int air;
|
||||
|
@ -30,6 +30,7 @@ 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;
|
||||
@ -202,8 +203,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.getBlockStates().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get();
|
||||
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||
try {
|
||||
int[] num_palette_buffer = new int[1];
|
||||
int air;
|
||||
|
@ -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.getBlockStates().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get();
|
||||
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||
try {
|
||||
int[] num_palette_buffer = new int[1];
|
||||
int air;
|
||||
|
@ -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.worldHeight; y++) {
|
||||
for (y = 0; y < FaweCache.WORLD_HEIGHT; 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.worldHeight; y++) {
|
||||
for (int y = 0; y < FaweCache.WORLD_HEIGHT; y++) {
|
||||
currentBiomes.setBiome(x, y, z, nmsBiome);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ 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) {
|
||||
@ -34,7 +37,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;
|
||||
@ -50,7 +53,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();
|
||||
|
@ -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<Extent> last = new ExtentTraverser<>(es.getExtent()).last();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
Extent extent = last.get();
|
||||
if (extent instanceof IQueueExtent) {
|
||||
last = last.previous();
|
||||
|
@ -54,7 +54,6 @@ 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 {
|
||||
@ -294,8 +293,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;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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;
|
||||
|
@ -9,7 +9,6 @@ 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;
|
||||
@ -100,7 +99,7 @@ public class RenderListener implements Listener {
|
||||
player.setViewDistance(value);
|
||||
}
|
||||
|
||||
private int getViewDistance(Entity player) {
|
||||
private int getViewDistance(Player player) {
|
||||
int[] value = views.get(player.getUniqueId());
|
||||
return value == null ? Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING : value[0];
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ 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 {
|
||||
|
||||
@ -10,7 +9,7 @@ public abstract class BukkitMaskManager extends FaweMaskManager {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public boolean hasMemberPermission(Permissible player) {
|
||||
public boolean hasMemberPermission(Player player) {
|
||||
return player.hasPermission("fawe." + getKey() + ".member");
|
||||
}
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -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();
|
||||
|
@ -15,7 +15,6 @@ 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;
|
||||
@ -33,12 +32,12 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
private ItemFrame[][] frames;
|
||||
private boolean reverse;
|
||||
|
||||
public BukkitImageViewer(Player player, MapManager mapManager) {
|
||||
this.mapManager = mapManager;
|
||||
public BukkitImageViewer(Player player) {
|
||||
mapManager = ((MapManagerPlugin) Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager();
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void selectFrame(Entity start) {
|
||||
public void selectFrame(ItemFrame start) {
|
||||
Location pos1 = start.getLocation().clone();
|
||||
Location pos2 = start.getLocation().clone();
|
||||
|
||||
@ -109,7 +108,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 && ent.getFacing() == facing) {
|
||||
if (ent instanceof ItemFrame && ((ItemFrame) ent).getFacing() == facing) {
|
||||
ItemFrame itemFrame = (ItemFrame) ent;
|
||||
itemFrame.setRotation(Rotation.NONE);
|
||||
contains = true;
|
||||
@ -138,7 +137,7 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
boolean initializing = last == null;
|
||||
|
||||
if (this.frames != null) {
|
||||
if (image == null) image = drawable.draw();
|
||||
if (image == null && drawable != null) image = drawable.draw();
|
||||
last = image;
|
||||
int width = frames.length;
|
||||
int height = frames[0].length;
|
||||
@ -159,7 +158,7 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
} else if (player.getInventory().getHeldItemSlot() != slot) {
|
||||
player.getInventory().setHeldItemSlot(slot);
|
||||
}
|
||||
if (image == null) image = drawable.draw();
|
||||
if (image == null && drawable != null) image = drawable.draw();
|
||||
last = image;
|
||||
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
MapWrapper mapWrapper = mapManager.wrapImage(scaled);
|
||||
@ -170,7 +169,7 @@ public class BukkitImageViewer implements ImageViewer {
|
||||
}
|
||||
}
|
||||
|
||||
private int getMapSlot(HumanEntity player) {
|
||||
private int getMapSlot(Player player) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
|
@ -376,7 +376,7 @@ public enum BukkitAdapter {
|
||||
* @param block The WorldEdit BlockStateHolder
|
||||
* @return The Bukkit BlockData
|
||||
*/
|
||||
public static <T extends BlockStateHolder<T>> BlockData adapt(@NotNull T block) {
|
||||
public static BlockData adapt(@NotNull BlockStateHolder block) {
|
||||
return getAdapter().adapt(block);
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,6 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
dynamicCommands = new CommandRegistration(plugin);
|
||||
}
|
||||
|
||||
CommandRegistration getDynamicCommands() {
|
||||
return dynamicCommands;
|
||||
}
|
||||
boolean isHookingEvents() {
|
||||
return hookingEvents;
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ 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;
|
||||
@ -576,7 +575,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
return wePlayer;
|
||||
}
|
||||
|
||||
public BukkitPlayer getCachedPlayer(Metadatable player) {
|
||||
public BukkitPlayer getCachedPlayer(Player player) {
|
||||
List<MetadataValue> meta = player.getMetadata("WE");
|
||||
if (meta == null || meta.isEmpty()) {
|
||||
return null;
|
||||
@ -649,24 +648,15 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
String buffer = event.getBuffer();
|
||||
int firstSpace = buffer.indexOf(' ');
|
||||
if (firstSpace < 0) return;
|
||||
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 String label = buffer.substring(0, firstSpace);
|
||||
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()), buffer);
|
||||
CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), event.getBuffer());
|
||||
getWorldEdit().getEventBus().post(suggestEvent);
|
||||
|
||||
event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions()));
|
||||
event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions()));
|
||||
event.setHandled(true);
|
||||
}
|
||||
}
|
||||
|
@ -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.isEmpty()) return type.getDefaultState();
|
||||
if (propList.size() == 0) return type.getDefaultState();
|
||||
String properties = blockData.getAsString();
|
||||
return BlockState.get(type, properties, type.getDefaultState());
|
||||
} catch (NullPointerException e) {
|
||||
|
@ -28,15 +28,10 @@ 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;
|
||||
@ -162,7 +157,7 @@ public class Fawe {
|
||||
* The platform specific implementation
|
||||
*/
|
||||
private final IFawe IMP;
|
||||
private final Thread thread;
|
||||
private Thread thread;
|
||||
|
||||
private Fawe(final IFawe implementation) {
|
||||
INSTANCE = this;
|
||||
@ -294,11 +289,7 @@ public class Fawe {
|
||||
String dateString = br.readLine();
|
||||
br.close();
|
||||
this.version = FaweVersion.tryParse(versionString, commitString, dateString);
|
||||
//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.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
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) {}
|
||||
@ -421,4 +412,12 @@ 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();
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ import java.util.function.Supplier
|
||||
object FaweCache : Trimable {
|
||||
|
||||
const val BLOCKS_PER_LAYER = 4096
|
||||
const val chunkLayers = 16
|
||||
const val worldHeight = chunkLayers shl 4
|
||||
const val worldMaxY = 255
|
||||
const val CHUNK_LAYERS = 16
|
||||
const val WORLD_HEIGHT = CHUNK_LAYERS shl 4
|
||||
const val WORLD_MAX_Y = WORLD_HEIGHT - 1
|
||||
|
||||
val EMPTY_CHAR_4096 = CharArray(4096)
|
||||
|
||||
@ -57,7 +57,7 @@ object FaweCache : Trimable {
|
||||
result
|
||||
}
|
||||
|
||||
val sectionBitsToChar = CleanableThreadLocal { CharArray(4096) }
|
||||
val SECTION_BITS_TO_CHAR = 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 blockStates = CleanableThreadLocal { LongArray(2048) }
|
||||
val BLOCK_STATES = CleanableThreadLocal { LongArray(2048) }
|
||||
|
||||
val sectionBlocks = CleanableThreadLocal { IntArray(4096) }
|
||||
val SECTION_BLOCKS = CleanableThreadLocal { IntArray(4096) }
|
||||
|
||||
val indexStore = CleanableThreadLocal { IntArray(256) }
|
||||
val INDEX_STORE = CleanableThreadLocal { IntArray(256) }
|
||||
|
||||
val heightStore = CleanableThreadLocal { IntArray(256) }
|
||||
val HEIGHT_STORE = CleanableThreadLocal { IntArray(256) }
|
||||
|
||||
private val paletteCache = CleanableThreadLocal(Supplier { Palette() })
|
||||
private val PALETTE_CACHE = CleanableThreadLocal(Supplier { Palette() })
|
||||
|
||||
/*
|
||||
* Vector cache
|
||||
*/
|
||||
|
||||
var mutableBlockVector3 = CleanableThreadLocal(Supplier { MutableBlockVector3() })
|
||||
var MUTABLE_BLOCKVECTOR3 = CleanableThreadLocal(Supplier { MutableBlockVector3() })
|
||||
|
||||
var mutableVector3: CleanableThreadLocal<MutableVector3> = object : CleanableThreadLocal<MutableVector3>(Supplier { MutableVector3() }) {
|
||||
var MUTABLE_VECTOR3: 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()
|
||||
blockStates.clean()
|
||||
sectionBlocks.clean()
|
||||
paletteCache.clean()
|
||||
BLOCK_STATES.clean()
|
||||
SECTION_BLOCKS.clean()
|
||||
PALETTE_CACHE.clean()
|
||||
PALETTE_TO_BLOCK_CHAR.clean()
|
||||
indexStore.clean()
|
||||
INDEX_STORE.clean()
|
||||
|
||||
mutableVector3.clean()
|
||||
mutableBlockVector3.clean()
|
||||
sectionBitsToChar.clean()
|
||||
MUTABLE_VECTOR3.clean()
|
||||
MUTABLE_BLOCKVECTOR3.clean()
|
||||
SECTION_BITS_TO_CHAR.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 = blockStates.get()
|
||||
val blocksCopy = sectionBlocks.get()
|
||||
val blockStates = BLOCK_STATES.get()
|
||||
val blocksCopy = SECTION_BLOCKS.get()
|
||||
|
||||
val blockIndexStart = layerOffset shl 12
|
||||
val blockIndexEnd = blockIndexStart + 4096
|
||||
@ -305,7 +305,7 @@ object FaweCache : Trimable {
|
||||
}
|
||||
|
||||
// Construct palette
|
||||
val palette = paletteCache.get()
|
||||
val palette = PALETTE_CACHE.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 value
|
||||
return null
|
||||
} else {
|
||||
val clazz = value.javaClass
|
||||
if (clazz.name.startsWith("com.intellectualcrafters.jnbt")) {
|
||||
@ -507,15 +507,15 @@ object FaweCache : Trimable {
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
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"))
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
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;
|
||||
@ -31,7 +34,7 @@ public class CombinedBlocks implements IBlocks {
|
||||
@Override
|
||||
public int getBitMask() {
|
||||
int bitMask = addMask;
|
||||
for (int layer = 0; layer < FaweCache.chunkLayers; layer++) {
|
||||
for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||
if (primary.hasSection(layer)) {
|
||||
bitMask |= (1 << layer);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public interface IBatchProcessor {
|
||||
}
|
||||
}
|
||||
int maxLayer = (maxY + 1) >> 4;
|
||||
for (int layer = maxLayer; layer < FaweCache.chunkLayers; layer++) {
|
||||
for (int layer = maxLayer; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
if (layer == minLayer) {
|
||||
char[] arr = set.load(layer);
|
||||
|
@ -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.chunkLayers).filter(this::hasSection)
|
||||
return IntStream.range(0, FaweCache.CHUNK_LAYERS).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.chunkLayers; layer++) {
|
||||
for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||
if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue;
|
||||
|
||||
char[] ids = this.load(layer);
|
||||
|
@ -78,7 +78,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
||||
|
||||
@Override
|
||||
default BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.at(30000000, FaweCache.worldMaxY, 30000000);
|
||||
return BlockVector3.at(30000000, FaweCache.WORLD_MAX_Y, 30000000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public class BitSetBlocks implements IChunkSet {
|
||||
|
||||
@Override
|
||||
public char[] load(int layer) {
|
||||
char[] arr = FaweCache.INSTANCE.getSectionBitsToChar().get();
|
||||
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
||||
if (nullRowY instanceof MemBlockSet.RowY) {
|
||||
char value = blockState.getOrdinalChar();
|
||||
|
@ -142,7 +142,7 @@ public class FallbackChunkGet implements IChunkGet {
|
||||
|
||||
@Override
|
||||
public char[] load(int layer) {
|
||||
char[] arr = FaweCache.INSTANCE.getSectionBitsToChar().get();
|
||||
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||
int by = layer << 4;
|
||||
for (int y = 0, i = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
|
@ -23,7 +23,6 @@ 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
|
||||
@ -40,9 +39,7 @@ 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() {
|
||||
|
@ -29,21 +29,22 @@ 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;
|
||||
@ -118,7 +119,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
limit.THROW_MAX_CHECKS(FaweCache.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -131,7 +132,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||
} catch (FaweException e) {
|
||||
@ -144,7 +145,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -157,7 +158,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
@ -170,7 +171,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -183,7 +184,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||
} catch (FaweException e) {
|
||||
@ -196,7 +197,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||
} catch (FaweException e) {
|
||||
@ -209,7 +210,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.worldHeight);
|
||||
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||
try {
|
||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
|
@ -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;
|
||||
|
@ -0,0 +1,312 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -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[1024];
|
||||
public final BiomeType[] biomes = new BiomeType[256];
|
||||
|
||||
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.getSectionBitsToChar().get();
|
||||
char[] buffer = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().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.getBlockStates().get();
|
||||
int[] blocksCopy = FaweCache.INSTANCE.getSectionBlocks().get();
|
||||
long[] blockstates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||
int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().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_INT_ARRAY;
|
||||
int type = NBTConstants.TYPE_BYTE_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.getSectionBitsToChar().get();
|
||||
char[] tmp = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||
int offset = layer << 12;
|
||||
System.arraycopy(blocks, offset, tmp, 0, 4096);
|
||||
return tmp;
|
||||
|
@ -138,7 +138,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.at((this.X << 9) + 511, FaweCache.worldMaxY, (this.Z << 9) + 511);
|
||||
return BlockVector3.at((this.X << 9) + 511, FaweCache.WORLD_MAX_Y, (this.Z << 9) + 511);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,42 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -136,51 +136,51 @@ public class FaweLimit {
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHANGES() {
|
||||
if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMaxChanges();
|
||||
if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||
}
|
||||
|
||||
public void THROW_MAX_FAILS() {
|
||||
if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMaxChecks();
|
||||
if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS() {
|
||||
if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMaxChecks();
|
||||
if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_ITERATIONS() {
|
||||
if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMaxIterations();
|
||||
if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_BLOCKSTATES() {
|
||||
if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMaxTiles();
|
||||
if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMAX_TILES();
|
||||
}
|
||||
|
||||
public void THROW_MAX_ENTITIES() {
|
||||
if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMaxEntities();
|
||||
if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES();
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHANGES(int amt) {
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChanges();
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||
}
|
||||
|
||||
public void THROW_MAX_FAILS(int amt) {
|
||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChecks();
|
||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS(int amt) {
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxChecks();
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_ITERATIONS(int amt) {
|
||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMaxIterations();
|
||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS();
|
||||
}
|
||||
|
||||
public void THROW_MAX_BLOCKSTATES(int amt) {
|
||||
if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxTiles();
|
||||
if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_TILES();
|
||||
}
|
||||
|
||||
public void THROW_MAX_ENTITIES(int amt) {
|
||||
if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMaxEntities();
|
||||
if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES();
|
||||
}
|
||||
|
||||
public boolean isUnlimited() {
|
||||
|
@ -0,0 +1,33 @@
|
||||
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));
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ 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 {
|
||||
@ -59,7 +58,7 @@ public class NullChangeSet extends AbstractChangeSet {
|
||||
|
||||
@Override
|
||||
public final Iterator<Change> getIterator(boolean undo) {
|
||||
return Collections.emptyIterator();
|
||||
return new ArrayList<Change>().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
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);
|
||||
|
@ -37,7 +37,7 @@ public class ShatterBrush extends ScatterBrush {
|
||||
LocalBlockVectorSet set = new LocalBlockVectorSet();
|
||||
set.add(pos);
|
||||
frontiers[i] = set;
|
||||
frontiersVisited[i] = new LocalBlockVectorSet(set);
|
||||
frontiersVisited[i] = set.clone();
|
||||
i++;
|
||||
}
|
||||
// Mask
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -62,7 +63,7 @@ public class SplineBrush implements Brush, ResettableTool {
|
||||
this.position = position;
|
||||
if (newPos) {
|
||||
if (positionSets.size() >= MAX_POINTS) {
|
||||
throw FaweCache.INSTANCE.getMaxChecks();
|
||||
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
final ArrayList<BlockVector3> points = new ArrayList<>();
|
||||
if (size > 0) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -11,7 +12,6 @@ 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<Pair<Integer, Integer>> visited = new HashSet<>();
|
||||
HashSet<IntegerPair> visited = new HashSet<>();
|
||||
for (BlockVector3 pos : clipboard.getRegion()) {
|
||||
Pair<Integer, Integer> pair = new Pair<>(pos.getBlockX(), pos.getBlockZ());
|
||||
IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
|
||||
if (visited.contains(pair)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -7,9 +7,13 @@ 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;
|
||||
@ -35,6 +39,7 @@ 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;
|
||||
@ -54,6 +59,7 @@ 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;
|
||||
@ -1557,12 +1563,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.getIndexStore().get();
|
||||
int[] indexes = FaweCache.INSTANCE.getINDEX_STORE().get();
|
||||
|
||||
int index;
|
||||
int maxY = 0;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int[] heightMap = FaweCache.INSTANCE.getHeightStore().get();
|
||||
int[] heightMap = FaweCache.INSTANCE.getHEIGHT_STORE().get();
|
||||
int globalIndex;
|
||||
for (int z = csz; z <= cez; z++) {
|
||||
globalIndex = z * getWidth() + csx;
|
||||
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
|
||||
private final MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private int from;
|
||||
private int to;
|
||||
|
||||
|
@ -87,10 +87,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
try {
|
||||
blockBag.fetchPlacedBlock(typeTo.getDefaultState());
|
||||
} catch (UnplaceableBlockException e) {
|
||||
throw FaweCache.INSTANCE.getBlockBag();
|
||||
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||
} catch (BlockBagException e) {
|
||||
missingBlocks[typeTo.getInternalId()]++;
|
||||
throw FaweCache.INSTANCE.getBlockBag();
|
||||
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||
}
|
||||
}
|
||||
if (mine) {
|
||||
|
@ -6,6 +6,8 @@ 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;
|
||||
@ -14,13 +16,12 @@ 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
|
||||
@ -402,23 +403,25 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Pair<Integer, Integer> readHeader() {
|
||||
public IntegerPair readHeader() {
|
||||
int ox = getOriginX();
|
||||
int oz = getOriginZ();
|
||||
if (ox == 0 && oz == 0 && bdFile.exists()) {
|
||||
try (FileInputStream fis = new FileInputStream(bdFile); FaweInputStream gis = MainUtil
|
||||
.getCompressedIS(fis)) {
|
||||
try (FileInputStream fis = new FileInputStream(bdFile)) {
|
||||
final 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 Pair<>(ox, oz);
|
||||
return new IntegerPair(ox, oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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 Collections.emptyIterator();
|
||||
return new ArrayList<MutableBiomeChange>().iterator();
|
||||
}
|
||||
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 Collections.emptyIterator();
|
||||
return new ArrayList<MutableEntityChange>().iterator();
|
||||
}
|
||||
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 Collections.emptyIterator();
|
||||
return new ArrayList<MutableTileChange>().iterator();
|
||||
}
|
||||
final MutableTileChange change = new MutableTileChange(null, create);
|
||||
try {
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -15,24 +16,23 @@ 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<Triple<Integer,Integer,Integer>, CompoundTag> nbtMapLoc;
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
|
||||
private final HashMap<Integer, CompoundTag> nbtMapIndex;
|
||||
|
||||
|
||||
@ -95,9 +95,9 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
if (nbtMapLoc.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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());
|
||||
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMapLoc.entrySet()) {
|
||||
IntegerTrio key = entry.getKey();
|
||||
setTile(getIndex(key.x, key.y, key.z), 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 Triple<>(x, y, z), tag);
|
||||
nbtMapLoc.put(new IntegerTrio(x, y, z), tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ 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;
|
||||
@ -38,10 +39,8 @@ 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)
|
||||
@ -52,7 +51,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
|
||||
private static int HEADER_SIZE = 14;
|
||||
|
||||
private final HashMap<Triple<Integer,Integer,Integer>, CompoundTag> nbtMap;
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMap;
|
||||
private final File file;
|
||||
|
||||
private RandomAccessFile braf;
|
||||
@ -61,41 +60,45 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
private FileChannel fileChannel;
|
||||
private boolean hasBiomes;
|
||||
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions, UUID uuid) throws IOException {
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions, UUID uuid) {
|
||||
this(dimensions, MainUtil.getFile(Fawe.get() != null ? Fawe.imp().getDirectory() : new File("."), Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd"));
|
||||
}
|
||||
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions) throws IOException {
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions) {
|
||||
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) throws IOException {
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions, File file) {
|
||||
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 {
|
||||
if (!file.exists()) {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
file.getParentFile().mkdirs();
|
||||
this.file = file;
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
file.createNewFile();
|
||||
}
|
||||
file.createNewFile();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} 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());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
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
|
||||
@ -307,9 +310,9 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
CompoundTag nbt;
|
||||
if (nbtMap.size() < 4) {
|
||||
nbt = null;
|
||||
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());
|
||||
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMap.entrySet()) {
|
||||
IntegerTrio key = entry.getKey();
|
||||
int index = getIndex(key.x, key.y, key.z);
|
||||
if (index == i) {
|
||||
nbt = entry.getValue();
|
||||
break;
|
||||
@ -320,7 +323,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 Triple<>(x, y, z));
|
||||
nbt = nbtMap.get(new IntegerTrio(x, y, z));
|
||||
}
|
||||
return state.toBaseBlock(nbt);
|
||||
}
|
||||
@ -329,7 +332,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 Triple<>(x, y, z));
|
||||
CompoundTag nbt = nbtMap.get(new IntegerTrio(x, y, z));
|
||||
return state.toBaseBlock(nbt);
|
||||
}
|
||||
return state.toBaseBlock();
|
||||
@ -360,7 +363,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||
nbtMap.put(new Triple<>(x, y, z), tag);
|
||||
nbtMap.put(new IntegerTrio(x, y, z), tag);
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
|
||||
values.put("x", new IntTag(x));
|
||||
values.put("y", new IntTag(y));
|
||||
@ -424,4 +427,16 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -19,15 +20,17 @@ 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.Map.Entry;
|
||||
import javax.annotation.Nullable;
|
||||
import kotlin.Triple;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
|
||||
@ -40,7 +43,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
private byte[] buffer = new byte[MainUtil.getMaxCompressedLength(BLOCK_SIZE)];
|
||||
private byte[] biomes = null;
|
||||
|
||||
private final HashMap<Triple<Integer,Integer,Integer>, CompoundTag> nbtMapLoc;
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
|
||||
private final HashMap<Integer, CompoundTag> nbtMapIndex;
|
||||
|
||||
|
||||
@ -68,9 +71,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
if (nbtMapLoc.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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());
|
||||
for (Map.Entry<IntegerTrio, CompoundTag> entry : nbtMapLoc.entrySet()) {
|
||||
IntegerTrio key = entry.getKey();
|
||||
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
|
||||
}
|
||||
nbtMapLoc.clear();
|
||||
}
|
||||
@ -263,7 +266,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||
nbtMapLoc.put(new Triple<>(x, y, z), tag);
|
||||
nbtMapLoc.put(new IntegerTrio(x, y, z), tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ 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;
|
||||
@ -69,8 +68,6 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
@ -84,7 +81,7 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
|
||||
public abstract List<? extends Entity> getEntities();
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
|
||||
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -45,7 +44,6 @@ 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));
|
||||
|
@ -0,0 +1,55 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.collection;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -16,7 +15,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 = Functions.identity();
|
||||
private static final Function SAME = o -> o;
|
||||
|
||||
private static final Function IMMUTABLE = o -> { throw new UnsupportedOperationException("Immutable"); };
|
||||
|
||||
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -93,7 +92,6 @@ 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
|
||||
|
@ -180,7 +180,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
boolean modified = false;
|
||||
Iterator<BlockVector3> it = iterator();
|
||||
Iterator it = iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!c.contains(it.next())) {
|
||||
it.remove();
|
||||
@ -192,7 +192,11 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return c.stream().map(this::remove).reduce(false, (a, b) -> a || b);
|
||||
boolean result = false;
|
||||
for (Object o : c) {
|
||||
result |= remove(o);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class CleanableThreadLocal<T> extends ThreadLocal<T> implements Closeable
|
||||
return list;
|
||||
}
|
||||
|
||||
public static <R> void iterate(ThreadLocal<R> instance, Consumer<Object> withMap) {
|
||||
public static void iterate(ThreadLocal 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 <R> void clean(ThreadLocal<R> instance) {
|
||||
public static void clean(ThreadLocal instance) {
|
||||
iterate(instance, new Consumer<Object>() {
|
||||
Method methodRemove;
|
||||
@Override
|
||||
|
@ -35,7 +35,7 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
|
||||
|
||||
public DifferentialArray(T array) {
|
||||
checkNotNull(array);
|
||||
Class<?> clazz = array.getClass();
|
||||
Class<? extends Object> clazz = array.getClass();
|
||||
checkArgument(clazz.isArray(), "Data must be an array");
|
||||
checkArgument(clazz.getComponentType().isPrimitive(), "Data must be a primitive array");
|
||||
this.data = array;
|
||||
|
@ -148,7 +148,7 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
|
||||
|
||||
if (changes == null) {
|
||||
changes = new char[t1][][][][];
|
||||
} else if (changes.length != 0) {
|
||||
} else if (changes != null && changes.length != 0) {
|
||||
initialChange(changes, chunkX, chunkZ, localX, localZ, y, (char) -combined);
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,6 @@ 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;
|
||||
@ -61,6 +56,11 @@ 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);
|
||||
|
@ -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) {
|
||||
|
@ -73,12 +73,10 @@ 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());
|
||||
}
|
||||
@ -175,10 +173,8 @@ 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>() {
|
||||
@ -283,6 +279,7 @@ public final class MemBlockSet extends BlockSet {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumY() {
|
||||
int maxY = 15;
|
||||
int maxy = 16;
|
||||
@ -327,6 +324,7 @@ public final class MemBlockSet extends BlockSet {
|
||||
return by;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumY() {
|
||||
int maxY = 0;
|
||||
int maxy = 0;
|
||||
@ -359,8 +357,8 @@ public final class MemBlockSet extends BlockSet {
|
||||
maxy = y + 1;
|
||||
}
|
||||
by = (Y << 4) + y;
|
||||
if (by == FaweCache.worldMaxY)
|
||||
return FaweCache.worldMaxY;
|
||||
if (by == FaweCache.WORLD_MAX_Y)
|
||||
return FaweCache.WORLD_MAX_Y;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
@ -741,7 +739,6 @@ public final class MemBlockSet extends BlockSet {
|
||||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
Arrays.fill(rows, NULL_ROW_X);
|
||||
}
|
||||
@ -830,7 +827,7 @@ public final class MemBlockSet extends BlockSet {
|
||||
public final IRow[] rows;
|
||||
|
||||
public RowZ() {
|
||||
this.rows = new IRow[FaweCache.chunkLayers];
|
||||
this.rows = new IRow[FaweCache.CHUNK_LAYERS];
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -864,7 +861,12 @@ public final class MemBlockSet extends BlockSet {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return Arrays.stream(rows).noneMatch(row -> row instanceof RowY);
|
||||
for (IRow row :rows) {
|
||||
if (row instanceof RowY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reset(int layer) {
|
||||
@ -872,7 +874,7 @@ public final class MemBlockSet extends BlockSet {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for (int i = 0; i < FaweCache.chunkLayers; i++) rows[i] = NULL_ROW_Y;
|
||||
for (int i = 0; i < FaweCache.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,338 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,48 +1,47 @@
|
||||
// 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} value. The values of a
|
||||
* {@code SparseBitSet} are indexed by non-negative integers.
|
||||
* bit set represents a <code>boolean</code> value. The values of a
|
||||
* <code>SparseBitSet</code> are indexed by non-negative integers.
|
||||
* Individual indexed values may be examined, set, cleared, or modified by
|
||||
* logical operations. One {@code SparseBitSet} or logical value may be
|
||||
* used to modify the contents of (another) {@code SparseBitSet} through
|
||||
* logical operations. One <code>SparseBitSet</code> or logical value may be
|
||||
* used to modify the contents of (another) <code>SparseBitSet</code> 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}.
|
||||
* All values in a bit set initially have the value <code>false</code>.
|
||||
* <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} is
|
||||
* {@link Integer#MAX_VALUE}, which means the bits of a
|
||||
* {@code SparseBitSet} are labelled {@code 0} ..
|
||||
* {@code Integer.MAX_VALUE − 1}.
|
||||
* After the last set bit of a {@code SparseBitSet}, any attempt to find
|
||||
* 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> .. <code>Integer.MAX_VALUE − 1</code>.
|
||||
* After the last set bit of a <code>SparseBitSet</code>, any attempt to find
|
||||
* a subsequent bit (<i>nextSetBit</i>()), will return an value of −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 − 1}, then similarly −1
|
||||
* <code>Integer.MAX_VALUE − 1</code>, then similarly −1
|
||||
* will be returned.
|
||||
* <p>
|
||||
* Unless otherwise noted, passing a null parameter to any of the methods in
|
||||
* a {@code SparseBitSet} will result in a
|
||||
* {@link NullPointerException}.
|
||||
* a <code>SparseBitSet</code> will result in a
|
||||
* <code>NullPointerException</code>.
|
||||
* <p>
|
||||
* A {@code SparseBitSet} is not safe for multi-threaded use without
|
||||
* A <code>SparseBitSet</code> is not safe for multi-threaded use without
|
||||
* external synchronization.
|
||||
*
|
||||
* @author Bruce K. Haddon
|
||||
@ -52,6 +51,7 @@ import java.util.Arrays;
|
||||
* @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}
|
||||
* represented by a long value, and is at bit position <code>i % 64</code>
|
||||
* 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}. This is a internal constructor that collects all the
|
||||
* <code>false</code>. 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}.
|
||||
* Initially all bits are effectively <code>false</code>.
|
||||
*
|
||||
* @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} through
|
||||
* at least {@code nbits-1}. Initially all bits are effectively
|
||||
* {@code false}.
|
||||
* 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>.
|
||||
* <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} if and only if it both initially had the value
|
||||
* {@code true} and the argument value is also {@code true}.
|
||||
* <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>.
|
||||
*
|
||||
* @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} 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
|
||||
* 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
|
||||
* 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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} 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}.
|
||||
* <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>.
|
||||
*
|
||||
* @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}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}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} if and only if it both initially had the value
|
||||
* {@code true} and the argument value is {@code false}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} 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
|
||||
* 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
|
||||
* 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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} 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}.
|
||||
* <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>.
|
||||
*
|
||||
* @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} whose
|
||||
* Creates a bit set from thie first <code>SparseBitSet</code> whose
|
||||
* corresponding bits are cleared by the set bits 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
|
||||
* <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
|
||||
* argument.
|
||||
*
|
||||
* @param a a SparseBitSet
|
||||
@ -552,8 +552,8 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bits set to {@code true} in this
|
||||
* {@code SparseBitSet}.
|
||||
* Returns the number of bits set to <code>true</code> in this
|
||||
* <code>SparseBitSet</code>.
|
||||
*
|
||||
* @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}.
|
||||
* Sets the bit at the specified index to <code>false</code>.
|
||||
*
|
||||
* @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} (inclusive) to the
|
||||
* specified {@code j} (exclusive) to {@code false}.
|
||||
* Sets the bits from the specified <code>i</code> (inclusive) to the
|
||||
* specified <code>j</code> (exclusive) to <code>false</code>.
|
||||
*
|
||||
* @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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} to
|
||||
* {@code false}.
|
||||
* Sets all of the bits in this <code>SparseBitSet</code> to
|
||||
* <code>false</code>.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
@ -621,15 +621,15 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloning this {@code SparseBitSet} produces a new
|
||||
* {@code SparseBitSet} that is <i>equal</i>() to it. The clone of the
|
||||
* Cloning this <code>SparseBitSet</code> produces a new
|
||||
* <code>SparseBitSet</code> 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} as this bit set.
|
||||
* <code>true</code> 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} is not normally decreased,
|
||||
* allocated to a <code>SparseBitSet</code> 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} 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,
|
||||
* <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,
|
||||
* <pre>((SparseBitSet)obj).get(i) == this.get(i)</pre>
|
||||
* must be true.
|
||||
*
|
||||
* @param obj the Object with which to compare
|
||||
* @return {@code true} if the objects are equivalent;
|
||||
* {@code false} otherwise.
|
||||
* @return <code>true</code> if the objects are equivalent;
|
||||
* <code>false</code> otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
@ -726,15 +726,15 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets each bit from the specified {@code i} (inclusive) to the
|
||||
* specified {@code j} (exclusive) to the complement of its current
|
||||
* Sets each bit from the specified <code>i</code> (inclusive) to the
|
||||
* specified <code>j</code> (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} is negative or is
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative, or
|
||||
* {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} if the bit with the index {@code i} is currently set
|
||||
* in this {@code SparseBitSet}; otherwise, the result is
|
||||
* {@code false}.
|
||||
* <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>.
|
||||
*
|
||||
* @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} composed of bits from this
|
||||
* {@code SparseBitSet} from {@code i} (inclusive) to {@code j}
|
||||
* Returns a new <code>SparseBitSet</code> composed of bits from this
|
||||
* <code>SparseBitSet</code> from <code>i</code> (inclusive) to <code>j</code>
|
||||
* (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} is negative or is
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative, or
|
||||
* {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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}. The
|
||||
* which bits have been set within this <code>SparseBitSet</code>. The
|
||||
* algorithm used to compute it may be described as follows.
|
||||
* <p>
|
||||
* 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
|
||||
* 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
|
||||
* <pre>
|
||||
* ((i>>6) < bits.length) && ((bits[i>>6] & (1L << (bit & 0x3F))) != 0)
|
||||
* </pre>
|
||||
* is true. Then the following definition of the {@code hashCode} method
|
||||
* is true. Then the following definition of the <code>hashCode</code> 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} 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}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} has any bits set to
|
||||
* {@code true} that are also set to {@code true} in this
|
||||
* {@code SparseBitSet}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} contains no bits that are
|
||||
* set to {@code true}.
|
||||
* Returns true if this <code>SparseBitSet</code> contains no bits that are
|
||||
* set to <code>true</code>.
|
||||
*
|
||||
* @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}: the index
|
||||
* of the highest set bit in the {@code SparseBitSet} plus one. Returns
|
||||
* zero if the {@code SparseBitSet} contains no set bits.
|
||||
* 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.
|
||||
*
|
||||
* @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} that
|
||||
* Returns the index of the first bit that is set to <code>false</code> 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} that
|
||||
* Returns the index of the first bit that is set to <code>true</code> 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} bits in a {@code SparseBitSet
|
||||
* sbs}, use the following loop:
|
||||
* To iterate over the <code>true</code> bits in a <code>SparseBitSet
|
||||
* sbs</code>, use the following loop:
|
||||
*
|
||||
* <pre>
|
||||
* for( int i = sbbits.nextSetBit(0); i >= 0; i = sbbits.nextSetBit(i+1) )
|
||||
@ -1168,8 +1168,8 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
/**
|
||||
* Performs a logical <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} if and only if it both initially had the value
|
||||
* {@code true} or the argument value is {@code true}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} 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
|
||||
* 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
|
||||
* 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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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}
|
||||
* 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}.
|
||||
* 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>.
|
||||
*
|
||||
* @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}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}.
|
||||
* 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>.
|
||||
*
|
||||
* @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} (inclusive) to the specified
|
||||
* {@code j} (exclusive) to {@code true}.
|
||||
* Sets the bits from the specified <code>i</code> (inclusive) to the specified
|
||||
* <code>j</code> (exclusive) to <code>true</code>.
|
||||
*
|
||||
* @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} is negative or is
|
||||
* equal to Integer.MAX_INT, or {@code j} is negative, or
|
||||
* {@code i} is larger than {@code j}.
|
||||
* @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>.
|
||||
* @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} (inclusive) to the specified
|
||||
* {@code j} (exclusive) to the specified value.
|
||||
* Sets the bits from the specified <code>i</code> (inclusive) to the specified
|
||||
* <code>j</code> (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} is negative or is
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative, or
|
||||
* {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} to represent bit values. The count of bits in
|
||||
* <code>SparseBitSet</code> 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>SparseBitSet</code>.
|
||||
*
|
||||
* @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} contains a bit in the set state, the decimal
|
||||
* this <code>SparseBitSet</code> 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()} returns "{@code {}}".
|
||||
* Now <code>drPepper.toString()</code> returns "<code>{}</code>".
|
||||
* <br>
|
||||
* <pre>
|
||||
* drPepper.set(2);
|
||||
* </pre>
|
||||
* Now {@code drPepper.toString()} returns "{@code {2}}".
|
||||
* Now <code>drPepper.toString()</code> returns "<code>{2}</code>".
|
||||
* <br>
|
||||
* <pre>
|
||||
* drPepper.set(3, 4);
|
||||
* drPepper.set(10);
|
||||
* </pre>
|
||||
* Now {@code drPepper.toString()} returns "{@code {2..4, 10}}".
|
||||
* Now <code>drPepper.toString()</code> returns "<code>{2..4, 10}</code>".
|
||||
* <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}.
|
||||
* of a <code>SparseBitSet</code>.
|
||||
*
|
||||
* @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}.
|
||||
* {@link #toString()} as a "sub-sequence," in the form <code>a..b</code>.
|
||||
* 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}s that
|
||||
* Note: this value will be passed to <code>SparseBitSet</code>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}() conversion.
|
||||
* individual entries in a <code>toString</code>() 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}, the current value of the
|
||||
* If <i>change</i> is <code>true</code>, the current value of the
|
||||
* <i>toStringCompaction</i>() value is made the default value for all
|
||||
* {@code SparseBitSet}s created from this point onward in this JVM.
|
||||
* <code>SparseBitSet</code>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} if and only one of the following statements holds:
|
||||
* value <code>true</code> if and only one of the following statements holds:
|
||||
* <ul>
|
||||
* <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}.
|
||||
* <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>.
|
||||
* </ul>
|
||||
*
|
||||
* @param i a bit index
|
||||
* @param value a boolean value to <b>XOR</b> with that bit
|
||||
* @exception IndexOutOfBoundsException if the specified index
|
||||
* @exception java.lang.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} if and only if one
|
||||
* within the range in it has the value <code>true</code> if and only if one
|
||||
* of the following statements holds:
|
||||
* <ul>
|
||||
* <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}.
|
||||
* <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>.
|
||||
* </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} is negative or
|
||||
* equal to Integer.MAX_VALUE, or {@code j} is negative,
|
||||
* or {@code i} is larger than {@code j}
|
||||
* @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>
|
||||
* @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} if and only if one of the following statements holds:
|
||||
* <code>true</code> if and only if one of the following statements holds:
|
||||
* <ul>
|
||||
* <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}.
|
||||
* <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>.
|
||||
* </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}s.
|
||||
* Performs a logical <b>XOR</b> of the two given <code>SparseBitSet</code>s.
|
||||
* The resulting bit set is created so that a bit in it has the value
|
||||
* {@code true} if and only if one of the following statements holds:
|
||||
* <code>true</code> if and only if one of the following statements holds:
|
||||
* <ul>
|
||||
* <li>A bit in the first argument has the value {@code true}, and the
|
||||
* <li>A bit in the first argument has the value <code>true</code>, and the
|
||||
* corresponding bit in the second argument has the value
|
||||
* {@code false}.</li>
|
||||
* <li>A bit in the first argument has the value {@code false}, and the
|
||||
* <code>false</code>.</li>
|
||||
* <li>A bit in the first argument has the value <code>false</code>, and the
|
||||
* corresponding bit in the second argument has the value
|
||||
* {@code true}.</li></ul>
|
||||
* <code>true</code>.</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}
|
||||
* Throw the exception to indicate a range error. The <code>String</code>
|
||||
* 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}. The strategy defines how to operate on a
|
||||
* <code>AbstractStrategy</code>. 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} instance to a stream
|
||||
* Save the state of the <code>SparseBitSet</code> 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},
|
||||
* 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.
|
||||
* followed by the <i>cache.count</i> value (an <code>int</code>,
|
||||
* the number of <code>int->long</code> pairs needed to describe
|
||||
* the set), followed by the index (<code>int</code>) and word
|
||||
* (<code>long</code>) for each <code>int->long</code> 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} instance from a stream
|
||||
* Reconstitute the <code>SparseBitSet</code> 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}s, except for the loadFactor and
|
||||
* Average_chain_length values, which are {@code float}s.
|
||||
* statistics are <code>int</code>s, except for the loadFactor and
|
||||
* Average_chain_length values, which are <code>float</code>s.
|
||||
* <p>
|
||||
* An array of {@code String}s may be obtained containing a
|
||||
* An array of <code>String</code>s may be obtained containing a
|
||||
* representation of each of these values. An element of such an array, say,
|
||||
* {@code values}, may be accessed, for example, by:
|
||||
* <code>values</code>, 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} class
|
||||
* <i>setScanner</i>() method of the main <code>SparseBitSet</code> 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} class.
|
||||
* <i>setScanner</i>() method of the main <code>SparseBitSet</code> class.
|
||||
*
|
||||
* @see SparseBitSet#setScanner(int i, int j,
|
||||
* SparseBitSet b, AbstractStrategy op)
|
||||
@ -2366,7 +2366,10 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
*/
|
||||
protected final boolean isZeroBlock(long[] a3)
|
||||
{
|
||||
return Arrays.stream(a3).noneMatch(word -> word != 0L);
|
||||
for (long word : a3)
|
||||
if (word != 0L)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.collection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Closeable;
|
||||
@ -13,9 +12,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<Integer> future;
|
||||
private Future future;
|
||||
|
||||
public YieldIterable(@Nullable Future<Integer> task) {
|
||||
public YieldIterable(@Nullable Future task) {
|
||||
this.queue = new LinkedBlockingQueue<>();
|
||||
this.future = task;
|
||||
}
|
||||
@ -24,11 +23,10 @@ public class YieldIterable<T> implements Iterable<T>, Consumer<T>, Closeable {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public void setFuture(Future<Integer> future) {
|
||||
public void setFuture(Future future) {
|
||||
this.future = future;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
|
@ -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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
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.getOutsideRegion());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -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.getLowMemory());
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getLOW_MEMORY());
|
||||
}
|
||||
return super.getExtent();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -37,7 +38,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
return null;
|
||||
}
|
||||
if (!limit.MAX_ENTITIES()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxEntities());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_ENTITIES());
|
||||
return null;
|
||||
}
|
||||
return super.createEntity(location, entity);
|
||||
@ -46,7 +47,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.getMaxChecks());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS());
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
} else {
|
||||
return extent.getBlock(x, y, z);
|
||||
@ -56,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 pos) {
|
||||
if (!limit.MAX_CHECKS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxChecks());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS());
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
} else {
|
||||
return extent.getFullBlock(pos);
|
||||
@ -78,18 +79,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.getMaxTiles());
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_TILES());
|
||||
return false;
|
||||
} else {
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMaxChanges());
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||
return false;
|
||||
}
|
||||
return extent.setBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMaxChanges());
|
||||
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||
return false;
|
||||
} else {
|
||||
return extent.setBlock(x, y, z, block);
|
||||
@ -99,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMaxChanges());
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||
return false;
|
||||
}
|
||||
return super.setBiome(position, biome);
|
||||
|
@ -4,6 +4,7 @@ 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;
|
||||
@ -19,7 +20,6 @@ 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 Triple[] getIntDirections() {
|
||||
Triple[] array = new Triple[directions.size()];
|
||||
private IntegerTrio[] getIntDirections() {
|
||||
IntegerTrio[] array = new IntegerTrio[directions.size()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
BlockVector3 dir = directions.get(i);
|
||||
array[i] = new Triple<>(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
|
||||
array[i] = new IntegerTrio(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;
|
||||
Triple[] dirs = getIntDirections();
|
||||
IntegerTrio[] 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 (Triple<Integer,Integer,Integer> direction : dirs) {
|
||||
for (IntegerTrio 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.getFirst(), from.getY() + direction.getSecond(), from.getZ() + direction.getThird());
|
||||
BlockVector3 bv2 = BlockVector3.at(from.getX() + direction.x, from.getY() + direction.y, from.getZ() + direction.z);
|
||||
if (isVisitable(bv, bv2)) {
|
||||
adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
|
||||
if ((!adjacent.equals(current.from))) {
|
||||
|
@ -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.getLowMemory();
|
||||
throw FaweCache.INSTANCE.getLOW_MEMORY();
|
||||
}
|
||||
}
|
||||
// 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.getNoRegion());
|
||||
regionExtent = new NullExtent(this.extent, FaweCache.INSTANCE.getNO_REGION());
|
||||
} else {
|
||||
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||
if (allowedRegions.length == 1) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import kotlin.UInt;
|
||||
|
||||
public class MathMan {
|
||||
|
||||
/**
|
||||
@ -416,10 +414,4 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -26,6 +26,11 @@ import java.util.Locale;
|
||||
*/
|
||||
public final class ByteArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||
}
|
||||
|
||||
private final byte[] value;
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,10 @@ 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;
|
||||
|
||||
|
@ -33,6 +33,11 @@ import java.util.UUID;
|
||||
*/
|
||||
public class CompoundTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
|
||||
private Map<String, Tag> value;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,10 @@ package com.sk89q.jnbt;
|
||||
*
|
||||
*/
|
||||
public final class DoubleTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_DOUBLE;
|
||||
}
|
||||
|
||||
private final double value;
|
||||
|
||||
|
@ -24,6 +24,11 @@ package com.sk89q.jnbt;
|
||||
*/
|
||||
public final class EndTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_END;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return null;
|
||||
|
@ -23,6 +23,10 @@ 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;
|
||||
|
||||
|
@ -28,6 +28,11 @@ import java.util.Locale;
|
||||
*/
|
||||
public final class IntArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_INT_ARRAY;
|
||||
}
|
||||
|
||||
private final int[] value;
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,10 @@ 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;
|
||||
|
||||
|
@ -32,6 +32,11 @@ 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;
|
||||
|
||||
|
@ -28,6 +28,11 @@ import java.util.Locale;
|
||||
*/
|
||||
public class LongArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG_ARRAY;
|
||||
}
|
||||
|
||||
private final long[] value;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,10 @@ package com.sk89q.jnbt;
|
||||
*
|
||||
*/
|
||||
public final class LongTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG;
|
||||
}
|
||||
|
||||
private final long value;
|
||||
|
||||
|
@ -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(NBTUtils.getTypeCode(tag0.getClass()));
|
||||
os.writeByte(tag0.getTypeCode());
|
||||
} else {
|
||||
os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ 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;
|
||||
|
||||
|
@ -26,6 +26,11 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -35,4 +35,6 @@ public abstract class Tag {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
public abstract int getTypeCode();
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class YAMLNode {
|
||||
|
||||
/**
|
||||
* Gets a property at a location. This will either return an Object
|
||||
* or null, with null meaning that no configuration value exists at
|
||||
* or null, with null meaning 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 an String
|
||||
* Gets a string at a location. This will either return a 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 an Vector
|
||||
* Gets a vector at a location. This will either return a 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 an Vector
|
||||
* Gets a 2D vector at a location. This will either return a 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 an Vector
|
||||
* Gets a string at a location. This will either return a 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 an String
|
||||
* Gets a string at a location. This will either return a 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 an double
|
||||
* Gets a double at a location. This will either return a 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 an double.
|
||||
* number types will be casted to a 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 an double
|
||||
* Gets a double at a location. This will either return a 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 an double.
|
||||
* number types will be casted to a 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 an boolean
|
||||
* Gets a boolean at a location. This will either return a 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 an boolean
|
||||
* Gets a boolean at a location. This will either return a boolean
|
||||
* or the default value. If the object at the particular location is not
|
||||
* actually a boolean, the default value will be returned.
|
||||
*
|
||||
|
@ -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.getOutsideRegion();
|
||||
throw FaweCache.INSTANCE.getOUTSIDE_REGION();
|
||||
}
|
||||
}
|
||||
final Set<BlockVector2> chunks = region.getChunks();
|
||||
|
@ -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.getMaxChecks();
|
||||
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
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.getMaxChecks();
|
||||
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw FaweCache.INSTANCE.getMaxChanges();
|
||||
throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||
}
|
||||
session.setClipboard(null);
|
||||
|
||||
|
@ -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.getMaxChecks();
|
||||
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||
}
|
||||
int affected = 0;
|
||||
try {
|
||||
|
@ -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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", 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(desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", 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) {
|
||||
|
@ -46,7 +46,6 @@ 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;
|
||||
@ -80,9 +79,7 @@ public class WorldEditCommands {
|
||||
|
||||
if (fVer != null) {
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
//noinspection MagicConstant
|
||||
Date date = new GregorianCalendar(2000 + version.year,
|
||||
version.month - 1, version.day)
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
|
||||
.getTime();
|
||||
|
||||
TextComponent dateArg = TextComponent.of(date.toLocaleString());
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
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;
|
||||
@ -26,8 +28,6 @@ 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;
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
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;
|
||||
@ -28,7 +29,6 @@ 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.
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
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;
|
||||
@ -31,7 +32,6 @@ 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;
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -130,6 +130,11 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return extent.getMaxY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return extent.getBlock(x, y, z);
|
||||
@ -172,12 +177,14 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
|
||||
throws WorldEditException {
|
||||
return extent.setBlock(position.getX(), position.getY(), position.getZ(), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return extent.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
default boolean cancel() {
|
||||
ExtentTraverser<Extent> traverser = new ExtentTraverser<>(this);
|
||||
|
||||
NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getManual());
|
||||
NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getMANUAL());
|
||||
|
||||
ExtentTraverser<Extent> next = traverser.next();
|
||||
if (next != null) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user