Class NMSAdapter

java.lang.Object
com.fastasyncworldedit.bukkit.adapter.NMSAdapter
All Implemented Interfaces:
FAWEPlatformAdapterImpl

public class NMSAdapter extends Object implements FAWEPlatformAdapterImpl
  • 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

      public void sendChunk(IChunkGet chunk, int mask, boolean lighting)
      Specified by:
      sendChunk in interface FAWEPlatformAdapterImpl
    • 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