-
Notifications
You must be signed in to change notification settings - Fork 0
How to use the API (version 1.9 and older)
There are a few classes that are most important to know about if you want to use HeadsPluginAPI:
This is the starting point in getting heads from the database. This class is a singleton, so you will have to use this code to get a HeadsUtils
object:
HeadsUtils hu = HeadsUtils.getInstance();
with this object you can get heads from one of the categories or one of the heads databases. Example:
List<Head> heads = hu.getHeads(searchString);
For a full list of methods, you can look here: link
This is an interface that is used to connect to a certain heads database. It has 3 implementing classes: FreshCoalLoader
, MineSkinLoader
and MinecraftHeadsLoader
.
To select which database to select to, you have to do the following:
// for connecting to the freshcoal.com database
hu.setDatabaseLoader(new FreshCoalLoader());
// for connecting to the mineskin.org database
hu.setDatabaseLoader(new MineSkinLoader());
// for connecting to the minecraft-heads.com database (where sender is a CommandSender to send progress messages to, because of how slow this connection is)
hu.setDatabaseLoader(new MinecraftHeadsLoader(sender));
// for selecting the default database (freshcoal). Always use this after changing the connection when you are done with requesting heads from the database, for backwards compatibility!
hu.setDatabaseLoader(HeadsPlugin.getDefaultDatabaseLoader());
This class is used to get an itemstack or itemstack list of the heads. Example:
List<ItemStack> itemStacks = HeadCreator.getItemStacks(heads);
You can then use these itemstacks to give the heads to the player, show them in an inventory, etc.
For a full list of methods, click here: link
This class is a helper class to place the heads somewhere in the world. Example:
ItemStack head = ...; // the head itemstack that you want to place in the world
int x, y, z = ...; // the x, y and z coordinates for where to put the head
int rotation = ...; // how the head should be rotated
World world = ...; // the world where you want to place the head
HeadsPlacer.placeHead(itemStack, x, y, z, rotation, world, Bukkit.getLogger()); // choose the logger that you prefer, like Bukkit.getLogger() or plugin.getLogger()
For a full list of methods, click here: link