Search in sources :

Example 1 with KickPlayerEvent

use of org.spongepowered.api.event.entity.living.player.KickPlayerEvent in project SpongeCommon by SpongePowered.

the class ServerPlayerMixin method bridge$kick.

@Override
public boolean bridge$kick(final Component message) {
    final Component messageToSend;
    if (ShouldFire.KICK_PLAYER_EVENT) {
        final KickPlayerEvent kickEvent = SpongeEventFactory.createKickPlayerEvent(PhaseTracker.getCauseStackManager().currentCause(), message, message, (ServerPlayer) this);
        if (Sponge.eventManager().post(kickEvent)) {
            return false;
        }
        messageToSend = kickEvent.message();
    } else {
        messageToSend = message;
    }
    final net.minecraft.network.chat.Component component = SpongeAdventure.asVanilla(messageToSend);
    this.connection.disconnect(component);
    return true;
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TextComponent(net.minecraft.network.chat.TextComponent) Component(net.kyori.adventure.text.Component) KickPlayerEvent(org.spongepowered.api.event.entity.living.player.KickPlayerEvent)

Aggregations

Component (net.kyori.adventure.text.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 KickPlayerEvent (org.spongepowered.api.event.entity.living.player.KickPlayerEvent)1