mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Only send entity metadata if dirty
This commit is contained in:
parent
2034ca6bf0
commit
dffccdd2d4
@ -136,7 +136,7 @@ class ProfileFetchThread implements Runnable {
|
||||
public void onProfileLookupFailed(GameProfile profile, Exception e) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug(
|
||||
"Profile lookup for player '" + profile.getName() + "' failed2: " + getExceptionMsg(e));
|
||||
"Profile lookup for player '" + profile.getName() + "' failed: " + getExceptionMsg(e));
|
||||
Messaging.debug(Throwables.getStackTraceAsString(e));
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class ProfileFetchThread implements Runnable {
|
||||
request.setResult(NMS.fillProfileProperties(profile, true), ProfileFetchResult.SUCCESS);
|
||||
} catch (Throwable e) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Profile lookup for player '" + profile.getName() + "' failed: "
|
||||
Messaging.debug("Filling profile lookup for player '" + profile.getName() + "' failed: "
|
||||
+ getExceptionMsg(e) + " " + isTooManyRequests(e));
|
||||
Messaging.debug(Throwables.getStackTraceAsString(e));
|
||||
}
|
||||
|
@ -23,8 +23,7 @@ public class PlayerAnimationImpl {
|
||||
switch (animation) {
|
||||
case SNEAK:
|
||||
player.getBukkitEntity().setSneaking(true);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()),
|
||||
player, radius);
|
||||
sendEntityData(radius, player);
|
||||
break;
|
||||
case START_ELYTRA:
|
||||
player.startFallFlying();
|
||||
@ -34,27 +33,24 @@ public class PlayerAnimationImpl {
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.startUsingItem(InteractionHand.MAIN_HAND);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()),
|
||||
player, radius);
|
||||
sendEntityData(radius, player);
|
||||
break;
|
||||
case START_USE_OFFHAND_ITEM:
|
||||
player.startUsingItem(InteractionHand.OFF_HAND);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()),
|
||||
player, radius);
|
||||
sendEntityData(radius, player);
|
||||
break;
|
||||
case STOP_SNEAKING:
|
||||
player.getBukkitEntity().setSneaking(false);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()),
|
||||
player, radius);
|
||||
sendEntityData(radius, player);
|
||||
break;
|
||||
case STOP_USE_ITEM:
|
||||
player.stopUsingItem();
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()),
|
||||
player, radius);
|
||||
sendEntityData(radius, player);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static void playDefaultAnimation(ServerPlayer player, int radius, int code) {
|
||||
@ -62,6 +58,13 @@ public class PlayerAnimationImpl {
|
||||
sendPacketNearby(packet, player, radius);
|
||||
}
|
||||
|
||||
private static void sendEntityData(int radius, final ServerPlayer player) {
|
||||
if (!player.getEntityData().isDirty())
|
||||
return;
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData().packDirty()), player,
|
||||
radius);
|
||||
}
|
||||
|
||||
protected static void sendPacketNearby(Packet<?> packet, ServerPlayer player, int radius) {
|
||||
NMSImpl.sendPacketNearby(player.getBukkitEntity(), player.getBukkitEntity().getLocation(), packet, radius);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user