Search in sources :

Example 1 with NPCLoadException

use of net.citizensnpcs.api.exception.NPCLoadException in project CitizensAPI by CitizensDev.

the class Owner method load.

@Override
public void load(DataKey key) throws NPCLoadException {
    if (key.keyExists("owner")) {
        owner = key.getString("owner");
        if (key.keyExists("uuid") && !key.getString("uuid").isEmpty()) {
            uuid = UUID.fromString(key.getString("uuid"));
        }
    } else {
        try {
            owner = key.getString("");
            uuid = null;
        } catch (Exception ex) {
            owner = SERVER;
            uuid = null;
            throw new NPCLoadException("Invalid owner.");
        }
    }
}
Also used : NPCLoadException(net.citizensnpcs.api.exception.NPCLoadException) NPCLoadException(net.citizensnpcs.api.exception.NPCLoadException)

Example 2 with NPCLoadException

use of net.citizensnpcs.api.exception.NPCLoadException in project Citizens2 by CitizensDev.

the class AdminCommands method reload.

@Command(aliases = { "citizens" }, usage = "reload", desc = "Reload Citizens", modifiers = { "reload" }, min = 1, max = 1, permission = "citizens.admin")
public void reload(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    Messaging.sendTr(sender, Messages.CITIZENS_RELOADING);
    try {
        plugin.reload();
        Messaging.sendTr(sender, Messages.CITIZENS_RELOADED);
    } catch (NPCLoadException ex) {
        ex.printStackTrace();
        throw new CommandException(Messages.CITIZENS_RELOAD_ERROR);
    }
}
Also used : CommandException(net.citizensnpcs.api.command.exception.CommandException) NPCLoadException(net.citizensnpcs.api.exception.NPCLoadException) Command(net.citizensnpcs.api.command.Command)

Aggregations

NPCLoadException (net.citizensnpcs.api.exception.NPCLoadException)2 Command (net.citizensnpcs.api.command.Command)1 CommandException (net.citizensnpcs.api.command.exception.CommandException)1