use paper writeLock

This commit is contained in:
Jesse Boyd 2019-05-02 04:30:32 +10:00
parent adb2c37a02
commit 18e6c09fdd
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -125,12 +125,20 @@ public class BukkitQueue extends SimpleCharQueueExtent {
fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount"); fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount");
fieldNonEmptyBlockCount.setAccessible(true); fieldNonEmptyBlockCount.setAccessible(true);
fieldLock = DataPaletteBlock.class.getDeclaredField("j"); {
fieldLock.setAccessible(true); Field tmp = null;
Field modifiersField = Field.class.getDeclaredField("modifiers"); try {
int modifiers = modifiersField.getInt(fieldLock); tmp = DataPaletteBlock.class.getDeclaredField("j");
modifiers &= ~Modifier.FINAL; } catch (NoSuchFieldException paper) {
modifiersField.setInt(fieldLock, modifiers); tmp = DataPaletteBlock.class.getDeclaredField("writeLock");
}
fieldLock = tmp;
fieldLock.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
int modifiers = modifiersField.getInt(fieldLock);
int newModifiers = modifiers & (~Modifier.FINAL);
if (newModifiers != modifiers) modifiersField.setInt(fieldLock, newModifiers);
}
Unsafe unsafe = UnsafeUtils.getUNSAFE(); Unsafe unsafe = UnsafeUtils.getUNSAFE();
CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class); CHUNKSECTION_BASE = unsafe.arrayBaseOffset(ChunkSection[].class);