Class BedwarsAPI

java.lang.Object
de.marcely.bedwars.api.BedwarsAPI

public class BedwarsAPI extends Object
Start here!

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 Details

    • getPlugin

      public static JavaPlugin getPlugin()
      Returns the main class of the MBedwars plugin.
      Returns:
      The main class
    • getState

      public static PluginState getState()
      Returns the current run state of the MBedwars plugin.
      Returns:
      The plugin state of MBedwars
    • getGameAPI

      public static GameAPI getGameAPI()
      Contains API for game related stuff, such as arenas, lobbies, spawners, special items etc.
      Returns:
      The global GameAPI instance
    • getArenaPickerAPI

      public static ArenaPickerAPI getArenaPickerAPI()
      Contains API that is relevant to arena pickers.
      Returns:
      The global ArenaPickerAPI instance
    • getRemoteAPI

      public static RemoteAPI 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

      public static void setRemoteAPI(RemoteAPI remoteAPI)
      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

      public static PlayerDataAPI getPlayerDataAPI()
      Contains API for getting and managing player data, such as stats and achievements.
      Returns:
      The global PlayerDataAPI instance
    • getMessageAPI

      public static MessageAPI getMessageAPI()
      Contains API for managing the messaging system.
      Returns:
      The global MessageAPI instance
    • getAddonAPI

      public static AddonAPI getAddonAPI()
      Contains API for handing addons.
      Returns:
      The global AddonAPI instance
    • getNMSHelper

      public static NMSHelper getNMSHelper()
      Contains API/Helper to access NMS stuff.
      Returns:
      The global NMSHelper instance
    • getHelper

      public static Helper getHelper()
      Contains utility stuff.
      Returns:
      The global Helper instance
    • getRootCommandsCollection

      public static CommandsCollection getRootCommandsCollection()
      Returns the commands collection that contains all sub commands under /bw.
      Returns:
      The very first commands collection
    • getWorldStorage

      @Nullable public static @Nullable WorldStorage getWorldStorage(World world)
      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

      public static MigrationProcess prepareMigrationProcess(MigrationProcess.Origin origin)
      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 using MigrationProcess.run().
      Returns:
      The process that has been initiated and is ready to be run
    • getRunningMigrationProcesses

      public static MigrationProcess[] getRunningMigrationProcesses()
      Returns all running migration processes. Manually start one using prepareMigrationProcess(MigrationProcess.Origin).
      Returns:
      All running migration processes.
    • getHookedPlugins

      public static Plugin[] getHookedPlugins()
      Returns all plugin with which this plugin has created a hook.
      Returns:
      All hooked plugins
    • getHookablePluginNames

      public static String[] 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

      public static boolean createPluginHook(Plugin plugin)
      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. Otherwise false
    • removePluginHook

      public static boolean removePluginHook(Plugin plugin)
      Removes a plugin hook.
      Parameters:
      plugin - The plugin that shall be unhooked
      Returns:
      true when we succeded. If the plugin is not hooked, then false
    • onReady

      public static void onReady(Runnable runn)
      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.

      
       try {
       	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;
        }
           
      Visit the following page to find a list with all api versions and their corresponding api version: https://s.marcely.de/mbww13
      Returns:
      The API version of the currently running plugin