Class BedwarsAPI
This API is build in a tree-like-structure. Everything is ordered and you can access most of it by starting here. Some classes, mainly enums, are still directly accessible.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
createPluginHook(Plugin plugin)
Tries to create a hook with a plugin.static AddonAPI
Contains API for handing addons.static int
Returns the current version of the API.static ArenaPickerAPI
Contains API that is relevant to arena pickers.static GameAPI
Contains API for game related stuff, such as arenas, lobbies, spawners, special items etc.static Helper
Contains utility stuff.static String[]
Returns the names of all plugin with which we can create a hook.static Plugin[]
Returns all plugin with which this plugin has created a hook.static MessageAPI
Contains API for managing the messaging system.static NMSHelper
Contains API/Helper to access NMS stuff.static PlayerDataAPI
Contains API for getting and managing player data, such as stats and achievements.static JavaPlugin
Returns the main class of the MBedwars plugin.static RemoteAPI
Contains API that is being used for communicating with other servers in a Proxy network.static CommandsCollection
Returns the commands collection that contains all sub commands under /bw.static MigrationProcess[]
Returns all running migration processes.static PluginState
getState()
Returns the current run state of the MBedwars plugin.static @Nullable WorldStorage
getWorldStorage(World world)
A world storage contains anything needed for creating custom entities or blocks.static void
Calls the callback when the API is ready to use.static MigrationProcess
Initiate a process of migration from another system, such as a Bedwars plugin or storage system.static boolean
removePluginHook(Plugin plugin)
Removes a plugin hook.static void
setRemoteAPI(RemoteAPI remoteAPI)
Implement your own remote API.
-
Method Details
-
getPlugin
Returns the main class of the MBedwars plugin.- Returns:
- The main class
-
getState
Returns the current run state of the MBedwars plugin.- Returns:
- The plugin state of MBedwars
-
getGameAPI
Contains API for game related stuff, such as arenas, lobbies, spawners, special items etc.- Returns:
- The global GameAPI instance
-
getArenaPickerAPI
Contains API that is relevant to arena pickers.- Returns:
- The global ArenaPickerAPI instance
-
getRemoteAPI
Contains API that is being used for communicating with other servers in a Proxy network.Generally, this API only gets replaced by the ProxySync addon. If it is not, because it for instance not installed, a general-use implementation will be used. In that case, it will for instance only return all arenas of the local server. This makes adding support for both solutions very easy, as you can just use this API if you plan to add support for remote servers, or just
getGameAPI()
if you don't.- Returns:
- The remote API. The API may change during the runtime
-
setRemoteAPI
Implement your own remote API.Generally, this API only gets replaced by the ProxySync addon. If it is not, because it for instance not installed, a general-use implementation will be used. In that case, it will for instance only return all arenas of the local server. This makes adding support for both solutions very easy, as you can just use this API if you plan to add support for remote servers, or just
getGameAPI()
if you don't.- Parameters:
remoteAPI
- The new remote API
-
getPlayerDataAPI
Contains API for getting and managing player data, such as stats and achievements.- Returns:
- The global PlayerDataAPI instance
-
getMessageAPI
Contains API for managing the messaging system.- Returns:
- The global MessageAPI instance
-
getAddonAPI
Contains API for handing addons.- Returns:
- The global AddonAPI instance
-
getNMSHelper
Contains API/Helper to access NMS stuff.- Returns:
- The global NMSHelper instance
-
getHelper
Contains utility stuff.- Returns:
- The global Helper instance
-
getRootCommandsCollection
Returns the commands collection that contains all sub commands under /bw.- Returns:
- The very first commands collection
-
getWorldStorage
A world storage contains anything needed for creating custom entities or blocks. This may include a ranking statue or a holographic dealer.- Parameters:
world
- There's an unique storage for every world. This parameter specifies which one we want- Returns:
- The storage corresponding to the given world.
null
if the world doesn't exist anymore
-
prepareMigrationProcess
Initiate a process of migration from another system, such as a Bedwars plugin or storage system. This doesn't effectively start the process, you must do that usingMigrationProcess.run()
.- Returns:
- The process that has been initiated and is ready to be run
-
getRunningMigrationProcesses
Returns all running migration processes. Manually start one usingprepareMigrationProcess(MigrationProcess.Origin)
.- Returns:
- All running migration processes.
-
getHookedPlugins
Returns all plugin with which this plugin has created a hook.- Returns:
- All hooked plugins
-
getHookablePluginNames
Returns the names of all plugin with which we can create a hook.Includes names of plugins that aren't installed on the server.
- Returns:
- Names of all plugins that we can hook into
-
createPluginHook
Tries to create a hook with a plugin.Reasons for failure:
- Plugin is already hooked
-PluginHookEvent
got cancelled
- Plugin is not supported (not hookable, version/version not supported)
- An error occured while we tried to hook into it
- It may only be hooked into after all arenas have been loaded
- Plugin is not enabled- Parameters:
plugin
- The plugin with a hook shall be created- Returns:
true
when we succeded. Otherwisefalse
-
removePluginHook
Removes a plugin hook.- Parameters:
plugin
- The plugin that shall be unhooked- Returns:
true
when we succeded. If the plugin is not hooked, thenfalse
-
onReady
Calls the callback when the API is ready to use.This event can be called at any situation (given that MBedwars is even loaded) and it will always get an response.
We HIGHLY encourage you to use it as MBedwars can take some time until it's fully loaded. Using
ConfigsLoadEvent
is not an alternative as it does not get called when your plugin is getting reloaded afterwards.- Parameters:
runn
- The callback
-
getAPIVersion
public static int getAPIVersion()Returns the current version of the API.You can for instance use it during the enabling process of your plugin to identify if the latest supported version of MBedwars is installed.
Visit the following page to find a list with all api versions and their corresponding api version: https://s.marcely.de/mbww13try { Class apiClass = Class.forName("de.marcely.bedwars.api.BedwarsAPI"); int apiVersion = (int) apiClass.getMethod("getAPIVersion").invoke(null); if (apiVersion < 1) throw new IllegalStateException(); } catch(Exception e) { getLogger().warning("Sorry, your installed version of MBedwars is not supported. Please install at least v5.0"); Bukkit.getPluginManager().disable(this); return; }
- Returns:
- The API version of the currently running plugin
-