public final class EntityActionHandler extends MessageHandler<EntityActionMessage> {
@Override
public void handleServer(ServerSession session, EntityActionMessage message) {
Player player = session.getPlayer();
Human human = player.get(Human.class);
List<Parameter<?>> parameters = new ArrayList<Parameter<?>>();
switch (message.getAction()) {
case EntityActionMessage.ACTION_CROUCH:
if (human != null) {
if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSneakingEvent(player, true)).isCancelled()) {
human.setSneaking(true);
}
}
break;
case EntityActionMessage.ACTION_UNCROUCH:
if (human != null) {
if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSneakingEvent(player, false)).isCancelled()) {
human.setSneaking(false);
}
}
break;
case EntityActionMessage.ACTION_LEAVE_BED:
player.getNetwork().callProtocolEvent(new EntityAnimationEvent(player, Animation.LEAVE_BED));
break;
case EntityActionMessage.ACTION_START_SPRINTING:
if (human != null) {
if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSprintingEvent(player, true)).isCancelled()) {
human.setSprinting(true);
}
}
break;
case EntityActionMessage.ACTION_STOP_SPRINTING:
if (human != null) {
if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSprintingEvent(player, false)).isCancelled()) {
human.setSprinting(false);
}
}
break;
default:
break;