use of org.spongepowered.api.event.entity.living.humanoid.player.PlayerChangeClientSettingsEvent in project LanternServer by LanternPowered.
the class HandlerPlayInClientSettings method handle.
@Override
public void handle(NetworkContext context, MessagePlayInClientSettings message) {
final LanternPlayer player = context.getSession().getPlayer();
final Cause cause = Cause.of(EventContext.empty(), player);
final PlayerChangeClientSettingsEvent event = SpongeEventFactory.createPlayerChangeClientSettingsEvent(cause, message.getChatVisibility(), LanternSkinPart.fromBitPattern(message.getSkinPartsBitPattern()), message.getLocale(), player, message.getEnableColors(), message.getViewDistance());
Sponge.getEventManager().post(event);
player.setLocale(event.getLocale());
player.setViewDistance(event.getViewDistance());
player.setChatVisibility(event.getChatVisibility());
player.setChatColorsEnabled(message.getEnableColors());
player.offer(LanternKeys.DISPLAYED_SKIN_PARTS, event.getDisplayedSkinParts());
player.offer(Keys.DOMINANT_HAND, message.getDominantHand());
}
use of org.spongepowered.api.event.entity.living.humanoid.player.PlayerChangeClientSettingsEvent in project SpongeCommon by SpongePowered.
the class MixinEntityPlayerMP method postClientSettingsEvent.
// Post before the player values are updated
@Inject(method = "handleClientSettings", at = @At("HEAD"))
public void postClientSettingsEvent(CPacketClientSettings packet, CallbackInfo ci) {
// TODO: add HandPreference to PlayerChangeClientSettingsEvent once DominantHandData is implemented
Sponge.getCauseStackManager().pushCause(this);
final PlayerChangeClientSettingsEvent event = SpongeEventFactory.createPlayerChangeClientSettingsEvent(Sponge.getCauseStackManager().getCurrentCause(), (ChatVisibility) (Object) packet.getChatVisibility(), SkinUtil.fromFlags(packet.getModelPartFlags()), LocaleCache.getLocale(packet.getLang()), this, packet.isColorsEnabled(), packet.view);
SpongeImpl.postEvent(event);
Sponge.getCauseStackManager().popCause();
}
Aggregations