Class AdvancementMain
-
Constructor Summary
ConstructorDescriptionAdvancementMain
(@NotNull Plugin owningPlugin) Creates a newAdvancementMain
.AdvancementMain
(@NotNull Plugin owningPlugin, String libFolder) Creates a newAdvancementMain
. -
Method Summary
Modifier and TypeMethodDescriptioncreateAdvancementTab
(@NotNull Plugin plugin, @NotNull String namespace) Creates a newAdvancementTab
with the provided namespace.void
disable()
Disables the API.void
Enables the API using an in-memory database.void
enableMySQL
(String username, String password, String databaseName, String host, @Range(from=1, to=Integer.MAX_VALUE) int port, @Range(from=1, to=Integer.MAX_VALUE) int poolSize, @Range(from=250L, to=Long.MAX_VALUE) long connectionTimeout) Enables the API using a MySQL database.void
enableSQLite
(File SQLiteDatabase) Enables the API using a SQLite database.filterNamespaces
(@Nullable String input) Returns the namespaced keys of every registered advancement which namespaced key starts with the provided one.getAdvancement
(@NotNull AdvancementKey namespacedKey) Returns the advancement with the provided namespaced key.getAdvancement
(@NotNull String namespacedKey) Returns the advancement with the provided namespaced key.getAdvancement
(@NotNull String namespace, @NotNull String key) Returns the advancement with the provided namespaced key.getAdvancementTab
(@NotNull String namespace) Gets an advancement tab by its namespace.Returns an unmodifiableSet
containing the namespaces of every registered advancement tab.Gets theDatabaseManager
.Gets the owning plugin data folder.Gets theEventManager
API global instance.@NotNull net.byteflux.libby.BukkitLibraryManager
Gets the libby manager.Gets the owning pluginLogger
.Gets the plugin that instantiated the API.getPluginAdvancementTabs
(@NotNull Plugin plugin) Returns an unmodifiableCollection
of the advancement tabs registered by the provided plugin.getTabs()
Returns an unmodifiableCollection
of every registered advancement tab.boolean
isAdvancementTabRegistered
(@NotNull String namespace) Returns whether an advancement tab with the provided namespace has already been registered.static boolean
Returns whether the API is enabled.static boolean
isLoaded()
Returns whether the API is loaded.void
load()
Loads the API.void
unregisterAdvancementTab
(@NotNull String namespace) Unregisters an advancement tab.void
unregisterAdvancementTabs
(@NotNull Plugin plugin) Unregisters all the advancement tabs owned by the provided plugin.void
updatePlayer
(@NotNull Player player) Updates every advancement to a player.
-
Constructor Details
-
AdvancementMain
Creates a newAdvancementMain
.The library folder is
"plugins/pluginDirectory/.libs"
. UseAdvancementMain(Plugin, String)
to customize.- Parameters:
owningPlugin
- The plugin instantiating the API.
-
AdvancementMain
Creates a newAdvancementMain
.- Parameters:
owningPlugin
- The plugin instantiating the API.libFolder
- The name of the folder when additional libraries will be stored into. The folder is created into the plugin directory.
-
-
Method Details
-
load
Loads the API.Cannot be called twice until
disable()
is called.- Throws:
InvalidVersionException
- If the minecraft version in use is not supported by this API version.IllegalStateException
- If it is called at an invalid moment.
-
enableSQLite
Enables the API using a SQLite database.Must be called after
load()
and cannot be called twice untildisable()
is called. Also, only one enable method can be called per loading.- Parameters:
SQLiteDatabase
- The SQLite database file.- Throws:
RuntimeException
- If the enabling fails. It is a wrapper for the real exception.InvalidVersionException
- If the minecraft version in use is not supported by this API version.IllegalStateException
- If it is called at an invalid moment.
-
enableMySQL
public void enableMySQL(String username, String password, String databaseName, String host, @Range(from=1, to=Integer.MAX_VALUE) int port, @Range(from=1, to=Integer.MAX_VALUE) int poolSize, @Range(from=250L, to=Long.MAX_VALUE) long connectionTimeout) Enables the API using a MySQL database.Must be called after
load()
and cannot be called twice untildisable()
is called. Also, only one enable method can be called per loading.- Parameters:
username
- The username.password
- The password.databaseName
- The name of the database.host
- The MySQL host.port
- The MySQL port. Must be greater than zero.poolSize
- The pool size. Must be greater than zero.connectionTimeout
- The connection timeout. Must be greater or equal to 250.- Throws:
RuntimeException
- If the enabling fails. It is a wrapper for the real exception.IllegalStateException
- If it is called at an invalid moment.
-
enableInMemory
public void enableInMemory()Enables the API using an in-memory database.Must be called after
load()
and cannot be called twice untildisable()
is called. Also, only one enable method can be called per loading.- Throws:
RuntimeException
- If the enabling fails. It is a wrapper for the real exception.InvalidVersionException
- If the minecraft version in use is not supported by this API version.IllegalStateException
- If it is called at an invalid moment.
-
disable
public void disable()Disables the API.If not called after an enable method or
load()
no action is done.- Throws:
InvalidVersionException
- If the minecraft version in use is not supported by this API version.
-
createAdvancementTab
@NotNull @Contract("_, _ -> new") public @NotNull AdvancementTab createAdvancementTab(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String namespace) throws DuplicatedException Creates a newAdvancementTab
with the provided namespace. The namespace must be unique.- Parameters:
plugin
- The owner of the new tab.namespace
- The unique namespace of the tab.- Returns:
- The new
AdvancementTab
. - Throws:
DuplicatedException
- If another tab with the name already exists.IllegalStateException
- If the API is not enabled.- See Also:
-
getAdvancementTab
Gets an advancement tab by its namespace.- Parameters:
namespace
- The namespace of the advancement tab.- Returns:
- The advancement tab with the provided namespace, or
null
if there isn't any tab with such namespace. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
isAdvancementTabRegistered
Returns whether an advancement tab with the provided namespace has already been registered.- Parameters:
namespace
- The namespace of the advancement tab.- Returns:
- Whether an advancement tab with the provided namespace has already been registered.
- Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getPluginAdvancementTabs
@NotNull public @UnmodifiableView @NotNull Collection<@NotNull AdvancementTab> getPluginAdvancementTabs(@NotNull @NotNull Plugin plugin) Returns an unmodifiableCollection
of the advancement tabs registered by the provided plugin.- Parameters:
plugin
- The plugin that owns the returned advancement tabs.- Returns:
- An unmodifiable
Collection
of the advancement tabs registered by the provided plugin. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
unregisterAdvancementTab
Unregisters an advancement tab.- Parameters:
namespace
- The namespace of the advancement tab to be unregistered.- Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
unregisterAdvancementTabs
Unregisters all the advancement tabs owned by the provided plugin.- Parameters:
plugin
- The plugin that owns the advancement tabs to be unregistered.- Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getAdvancement
Returns the advancement with the provided namespaced key.- Parameters:
namespacedKey
- The namespaced key of the advancement. It must be in the format"namespace:key"
.- Returns:
- The advancement with the provided namespaced key., or
null
if it doesn't exist. - Throws:
IllegalStateException
- If the API is not enabled.IllegalArgumentException
- If the namespaced key is malformed.- See Also:
-
getAdvancement
@Nullable public @Nullable Advancement getAdvancement(@NotNull @NotNull String namespace, @NotNull @NotNull String key) Returns the advancement with the provided namespaced key.- Parameters:
namespace
- The namespace of the advancement's tab.key
- The key of the advancement.- Returns:
- The advancement with the provided namespaced key, or
null
if it doesn't exist. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getAdvancement
@Nullable public @Nullable Advancement getAdvancement(@NotNull @NotNull AdvancementKey namespacedKey) Returns the advancement with the provided namespaced key.- Parameters:
namespacedKey
- TheAdvancementKey
of the advancement.- Returns:
- The advancement with the provided namespaced key, or
null
if it doesn't exist. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getAdvancementTabNamespaces
@NotNull @Contract(pure=true) public @NotNull @UnmodifiableView Set<@NotNull String> getAdvancementTabNamespaces()Returns an unmodifiableSet
containing the namespaces of every registered advancement tab.- Returns:
- An unmodifiable
Set
containing the namespaces of every registered advancement tab. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
filterNamespaces
@NotNull @Contract(pure=true, value="_ -> new") public @NotNull List<@NotNull String> filterNamespaces(@Nullable @Nullable String input) Returns the namespaced keys of every registered advancement which namespaced key starts with the provided one.- Parameters:
input
- The partial namespaced key that acts as a filter.- Returns:
- A filtered
List
that contains only the matching namespaced keys of the registered advancements. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getTabs
Returns an unmodifiableCollection
of every registered advancement tab.- Returns:
- An unmodifiable
Collection
of every registered advancement tab. - Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
updatePlayer
Updates every advancement to a player.An advancement is updated only if its tab is shown to the player (see
AdvancementTab.isShownTo(Player)
).- Parameters:
player
- The player to be updated.- Throws:
IllegalStateException
- If the API is not enabled.- See Also:
-
getOwningPlugin
Gets the plugin that instantiated the API.- Returns:
- The plugin that instantiated the API.
-
getEventManager
Gets theEventManager
API global instance.- Returns:
- The
EventManager
API global instance.
-
getDatabaseManager
Gets theDatabaseManager
.- Returns:
- The
DatabaseManager
.
-
getLibbyManager
Gets the libby manager.Libby is a library to handle dependencies at runtime. Check it out here.
- Returns:
- The libby manager.
-
isLoaded
public static boolean isLoaded()Returns whether the API is loaded.- Returns:
- Whether the API is loaded.
-
isEnabled
public static boolean isEnabled()Returns whether the API is enabled.- Returns:
- Whether the API is enabled.
-
getLogger
Gets the owning pluginLogger
.This method is equivalent to
getOwningPlugin().getLogger()
.- Returns:
- The owning plugin
Logger
.
-
getDataFolder
Gets the owning plugin data folder.This method is equivalent to
getOwningPlugin().getDataFolder()
.- Returns:
- The owning plugin data folder.
-