Search in sources :

Example 6 with BarFlag

use of org.bukkit.boss.BarFlag in project Citizens2 by CitizensDev.

the class Commands method bossbar.

@Command(aliases = { "npc" }, usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]", desc = "Edit bossbar properties", modifiers = { "bossbar" }, min = 1, max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    BossBarTrait trait = npc.getTrait(BossBarTrait.class);
    if (args.hasValueFlag("color")) {
        BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
        trait.setColor(color);
    }
    if (args.hasValueFlag("title")) {
        trait.setTitle(args.getFlag("title"));
    }
    if (args.hasValueFlag("visible")) {
        trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
    }
    if (args.hasValueFlag("flags")) {
        List<BarFlag> flags = Lists.newArrayList();
        for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
            BarFlag flag = Util.matchEnum(BarFlag.values(), s);
            if (flag != null) {
                flags.add(flag);
            }
        }
        trait.setFlags(flags);
    }
}
Also used : BarColor(org.bukkit.boss.BarColor) BarFlag(org.bukkit.boss.BarFlag) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Example 7 with BarFlag

use of org.bukkit.boss.BarFlag in project Citizens2 by CitizensDev.

the class BossBarTrait method run.

@Override
public void run() {
    if (!npc.isSpawned() || !isBoss(npc.getEntity()))
        return;
    BossBar bar = NMSImpl.getBossBar(npc.getEntity());
    bar.setVisible(visible);
    if (color != null) {
        bar.setColor(color);
    }
    if (title != null) {
        bar.setTitle(title);
    }
    for (BarFlag flag : BarFlag.values()) {
        bar.removeFlag(flag);
    }
    for (BarFlag flag : flags) {
        bar.addFlag(flag);
    }
}
Also used : BarFlag(org.bukkit.boss.BarFlag) BossBar(org.bukkit.boss.BossBar)

Example 8 with BarFlag

use of org.bukkit.boss.BarFlag in project Citizens2 by CitizensDev.

the class BossBarTrait method run.

@Override
public void run() {
    if (!npc.isSpawned() || !isBoss(npc.getEntity()))
        return;
    BossBar bar = NMSImpl.getBossBar(npc.getEntity());
    bar.setVisible(visible);
    if (color != null) {
        bar.setColor(color);
    }
    if (title != null) {
        bar.setTitle(title);
    }
    for (BarFlag flag : BarFlag.values()) {
        bar.removeFlag(flag);
    }
    for (BarFlag flag : flags) {
        bar.addFlag(flag);
    }
}
Also used : BarFlag(org.bukkit.boss.BarFlag) BossBar(org.bukkit.boss.BossBar)

Aggregations

BarFlag (org.bukkit.boss.BarFlag)8 BarColor (org.bukkit.boss.BarColor)5 BossBar (org.bukkit.boss.BossBar)5 Command (net.citizensnpcs.api.command.Command)3 Requirements (net.citizensnpcs.api.command.Requirements)3 BarStyle (org.bukkit.boss.BarStyle)2 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 ListTag (com.denizenscript.denizencore.objects.core.ListTag)1 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)1 Element (net.aufdemrand.denizencore.objects.Element)1 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)1