Search in sources :

Example 1 with ModifyArg

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;
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) MessageChannel(org.spongepowered.api.text.channel.MessageChannel) MessageEvent(org.spongepowered.api.event.message.MessageEvent) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) ModifyArg(org.spongepowered.asm.mixin.injection.ModifyArg)

Aggregations

Player (org.spongepowered.api.entity.living.player.Player)1 MessageEvent (org.spongepowered.api.event.message.MessageEvent)1 ClientConnectionEvent (org.spongepowered.api.event.network.ClientConnectionEvent)1 MessageChannel (org.spongepowered.api.text.channel.MessageChannel)1 ModifyArg (org.spongepowered.asm.mixin.injection.ModifyArg)1