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 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user