fancydialogs: Make dialog registry accessible through api

This commit is contained in:
Oliver
2025-06-19 16:57:20 +02:00
parent dbc62110f9
commit a3be8d71ce
4 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
package com.fancyinnovations.fancydialogs.api;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public interface DialogRegistry {
/**
* Registers a new dialog in the registry.
*
* @param dialog the dialog to register
*/
void register(@NotNull Dialog dialog);
/**
* Unregisters a dialog from the registry.
*
* @param id the ID of the dialog to unregister
*/
void unregister(@NotNull String id);
/**
* Retrieves a dialog by its ID.
*
* @param id the ID of the dialog to retrieve
* @return the dialog, or null if not found
*/
Dialog get(String id);
/**
* Retrieves all registered dialogs.
*
* @return a collection of all registered dialogs
*/
Collection<Dialog> getAll();
/**
* Clears all registered dialogs.
*/
void clear();
}

View File

@@ -13,4 +13,6 @@ public interface FancyDialogs {
Dialog createDialog(DialogData data);
DialogRegistry getDialogRegistry();
}

View File

@@ -203,6 +203,7 @@ public class FancyDialogsPlugin extends JavaPlugin implements FancyDialogs {
return fdConfig;
}
@Override
public DialogRegistry getDialogRegistry() {
return dialogRegistry;
}

View File

@@ -7,7 +7,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class DialogRegistry {
public class DialogRegistry implements com.fancyinnovations.fancydialogs.api.DialogRegistry {
private final Map<String, Dialog> dialogs;