mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: Always respawn npcs with a delay when using Folia
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package de.oliver.fancynpcs.api;
|
package de.oliver.fancynpcs.api;
|
||||||
|
|
||||||
import de.oliver.fancylib.RandomUtils;
|
import de.oliver.fancylib.RandomUtils;
|
||||||
|
import de.oliver.fancylib.serverSoftware.ServerSoftware;
|
||||||
import de.oliver.fancylib.translations.Translator;
|
import de.oliver.fancylib.translations.Translator;
|
||||||
import de.oliver.fancynpcs.api.actions.ActionTrigger;
|
import de.oliver.fancynpcs.api.actions.ActionTrigger;
|
||||||
import de.oliver.fancynpcs.api.actions.NpcAction;
|
import de.oliver.fancynpcs.api.actions.NpcAction;
|
||||||
@@ -18,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public abstract class Npc {
|
public abstract class Npc {
|
||||||
|
|
||||||
@@ -110,6 +112,15 @@ public abstract class Npc {
|
|||||||
|
|
||||||
if (shouldBeVisible && !wasVisible) {
|
if (shouldBeVisible && !wasVisible) {
|
||||||
spawn(player);
|
spawn(player);
|
||||||
|
|
||||||
|
// Respawn the npc to fix visibility issues on Folia
|
||||||
|
if (ServerSoftware.isFolia()) {
|
||||||
|
FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
|
||||||
|
remove(player);
|
||||||
|
spawn(player);
|
||||||
|
}, 100, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (!shouldBeVisible && wasVisible) {
|
} else if (!shouldBeVisible && wasVisible) {
|
||||||
remove(player);
|
remove(player);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user