mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Use holograms instead of scoreboard for names
This commit is contained in:
parent
d333c98823
commit
0a58215541
@ -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().<Object> 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().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
|
||||
((LivingEntity) getEntity()).setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
|
||||
String nameplateVisible = data().<Object> 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);
|
||||
}
|
||||
|
@ -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<String> 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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user