Randomise name if using holograms to have unique scoreboard names

This commit is contained in:
fullwall 2020-07-08 18:58:39 +08:00
parent 202c2487a6
commit 0a4905c0f3
8 changed files with 33 additions and 5 deletions

View File

@ -32,8 +32,11 @@ public class HumanController extends AbstractEntityController {
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -32,8 +32,11 @@ public class HumanController extends AbstractEntityController {
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -32,8 +32,11 @@ public class HumanController extends AbstractEntityController {
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -33,6 +33,10 @@ public class HumanController extends AbstractEntityController {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -32,8 +32,11 @@ public class HumanController extends AbstractEntityController {
protected Entity createEntity(final Location at, final NPC npc) {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -33,6 +33,10 @@ public class HumanController extends AbstractEntityController {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -33,6 +33,10 @@ public class HumanController extends AbstractEntityController {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -33,6 +33,10 @@ public class HumanController extends AbstractEntityController {
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
String coloredName = npc.getFullName();
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
if (npc.requiresNameHologram()) {
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
name = name.substring(0, 16);
}
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version