mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Show welcome dialog to new players on join
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.fancyinnovations.fancydialogs.listener;
|
||||
|
||||
import com.fancyinnovations.fancydialogs.FancyDialogsPlugin;
|
||||
import com.fancyinnovations.fancydialogs.api.Dialog;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -8,7 +10,16 @@ public class PlayerJoinListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
||||
boolean isNewPlayer = !event.getPlayer().hasPlayedBefore();
|
||||
if (isNewPlayer) {
|
||||
String welcomeDialogID = FancyDialogsPlugin.get().getFancyDialogsConfig().getWelcomeDialogID();
|
||||
Dialog dialog = FancyDialogsPlugin.get().getDialogRegistry().get(welcomeDialogID);
|
||||
if (dialog != null) {
|
||||
dialog.open(event.getPlayer());
|
||||
} else {
|
||||
FancyDialogsPlugin.get().getLogger().warning("Welcome dialog with ID " + welcomeDialogID + " not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user