mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-20 15:57:49 +01:00
Cache custom name for armor stands in Minecraft 1.13+
This commit is contained in:
parent
8293f8b642
commit
66666dc510
@ -41,6 +41,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -167,16 +168,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -176,16 +177,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -176,16 +177,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -178,16 +179,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return CraftChatMessage.fromComponent(super.getCustomName());
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -178,16 +179,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return CraftChatMessage.fromComponent(super.getCustomName());
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +45,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
@ -180,16 +181,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return CraftChatMessage.fromComponent(super.getCustomName());
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,8 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -156,16 +158,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,6 +46,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -166,16 +167,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,6 +46,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -166,16 +167,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,6 +44,8 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -174,16 +176,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private boolean lockTick;
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
@ -167,16 +168,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 300) {
|
||||
name = name.substring(0, 300);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,14 @@ public class Utils extends Object {
|
||||
}
|
||||
|
||||
|
||||
public static String limitLength(String s, int maxLength) {
|
||||
if (s != null && s.length() > maxLength) {
|
||||
s = s.substring(0, maxLength);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public static int floor(double num) {
|
||||
int floor = (int) num;
|
||||
return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63);
|
||||
|
Loading…
Reference in New Issue
Block a user