Skip to content

Commit

Permalink
Randomise name if using holograms to have unique scoreboard names
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 8, 2020
1 parent 202c248 commit 0a4905c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public HumanController() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public HumanController() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public HumanController() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public HumanController() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ 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
long msb = uuid.getMostSignificantBits();
Expand Down

0 comments on commit 0a4905c

Please sign in to comment.