ProtocolLib

3M Downloads

set custom name datawatcher

corentingosselin opened this issue ยท 3 comments

commented
  • [ Y] You're using the latest build for your server version
  • [ Y] This isn't an issue caused by another plugin
  • [ Y] You've checked for duplicate issues
  • [ Y] You didn't use /reload

Description and relevant errors:

This code is perfectly working for 1.13.2, the same with 1.14.4/1.14.2 does not while anything has changed since 1.14.2:
https://wiki.vg/Pre-release_protocol#Mobs

Readable code here: https://hastebin.com/betigonuce.cpp

public void setCustomName(String name) { if(VersionChecker.isHigherOrEqualThan(VersionChecker.v1_14_R1)) { Optional<?> opt = Optional.of(WrappedChatComponent.fromChatMessage(name)[0].getHandle()); dataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), opt);
} else if(VersionChecker.isHigherOrEqualThan(VersionChecker.v1_13_R1)) { dataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)) , Optional.ofNullable(WrappedChatComponent.fromChatMessage(name)[0].getHandle())); } else { setDataWatcherObject(String.class, 2, name); } }

commented

I think you still need to set custom name visible (boolean index 3)

commented

Did it too
As I said the code is working for 1.13