Improves NMS error handling when the server version is not supported

This commit is contained in:
Christian Koop 2023-06-14 21:25:19 +02:00
parent aef95bb831
commit 7f0f2a1acb
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
1 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package com.songoda.epicanchors.tasks;
import com.songoda.core.nms.NmsManager;
import com.craftaro.core.nms.Nms;
import com.craftaro.core.nms.UnsupportedServerVersionException;
import com.songoda.epicanchors.Anchor;
import com.songoda.epicanchors.AnchorManager;
import com.songoda.epicanchors.EpicAnchors;
@ -104,8 +105,8 @@ public class AnchorTask extends BukkitRunnable {
}
try {
NmsManager.getWorld().tickInactiveSpawners(chunk, TASK_INTERVAL);
} catch (ReflectiveOperationException ex) {
Nms.getImplementations().getWorld().tickInactiveSpawners(chunk, TASK_INTERVAL);
} catch (UnsupportedServerVersionException | ReflectiveOperationException | IncompatibleClassChangeError ex) {
this.plugin.getLogger().log(Level.SEVERE, ex,
() -> "Failed to do spawner ticks on this server implementation(/version) - " +
"Skipping further spawner ticks.");
@ -120,8 +121,8 @@ public class AnchorTask extends BukkitRunnable {
}
try {
NmsManager.getWorld().randomTickChunk(chunk, randomTicks);
} catch (ReflectiveOperationException ex) {
Nms.getImplementations().getWorld().randomTickChunk(chunk, randomTicks);
} catch (UnsupportedServerVersionException | ReflectiveOperationException | IncompatibleClassChangeError ex) {
this.plugin.getLogger().log(Level.SEVERE, ex,
() -> "Failed to do random ticks on this server implementation(/version) - " +
"Skipping further random ticks.");