In the case we're doing a copy entity disguise, try avoid failing a copy. Doesn't fix the underlying issue I believe.

This commit is contained in:
libraryaddict 2022-01-17 16:43:44 +13:00
parent 18081cf1ba
commit 1a800f7ae3

View File

@ -97,7 +97,7 @@ public class FlagWatcher {
} }
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity()) PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
.createPacket(getDisguise().getEntity()); .createPacket(getDisguise().getEntity());
try { try {
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
@ -343,7 +343,7 @@ public class FlagWatcher {
float health = ((Number) watch.getRawValue()).floatValue(); float health = ((Number) watch.getRawValue()).floatValue();
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ? String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName(); ((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health)); ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
} }
@ -383,7 +383,7 @@ public class FlagWatcher {
} }
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ? String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName(); ((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health)); ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
} }
@ -580,7 +580,7 @@ public class FlagWatcher {
if (NmsVersion.v1_13.isSupported()) { if (NmsVersion.v1_13.isSupported()) {
Optional<WrappedChatComponent> optional = Optional<WrappedChatComponent> optional =
Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name)))); Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name))));
setData(MetaIndex.ENTITY_CUSTOM_NAME, optional); setData(MetaIndex.ENTITY_CUSTOM_NAME, optional);
} else { } else {
@ -1022,7 +1022,11 @@ public class FlagWatcher {
@Deprecated @Deprecated
public <Y> void setUnsafeData(MetaIndex<Y> id, Y value) { public <Y> void setUnsafeData(MetaIndex<Y> id, Y value) {
setData(id, value); if (!id.getDefault().getClass().isInstance(value)) {
setBackupValue(id, value);
} else {
setData(id, value);
}
} }
protected <Y> void setData(MetaIndex<Y> id, Y value) { protected <Y> void setData(MetaIndex<Y> id, Y value) {