-
Notifications
You must be signed in to change notification settings - Fork 11
Resource Manager
Spigot offers a resource section where plugin developers can upload their plugins for Bukkit, BungeeCord, Spigot or something else Minecraft related.
The SpigotSite API offers a great way to get these resources, download them and even edit them.
All actions involving spigot resources require the Resource manager.
ResourceManager resourceManager SpigotSite.getAPI().getResourceManager();
Spigot has a few resource categories. Despite them not changing that often they are not embedded in the API since they can be changed in the future. Examples of these categories are:
- Premium
- Bukkit
- BungeeCord
- ...
To get a list of all resource categories you can use the following method.
List<ResourceCategory> categories = resourceManager.getResourceCategories();
This will return a list with resource categories including the amount of resources inside that category but will not fetch a list of all resources inside it
To get a specific resource category by its identifier you can use the following method:
ResourceCategory category resourceManager.getResourceCategoryById(2);
This will first fetch a list of all resources before returning the actual resource category.
To get all resources inside a category you first have to get a recent instance of the resource category. Keep in mind this call can take several seconds depending on the amount of plugins inside the category.
List<Resource> resources = resourceManager.getResourcesByCategory(category);
You can get the resources made by a specific user. The method returns a list with resources and can be called with a user instance or user identifier.
List<Resource> resources = resourceManager.getResourcesByUser(1);
You can get the resources a user bought. This method requires an authenticated user since the information of bought resources is private.
List<Resource> resources = resourceManager.getPurchasedResources(user);