mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Add /npc bossbar --viewpermission
This commit is contained in:
parent
6d6cc40efa
commit
053438bfbf
@ -51,6 +51,8 @@ public class BossBarTrait extends Trait {
|
||||
@Persist
|
||||
private String track;
|
||||
@Persist
|
||||
private String viewPermission;
|
||||
@Persist
|
||||
private boolean visible = true;
|
||||
|
||||
public BossBarTrait() {
|
||||
@ -91,6 +93,10 @@ public class BossBarTrait extends Trait {
|
||||
return track;
|
||||
}
|
||||
|
||||
public String getViewPermission() {
|
||||
return viewPermission;
|
||||
}
|
||||
|
||||
private boolean isBoss(Entity entity) {
|
||||
boolean isBoss = entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|
||||
|| entity.getType() == EntityType.GUARDIAN;
|
||||
@ -168,6 +174,8 @@ public class BossBarTrait extends Trait {
|
||||
barCache.removeAll();
|
||||
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getEntity().getLocation(),
|
||||
range > 0 ? range : Setting.BOSSBAR_RANGE.asInt())) {
|
||||
if (viewPermission != null && !player.hasPermission(viewPermission))
|
||||
continue;
|
||||
barCache.addPlayer(player);
|
||||
}
|
||||
}
|
||||
@ -201,13 +209,17 @@ public class BossBarTrait extends Trait {
|
||||
this.track = variable;
|
||||
}
|
||||
|
||||
public void setViewPermission(String viewpermission) {
|
||||
this.viewPermission = viewpermission;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder] --range [range]",
|
||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --viewpermission [permission] --flags [flags] --track [health | placeholder] --range [range]",
|
||||
desc = "Edit bossbar properties",
|
||||
modifiers = { "bossbar" },
|
||||
min = 1,
|
||||
@ -215,8 +227,8 @@ public class BossBarTrait extends Trait {
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public static void bossbar(CommandContext args, CommandSender sender, NPC npc, @Flag("style") BarStyle style,
|
||||
@Flag("track") String track, @Flag("color") BarColor color, @Flag("visible") Boolean visible,
|
||||
@Flag("range") Integer range, @Flag("title") String title, @Flag("flags") String flags)
|
||||
throws CommandException {
|
||||
@Flag("range") Integer range, @Flag("title") String title, @Flag("flags") String flags,
|
||||
@Flag("viewpermission") String viewpermission) throws CommandException {
|
||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||
if (style != null) {
|
||||
trait.setStyle(style);
|
||||
@ -236,6 +248,9 @@ public class BossBarTrait extends Trait {
|
||||
if (range != null) {
|
||||
trait.setRange(range);
|
||||
}
|
||||
if (viewpermission != null) {
|
||||
trait.setViewPermission(viewpermission);
|
||||
}
|
||||
if (flags != null) {
|
||||
List<BarFlag> parsed = Lists.newArrayList();
|
||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(flags)) {
|
||||
|
Loading…
Reference in New Issue
Block a user