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
    • reload

      public static boolean reload(@Nullable @Nullable CommandSender sender)
      Attempts to reload the MBedwars plugin 1. Kick all players from all running arenas 2. Cancel any running migration processes 3. Unload data, (Achievements, Stats, Player Properties, etc) 4. Reload all MBedwars config files
      Parameters:
      sender - Who is trying to reload the plugin. Where reload progress messages will be sent
      Returns:
      if the plugin was successfully able to reload
    • 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
    • getHookAPI

      public static HookAPI getHookAPI()
      Contains API for managing hooks.
      Returns:
      The global HookAPI instance
    • getConfigurationAPI

      public static ConfigurationAPI getConfigurationAPI()
      Contains API for getting/setting configs, as well as saving config files.
      Returns:
      The global ConfigurationAPI 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.
    • 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 < 100)
       		throw new IllegalStateException();
        } catch(Exception e) {
        	getLogger().warning("Sorry, your installed version of MBedwars is not supported. Please install at least v5.4");
         	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