fancynpcs: Add enable-folia-visibility-fix fflag

This commit is contained in:
Oliver
2025-11-18 11:32:06 +01:00
parent f71c783163
commit 540b3ad738
4 changed files with 10 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT")
compileOnly(project(":libraries:common")) compileOnly(project(":libraries:common"))
compileOnly(project(":libraries:config"))
compileOnly("de.oliver.FancyAnalytics:logger:0.0.8") compileOnly("de.oliver.FancyAnalytics:logger:0.0.8")
implementation("org.lushplugins:ChatColorHandler:6.0.2") implementation("org.lushplugins:ChatColorHandler:6.0.2")

View File

@@ -1,5 +1,6 @@
package de.oliver.fancynpcs.api; package de.oliver.fancynpcs.api;
import com.fancyinnovations.config.featureflags.FeatureFlagConfig;
import de.oliver.fancyanalytics.logger.ExtendedFancyLogger; import de.oliver.fancyanalytics.logger.ExtendedFancyLogger;
import de.oliver.fancylib.serverSoftware.schedulers.FancyScheduler; import de.oliver.fancylib.serverSoftware.schedulers.FancyScheduler;
import de.oliver.fancylib.translations.Translator; import de.oliver.fancylib.translations.Translator;
@@ -44,6 +45,8 @@ public interface FancyNpcsPlugin {
FancyNpcsConfig getFancyNpcConfig(); FancyNpcsConfig getFancyNpcConfig();
FeatureFlagConfig getFeatureFlagConfig();
NpcManager getNpcManager(); NpcManager getNpcManager();
AttributeManager getAttributeManager(); AttributeManager getAttributeManager();

View File

@@ -114,7 +114,7 @@ public abstract class Npc {
spawn(player); spawn(player);
// Respawn the npc to fix visibility issues on Folia // Respawn the npc to fix visibility issues on Folia
if (ServerSoftware.isFolia()) { if (ServerSoftware.isFolia() && FancyNpcsPlugin.get().getFeatureFlagConfig().getFeatureFlag("enable-folia-visibility-fix").isEnabled()) {
FancyNpcsPlugin.get().getNpcThread().schedule(() -> { FancyNpcsPlugin.get().getNpcThread().schedule(() -> {
remove(player); remove(player);
spawn(player); spawn(player);

View File

@@ -81,6 +81,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
public static final FeatureFlag PLAYER_NPCS_FEATURE_FLAG = new FeatureFlag("player-npcs", "Every player can only manage the npcs they have created", false); public static final FeatureFlag PLAYER_NPCS_FEATURE_FLAG = new FeatureFlag("player-npcs", "Every player can only manage the npcs they have created", false);
public static final FeatureFlag USE_NATIVE_THREADS_FEATURE_FLAG = new FeatureFlag("use-native-threads", "Use native threads instead of virtual threads.", false); public static final FeatureFlag USE_NATIVE_THREADS_FEATURE_FLAG = new FeatureFlag("use-native-threads", "Use native threads instead of virtual threads.", false);
public static final FeatureFlag ENABLE_DEBUG_MODE_FEATURE_FLAG = new FeatureFlag("enable-debug-mode", "Enable debug mode", false); public static final FeatureFlag ENABLE_DEBUG_MODE_FEATURE_FLAG = new FeatureFlag("enable-debug-mode", "Enable debug mode", false);
public static final FeatureFlag ENABLE_FOLIA_VISIBILITY_FIX_FEATURE_FLAG = new FeatureFlag("enable-folia-visibility-fix", "When enabled, all npcs will respawn after 100ms when they should spawn", false);
private static FancyNpcs instance; private static FancyNpcs instance;
private final ExtendedFancyLogger fancyLogger; private final ExtendedFancyLogger fancyLogger;
@@ -152,6 +153,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
featureFlagConfig.addFeatureFlag(PLAYER_NPCS_FEATURE_FLAG); featureFlagConfig.addFeatureFlag(PLAYER_NPCS_FEATURE_FLAG);
featureFlagConfig.addFeatureFlag(USE_NATIVE_THREADS_FEATURE_FLAG); featureFlagConfig.addFeatureFlag(USE_NATIVE_THREADS_FEATURE_FLAG);
featureFlagConfig.addFeatureFlag(ENABLE_DEBUG_MODE_FEATURE_FLAG); featureFlagConfig.addFeatureFlag(ENABLE_DEBUG_MODE_FEATURE_FLAG);
featureFlagConfig.addFeatureFlag(ENABLE_FOLIA_VISIBILITY_FIX_FEATURE_FLAG);
featureFlagConfig.load(); featureFlagConfig.load();
if (ENABLE_DEBUG_MODE_FEATURE_FLAG.isEnabled()) { if (ENABLE_DEBUG_MODE_FEATURE_FLAG.isEnabled()) {
@@ -595,6 +597,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin {
return textConfig; return textConfig;
} }
@Override
public FeatureFlagConfig getFeatureFlagConfig() { public FeatureFlagConfig getFeatureFlagConfig() {
return featureFlagConfig; return featureFlagConfig;
} }