Search in sources :

Example 1 with ScoreboardTrait

use of net.citizensnpcs.trait.ScoreboardTrait in project Citizens2 by CitizensDev.

the class NPCCommands method scoreboard.

@Command(aliases = { "npc" }, usage = "scoreboard --addtag [tags] --removetag [tags]", desc = "Controls an NPC's scoreboard", modifiers = { "scoreboard" }, min = 1, max = 1, permission = "citizens.npc.scoreboard")
public void scoreboard(CommandContext args, CommandSender sender, NPC npc) {
    ScoreboardTrait trait = npc.getOrAddTrait(ScoreboardTrait.class);
    String output = "";
    if (args.hasValueFlag("addtag")) {
        for (String tag : args.getFlag("addtag").split(",")) {
            trait.addTag(tag);
        }
        output += " " + Messaging.tr(Messages.ADDED_SCOREBOARD_TAGS, args.getFlag("addtag"));
    }
    if (args.hasValueFlag("removetag")) {
        for (String tag : args.getFlag("removetag").split(",")) {
            trait.removeTag(tag);
        }
        output += " " + Messaging.tr(Messages.REMOVED_SCOREBOARD_TAGS, args.getFlag("removetag"));
    }
    if (!output.isEmpty()) {
        Messaging.send(sender, output.trim());
    }
}
Also used : ScoreboardTrait(net.citizensnpcs.trait.ScoreboardTrait) Command(net.citizensnpcs.api.command.Command)

Aggregations

Command (net.citizensnpcs.api.command.Command)1 ScoreboardTrait (net.citizensnpcs.trait.ScoreboardTrait)1