Search in sources :

Example 1 with SpongeStatusClient

use of org.spongepowered.common.network.status.SpongeStatusClient in project SpongeCommon by SpongePowered.

the class ServerStatusPacketListenerImplMixin method handleStatusRequest.

/**
 * @author Minecrell - January 18th, 2015
 * @reason Post the server status ping event for plugins.
 */
@Overwrite
public void handleStatusRequest(final ServerboundStatusRequestPacket packetIn) {
    if (this.hasRequestedStatus) {
        this.connection.disconnect(ServerStatusPacketListenerImplMixin.DISCONNECT_REASON);
    } else {
        this.hasRequestedStatus = true;
        final ServerStatus response = SpongeStatusResponse.post(this.server, new SpongeStatusClient(this.connection));
        if (response != null) {
            this.connection.send(new ClientboundStatusResponsePacket(response));
        } else {
            this.connection.disconnect(null);
        }
    }
}
Also used : ServerStatus(net.minecraft.network.protocol.status.ServerStatus) SpongeStatusClient(org.spongepowered.common.network.status.SpongeStatusClient) ClientboundStatusResponsePacket(net.minecraft.network.protocol.status.ClientboundStatusResponsePacket) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 2 with SpongeStatusClient

use of org.spongepowered.common.network.status.SpongeStatusClient in project Sponge by SpongePowered.

the class ServerStatusPacketListenerImplMixin method handleStatusRequest.

/**
 * @author Minecrell - January 18th, 2015
 * @reason Post the server status ping event for plugins.
 */
@Overwrite
public void handleStatusRequest(final ServerboundStatusRequestPacket packetIn) {
    if (this.hasRequestedStatus) {
        this.connection.disconnect(ServerStatusPacketListenerImplMixin.DISCONNECT_REASON);
    } else {
        this.hasRequestedStatus = true;
        final ServerStatus response = SpongeStatusResponse.post(this.server, new SpongeStatusClient(this.connection));
        if (response != null) {
            this.connection.send(new ClientboundStatusResponsePacket(response));
        } else {
            this.connection.disconnect(null);
        }
    }
}
Also used : ServerStatus(net.minecraft.network.protocol.status.ServerStatus) SpongeStatusClient(org.spongepowered.common.network.status.SpongeStatusClient) ClientboundStatusResponsePacket(net.minecraft.network.protocol.status.ClientboundStatusResponsePacket) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 3 with SpongeStatusClient

use of org.spongepowered.common.network.status.SpongeStatusClient in project SpongeCommon by SpongePowered.

the class MixinNetHandlerStatusServer method processServerQuery.

/**
 * @author Minecrell - January 18th, 2015
 * @reason Post the server status ping event for plugins.
 */
@Overwrite
public void processServerQuery(CPacketServerQuery packetIn) {
    if (this.handled) {
        this.networkManager.closeChannel(EXIT_MESSAGE);
    } else {
        this.handled = true;
        ServerStatusResponse response = SpongeStatusResponse.post(this.server, new SpongeStatusClient(this.networkManager));
        if (response != null) {
            this.networkManager.sendPacket(new SPacketServerInfo(response));
        } else {
            this.networkManager.closeChannel(null);
        }
    }
}
Also used : SpongeStatusClient(org.spongepowered.common.network.status.SpongeStatusClient) ServerStatusResponse(net.minecraft.network.ServerStatusResponse) SPacketServerInfo(net.minecraft.network.status.server.SPacketServerInfo) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

Overwrite (org.spongepowered.asm.mixin.Overwrite)3 SpongeStatusClient (org.spongepowered.common.network.status.SpongeStatusClient)3 ClientboundStatusResponsePacket (net.minecraft.network.protocol.status.ClientboundStatusResponsePacket)2 ServerStatus (net.minecraft.network.protocol.status.ServerStatus)2 ServerStatusResponse (net.minecraft.network.ServerStatusResponse)1 SPacketServerInfo (net.minecraft.network.status.server.SPacketServerInfo)1