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