mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-06-28 15:35:02 +02:00
Compare commits
No commits in common. "fe5a088f7a5799401a7b035e57d976bbbf746ac6" and "9fb4b11ce77594be7d2f2022a2378192de05c4ec" have entirely different histories.
fe5a088f7a
...
9fb4b11ce7
|
@ -48,7 +48,7 @@ import net.citizensnpcs.util.Util;
|
||||||
* Manages a set of <em>holograms</em> attached to the NPC. Holograms are lines of text or items that follow the NPC at
|
* Manages a set of <em>holograms</em> attached to the NPC. Holograms are lines of text or items that follow the NPC at
|
||||||
* some offset (typically vertically offset).
|
* some offset (typically vertically offset).
|
||||||
*/
|
*/
|
||||||
// TODO: cleanup: make HologramRenderer static, possibly make it singleton-friendly?
|
// TODO: cleanup
|
||||||
@TraitName("hologramtrait")
|
@TraitName("hologramtrait")
|
||||||
public class HologramTrait extends Trait {
|
public class HologramTrait extends Trait {
|
||||||
private Location currentLoc;
|
private Location currentLoc;
|
||||||
|
@ -97,11 +97,6 @@ public class HologramTrait extends Trait {
|
||||||
reloadLineHolograms();
|
reloadLineHolograms();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTemporaryLine(String text, int ticks, HologramRenderer hr) {
|
|
||||||
lines.add(new HologramLine(text, false, ticks, hr));
|
|
||||||
reloadLineHolograms();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all hologram lines
|
* Clears all hologram lines
|
||||||
*/
|
*/
|
||||||
|
@ -400,7 +395,7 @@ public class HologramTrait extends Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HologramLine(String text, boolean persist, int ticks, HologramRenderer hr) {
|
public HologramLine(String text, boolean persist, int ticks, HologramRenderer hr) {
|
||||||
if (ITEM_MATCHER.matcher(text).find()) {
|
if (ITEM_MATCHER.matcher(text).matches()) {
|
||||||
mb = 0.21;
|
mb = 0.21;
|
||||||
mt = 0.07;
|
mt = 0.07;
|
||||||
hr = new ItemRenderer();
|
hr = new ItemRenderer();
|
||||||
|
@ -425,7 +420,7 @@ public class HologramTrait extends Trait {
|
||||||
|
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text == null ? "" : text;
|
this.text = text == null ? "" : text;
|
||||||
if (ITEM_MATCHER.matcher(text).find()) {
|
if (ITEM_MATCHER.matcher(text).matches()) {
|
||||||
renderer.destroy();
|
renderer.destroy();
|
||||||
mb = 0.21;
|
mb = 0.21;
|
||||||
mt = 0.07;
|
mt = 0.07;
|
||||||
|
@ -484,7 +479,6 @@ public class HologramTrait extends Trait {
|
||||||
@Override
|
@Override
|
||||||
protected NPC createNPC(Entity base, String name, Vector3d offset) {
|
protected NPC createNPC(Entity base, String name, Vector3d offset) {
|
||||||
Matcher itemMatcher = ITEM_MATCHER.matcher(name);
|
Matcher itemMatcher = ITEM_MATCHER.matcher(name);
|
||||||
itemMatcher.find();
|
|
||||||
Material item = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(itemMatcher.group(1), false)
|
Material item = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(itemMatcher.group(1), false)
|
||||||
: Material.matchMaterial(itemMatcher.group(1));
|
: Material.matchMaterial(itemMatcher.group(1));
|
||||||
ItemStack itemStack = new ItemStack(item, 1);
|
ItemStack itemStack = new ItemStack(item, 1);
|
||||||
|
@ -504,8 +498,7 @@ public class HologramTrait extends Trait {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void render0(NPC npc, Vector3d offset) {
|
protected void render0(NPC npc, Vector3d offset) {
|
||||||
hologram.getEntity().teleport(
|
hologram.getEntity().teleport(npc.getStoredLocation().clone().add(offset.x, offset.y, offset.z),
|
||||||
npc.getStoredLocation().clone().add(offset.x, offset.y + getEntityBbHeight(), offset.z),
|
|
||||||
TeleportCause.PLUGIN);
|
TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,13 +555,13 @@ public class HologramTrait extends Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateText(NPC npc, String raw) {
|
public void updateText(NPC npc, String text) {
|
||||||
this.text = Placeholders.replace(raw, null, npc);
|
this.text = Placeholders.replace(text, null, npc);
|
||||||
if (hologram == null)
|
if (hologram == null)
|
||||||
return;
|
return;
|
||||||
hologram.setName(text);
|
hologram.setName(text);
|
||||||
if (!Placeholders.containsPlaceholders(raw)) {
|
if (!Placeholders.containsPlaceholders(text)) {
|
||||||
hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, Messaging.stripColor(raw).length() > 0);
|
hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, Messaging.stripColor(text).length() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -607,7 +600,7 @@ public class HologramTrait extends Trait {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern ITEM_MATCHER = Pattern.compile("<item:([a-zA-Z0-9_ ]*?)([:].*?)?>");
|
private static final Pattern ITEM_MATCHER = Pattern.compile("<item:(.*?)([:].*?)?>");
|
||||||
private static boolean SUPPORTS_DISPLAY = false;
|
private static boolean SUPPORTS_DISPLAY = false;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user