Fix NullPointerException

This commit is contained in:
filoghost 2021-12-26 16:36:44 +01:00
parent ae7591f952
commit 243bf9ea0a
5 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,9 @@ abstract class DataWatcherPacketBuilder<T> {
}
DataWatcherPacketBuilder<T> setCustomName(String customName) {
if (customName == null) {
customName = "";
}
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME, Strings.truncate(customName, 300));
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME_VISIBILITY, !Strings.isEmpty(customName));
return this;

View File

@ -30,6 +30,9 @@ abstract class DataWatcherPacketBuilder<T> {
}
DataWatcherPacketBuilder<T> setCustomName(String customName) {
if (customName == null) {
customName = "";
}
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME, Strings.truncate(customName, 300));
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME_VISIBILITY, !Strings.isEmpty(customName));
return this;

View File

@ -30,6 +30,9 @@ abstract class DataWatcherPacketBuilder<T> {
}
DataWatcherPacketBuilder<T> setCustomName(String customName) {
if (customName == null) {
customName = "";
}
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME, Strings.truncate(customName, 300));
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME_VISIBILITY, !Strings.isEmpty(customName));
return this;

View File

@ -30,6 +30,9 @@ abstract class DataWatcherPacketBuilder<T> {
}
DataWatcherPacketBuilder<T> setCustomName(String customName) {
if (customName == null) {
customName = "";
}
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME, Strings.truncate(customName, 300));
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME_VISIBILITY, Strings.isEmpty(customName) ? (byte) 0 : (byte) 1);
return this;

View File

@ -31,6 +31,9 @@ abstract class DataWatcherPacketBuilder<T> {
}
DataWatcherPacketBuilder<T> setCustomName(String customName) {
if (customName == null) {
customName = "";
}
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME, Strings.truncate(customName, 300));
packetByteBuffer.writeDataWatcherEntry(DataWatcherKey.CUSTOM_NAME_VISIBILITY, !Strings.isEmpty(customName));
return this;