refactor: rename compatibility helper classes for clarity
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public final class CarpetCalculatorCompatHelper {
|
||||
public final class CarpetCalculatorHelper {
|
||||
|
||||
public static boolean handleChat(ServerPlayer player, String rawMessage) {
|
||||
if (!GeneralCompatConfig.simpleInGameCalculator || !rawMessage.startsWith("=")) {
|
||||
+2
-2
@@ -10,8 +10,7 @@ import org.leavesmc.leaves.protocol.CarpetServerProtocol;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// WARNING: THIS FILE NEED TO FULLY REWRITTEN
|
||||
public final class CarpetCompatSync {
|
||||
public final class CarpetProtocalDataBase {
|
||||
private static boolean init = false;
|
||||
|
||||
public static void apply() {
|
||||
@@ -24,6 +23,7 @@ public final class CarpetCompatSync {
|
||||
return configuredLoggers == null ? List.of() : List.copyOf(configuredLoggers);
|
||||
}
|
||||
|
||||
// Rules may be need update because we redirected many config path & the carpet version updated
|
||||
private static void registerProtocolRules() {
|
||||
CarpetServerProtocol.CarpetRules.beginBatch();
|
||||
try {
|
||||
+1
-1
@@ -2,7 +2,7 @@ package fun.bm.lophine.carpet;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class InteractionUpdateCompatHelper {
|
||||
public final class InteractionUpdateHelper {
|
||||
private static final ThreadLocal<Integer> SUPPRESSED_DEPTH = ThreadLocal.withInitial(() -> 0);
|
||||
|
||||
public static boolean shouldSkipUpdates() {
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public final class LagFreeSpawningCompatHelper {
|
||||
public final class LagFreeSpawningHelper {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Map<RegionizedWorldData, Map<EntityType<?>, Mob>> PRECOOKED_MOBS = new WeakHashMap<>();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import fun.bm.lophine.carpet.CarpetCompatSync;
|
||||
import fun.bm.lophine.carpet.CarpetProtocalDataBase;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
@@ -193,6 +193,6 @@ public class GeneralCompatConfig implements IConfigModule {
|
||||
@Override
|
||||
public void beforeFinalLoad() {
|
||||
// send changes to client
|
||||
CarpetCompatSync.apply();
|
||||
CarpetProtocalDataBase.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ public enum GlobalEntitiesCounterType {
|
||||
DEFAULT_ASYNC(true, true, true),
|
||||
PRECISE(true, false, false);
|
||||
|
||||
private boolean enabled;
|
||||
private boolean async;
|
||||
private boolean defaultModule;
|
||||
private final boolean enabled;
|
||||
private final boolean async;
|
||||
private final boolean defaultModule;
|
||||
|
||||
private GlobalEntitiesCounterType(boolean enabled, boolean async, boolean defaultModule) {
|
||||
this.enabled = enabled;
|
||||
|
||||
+8
-8
@@ -23,10 +23,10 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 一个简单的基于folia的RegionizedTaskQueue引用计数的轻量ticket区块加载器
|
||||
* 用于在folia传送门搜索的高频率scheduleChunkLoad的调用下减少ticket操作从而减轻锁负载
|
||||
* 大部分内容物均取自folia的RegionizedTaskQueue(引用计数), ttl机制取自我的优化
|
||||
*
|
||||
* 一个简单的基于folia的RegionizedTaskQueue引用计数的轻量ticket区块加载器
|
||||
* 用于在folia传送门搜索的高频率scheduleChunkLoad的调用下减少ticket操作从而减轻锁负载
|
||||
* 大部分内容物均取自folia的RegionizedTaskQueue(引用计数), ttl机制取自我的优化
|
||||
*
|
||||
* @see io.papermc.paper.threadedregions.RegionizedTaskQueue
|
||||
* @see Entity#findOrCreatePortalAsync(ServerLevel, BlockPos, ServerLevel, Entity.PortalType, CallbackCompletable)
|
||||
*/
|
||||
@@ -164,7 +164,7 @@ public class ReferenceCountingChunkLoader {
|
||||
RegionizedServer.getInstance().taskQueue.queueChunkTask(this.world, chunkX, chunkZ, () -> {
|
||||
try {
|
||||
callback.accept(cached);
|
||||
}finally {
|
||||
} finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}, priority);
|
||||
@@ -179,7 +179,7 @@ public class ReferenceCountingChunkLoader {
|
||||
increased.cached = chunk;
|
||||
|
||||
callback.accept(chunk);
|
||||
}finally {
|
||||
} finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public class ReferenceCountingChunkLoader {
|
||||
|
||||
public boolean addCount() {
|
||||
int failures = 0;
|
||||
for (long curr = this.referenceCount.get();;) {
|
||||
for (long curr = this.referenceCount.get(); ; ) {
|
||||
for (int i = 0; i < failures; ++i) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
@@ -277,7 +277,7 @@ public class ReferenceCountingChunkLoader {
|
||||
|
||||
if (curr == (curr = this.referenceCount.compareAndExchange(curr, curr + 1L))) {
|
||||
int ttlFailures = 0;
|
||||
for (long currTTL = this.referenceTTL.get();;) {
|
||||
for (long currTTL = this.referenceTTL.get(); ; ) {
|
||||
for (int i = 0; i < ttlFailures; i++) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user