mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-25 09:59:15 +00:00
General patch cleanup & New reject policy
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
package org.dreeam.leaf.async.ai;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class AsyncGoalExecutor {
|
||||
@Nullable
|
||||
public static java.util.concurrent.ExecutorService EXECUTOR;
|
||||
public static ExecutorService EXECUTOR;
|
||||
|
||||
public static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger("Leaf Async Entity Lookup");
|
||||
public static final Logger LOGGER = LogManager.getLogger("Leaf Async Entity Lookup");
|
||||
|
||||
public static void runTasks(List<Runnable> tasks) {
|
||||
for (Runnable task : tasks) {
|
||||
|
||||
@@ -6,7 +6,8 @@ import java.util.Locale;
|
||||
|
||||
public enum PathfindTaskRejectPolicy {
|
||||
FLUSH_ALL,
|
||||
CALLER_RUNS;
|
||||
CALLER_RUNS,
|
||||
DISCARD;
|
||||
|
||||
public static PathfindTaskRejectPolicy fromString(String policy) {
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class AsyncMobSpawning extends ConfigModules {
|
||||
This just offloads some expensive calculations that are required for mob spawning.""",
|
||||
"""
|
||||
是否异步化生物生成.
|
||||
在实体较多的服务器上, 异步生成可最高带来15%的性能提升.
|
||||
在实体较多的服务器上, 异步生成可最高带来 15% 的性能提升.
|
||||
须在Paper配置文件中打开 per-player-mob-spawns 才能生效.""");
|
||||
|
||||
// This prevents us from changing the value during a reload.
|
||||
|
||||
@@ -24,11 +24,13 @@ public class AsyncPathfinding extends ConfigModules {
|
||||
"""
|
||||
The policy to use when the queue is full and a new task is submitted.
|
||||
FLUSH_ALL: All pending tasks will be run on server thread.
|
||||
CALLER_RUNS: Newly submitted task will be run on server thread.""",
|
||||
CALLER_RUNS: Newly submitted task will be run on server thread.
|
||||
DISCARD: Newly submitted task will be dropped directly.""",
|
||||
"""
|
||||
当队列满时, 新提交的任务将使用以下策略处理.
|
||||
FLUSH_ALL: 所有等待中的任务都将在主线程上运行.
|
||||
CALLER_RUNS: 新提交的任务将在主线程上运行."""
|
||||
CALLER_RUNS: 新提交的任务将在主线程上运行.
|
||||
DISCARD: 新提交的任务会被直接丢弃."""
|
||||
);
|
||||
if (asyncPathfindingInitialized) {
|
||||
config.getConfigSection(getBasePath());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
package org.dreeam.leaf.config.modules.async;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import org.dreeam.leaf.async.ai.AsyncGoalExecutor;
|
||||
import org.dreeam.leaf.config.ConfigModules;
|
||||
import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
import org.dreeam.leaf.config.LeafConfig;
|
||||
import org.dreeam.leaf.config.annotations.Experimental;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
@@ -62,12 +62,11 @@ public class AsyncTargetFinding extends ConfigModules {
|
||||
0L,
|
||||
TimeUnit.MILLISECONDS,
|
||||
new ArrayBlockingQueue<>(128),
|
||||
new com.google.common.util.concurrent.ThreadFactoryBuilder()
|
||||
new ThreadFactoryBuilder()
|
||||
.setNameFormat("Leaf Async Target Finding Thread")
|
||||
.setDaemon(true)
|
||||
.setPriority(Thread.NORM_PRIORITY - 2)
|
||||
.build(),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
LeafConfig.LOGGER.info("Using 1 threads for Async Target Finding");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ public class MultithreadedTracker extends ConfigModules {
|
||||
|
||||
@Override
|
||||
public void onLoaded() {
|
||||
config.addCommentRegionBased(getBasePath(), """
|
||||
config.addCommentRegionBased(getBasePath(),
|
||||
"""
|
||||
Make entity tracking saving asynchronously, can improve performance significantly,
|
||||
especially in some massive entities in small area situations.""",
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SparklyPaperParallelWorldTicking extends ConfigModules {
|
||||
config.addCommentRegionBased(getBasePath(),
|
||||
"""
|
||||
**Experimental feature**
|
||||
Enables parallel world ticking to improve performance on multi-core systems..""",
|
||||
Enables parallel world ticking to improve performance on multi-core systems.""",
|
||||
"""
|
||||
**实验性功能**
|
||||
启用并行世界处理以提高多核 CPU 使用率.""");
|
||||
|
||||
@@ -67,8 +67,8 @@ public class FastRNG extends ConfigModules {
|
||||
Use direct random implementation instead of delegating to Java's RandomGenerator.
|
||||
This may improve performance but potentially changes RNG behavior.""",
|
||||
"""
|
||||
使用直接随机实现而不是委托给Java的RandomGenerator.
|
||||
这可能会提高性能,但可能会改变RNG行为。"""));
|
||||
使用直接随机实现而不是委派给 RandomGenerator.
|
||||
这可能会提高性能, 但可能会改变 RNG 行为."""));
|
||||
|
||||
if (enabled) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user