本帖最后由 louyukai 于 2023-4-2 19:42 编辑
paper-1.18.2-379 NewCustomCuiLianPro v4.3.2 SX-Attribute v3.6.4-SNAPSHOT
服务器启动时SX-Attribute有报错,启动完毕后NewCustomCuiLianPro不停报错刷屏,且淬炼的属性功能无法使用。
报错如下:
复制代码完整日志:
latest.log
(883.31 KB, 下载次数: 0)
已自行解决:换用attributeplus插件,属性可生效;至于报错则使用consolespanfix屏蔽,眼不见为净。
paper-1.18.2-379 NewCustomCuiLianPro v4.3.2 SX-Attribute v3.6.4-SNAPSHOT
服务器启动时SX-Attribute有报错,启动完毕后NewCustomCuiLianPro不停报错刷屏,且淬炼的属性功能无法使用。
报错如下:
- [22:25:52] [Craft Scheduler Thread - 58 - NewCustomCuiLianPro/WARN]: [NewCustomCuiLianPro] Plugin NewCustomCuiLianPro v4.3.2 generated an exception while executing task 685
- java.lang.IllegalStateException: Asynchronous Chunk getEntities call!
- at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:16) ~[paper-1.18.2.jar:git-Paper-379]
- at net.minecraft.server.level.ServerLevel.getEntities(ServerLevel.java:2353) ~[?:?]
- at org.bukkit.craftbukkit.v1_18_R2.CraftWorld.getNMSEntities(CraftWorld.java:1053) ~[paper-1.18.2.jar:git-Paper-379]
- at org.bukkit.craftbukkit.v1_18_R2.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:415) ~[paper-1.18.2.jar:git-Paper-379]
- at lvhaoxuan.custom.cuilian.runnable.SyncEffectRunnable.getEntities(SyncEffectRunnable.java:92) ~[NewCustomCuiLianPro.jar:?]
- at lvhaoxuan.custom.cuilian.runnable.ScriptRunnable.run(ScriptRunnable.java:31) ~[NewCustomCuiLianPro.jar:?]
- at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.18.2.jar:git-Paper-379]
- at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.18.2.jar:git-Paper-379]
- at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.18.2.jar:git-Paper-379]
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
- at java.lang.Thread.run(Thread.java:833) ~[?:?]

已自行解决:换用attributeplus插件,属性可生效;至于报错则使用consolespanfix屏蔽,眼不见为净。
根据错误日志,SX-Attribute 插件启动时也出现了错误,并且 NewCustomCuiLianPro 在服务器启动后不停地报错。同时,淬炼的属性功能无法使用。
首先来处理 SX-Attribute 插件的错误,这个错误虽然没有显示在你提供的错误日志中,但是可能是引发后续错误的原因。根据你提供的信息,SX-Attribute 插件的版本是 v3.6.4-SNAPSHOT,这是一个开发版或快照版,有可能存在 bug,建议升级到官方发布的稳定版。如果你已经使用了官方稳定版,可以检查配置文件是否正确,或者在论坛或社区寻求帮助。
对于 NewCustomCuiLianPro 插件报错的问题,根据错误日志显示,getEntities 方法在异步调用时导致了 IllegalStateException 异常|
解决这个问题的方法很简单,只需要将这一行代码包装在 syncTask 方法内即可。syncTask 方法可以使该操作在主线程中同步执行,避免了多线程问题。
下面是改进后的代码:
java
复制代码
private List<Entity> getEntities(Location location, double radius, Predicate<Entity> predicate) {
// 在主线程中同步执行操作
return syncTask(() -> {
List<Entity> entities = new ArrayList<>();
World world = location.getWorld();
if (world == null) {
return entities;
}
double radiusSquared = radius * radius;
for (Entity entity : world.getNearbyEntities(location, radius, radius, radius, predicate)) {
if (entity.getLocation().distanceSquared(location) <= radiusSquared) {
entities.add(entity);
}
}
return entities;
});
}
根据错误日志,看起来是在 SyncEffectRunnable 类的第 92 行发生了异常。这一行代码使用了 Bukkit API 中的 getEntities 方法来获取实体,但是当前处理线程不支持异步操作,因此导致了 IllegalStateException 异常。
如果还有其他问题,需要检查其他类和方法的实现,并查看是否有异步操作导致了类似的异常。同时,在使用 Bukkit API 时最好注意线程安全性,避免不必要的异常。
首先来处理 SX-Attribute 插件的错误,这个错误虽然没有显示在你提供的错误日志中,但是可能是引发后续错误的原因。根据你提供的信息,SX-Attribute 插件的版本是 v3.6.4-SNAPSHOT,这是一个开发版或快照版,有可能存在 bug,建议升级到官方发布的稳定版。如果你已经使用了官方稳定版,可以检查配置文件是否正确,或者在论坛或社区寻求帮助。
对于 NewCustomCuiLianPro 插件报错的问题,根据错误日志显示,getEntities 方法在异步调用时导致了 IllegalStateException 异常|
解决这个问题的方法很简单,只需要将这一行代码包装在 syncTask 方法内即可。syncTask 方法可以使该操作在主线程中同步执行,避免了多线程问题。
下面是改进后的代码:
java
复制代码
private List<Entity> getEntities(Location location, double radius, Predicate<Entity> predicate) {
// 在主线程中同步执行操作
return syncTask(() -> {
List<Entity> entities = new ArrayList<>();
World world = location.getWorld();
if (world == null) {
return entities;
}
double radiusSquared = radius * radius;
for (Entity entity : world.getNearbyEntities(location, radius, radius, radius, predicate)) {
if (entity.getLocation().distanceSquared(location) <= radiusSquared) {
entities.add(entity);
}
}
return entities;
});
}
根据错误日志,看起来是在 SyncEffectRunnable 类的第 92 行发生了异常。这一行代码使用了 Bukkit API 中的 getEntities 方法来获取实体,但是当前处理线程不支持异步操作,因此导致了 IllegalStateException 异常。
如果还有其他问题,需要检查其他类和方法的实现,并查看是否有异步操作导致了类似的异常。同时,在使用 Bukkit API 时最好注意线程安全性,避免不必要的异常。