Class NMSAdapter
- All Implemented Interfaces:
FAWEPlatformAdapterImpl
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static final class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
beginChunkPacketSend
(String worldName, IntPair pair, NMSAdapter.StampLockHolder stampedLock) Called before sending a chunk packet, filling the given stamp and stampedLock arrays' zeroth indices if the chunk packet send should go ahead.static int
createPalette
(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, char[] set, CachedBukkitAdapter adapter, short[] nonEmptyBlockCount) static int
createPalette
(int layer, int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, Function<Integer, char[]> get, char[] set, CachedBukkitAdapter adapter, short[] nonEmptyBlockCount) protected static void
endChunkPacketSend
(String worldName, IntPair pair, NMSAdapter.StampLockHolder lockHolder) Releases the read lock acquired when sending a chunk packet for a chunkvoid
protected static <LevelChunkSection>
booleansetSectionAtomic
(String worldName, IntPair pair, LevelChunkSection[] sections, LevelChunkSection expected, LevelChunkSection value, int layer) Atomically set the given chunk section to the chunk section array stored in the chunk, given the expected existing chunk section instance at the given layer position.
-
Constructor Details
-
NMSAdapter
public NMSAdapter()
-
-
Method Details
-
createPalette
public static int createPalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, char[] set, CachedBukkitAdapter adapter, short[] nonEmptyBlockCount) -
createPalette
public static int createPalette(int layer, int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, Function<Integer, char[]> get, char[] set, CachedBukkitAdapter adapter, short[] nonEmptyBlockCount) -
sendChunk
- Specified by:
sendChunk
in interfaceFAWEPlatformAdapterImpl
-
setSectionAtomic
protected static <LevelChunkSection> boolean setSectionAtomic(String worldName, IntPair pair, LevelChunkSection[] sections, LevelChunkSection expected, LevelChunkSection value, int layer) Atomically set the given chunk section to the chunk section array stored in the chunk, given the expected existing chunk section instance at the given layer position.Acquires a (FAWE-implemented only) write-lock on the chunk packet lock, waiting if required before writing, then freeing the lock. Also sets a boolean to indicate a write is waiting and therefore reads should not occur.
Utilises ConcurrentHashMap#compute for easy synchronisation for all of the above. Only tryWriteLock is used in blocks synchronised using ConcurrentHashMap methods.
- Since:
- 2.12.0
-
beginChunkPacketSend
protected static void beginChunkPacketSend(String worldName, IntPair pair, NMSAdapter.StampLockHolder stampedLock) Called before sending a chunk packet, filling the given stamp and stampedLock arrays' zeroth indices if the chunk packet send should go ahead.Chunk packets should be sent if both of the following are met: - There is no more than one current packet send ongoing - There is no chunk section "write" waiting or ongoing, which are determined by the number of readers currently locking the StampedLock (i.e. the number of sends), if the stamped lock is currently write-locked and if the boolean for waiting write is true.
Utilises ConcurrentHashMap#compute for easy synchronisation
- Since:
- 2.12.0
-
endChunkPacketSend
protected static void endChunkPacketSend(String worldName, IntPair pair, NMSAdapter.StampLockHolder lockHolder) Releases the read lock acquired when sending a chunk packet for a chunk- Since:
- 2.12.0
-