Repository navigation
API
Mantice edited this page Sep 2, 2025
·
2 revisions
/**
* Get MythBoard's implementation of the {@link MythBoardAPI}
* @return {@link MythBoardAPI}
* @throws IllegalStateException if the API is not registered. Typically, this only happens if the MythBoard plugin is not enabled yet
*/
static @NotNull MythBoardAPI getApi() {
final MythBoardAPI api = Bukkit.getServicesManager().load(MythBoardAPI.class);
if (api == null) {
throw new IllegalStateException("MythBoardAPI is not registered. Please ensure the plugin is enabled!");
}
return api;
}
/**
* Get MythBoard's implementation of the {@link CriteriaManager}
* @return {@link CriteriaManager}
*/
@Nullable CriteriaManager getCriteriaManager(); /**
* Check if a specific addon is enabled
* @param addonId {@link String}
* @return <code>true</code> if enabled, <code>false</code> if disabled or not registered
*/
boolean isAddonEnabled(final @NotNull String addonId);
/**
* Get the author of any registered addon
* @param addonId {@link String}
* @return {@link String}
*/
@NotNull String getAddonAuthor(final @NotNull String addonId);
/**
* Manually register an addon to the {@link AddonManager} from YOUR plugin!<br>
* This means you're creating an addon inside your own plugin, not just a simple addon jar.<br><br>
* Addons placed inside MythBoard's addons folder are registered automatically and DO NOT need to call this method.
* @param addon The {@link MythBoardAddon} to register
* @param plugin The {@link JavaPlugin} providing the addon, can be <code>null</code>
* @return <code>true</code> if the addon was registered successfully, <code>false</code> if there was already an addon with that ID
*/
boolean register(final @NotNull MythBoardAddon addon, final @NotNull JavaPlugin plugin);/**
*
* This defines a class as the main class of any addon.<br>
* This class determines what happens when the addon is enabled or disabled.
* <br><br>
* When the MythBoard plugin is reloaded, the {@link MythBoardAddon#onDisable()} method<br>
* is called, then {@link MythBoardAddon#onEnable()}, essentially restarting the addon.
*/
public interface MythBoardAddon {
/**
* Called when enabling the addon
* @return <code>true</code> if the addon was enabled successfully, <code>false</code> if not
*/
boolean onEnable();
/**
* Called when disabling the addon
*/
void onDisable();
/**
* The ID of your addon, must be unique
* @return {@link String}
*/
@NotNull String getId();
/**
* The name of your addon
* @return {@link String}
*/
@NotNull String getName();
/**
* The author who made the addon
* @return {@link String}
*/
@NotNull String getAuthor();
}/**
* A wrapper of information regarding a {@link MythBoardAddon}
*/
public interface MythBoardAddonMeta {
/**
* Returns the addon's ID
* @return {@link String}
*/
@NotNull String getId();
/**
* Returns the addon's author
* @return {@link String}
*/
@NotNull String getAuthor();
/**
* Returns the addon's name
* @return {@link String}
*/
@NotNull String getName();
/**
* Returns the plugin that registered the addon (if any)
* @return {@link String} plugin name, or <code>null</code> if no plugin registered the addon
*/
@Nullable String getPluginName();
} /**
* Register a criteria
* @param criteria Your {@link CriteriaType}
* @param addon Your {@link MythBoardAddon}
* @return <code>true</code> if registered, <code>false</code> if a criteria with that ID already exists
*/
boolean register(final @NotNull CriteriaType criteria, final @NotNull MythBoardAddon addon);
/**
* Unregister a criteria by its ID
* @param criteriaId Your {@link CriteriaType} ID
* @param addon Your {@link MythBoardAddon}
* @return <code>true</code> if unregistered, <code>false</code> if it was not present or from your addon
*/
boolean unregister(final @NotNull String criteriaId, final @NotNull MythBoardAddon addon);
/**
* Unregister a criteria
* @param criteria Your {@link CriteriaType}
* @param addon Your {@link MythBoardAddon}
* @return <code>true</code> if unregistered, <code>false</code> if it was not present or from your addon
*/
default boolean unregister(final @NotNull CriteriaType criteria, final @NotNull MythBoardAddon addon) {
return unregister(criteria.getId(), addon);
}
/**
* Checks if a {@link CriteriaType} with this ID exists in the registry
* @param id {@link String} ID of the {@link CriteriaType}
* @return <code>true</code> if a {@link CriteriaType} exists in the registry, <code>false</code> if otherwise
*/
boolean exists(final @NotNull String id);
/**
* Get a {@link CriteriaType} from the registry by its ID
* @param id {@link String} ID for the {@link CriteriaType}
* @return {@link CriteriaType} or <code>null</code> if it does not exist within the registry
*/
@Nullable CriteriaType getCriteria(final @Nullable String id); /**
* Get the ID for this {@link CriteriaType}
* @return {@link String}
*/
@NotNull String getId();
/**
* Create an {@link CriteriaInstance} of this {@link CriteriaType}
* @param options {@link Map}<{@link String}, {@link Object}>
* @return {@link CriteriaInstance}
*/
@NotNull CriteriaInstance create(final @NotNull Map<String, Object> options); /**
* Check if a {@link Player} meets this criteria
* @param player {@link Player}
* @return <code>true</code> if the {@link Player} meets the criteria, <code>false</code> otherwise
*/
boolean meets(final @NotNull Player player);