From 0a58215541ec85c5f7a806acdcd6ca2006d0cb8f Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 6 Jul 2020 16:37:34 +0800 Subject: [PATCH] Use holograms instead of scoreboard for names --- .../net/citizensnpcs/npc/CitizensNPC.java | 16 +++++-- .../net/citizensnpcs/trait/HologramTrait.java | 46 +++++++++++++------ .../nms/v1_10_R1/entity/HumanController.java | 16 ++----- .../nms/v1_11_R1/entity/HumanController.java | 16 ++----- .../nms/v1_12_R1/entity/HumanController.java | 14 +----- .../nms/v1_13_R2/entity/HumanController.java | 15 +----- .../nms/v1_14_R1/entity/HumanController.java | 14 +----- .../nms/v1_15_R1/entity/HumanController.java | 15 +----- .../nms/v1_16_R1/entity/HumanController.java | 16 +------ .../nms/v1_8_R3/entity/HumanController.java | 17 ++----- 10 files changed, 63 insertions(+), 122 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index 09e06e51f..b6558edb3 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -31,6 +31,7 @@ import net.citizensnpcs.api.event.NPCSpawnEvent; import net.citizensnpcs.api.event.SpawnReason; import net.citizensnpcs.api.npc.AbstractNPC; import net.citizensnpcs.api.npc.BlockBreaker; +import net.citizensnpcs.api.npc.MemoryNPCDataStore; import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPCRegistry; @@ -43,6 +44,7 @@ import net.citizensnpcs.npc.ai.CitizensNavigator; import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.trait.CurrentLocation; import net.citizensnpcs.trait.Gravity; +import net.citizensnpcs.trait.HologramTrait; import net.citizensnpcs.trait.ScoreboardTrait; import net.citizensnpcs.util.ChunkCoord; import net.citizensnpcs.util.Messages; @@ -53,6 +55,8 @@ import net.citizensnpcs.util.Util; public class CitizensNPC extends AbstractNPC { private ChunkCoord cachedCoord; private EntityController entityController; + private final NPC nameHologram = null; + private final NPCRegistry registry = CitizensAPI.createAnonymousNPCRegistry(new MemoryNPCDataStore()); private final CitizensNavigator navigator = new CitizensNavigator(this); private int updateCounter = 0; @@ -267,6 +271,12 @@ public class CitizensNPC extends AbstractNPC { NMS.setHeadYaw(getEntity(), at.getYaw()); NMS.setBodyYaw(getEntity(), at.getYaw()); + if (requiresNameHologram() && !hasTrait(HologramTrait.class)) { + addTrait(HologramTrait.class); + } + String nameplateVisible = data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); + getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible)); + // Set the spawned state getTrait(CurrentLocation.class).setLocation(at); getTrait(Spawned.class).setSpawned(true); @@ -362,10 +372,10 @@ public class CitizensNPC extends AbstractNPC { updateCounter = 0; } - if (isLiving) { - String nameplateVisible = data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); - ((LivingEntity) getEntity()).setCustomNameVisible(Boolean.parseBoolean(nameplateVisible)); + String nameplateVisible = data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); + getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible)); + if (isLiving) { NMS.setKnockbackResistance((LivingEntity) getEntity(), data().get(NPC.DEFAULT_PROTECTED_METADATA, true) ? 1D : 0D); } diff --git a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java index cd43f2a90..d01a1fdd5 100644 --- a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java @@ -3,7 +3,6 @@ package net.citizensnpcs.trait; import java.util.List; import org.bukkit.Location; -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -31,6 +30,7 @@ public class HologramTrait extends Trait { private double lineHeight = -1; @Persist private final List lines = Lists.newArrayList(); + private NPC nameNPC; private final NPCRegistry registry = CitizensAPI.createAnonymousNPCRegistry(new MemoryNPCDataStore()); public HologramTrait() { @@ -43,6 +43,20 @@ public class HologramTrait extends Trait { load(); } + private NPC createHologram(String line, double heightOffset) { + NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line); + ArmorStandTrait trait = hologramNPC.getTrait(ArmorStandTrait.class); + trait.setVisible(false); + trait.setSmall(true); + trait.setMarker(true); + trait.setGravity(false); + trait.setHasArms(false); + trait.setHasBaseplate(false); + hologramNPC.spawn(currentLoc.clone().add(0, getEntityHeight() + heightOffset, 0)); + hologramNPC.getEntity().setInvulnerable(true); + return hologramNPC; + } + private double getEntityHeight() { if (SUPPORT_GET_HEIGHT) { try { @@ -63,20 +77,13 @@ public class HologramTrait extends Trait { } private void load() { - int i = 0; currentLoc = npc.getStoredLocation(); + int i = 0; + if (npc.requiresNameHologram()) { + nameNPC = createHologram(npc.getFullName(), 0); + } for (String line : lines) { - NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, Placeholders.replace(line, null, npc)); - ArmorStandTrait trait = hologramNPC.getTrait(ArmorStandTrait.class); - trait.setVisible(false); - trait.setSmall(true); - trait.setMarker(true); - trait.setGravity(false); - trait.setHasArms(false); - trait.setHasBaseplate(false); - hologramNPC.spawn(currentLoc.clone().add(0, getEntityHeight() + getHeight(i), 0)); - hologramNPC.getEntity().setInvulnerable(true); - hologramNPCs.add(hologramNPC); + hologramNPCs.add(createHologram(Placeholders.replace(line, null, npc), getHeight(i))); i++; } } @@ -112,10 +119,15 @@ public class HologramTrait extends Trait { if (update) { currentLoc = npc.getStoredLocation(); } + if (nameNPC != null && nameNPC.isSpawned()) { + if (update) { + nameNPC.teleport(currentLoc.clone().add(0, getEntityHeight(), 0), TeleportCause.PLUGIN); + } + nameNPC.setName(npc.getFullName()); + } for (int i = 0; i < hologramNPCs.size(); i++) { NPC hologramNPC = hologramNPCs.get(i); - ArmorStand hologram = (ArmorStand) hologramNPC.getEntity(); - if (hologram == null) + if (!hologramNPC.isSpawned()) continue; if (update) { hologramNPC.teleport(currentLoc.clone().add(0, getEntityHeight() + getHeight(i), 0), @@ -138,6 +150,10 @@ public class HologramTrait extends Trait { } private void unload() { + if (nameNPC != null) { + nameNPC.destroy(); + nameNPC = null; + } if (hologramNPCs.isEmpty()) return; for (NPC npc : hologramNPCs) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/HumanController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/HumanController.java index 3ff1fd2c8..7e2301bdb 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/HumanController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/HumanController.java @@ -2,7 +2,6 @@ package net.citizensnpcs.nms.v1_10_R1.entity; import java.util.UUID; -import net.citizensnpcs.util.Util; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; @@ -16,11 +15,11 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; import net.minecraft.server.v1_10_R1.PlayerInteractManager; import net.minecraft.server.v1_10_R1.WorldServer; @@ -32,12 +31,9 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); + String coloredName = npc.getFullName(); - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +72,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/HumanController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/HumanController.java index 6ab84aa34..7227485ba 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/HumanController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/HumanController.java @@ -2,7 +2,6 @@ package net.citizensnpcs.nms.v1_11_R1.entity; import java.util.UUID; -import net.citizensnpcs.util.Util; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; @@ -16,11 +15,11 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; import net.minecraft.server.v1_11_R1.PlayerInteractManager; import net.minecraft.server.v1_11_R1.WorldServer; @@ -32,12 +31,9 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); + String coloredName = npc.getFullName(); - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +72,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/HumanController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/HumanController.java index 4a1550f61..fb86f4046 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/HumanController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/HumanController.java @@ -15,7 +15,6 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; @@ -32,12 +31,9 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); + String coloredName = npc.getFullName(); - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +72,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/HumanController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/HumanController.java index 47a92f6e5..ca9562d04 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/HumanController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/HumanController.java @@ -15,7 +15,6 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; @@ -32,12 +31,8 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); - - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String coloredName = npc.getFullName(); + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +71,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/HumanController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/HumanController.java index d5d8a9775..35cd42a8e 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/HumanController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/HumanController.java @@ -15,7 +15,6 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; @@ -32,12 +31,9 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); + String coloredName = npc.getFullName(); - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +72,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/HumanController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/HumanController.java index d519715c6..b2d365c89 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/HumanController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/HumanController.java @@ -15,7 +15,6 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; @@ -32,12 +31,8 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); - - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String coloredName = npc.getFullName(); + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +71,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_16_R1/src/main/java/net/citizensnpcs/nms/v1_16_R1/entity/HumanController.java b/v1_16_R1/src/main/java/net/citizensnpcs/nms/v1_16_R1/entity/HumanController.java index 76bfdfe1d..6fe68c4b7 100644 --- a/v1_16_R1/src/main/java/net/citizensnpcs/nms/v1_16_R1/entity/HumanController.java +++ b/v1_16_R1/src/main/java/net/citizensnpcs/nms/v1_16_R1/entity/HumanController.java @@ -15,7 +15,6 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; @@ -32,12 +31,8 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); - - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String coloredName = npc.getFullName(); + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -46,7 +41,6 @@ public class HumanController extends AbstractEntityController { msb |= 0x0000000000002000L; uuid = new UUID(msb, uuid.getLeastSignificantBits()); } - final GameProfile profile = new GameProfile(uuid, name); final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile, @@ -76,12 +70,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName); diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java index 1d7339ba4..e80d00995 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java @@ -2,7 +2,6 @@ package net.citizensnpcs.nms.v1_8_R3.entity; import java.util.UUID; -import net.citizensnpcs.util.Util; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -16,11 +15,11 @@ import com.mojang.authlib.GameProfile; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.api.util.Colorizer; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.skin.Skin; import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; import net.minecraft.server.v1_8_R3.PlayerInteractManager; import net.minecraft.server.v1_8_R3.WorldServer; @@ -32,12 +31,8 @@ public class HumanController extends AbstractEntityController { @Override protected Entity createEntity(final Location at, final NPC npc) { final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle(); - String coloredName = Colorizer.parseColors(npc.getFullName()); - - String[] nameSplit = Util.splitPlayerName(coloredName); - String name = nameSplit[0]; - - final String prefixCapture = nameSplit[1], suffixCapture = nameSplit[2]; + String coloredName = npc.getFullName(); + String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName; UUID uuid = npc.getUniqueId(); if (uuid.version() == 4) { // clear version @@ -76,12 +71,6 @@ public class HumanController extends AbstractEntityController { team = scoreboard.registerNewTeam(teamName); mode = 0; } - if (prefixCapture != null) { - team.setPrefix(prefixCapture); - } - if (suffixCapture != null) { - team.setSuffix(suffixCapture); - } team.addPlayer(handle.getBukkitEntity()); handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);