Skip to content
RonanCraft edited this page Apr 30, 2021 · 7 revisions

The Pueblos API allows to directly hook into Pueblos, allowing to change, cancel and add to the base plugin!

Getting Started

Remember to add Pueblos to your plugin.yml -> softdepend.
Pueblos does not currently have an online maven repository, so this will need to be installed manually.

Events

Events are implemented right into the Bukkit API. Just use a Listener class and @EventHandler to listen to these events.

Event Name Cancellable Description Version
PueblosEvent_ClaimAttemptCreate True Called when a claim is attempting to be created (being checked if could be created) 1.2.0
PueblosEvent_ClaimCreate False Called when a claim is successfully created 1.2.0
PueblosEvent_ClaimDelete False Called when a claim is deleted 1.2.0
PueblosEvent_ClaimResize True Called when a claim is resized 1.2.0
PueblosEvent_ClaimTeleportTo True Called when a player teleports to a claim 1.2.0
PueblosEvent_ClaimWalkedIn False Called when a player walks into a claim 1.2.1
PueblosEvent_ClaimWalkedOut False Called when a player walks out of a claim 1.2.1
PueblosEvent_CommandExecuted False Called when a pueblos "/pueblos " command is executed 1.2.0
PueblosEvent_MemberLeave True Called when a member leaves a claim 1.2.0

Tip: If an event is cancellable, when it is cancelled by any means, a message will be sent out to the executor that an external force has caused this action to fail. To disable this message, simply call the setSendCancelledMessage and set the variable to false. Here you can send your own message if you wish.

Commands

With Pueblos, you are able to extend the command library by registering your own sub command. Lets for example try to add link into the list of commands, creating /pueblos link.
This can be used by implementing PueblosCommand

import me.RonanCraft.Pueblos.player.command.PueblosCommand;

public class LinkCommand implements PueblosCommand {

    public String getName() {
        return "link";
    }

    @Override
    public void execute(CommandSender sendi, String label, String[] args) {
        sendi.sendMessage("Link Command!");
    }
}

If you would like add a help message when someone executes /pueblos help, have the class also implement PueblosCommandHelpable

import me.RonanCraft.Pueblos.player.command.PueblosCommand;
import me.RonanCraft.Pueblos.player.command.PueblosCommandHelpable;

public class LinkCommand implements PueblosCommand, PueblosCommandHelpable{

    public String getName() {
        return "link";
    }

    @Override
    public String getHelp() {
        return " - &6/%command% link &8| &7Help with linking!";
    }
}

Registering Commands

Now that we know how to create a command, we need to load the command into Pueblos.
We can achieve this by running the method load() in the following.

import me.RonanCraft.Pueblos.Pueblos;

public class AddonCommands {

    private final LinkCommand cmd = new LinkCommand();

    public load() {
        Pueblos.getInstance().getCmd().registerCommand(cmd);
    }
}

Reload Listener

Adding commands are nice, but one pet peeve is that the command gets unloaded every time someone executes /pueblos reload. So we will need a reload listener and register our commands every time this happens. Which can be detected using the PueblosEvent_CommandExecuted event.

Example:

import me.RonanCraft.Pueblos.player.command.types.CmdReload;
import me.RonanCraft.Pueblos.customevents.PueblosEvent_CommandExecuted;

public class ReloadListener implements Listener {

    public ReloadListener(Plugin pl) {
        Bukkit.getPluginManager().registerEvents(this, pl);
    }

    @EventHandler
    void reload(PueblosEvent_CommandExecuted e) {
        if (e.getCommand() instanceof CmdReload)
            AddonCommands.load();
    }
}

Getting Started


Other Resources


Other

Clone this wiki locally