mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Add disable-welcome-dialog featureflag
This commit is contained in:
@@ -7,10 +7,12 @@ import de.oliver.fancylib.featureFlags.FeatureFlagConfig;
|
||||
public class FDFeatureFlags {
|
||||
|
||||
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() {
|
||||
FeatureFlagConfig config = new FeatureFlagConfig(FancyDialogsPlugin.get());
|
||||
config.addFeatureFlag(DEBUG_MODE);
|
||||
config.addFeatureFlag(DISABLE_WELCOME_DIALOG);
|
||||
config.load();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.fancyinnovations.fancydialogs.listener;
|
||||
|
||||
import com.fancyinnovations.fancydialogs.FancyDialogsPlugin;
|
||||
import com.fancyinnovations.fancydialogs.api.Dialog;
|
||||
import com.fancyinnovations.fancydialogs.config.FDFeatureFlags;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -12,6 +13,11 @@ public class PlayerJoinListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
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());
|
||||
if (FancyDialogsPlugin.get().getFancyDialogsConfig().getLogLevel().equalsIgnoreCase("debug")) {
|
||||
hasJoinedBefore = false;
|
||||
@@ -23,12 +29,12 @@ public class PlayerJoinListener implements Listener {
|
||||
if (dialog != null) {
|
||||
dialog.open(event.getPlayer());
|
||||
} else {
|
||||
FancyDialogsPlugin.get().getLogger().warning("Welcome dialog with ID " + welcomeDialogID + " not found.");
|
||||
FancyDialogsPlugin.get().getLogger().warning("Welcome dialog with ID " + welcomeDialogID + " not found");
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user