use of org.spongepowered.asm.mixin.injection.ModifyArg in project SpongeForge by SpongePowered.
the class MixinIntegratedServerAnonInner3 method beforeFirePlayerLoggedOut.
/**
* @author Simon816
*
* PlayerQuitEvent must be fired manually just before playerLoggedOut.
*
* @see MixinPlayerList#onFirePlayerLoggedOutCall
*/
@ModifyArg(method = "run()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/management/PlayerList;playerLoggedOut(Lnet/minecraft/entity/player/EntityPlayerMP;)V"))
public EntityPlayerMP beforeFirePlayerLoggedOut(EntityPlayerMP playerIn) {
Player player = (Player) playerIn;
MessageChannel originalChannel = player.getMessageChannel();
Sponge.getCauseStackManager().pushCause(player);
ClientConnectionEvent.Disconnect event = SpongeEventFactory.createClientConnectionEventDisconnect(Sponge.getCauseStackManager().getCurrentCause(), originalChannel, Optional.of(originalChannel), new MessageEvent.MessageFormatter(), player, true);
SpongeImpl.postEvent(event);
// are quitting anyway
return playerIn;
}
Aggregations