fancydialogs: Add disable-welcome-dialog featureflag

This commit is contained in:
Oliver
2025-06-27 19:13:54 +02:00
parent 84c6661c1a
commit 0ea93f0b75
2 changed files with 10 additions and 2 deletions

View File

@@ -7,10 +7,12 @@ import de.oliver.fancylib.featureFlags.FeatureFlagConfig;
public class FDFeatureFlags { public class FDFeatureFlags {
public static final FeatureFlag DEBUG_MODE = new FeatureFlag("debug-mode", "Enable debug mode", false); public static final FeatureFlag DEBUG_MODE = new FeatureFlag("debug-mode", "Enable debug mode", false);
public static final FeatureFlag DISABLE_WELCOME_DIALOG = new FeatureFlag("disable-welcome-dialog", "Disable showing a welcome dialog when a player joins for the first time", false);
public static void load() { public static void load() {
FeatureFlagConfig config = new FeatureFlagConfig(FancyDialogsPlugin.get()); FeatureFlagConfig config = new FeatureFlagConfig(FancyDialogsPlugin.get());
config.addFeatureFlag(DEBUG_MODE); config.addFeatureFlag(DEBUG_MODE);
config.addFeatureFlag(DISABLE_WELCOME_DIALOG);
config.load(); config.load();
} }

View File

@@ -2,6 +2,7 @@ package com.fancyinnovations.fancydialogs.listener;
import com.fancyinnovations.fancydialogs.FancyDialogsPlugin; import com.fancyinnovations.fancydialogs.FancyDialogsPlugin;
import com.fancyinnovations.fancydialogs.api.Dialog; import com.fancyinnovations.fancydialogs.api.Dialog;
import com.fancyinnovations.fancydialogs.config.FDFeatureFlags;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@@ -12,6 +13,11 @@ public class PlayerJoinListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
CustomClickActionPacketListener.get().getPacketListener().inject(event.getPlayer()); CustomClickActionPacketListener.get().getPacketListener().inject(event.getPlayer());
if (FDFeatureFlags.DISABLE_WELCOME_DIALOG.isEnabled()) {
FancyDialogsPlugin.get().getFancyLogger().debug("Welcome dialog is disabled via feature flag");
return;
}
boolean hasJoinedBefore = FancyDialogsPlugin.get().getJoinedPlayersCache().checkIfPlayerJoined(event.getPlayer().getUniqueId()); boolean hasJoinedBefore = FancyDialogsPlugin.get().getJoinedPlayersCache().checkIfPlayerJoined(event.getPlayer().getUniqueId());
if (FancyDialogsPlugin.get().getFancyDialogsConfig().getLogLevel().equalsIgnoreCase("debug")) { if (FancyDialogsPlugin.get().getFancyDialogsConfig().getLogLevel().equalsIgnoreCase("debug")) {
hasJoinedBefore = false; hasJoinedBefore = false;
@@ -23,12 +29,12 @@ public class PlayerJoinListener implements Listener {
if (dialog != null) { if (dialog != null) {
dialog.open(event.getPlayer()); dialog.open(event.getPlayer());
} else { } else {
FancyDialogsPlugin.get().getLogger().warning("Welcome dialog with ID " + welcomeDialogID + " not found."); FancyDialogsPlugin.get().getLogger().warning("Welcome dialog with ID " + welcomeDialogID + " not found");
return; return;
} }
FancyDialogsPlugin.get().getJoinedPlayersCache().addPlayer(event.getPlayer().getUniqueId()); FancyDialogsPlugin.get().getJoinedPlayersCache().addPlayer(event.getPlayer().getUniqueId());
FancyDialogsPlugin.get().getFancyLogger().debug("Player " + event.getPlayer().getName() + " has joined for the first time and the welcome dialog has been opened."); FancyDialogsPlugin.get().getFancyLogger().debug("Player " + event.getPlayer().getName() + " has joined for the first time and the welcome dialog has been opened");
} }
} }