Minor code quality changes

Changed Lock to subclass ReentrantLock since that is the only subclass DelegateLock should be using. The lock should also never be null so I added an annotation in the constructor.
I also removed some code and replaced it with PaperLib code to just clean up things a little bit.
This commit is contained in:
MattBDev
2020-02-07 14:33:51 -05:00
parent 5feac07bf0
commit 0047f20d5d
5 changed files with 17 additions and 29 deletions

View File

@@ -12,6 +12,7 @@ import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
@@ -96,7 +97,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
try {
synchronized (section) {
DataPaletteBlock<IBlockData> blocks = section.getBlocks();
Lock currentLock = (Lock) fieldLock.get(blocks);
ReentrantLock currentLock = (ReentrantLock) fieldLock.get(blocks);
if (currentLock instanceof DelegateLock) {
return (DelegateLock) currentLock;
}