Add /npc hologram clear

This commit is contained in:
fullwall 2020-07-07 01:07:01 +08:00
parent ed141532a8
commit 29e6e20feb
4 changed files with 10 additions and 9 deletions

View File

@ -745,6 +745,9 @@ public class NPCCommands {
}
trait.removeLine(idx);
Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_REMOVED, idx);
} else if (args.getString(1).equalsIgnoreCase("clear")) {
trait.clear();
Messaging.sendTr(sender, Messages.HOLOGRAM_CLEARED);
} else if (args.getString(1).equalsIgnoreCase("lineheight")) {
trait.setLineHeight(args.getDouble(2));
Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_HEIGHT_SET, args.getDouble(2));

View File

@ -43,6 +43,11 @@ public class HologramTrait extends Trait {
load();
}
public void clear() {
unload();
lines.clear();
}
private NPC createHologram(String line, double heightOffset) {
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
ArmorStandTrait trait = hologramNPC.getTrait(ArmorStandTrait.class);
@ -58,13 +63,6 @@ public class HologramTrait extends Trait {
}
private double getEntityHeight() {
if (SUPPORT_GET_HEIGHT) {
try {
return npc.getEntity().getHeight();
} catch (NoSuchMethodError err) {
SUPPORT_GET_HEIGHT = false;
}
}
return NMS.getHeight(npc.getEntity());
}
@ -162,6 +160,4 @@ public class HologramTrait extends Trait {
}
hologramNPCs.clear();
}
private static boolean SUPPORT_GET_HEIGHT = true;
}

View File

@ -136,6 +136,7 @@ public class Messages {
public static final String GUIDED_WAYPOINT_EDITOR_ALREADY_TAKEN = "citizens.editors.waypoints.guided.already-taken";
public static final String GUIDED_WAYPOINT_EDITOR_BEGIN = "citizens.editors.waypoints.guided.begin";
public static final String GUIDED_WAYPOINT_EDITOR_END = "citizens.editors.waypoints.guided.end";
public static final String HOLOGRAM_CLEARED = "citizens.commands.npc.hologram.cleared";
public static final String HOLOGRAM_DESCRIBE_HEADER = "citizens.commands.npc.hologram.text-describe-header";
public static final String HOLOGRAM_INVALID_LINE = "citizens.commands.npc.hologram.invalid-text-id";
public static final String HOLOGRAM_LINE_ADD = "citizens.commands.npc.hologram.line-add";

View File

@ -96,6 +96,7 @@ citizens.commands.npc.hologram.invalid-text-id=Invalid line number.
citizens.commands.npc.hologram.line-height-set=Line height set to [[{0}]].
citizens.commands.npc.hologram.line-removed=Removed line [[{0}]].
citizens.commands.npc.hologram.line-add=Added a new hologram line: [[{0}]].
citizens.commands.npc.hologram.cleared=Hologram lines cleared.
citizens.commands.npc.horse.chest-set=The horse is now carrying a chest.
citizens.commands.npc.horse.chest-unset=The horse is no longer carrying a chest.
citizens.commands.npc.horse.color-set=The horse''s color was set to [[{0}]].