The API is accessible through QuesteAPI.getAPI()
. You can then access the translator and manager instances.
Contains everything related to storage (i.e mysql). You can get a QuesteAccount
like so:
QuesteAPI api = QuesteAPI.getAPI();
api.getStorageManager().getAccount(...).thenAccept(account -> {
// do something with the account
});
Using removeCachedAccount
will remove the account from the cache and save its data. You will generally not need to use this as it is handled by the plugin already.
Houses all the quests. You can add, get, and remove. Example;
QuesteAPI api = QuesteAPI.getAPI();
Quest quest = api.getManagers().getQuesteCache().getQuest("QuestName");
// do something with the quest
Contains all the data relating to a player. For example, their completed and active quests.
QuesteAPI api = QuesteAPI.getAPI();
api.getManagers().getStorageManager().getAccount(...).thenAccept(account -> {
// do something with the accounts
});
To register any extensions you have made, you will need to use the QuesteRegistry
. You should do this in your onEnable
method in your plugin. Registering via the QuesteRegistry is easy, and an objective example is below;
QuesteAPI api = QuesteAPI.getAPI();
QuesteRegistry<QuestObjective> registry = (QuestObjectiveRegistry) api.getManagers().getQuestRegistry(QuestObjectiveRegistry.class);
if (registry == null) {
getLogger().warning("Unable to register objectives");
return;
}
registry.register(YourObjectiveClass.class);
You can do the same for the other registries, which are:
Queste has an easy way to allow the values within your extensions to be edited. Simply add the @GuiEditable
annotation to a field. The value is the name in the GUI, and you can also specify how the user edits this via the type
value and setting it to one of the GuiEditableType
;
CHAT,
ANVIL,
DEFAULT
Example:
@GuiEditable(value = "Locations", type = GuiEditable.GuiEditableType.CHAT)
private List<Location> locations;
You can also choose to have your class implement ICustomGuiFeedback
. This will allow you to manage how the player input is managed. Example:
@Override
public void feedback(Player player, String input) {
Location location = LocationUtils.getLocationFromInput(player, input);
if (location == null) {
player.sendMessage(ChatColor.RED + "Location could not be set: return value was null.");
return;
}
// Test if it already exists
for (Location testLocation : locations) {
int testX = testLocation.getBlockX();
int testY = testLocation.getBlockY();
int testZ = testLocation.getBlockZ();
if (location.getBlockX() == testX && location.getBlockY() == testY && location.getBlockZ() == testZ) {
locations.remove(testLocation);
return;
}
}
addLocation(location);
player.sendMessage(ChatColor.GREEN + "Location added.");
}
@Override
public String info() {
return "Enter 'TARGET' to set to eye location, 'SELF' for your location, or enter chat coordinates, " +
"e.g 'x;y;z;yaw;pitch' (yaw/pitch optional). If the location already exists, it will be removed.";
}
Create a class that extends what you want to create, for example, a quest reward would extend QuestReward
. This abstract class contains one method, award(Player)
.It also implements the IGuiEditable
interface. This allows your reward to be edited. You will need to specify a displayname in the getName
method. The award method will be called when the player needs to be given your reward. Once this class is created you can simply add it to any quest you want, in code:
QuestReward reward = new YourReward();
Quest quest = ... // Get a quest, see other api methods
quest.addReward(reward);
Example of reward class:
/**
* Reward to send messages to the player. More complex messages can use the tellraw command in {@link ConsoleCommandReward}.
*/
public final class MessageReward extends QuestReward {
private final List<String> messages;
public MessageReward() {
this.messages = Arrays.asList("Message one!", "Message two!");
}
public MessageReward(List<String> messages) {
this.messages = messages;
}
@Override
public void award(Player player) {
messages.forEach(message -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', message)));
}
@Override
public String getName() {
return "Message";
}
}
This is similar for all other extensions.
Don't forget to register your extension!