Class NMSAdapter
- All Implemented Interfaces:
FAWEPlatformAdapterImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidbeginChunkPacketSend(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 intcreatePalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, char[] set, CachedBukkitAdapter adapter) static intcreatePalette(int layer, int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, IntFunction<char[]> get, char[] set, CachedBukkitAdapter adapter) protected static voidendChunkPacketSend(String worldName, IntPair pair, NMSAdapter.StampLockHolder lockHolder) Releases the read lock acquired when sending a chunk packet for a chunkvoidprotected 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) -
createPalette
public static int createPalette(int layer, int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy, IntFunction<char[]> get, char[] set, CachedBukkitAdapter adapter) -
sendChunk
- Specified by:
sendChunkin 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
-