Fix rebase

This commit is contained in:
TheMode 2021-06-14 00:18:53 +02:00
parent eadb32eba3
commit f2bf27c86e
2 changed files with 10 additions and 9 deletions

View File

@ -1,7 +1,6 @@
package net.minestom.server.event.server;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.event.Event;
import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.utils.time.UpdateOption;
@ -14,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
*
* @see ServerListPingEvent
*/
public class ClientPingServerEvent extends Event implements CancellableEvent {
public class ClientPingServerEvent implements CancellableEvent {
private static final UpdateOption DEFAULT_DELAY = new UpdateOption(0, TimeUnit.MILLISECOND);
private final PlayerConnection connection;
@ -27,7 +26,7 @@ public class ClientPingServerEvent extends Event implements CancellableEvent {
* Creates a new client ping server event with 0 delay
*
* @param connection the player connection
* @param payload the payload the client sent
* @param payload the payload the client sent
*/
public ClientPingServerEvent(@NotNull PlayerConnection connection, long payload) {
this.connection = connection;
@ -39,7 +38,7 @@ public class ClientPingServerEvent extends Event implements CancellableEvent {
* Creates a new client ping server event with 0 delay
*
* @param connection the player connection
* @param payload the payload the client sent
* @param payload the payload the client sent
*/
public ClientPingServerEvent(@NotNull PlayerConnection connection, long payload, UpdateOption delay) {
this.connection = connection;
@ -69,8 +68,9 @@ public class ClientPingServerEvent extends Event implements CancellableEvent {
/**
* Sets the payload to respond with.
*
* <p>
* Note: This should be the same as the client sent, however vanilla 1.17 seems to be OK with a different payload.
*
* @param payload the payload
*/
public void setPayload(long payload) {

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.status;
import net.kyori.adventure.text.Component;
import net.minestom.server.MinecraftServer;
import net.minestom.server.event.EventDispatcher;
import net.minestom.server.event.server.ClientPingServerEvent;
import net.minestom.server.network.packet.client.ClientPreplayPacket;
import net.minestom.server.network.packet.server.status.PongPacket;
@ -14,12 +14,13 @@ public class PingPacket implements ClientPreplayPacket {
private long number;
public PingPacket() {}
public PingPacket() {
}
@Override
public void process(@NotNull PlayerConnection connection) {
final ClientPingServerEvent clientPingEvent = new ClientPingServerEvent(connection, number);
MinecraftServer.getGlobalEventHandler().callEvent(ClientPingServerEvent.class, clientPingEvent);
EventDispatcher.call(clientPingEvent);
if (clientPingEvent.isCancelled()) {
connection.disconnect();