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);
}
}
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);
}
}
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);
}
}
Aggregations