mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Add nullability annotations to blockmeta
This commit is contained in:
parent
a39c7420b9
commit
d08c9391b0
@ -2,6 +2,8 @@ package com.gmail.nossr50.util.blockmeta;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
@ -19,7 +21,7 @@ public class BitSetChunkStore implements ChunkStore, Serializable {
|
|||||||
private int worldHeight;
|
private int worldHeight;
|
||||||
private UUID worldUid;
|
private UUID worldUid;
|
||||||
|
|
||||||
public BitSetChunkStore(World world, int cx, int cz) {
|
public BitSetChunkStore(@NotNull World world, int cx, int cz) {
|
||||||
this.cx = cx;
|
this.cx = cx;
|
||||||
this.cz = cz;
|
this.cz = cz;
|
||||||
this.worldUid = world.getUID();
|
this.worldUid = world.getUID();
|
||||||
@ -50,7 +52,7 @@ public class BitSetChunkStore implements ChunkStore, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getWorldId() {
|
public @NotNull UUID getWorldId() {
|
||||||
return worldUid;
|
return worldUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ public class BitSetChunkStore implements ChunkStore, Serializable {
|
|||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BitSetChunkStore deserialize(DataInputStream in) throws IOException {
|
private static BitSetChunkStore deserialize(@NotNull DataInputStream in) throws IOException {
|
||||||
int magic = in.readInt();
|
int magic = in.readInt();
|
||||||
// Can be used to determine the format of the file
|
// Can be used to determine the format of the file
|
||||||
int fileVersionNumber = in.readInt();
|
int fileVersionNumber = in.readInt();
|
||||||
@ -182,7 +184,7 @@ public class BitSetChunkStore implements ChunkStore, Serializable {
|
|||||||
|
|
||||||
public static final short STREAM_MAGIC = (short)0xACDC;
|
public static final short STREAM_MAGIC = (short)0xACDC;
|
||||||
|
|
||||||
public static ChunkStore readChunkStore(DataInputStream inputStream) throws IOException {
|
public static @NotNull ChunkStore readChunkStore(DataInputStream inputStream) throws IOException {
|
||||||
if (inputStream.markSupported())
|
if (inputStream.markSupported())
|
||||||
inputStream.mark(2);
|
inputStream.mark(2);
|
||||||
short magicNumber = inputStream.readShort();
|
short magicNumber = inputStream.readShort();
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util.blockmeta;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface ChunkManager {
|
public interface ChunkManager {
|
||||||
void closeAll();
|
void closeAll();
|
||||||
@ -14,7 +15,7 @@ public interface ChunkManager {
|
|||||||
* @param cz Chunk Z coordinate that is to be saved
|
* @param cz Chunk Z coordinate that is to be saved
|
||||||
* @param world World that the Chunk is in
|
* @param world World that the Chunk is in
|
||||||
*/
|
*/
|
||||||
void saveChunk(int cx, int cz, World world);
|
void saveChunk(int cx, int cz, @Nullable World world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the ChunkletManager a chunk is unloaded
|
* Informs the ChunkletManager a chunk is unloaded
|
||||||
@ -23,7 +24,7 @@ public interface ChunkManager {
|
|||||||
* @param cz Chunk Z coordinate that is unloaded
|
* @param cz Chunk Z coordinate that is unloaded
|
||||||
* @param world World that the chunk was unloaded in
|
* @param world World that the chunk was unloaded in
|
||||||
*/
|
*/
|
||||||
void chunkUnloaded(int cx, int cz, World world);
|
void chunkUnloaded(int cx, int cz, @Nullable World world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save all ChunkletStores related to the given world
|
* Save all ChunkletStores related to the given world
|
||||||
@ -53,7 +54,7 @@ public interface ChunkManager {
|
|||||||
* @param world World to check in
|
* @param world World to check in
|
||||||
* @return true if the given location is set to true, false if otherwise
|
* @return true if the given location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
boolean isTrue(int x, int y, int z, World world);
|
boolean isTrue(int x, int y, int z, @Nullable World world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if a given block location is set to true
|
* Check to see if a given block location is set to true
|
||||||
@ -61,7 +62,7 @@ public interface ChunkManager {
|
|||||||
* @param block Block location to check
|
* @param block Block location to check
|
||||||
* @return true if the given block location is set to true, false if otherwise
|
* @return true if the given block location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
boolean isTrue(Block block);
|
boolean isTrue(@Nullable Block block);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if a given BlockState location is set to true
|
* Check to see if a given BlockState location is set to true
|
||||||
@ -69,7 +70,7 @@ public interface ChunkManager {
|
|||||||
* @param blockState BlockState to check
|
* @param blockState BlockState to check
|
||||||
* @return true if the given BlockState location is set to true, false if otherwise
|
* @return true if the given BlockState location is set to true, false if otherwise
|
||||||
*/
|
*/
|
||||||
boolean isTrue(BlockState blockState);
|
boolean isTrue(@Nullable BlockState blockState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||||
@ -79,21 +80,21 @@ public interface ChunkManager {
|
|||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
void setTrue(int x, int y, int z, World world);
|
void setTrue(int x, int y, int z, @Nullable World world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given block location to true, should create stores as necessary if the location does not exist
|
* Set a given block location to true, should create stores as necessary if the location does not exist
|
||||||
*
|
*
|
||||||
* @param block Block location to set
|
* @param block Block location to set
|
||||||
*/
|
*/
|
||||||
void setTrue(Block block);
|
void setTrue(@Nullable Block block);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given BlockState location to true, should create stores as necessary if the location does not exist
|
* Set a given BlockState location to true, should create stores as necessary if the location does not exist
|
||||||
*
|
*
|
||||||
* @param blockState BlockState location to set
|
* @param blockState BlockState location to set
|
||||||
*/
|
*/
|
||||||
void setTrue(BlockState blockState);
|
void setTrue(@Nullable BlockState blockState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||||
@ -103,21 +104,21 @@ public interface ChunkManager {
|
|||||||
* @param z Z coordinate to set
|
* @param z Z coordinate to set
|
||||||
* @param world World to set in
|
* @param world World to set in
|
||||||
*/
|
*/
|
||||||
void setFalse(int x, int y, int z, World world);
|
void setFalse(int x, int y, int z, @Nullable World world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given block location to false, should not create stores if one does not exist for the given location
|
* Set a given block location to false, should not create stores if one does not exist for the given location
|
||||||
*
|
*
|
||||||
* @param block Block location to set
|
* @param block Block location to set
|
||||||
*/
|
*/
|
||||||
void setFalse(Block block);
|
void setFalse(@Nullable Block block);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a given BlockState location to false, should not create stores if one does not exist for the given location
|
* Set a given BlockState location to false, should not create stores if one does not exist for the given location
|
||||||
*
|
*
|
||||||
* @param blockState BlockState location to set
|
* @param blockState BlockState location to set
|
||||||
*/
|
*/
|
||||||
void setFalse(BlockState blockState);
|
void setFalse(@Nullable BlockState blockState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete any ChunkletStores that are empty
|
* Delete any ChunkletStores that are empty
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.gmail.nossr50.util.blockmeta;
|
package com.gmail.nossr50.util.blockmeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ChunkManagerFactory {
|
public class ChunkManagerFactory {
|
||||||
public static ChunkManager getChunkManager() {
|
public static @NotNull ChunkManager getChunkManager() {
|
||||||
HiddenConfig hConfig = HiddenConfig.getInstance();
|
HiddenConfig hConfig = HiddenConfig.getInstance();
|
||||||
|
|
||||||
if (hConfig.getChunkletsEnabled()) {
|
if (hConfig.getChunkletsEnabled()) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.blockmeta;
|
package com.gmail.nossr50.util.blockmeta;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public interface ChunkStore {
|
|||||||
*/
|
*/
|
||||||
int getChunkZ();
|
int getChunkZ();
|
||||||
|
|
||||||
UUID getWorldId();
|
@NotNull UUID getWorldId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the value at the given coordinates
|
* Checks the value at the given coordinates
|
||||||
|
@ -5,14 +5,16 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class HashChunkManager implements ChunkManager {
|
public class HashChunkManager implements ChunkManager {
|
||||||
private final HashMap<CoordinateKey, McMMOSimpleRegionFile> regionMap = new HashMap<>(); // Tracks active regions
|
private final @NotNull HashMap<CoordinateKey, McMMOSimpleRegionFile> regionMap = new HashMap<>(); // Tracks active regions
|
||||||
private final HashMap<CoordinateKey, HashSet<CoordinateKey>> chunkUsageMap = new HashMap<>(); // Tracks active chunks by region
|
private final @NotNull HashMap<CoordinateKey, HashSet<CoordinateKey>> chunkUsageMap = new HashMap<>(); // Tracks active chunks by region
|
||||||
private final HashMap<CoordinateKey, ChunkStore> chunkMap = new HashMap<>(); // Tracks active chunks
|
private final @NotNull HashMap<CoordinateKey, ChunkStore> chunkMap = new HashMap<>(); // Tracks active chunks
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void closeAll() {
|
public synchronized void closeAll() {
|
||||||
@ -32,7 +34,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
regionMap.clear();
|
regionMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized ChunkStore readChunkStore(World world, int cx, int cz) throws IOException {
|
private synchronized @Nullable ChunkStore readChunkStore(@NotNull World world, int cx, int cz) throws IOException {
|
||||||
McMMOSimpleRegionFile rf = getSimpleRegionFile(world, cx, cz, false);
|
McMMOSimpleRegionFile rf = getSimpleRegionFile(world, cx, cz, false);
|
||||||
if (rf == null)
|
if (rf == null)
|
||||||
return null; // If there is no region file, there can't be a chunk
|
return null; // If there is no region file, there can't be a chunk
|
||||||
@ -43,7 +45,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void writeChunkStore(World world, ChunkStore data) {
|
private synchronized void writeChunkStore(@NotNull World world, @NotNull ChunkStore data) {
|
||||||
if (!data.isDirty())
|
if (!data.isDirty())
|
||||||
return; // Don't save unchanged data
|
return; // Don't save unchanged data
|
||||||
try {
|
try {
|
||||||
@ -58,7 +60,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized McMMOSimpleRegionFile getSimpleRegionFile(World world, int cx, int cz, boolean createIfAbsent) {
|
private synchronized @Nullable McMMOSimpleRegionFile getSimpleRegionFile(World world, int cx, int cz, boolean createIfAbsent) {
|
||||||
CoordinateKey regionKey = toRegionKey(world.getUID(), cx, cz);
|
CoordinateKey regionKey = toRegionKey(world.getUID(), cx, cz);
|
||||||
|
|
||||||
return regionMap.computeIfAbsent(regionKey, k -> {
|
return regionMap.computeIfAbsent(regionKey, k -> {
|
||||||
@ -73,7 +75,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChunkStore loadChunk(int cx, int cz, World world) {
|
private @Nullable ChunkStore loadChunk(int cx, int cz, World world) {
|
||||||
try {
|
try {
|
||||||
return readChunkStore(world, cx, cz);
|
return readChunkStore(world, cx, cz);
|
||||||
}
|
}
|
||||||
@ -82,7 +84,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unloadChunk(int cx, int cz, World world) {
|
private void unloadChunk(int cx, int cz, @NotNull World world) {
|
||||||
CoordinateKey chunkKey = toChunkKey(world.getUID(), cx, cz);
|
CoordinateKey chunkKey = toChunkKey(world.getUID(), cx, cz);
|
||||||
ChunkStore chunkStore = chunkMap.remove(chunkKey); // Remove from chunk map
|
ChunkStore chunkStore = chunkMap.remove(chunkKey); // Remove from chunk map
|
||||||
if (chunkStore == null)
|
if (chunkStore == null)
|
||||||
@ -102,7 +104,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void saveChunk(int cx, int cz, World world) {
|
public synchronized void saveChunk(int cx, int cz, @Nullable World world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -120,7 +122,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void chunkUnloaded(int cx, int cz, World world) {
|
public synchronized void chunkUnloaded(int cx, int cz, @Nullable World world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -128,7 +130,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void saveWorld(World world) {
|
public synchronized void saveWorld(@Nullable World world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void unloadWorld(World world) {
|
public synchronized void unloadWorld(@Nullable World world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -185,7 +187,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isTrue(int x, int y, int z, World world) {
|
public synchronized boolean isTrue(int x, int y, int z, @Nullable World world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -214,7 +216,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isTrue(Block block) {
|
public synchronized boolean isTrue(@Nullable Block block) {
|
||||||
if (block == null)
|
if (block == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -222,7 +224,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isTrue(BlockState blockState) {
|
public synchronized boolean isTrue(@Nullable BlockState blockState) {
|
||||||
if (blockState == null)
|
if (blockState == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -230,12 +232,12 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setTrue(int x, int y, int z, World world) {
|
public synchronized void setTrue(int x, int y, int z, @Nullable World world) {
|
||||||
set(x, y, z, world, true);
|
set(x, y, z, world, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setTrue(Block block) {
|
public synchronized void setTrue(@Nullable Block block) {
|
||||||
if (block == null)
|
if (block == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -243,7 +245,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setTrue(BlockState blockState) {
|
public synchronized void setTrue(@Nullable BlockState blockState) {
|
||||||
if (blockState == null)
|
if (blockState == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -251,12 +253,12 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setFalse(int x, int y, int z, World world) {
|
public synchronized void setFalse(int x, int y, int z, @Nullable World world) {
|
||||||
set(x, y, z, world, false);
|
set(x, y, z, world, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setFalse(Block block) {
|
public synchronized void setFalse(@Nullable Block block) {
|
||||||
if (block == null)
|
if (block == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -264,14 +266,14 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setFalse(BlockState blockState) {
|
public synchronized void setFalse(@Nullable BlockState blockState) {
|
||||||
if (blockState == null)
|
if (blockState == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setFalse(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
|
setFalse(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void set(int x, int y, int z, World world, boolean value){
|
public synchronized void set(int x, int y, int z, @Nullable World world, boolean value){
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -307,15 +309,15 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
cStore.set(ix, y, iz, value);
|
cStore.set(ix, y, iz, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoordinateKey blockCoordinateToChunkKey(UUID worldUid, int x, int y, int z) {
|
private CoordinateKey blockCoordinateToChunkKey(@NotNull UUID worldUid, int x, int y, int z) {
|
||||||
return toChunkKey(worldUid, x >> 4, z >> 4);
|
return toChunkKey(worldUid, x >> 4, z >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoordinateKey toChunkKey(UUID worldUid, int cx, int cz){
|
private CoordinateKey toChunkKey(@NotNull UUID worldUid, int cx, int cz){
|
||||||
return new CoordinateKey(worldUid, cx, cz);
|
return new CoordinateKey(worldUid, cx, cz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoordinateKey toRegionKey(UUID worldUid, int cx, int cz) {
|
private CoordinateKey toRegionKey(@NotNull UUID worldUid, int cx, int cz) {
|
||||||
// Compute region index (32x32 chunk regions)
|
// Compute region index (32x32 chunk regions)
|
||||||
int rx = cx >> 5;
|
int rx = cx >> 5;
|
||||||
int rz = cz >> 5;
|
int rz = cz >> 5;
|
||||||
@ -323,11 +325,11 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class CoordinateKey {
|
private static final class CoordinateKey {
|
||||||
public final UUID worldID;
|
public final @NotNull UUID worldID;
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
|
|
||||||
private CoordinateKey(UUID worldID, int x, int z) {
|
private CoordinateKey(@NotNull UUID worldID, int x, int z) {
|
||||||
this.worldID = worldID;
|
this.worldID = worldID;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.nossr50.util.blockmeta;
|
package com.gmail.nossr50.util.blockmeta;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.zip.DeflaterOutputStream;
|
import java.util.zip.DeflaterOutputStream;
|
||||||
@ -54,7 +57,7 @@ public class McMMOSimpleRegionFile {
|
|||||||
private final int segmentMask;
|
private final int segmentMask;
|
||||||
|
|
||||||
// File location
|
// File location
|
||||||
private final File parent;
|
private final @NotNull File parent;
|
||||||
// File access
|
// File access
|
||||||
private final RandomAccessFile file;
|
private final RandomAccessFile file;
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ public class McMMOSimpleRegionFile {
|
|||||||
private final int rx;
|
private final int rx;
|
||||||
private final int rz;
|
private final int rz;
|
||||||
|
|
||||||
public McMMOSimpleRegionFile(File f, int rx, int rz) {
|
public McMMOSimpleRegionFile(@NotNull File f, int rx, int rz) {
|
||||||
this.rx = rx;
|
this.rx = rx;
|
||||||
this.rz = rz;
|
this.rz = rz;
|
||||||
this.parent = f;
|
this.parent = f;
|
||||||
@ -104,7 +107,7 @@ public class McMMOSimpleRegionFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized DataOutputStream getOutputStream(int x, int z) {
|
public synchronized @NotNull DataOutputStream getOutputStream(int x, int z) {
|
||||||
int index = getChunkIndex(x, z); // Get chunk index
|
int index = getChunkIndex(x, z); // Get chunk index
|
||||||
return new DataOutputStream(new DeflaterOutputStream(new McMMOSimpleChunkBuffer(this, index)));
|
return new DataOutputStream(new DeflaterOutputStream(new McMMOSimpleChunkBuffer(this, index)));
|
||||||
}
|
}
|
||||||
@ -144,7 +147,7 @@ public class McMMOSimpleRegionFile {
|
|||||||
file.writeInt(chunkNumBytes[index]);
|
file.writeInt(chunkNumBytes[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized DataInputStream getInputStream(int x, int z) throws IOException {
|
public synchronized @Nullable DataInputStream getInputStream(int x, int z) throws IOException {
|
||||||
int index = getChunkIndex(x, z); // Get chunk index
|
int index = getChunkIndex(x, z); // Get chunk index
|
||||||
int byteLength = chunkNumBytes[index]; // Get byte length of data
|
int byteLength = chunkNumBytes[index]; // Get byte length of data
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import com.gmail.nossr50.util.blockmeta.*;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
@ -227,7 +228,7 @@ public class ChunkStoreTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getWorldId() {
|
public @NotNull UUID getWorldId() {
|
||||||
return worldUid;
|
return worldUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user