Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 09:20:08 +01:00
API improvements
Dieser Commit ist enthalten in:
Ursprung
da7c21d32a
Commit
0cad7f229b
@ -3,7 +3,7 @@ package com.boydti.fawe.bukkit.adapter;
|
|||||||
import com.sk89q.worldedit.world.block.BlockID;
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class NMSAdapter<T> {
|
public class NMSAdapter {
|
||||||
public static int createPalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, int[] num_palette_buffer, char[] set) {
|
public static int createPalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, int[] num_palette_buffer, char[] set) {
|
||||||
int air = 0;
|
int air = 0;
|
||||||
int num_palette = 0;
|
int num_palette = 0;
|
||||||
|
@ -102,7 +102,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
* @param notifyAndLight notify and light if set
|
* @param notifyAndLight notify and light if set
|
||||||
* @return true if a block was likely changed
|
* @return true if a block was likely changed
|
||||||
*/
|
*/
|
||||||
boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight);
|
<B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies the simulation that the block at the given location has
|
* Notifies the simulation that the block at the given location has
|
||||||
|
@ -231,7 +231,7 @@ public interface IBukkitAdapter {
|
|||||||
* @param block The WorldEdit BlockStateHolder
|
* @param block The WorldEdit BlockStateHolder
|
||||||
* @return The Bukkit BlockData
|
* @return The Bukkit BlockData
|
||||||
*/
|
*/
|
||||||
default BlockData adapt(BlockStateHolder block) {
|
default <B extends BlockStateHolder<B>> BlockData adapt(B block) {
|
||||||
return Bukkit.createBlockData(block.getAsString());
|
return Bukkit.createBlockData(block.getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
|
|||||||
return getParent().getBlock(location);
|
return getParent().getBlock(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
|
default <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
|
||||||
return getParent().setBlock(location, state, notifyAndLight);
|
return getParent().setBlock(location, state, notifyAndLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockData adapt(BlockStateHolder block) {
|
default <B extends BlockStateHolder<B>> BlockData adapt(B block) {
|
||||||
return getParent().adapt(block);
|
return getParent().adapt(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
|||||||
* @return The Bukkit BlockData
|
* @return The Bukkit BlockData
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public BlockData adapt(BlockStateHolder block) {
|
public <B extends BlockStateHolder<B>> BlockData adapt(B block) {
|
||||||
try {
|
try {
|
||||||
checkNotNull(block);
|
checkNotNull(block);
|
||||||
int typeId = block.getInternalBlockTypeId();
|
int typeId = block.getInternalBlockTypeId();
|
||||||
|
@ -162,7 +162,6 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
return IRegistry.BLOCK.get(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
return IRegistry.BLOCK.get(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Location location) {
|
public BaseBlock getBlock(Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
@ -188,7 +187,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
|
||||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +313,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData adapt(BlockStateHolder state) {
|
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
|
||||||
try {
|
try {
|
||||||
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
||||||
return material.getCraftBlockData();
|
return material.getCraftBlockData();
|
||||||
@ -397,7 +396,7 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
public boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
|
public boolean regenerate(org.bukkit.World world, Region region, @Nullable Long seed, @Nullable BiomeType biome, EditSession editSession) {
|
||||||
WorldServer originalWorld = ((CraftWorld) world).getHandle();
|
WorldServer originalWorld = ((CraftWorld) world).getHandle();
|
||||||
ChunkProviderServer provider = originalWorld.getChunkProvider();
|
ChunkProviderServer provider = originalWorld.getChunkProvider();
|
||||||
if (!(provider instanceof ChunkProviderServer)) {
|
if (provider == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
|
||||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData adapt(BlockStateHolder state) {
|
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
|
||||||
BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial();
|
BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial();
|
||||||
return material.getCraftBlockData();
|
return material.getCraftBlockData();
|
||||||
}
|
}
|
||||||
|
@ -186,11 +186,11 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(Location location, B state, boolean notifyAndLight) {
|
||||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, B state, boolean update) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk;
|
CraftChunk craftChunk = (CraftChunk) chunk;
|
||||||
Chunk nmsChunk = craftChunk.getHandle();
|
Chunk nmsChunk = craftChunk.getHandle();
|
||||||
World nmsWorld = nmsChunk.getWorld();
|
World nmsWorld = nmsChunk.getWorld();
|
||||||
@ -312,7 +312,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData adapt(BlockStateHolder state) {
|
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
|
||||||
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial();
|
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial();
|
||||||
return material.getCraftBlockData();
|
return material.getCraftBlockData();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
@ -155,8 +156,8 @@ public class FaweAPI {
|
|||||||
* @param autoQueue If it should start dispatching before you enqueue it.
|
* @param autoQueue If it should start dispatching before you enqueue it.
|
||||||
* @return the queue extent
|
* @return the queue extent
|
||||||
*/
|
*/
|
||||||
public static IQueueExtent createQueue(World world, boolean autoQueue) {
|
public static IQueueExtent<IQueueChunk> createQueue(World world, boolean autoQueue) {
|
||||||
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
|
IQueueExtent<IQueueChunk> queue = Fawe.get().getQueueHandler().getQueue(world);
|
||||||
if (!autoQueue) {
|
if (!autoQueue) {
|
||||||
queue.disableQueue();
|
queue.disableQueue();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class Flood {
|
|||||||
|
|
||||||
public synchronized void run(World world) {
|
public synchronized void run(World world) {
|
||||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||||
IQueueExtent fq = queueHandler.getQueue(world);
|
IQueueExtent<IQueueChunk> fq = queueHandler.getQueue(world);
|
||||||
while (!chunkQueues.isEmpty()) {
|
while (!chunkQueues.isEmpty()) {
|
||||||
long firstKey = chunkQueues.firstLongKey();
|
long firstKey = chunkQueues.firstLongKey();
|
||||||
int x = MathMan.unpairIntX(firstKey);
|
int x = MathMan.unpairIntX(firstKey);
|
||||||
|
@ -3,7 +3,6 @@ package com.boydti.fawe.beta.implementation.queue;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.IBatchProcessor;
|
import com.boydti.fawe.beta.IBatchProcessor;
|
||||||
import com.boydti.fawe.beta.IChunk;
|
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.boydti.fawe.beta.IQueueChunk;
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
@ -46,7 +45,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
private ConcurrentLinkedQueue<FutureTask> syncWhenFree = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<FutureTask> syncWhenFree = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
private Map<World, WeakReference<IChunkCache<IChunkGet>>> chunkGetCache = new HashMap<>();
|
private Map<World, WeakReference<IChunkCache<IChunkGet>>> chunkGetCache = new HashMap<>();
|
||||||
private CleanableThreadLocal<IQueueExtent> queuePool = new CleanableThreadLocal<>(QueueHandler.this::create);
|
private CleanableThreadLocal<IQueueExtent<IQueueChunk>> queuePool = new CleanableThreadLocal<>(QueueHandler.this::create);
|
||||||
/**
|
/**
|
||||||
* Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the
|
* Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the
|
||||||
* server
|
* server
|
||||||
@ -263,16 +262,16 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueueExtent create() {
|
public IQueueExtent<IQueueChunk> create() {
|
||||||
return new SingleThreadQueueExtent();
|
return new SingleThreadQueueExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uncache() {
|
public void unCache() {
|
||||||
queuePool.set(null);
|
queuePool.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IQueueExtent pool() {
|
private IQueueExtent<IQueueChunk> pool() {
|
||||||
IQueueExtent queue = queuePool.get();
|
IQueueExtent<IQueueChunk> queue = queuePool.get();
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
queuePool.set(queue = queuePool.init());
|
queuePool.set(queue = queuePool.init());
|
||||||
}
|
}
|
||||||
@ -283,12 +282,12 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
|
|
||||||
public abstract void endSet(boolean parallel);
|
public abstract void endSet(boolean parallel);
|
||||||
|
|
||||||
public IQueueExtent getQueue(World world) {
|
public IQueueExtent<IQueueChunk> getQueue(World world) {
|
||||||
return getQueue(world, null);
|
return getQueue(world, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueueExtent getQueue(World world, IBatchProcessor processor) {
|
public IQueueExtent<IQueueChunk> getQueue(World world, IBatchProcessor processor) {
|
||||||
final IQueueExtent queue = pool();
|
final IQueueExtent<IQueueChunk> queue = pool();
|
||||||
IChunkCache<IChunkGet> cacheGet = getOrCreateWorldCache(world);
|
IChunkCache<IChunkGet> cacheGet = getOrCreateWorldCache(world);
|
||||||
IChunkCache<IChunkSet> set = null; // TODO cache?
|
IChunkCache<IChunkSet> set = null; // TODO cache?
|
||||||
queue.init(world, cacheGet, set);
|
queue.init(world, cacheGet, set);
|
||||||
|
@ -37,12 +37,12 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ReadOnlyClipboard of(Extent extent, final Region region) {
|
public static ReadOnlyClipboard of(Extent extent, final Region region) {
|
||||||
Fawe.get().getQueueHandler().uncache();
|
Fawe.get().getQueueHandler().unCache();
|
||||||
return of(() -> extent, region);
|
return of(() -> extent, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReadOnlyClipboard of(Extent extent, final Region region, boolean copyEntities, boolean copyBiomes) {
|
public static ReadOnlyClipboard of(Extent extent, final Region region, boolean copyEntities, boolean copyBiomes) {
|
||||||
Fawe.get().getQueueHandler().uncache();
|
Fawe.get().getQueueHandler().unCache();
|
||||||
return of(() -> extent, region, copyEntities, copyBiomes);
|
return of(() -> extent, region, copyEntities, copyBiomes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.regions.general.integrations.plotquared;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -13,12 +14,11 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
|
||||||
|
|
||||||
// TODO FIXME
|
// TODO FIXME
|
||||||
public class FaweLocalBlockQueue extends LocalBlockQueue {
|
public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||||
|
|
||||||
public final IQueueExtent IMP;
|
public final IQueueExtent<IQueueChunk> IMP;
|
||||||
private final World world;
|
private final World world;
|
||||||
private BlockVector3 mutable = new MutableBlockVector3();
|
private BlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
|||||||
super(worldName);
|
super(worldName);
|
||||||
this.world = FaweAPI.getWorld(worldName);
|
this.world = FaweAPI.getWorld(worldName);
|
||||||
IMP = Fawe.get().getQueueHandler().getQueue(world);
|
IMP = Fawe.get().getQueueHandler().getQueue(world);
|
||||||
Fawe.get().getQueueHandler().uncache();
|
Fawe.get().getQueueHandler().unCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.IBatchProcessor;
|
import com.boydti.fawe.beta.IBatchProcessor;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.implementation.processors.LimitProcessor;
|
import com.boydti.fawe.beta.implementation.processors.LimitProcessor;
|
||||||
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
||||||
@ -323,7 +324,7 @@ public class EditSessionBuilder {
|
|||||||
this.limit = limit.copy();
|
this.limit = limit.copy();
|
||||||
|
|
||||||
if (extent == null) {
|
if (extent == null) {
|
||||||
IQueueExtent queue = null;
|
IQueueExtent<IQueueChunk> queue = null;
|
||||||
World unwrapped = WorldWrapper.unwrap(world);
|
World unwrapped = WorldWrapper.unwrap(world);
|
||||||
boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
||||||
|
|
||||||
|
@ -25,10 +25,6 @@ import java.util.Locale;
|
|||||||
* The {@code TAG_Byte_Array} tag.
|
* The {@code TAG_Byte_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteArrayTag extends Tag {
|
public final class ByteArrayTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Byte_Array";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -27,10 +27,6 @@ public final class ByteTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_BYTE;
|
return NBTConstants.TYPE_BYTE;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Byte";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
|
@ -32,10 +32,6 @@ import java.util.UUID;
|
|||||||
* The {@code TAG_Compound} tag.
|
* The {@code TAG_Compound} tag.
|
||||||
*/
|
*/
|
||||||
public class CompoundTag extends Tag {
|
public class CompoundTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Compound";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -28,10 +28,6 @@ public final class DoubleTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_DOUBLE;
|
return NBTConstants.TYPE_DOUBLE;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Double";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
|
@ -23,10 +23,6 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_End} tag.
|
* The {@code TAG_End} tag.
|
||||||
*/
|
*/
|
||||||
public final class EndTag extends Tag {
|
public final class EndTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_End";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -27,10 +27,6 @@ public final class FloatTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_FLOAT;
|
return NBTConstants.TYPE_FLOAT;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Float";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final float value;
|
private final float value;
|
||||||
|
|
||||||
|
@ -23,16 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_Int_Array} tag.
|
* The {@code TAG_Int_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntArrayTag extends Tag {
|
public final class IntArrayTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Int_Array";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -27,10 +27,6 @@ public final class IntTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_INT;
|
return NBTConstants.TYPE_INT;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Int";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
|
@ -31,10 +31,6 @@ import javax.annotation.Nullable;
|
|||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
*/
|
*/
|
||||||
public class ListTag extends Tag {
|
public class ListTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_List";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -23,16 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_Long_Array} tag.
|
* The {@code TAG_Long_Array} tag.
|
||||||
*/
|
*/
|
||||||
public class LongArrayTag extends Tag {
|
public class LongArrayTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Long_Array";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -28,10 +28,6 @@ public final class LongTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_LONG;
|
return NBTConstants.TYPE_LONG;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Long";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
checkNotNull(name);
|
checkNotNull(name);
|
||||||
checkNotNull(tag);
|
checkNotNull(tag);
|
||||||
|
|
||||||
int type = tag.getTypeCode();
|
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
writeNamedTagName(name, type);
|
writeNamedTagName(name, type);
|
||||||
|
|
||||||
if (type == NBTConstants.TYPE_END) {
|
if (type == NBTConstants.TYPE_END) {
|
||||||
@ -189,7 +189,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTag(Tag tag) throws IOException {
|
public void writeTag(Tag tag) throws IOException {
|
||||||
int type = tag.getTypeCode();
|
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
os.writeByte(type);
|
os.writeByte(type);
|
||||||
writeTagPayload(tag);
|
writeTagPayload(tag);
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
* if an I/O error occurs.
|
* if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public void writeTagPayload(Tag tag) throws IOException {
|
public void writeTagPayload(Tag tag) throws IOException {
|
||||||
int type = tag.getTypeCode();
|
int type = NBTUtils.getTypeCode(tag.getClass());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NBTConstants.TYPE_END:
|
case NBTConstants.TYPE_END:
|
||||||
writeEndTagPayload((EndTag) tag);
|
writeEndTagPayload((EndTag) tag);
|
||||||
|
@ -27,10 +27,6 @@ public final class ShortTag extends NumberTag {
|
|||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
return NBTConstants.TYPE_SHORT;
|
return NBTConstants.TYPE_SHORT;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_Short";
|
|
||||||
}
|
|
||||||
|
|
||||||
private final short value;
|
private final short value;
|
||||||
|
|
||||||
|
@ -25,10 +25,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_String} tag.
|
* The {@code TAG_String} tag.
|
||||||
*/
|
*/
|
||||||
public final class StringTag extends Tag {
|
public final class StringTag extends Tag {
|
||||||
@Override
|
|
||||||
public String getTypeName() {
|
|
||||||
return "TAG_String";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeCode() {
|
public int getTypeCode() {
|
||||||
|
@ -37,6 +37,4 @@ public abstract class Tag {
|
|||||||
|
|
||||||
public abstract int getTypeCode();
|
public abstract int getTypeCode();
|
||||||
|
|
||||||
public abstract String getTypeName();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren