mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-16 15:45:21 +01:00
Static packet ids (#2034)
This commit is contained in:
parent
705ec5cc07
commit
9cfffc6ee4
@ -1,8 +1,6 @@
|
|||||||
package net.minestom.server.network.packet.client;
|
package net.minestom.server.network.packet.client;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a packet received from a client.
|
* Represents a packet received from a client.
|
||||||
@ -10,8 +8,4 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Packets are value-based, and should therefore not be reliant on identity.
|
* Packets are value-based, and should therefore not be reliant on identity.
|
||||||
*/
|
*/
|
||||||
public interface ClientPacket extends NetworkBuffer.Writer {
|
public interface ClientPacket extends NetworkBuffer.Writer {
|
||||||
|
|
||||||
default @Nullable ConnectionState nextState() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.client.play;
|
package net.minestom.server.network.packet.client.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.client.ClientPacket;
|
import net.minestom.server.network.packet.client.ClientPacket;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record ClientConfigurationAckPacket() implements ClientPacket {
|
public record ClientConfigurationAckPacket() implements ClientPacket {
|
||||||
|
|
||||||
public ClientConfigurationAckPacket(@NotNull NetworkBuffer buffer) {
|
public ClientConfigurationAckPacket(@NotNull NetworkBuffer buffer) {
|
||||||
this();
|
this();
|
||||||
}
|
}
|
||||||
@ -14,9 +12,4 @@ public record ClientConfigurationAckPacket() implements ClientPacket {
|
|||||||
@Override
|
@Override
|
||||||
public void write(@NotNull NetworkBuffer writer) {
|
public void write(@NotNull NetworkBuffer writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ConnectionState nextState() {
|
|
||||||
return ConnectionState.CONFIGURATION;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package net.minestom.server.network.packet.server;
|
|
||||||
|
|
||||||
import net.minestom.server.adventure.ComponentHolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A server packet that can hold components.
|
|
||||||
*/
|
|
||||||
public interface ComponentHoldingServerPacket extends ServerPacket, ComponentHolder<ServerPacket> { }
|
|
@ -1,17 +1,22 @@
|
|||||||
package net.minestom.server.network.packet.server;
|
package net.minestom.server.network.packet.server;
|
||||||
|
|
||||||
|
import net.minestom.server.adventure.ComponentHolder;
|
||||||
import net.minestom.server.network.ConnectionState;
|
import net.minestom.server.network.ConnectionState;
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
|
import net.minestom.server.utils.PacketUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a packet which can be sent to a player using {@link PlayerConnection#sendPacket(SendablePacket)}.
|
* Represents a packet which can be sent to a player using {@link PlayerConnection#sendPacket(SendablePacket)}.
|
||||||
* <p>
|
* <p>
|
||||||
* Packets are value-based, and should therefore not be reliant on identity.
|
* Packets are value-based, and should therefore not be reliant on identity.
|
||||||
*/
|
*/
|
||||||
public non-sealed interface ServerPacket extends NetworkBuffer.Writer, SendablePacket {
|
public sealed interface ServerPacket extends NetworkBuffer.Writer, SendablePacket permits
|
||||||
|
ServerPacket.Configuration, ServerPacket.Status, ServerPacket.Login, ServerPacket.Play {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of this packet.
|
* Gets the id of this packet.
|
||||||
@ -20,6 +25,40 @@ public non-sealed interface ServerPacket extends NetworkBuffer.Writer, SendableP
|
|||||||
*
|
*
|
||||||
* @return the id of this packet
|
* @return the id of this packet
|
||||||
*/
|
*/
|
||||||
int getId(@NotNull ConnectionState state);
|
default int getId(@NotNull ConnectionState state) {
|
||||||
|
final int id = switch (state) {
|
||||||
|
case HANDSHAKE -> -1;
|
||||||
|
case CONFIGURATION -> this instanceof Configuration configuration ? configuration.configurationId() : -1;
|
||||||
|
case STATUS -> this instanceof Status status ? status.statusId() : -1;
|
||||||
|
case LOGIN -> this instanceof Login login ? login.loginId() : -1;
|
||||||
|
case PLAY -> this instanceof Play play ? play.playId() : -1;
|
||||||
|
};
|
||||||
|
if (id != -1) return id;
|
||||||
|
// Invalid state, generate error
|
||||||
|
List<ConnectionState> validStates = new ArrayList<>();
|
||||||
|
if (this instanceof Configuration) validStates.add(ConnectionState.CONFIGURATION);
|
||||||
|
if (this instanceof Status) validStates.add(ConnectionState.STATUS);
|
||||||
|
if (this instanceof Login) validStates.add(ConnectionState.LOGIN);
|
||||||
|
if (this instanceof Play) validStates.add(ConnectionState.PLAY);
|
||||||
|
return PacketUtils.invalidPacketState(getClass(), state, validStates.toArray(ConnectionState[]::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
non-sealed interface Configuration extends ServerPacket {
|
||||||
|
int configurationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
non-sealed interface Status extends ServerPacket {
|
||||||
|
int statusId();
|
||||||
|
}
|
||||||
|
|
||||||
|
non-sealed interface Login extends ServerPacket {
|
||||||
|
int loginId();
|
||||||
|
}
|
||||||
|
|
||||||
|
non-sealed interface Play extends ServerPacket {
|
||||||
|
int playId();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ComponentHolding extends ComponentHolder<ServerPacket> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -15,7 +12,8 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
||||||
|
|
||||||
public record DisconnectPacket(@NotNull Component message) implements ComponentHoldingServerPacket {
|
public record DisconnectPacket(@NotNull Component message) implements ServerPacket.Configuration, ServerPacket.Play,
|
||||||
|
ServerPacket.ComponentHolding {
|
||||||
public DisconnectPacket(@NotNull NetworkBuffer reader) {
|
public DisconnectPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT));
|
this(reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -26,12 +24,13 @@ public record DisconnectPacket(@NotNull Component message) implements ComponentH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_DISCONNECT;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_DISCONNECT;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.DISCONNECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.DISCONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.LONG;
|
import static net.minestom.server.network.NetworkBuffer.LONG;
|
||||||
|
|
||||||
public record KeepAlivePacket(long id) implements ServerPacket {
|
public record KeepAlivePacket(long id) implements ServerPacket.Configuration, ServerPacket.Play {
|
||||||
public KeepAlivePacket(@NotNull NetworkBuffer reader) {
|
public KeepAlivePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(LONG));
|
this(reader.read(LONG));
|
||||||
}
|
}
|
||||||
@ -20,11 +18,12 @@ public record KeepAlivePacket(long id) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_KEEP_ALIVE;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_KEEP_ALIVE;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.KEEP_ALIVE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.KEEP_ALIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||||
|
|
||||||
public record PingPacket(int id) implements ServerPacket {
|
public record PingPacket(int id) implements ServerPacket.Configuration, ServerPacket.Play {
|
||||||
public PingPacket(@NotNull NetworkBuffer reader) {
|
public PingPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(INT));
|
this(reader.read(INT));
|
||||||
}
|
}
|
||||||
@ -20,11 +18,12 @@ public record PingPacket(int id) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_PING;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PING;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.PING;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.PING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.LONG;
|
import static net.minestom.server.network.NetworkBuffer.LONG;
|
||||||
|
|
||||||
public record PingResponsePacket(long number) implements ServerPacket {
|
public record PingResponsePacket(long number) implements ServerPacket.Status, ServerPacket.Play {
|
||||||
public PingResponsePacket(@NotNull NetworkBuffer reader) {
|
public PingResponsePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(LONG));
|
this(reader.read(LONG));
|
||||||
}
|
}
|
||||||
@ -20,11 +18,12 @@ public record PingResponsePacket(long number) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int statusId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.STATUS_PING_RESPONSE;
|
||||||
case STATUS -> ServerPacketIdentifier.STATUS_PING_RESPONSE;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.PING_RESPONSE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.STATUS);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.PING_RESPONSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.RAW_BYTES;
|
import static net.minestom.server.network.NetworkBuffer.RAW_BYTES;
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record PluginMessagePacket(String channel, byte[] data) implements ServerPacket {
|
public record PluginMessagePacket(String channel,
|
||||||
|
byte[] data) implements ServerPacket.Configuration, ServerPacket.Play {
|
||||||
public PluginMessagePacket(@NotNull NetworkBuffer reader) {
|
public PluginMessagePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(STRING), reader.read(RAW_BYTES));
|
this(reader.read(STRING), reader.read(RAW_BYTES));
|
||||||
}
|
}
|
||||||
@ -23,12 +22,13 @@ public record PluginMessagePacket(String channel, byte[] data) implements Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_PLUGIN_MESSAGE;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PLUGIN_MESSAGE;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.PLUGIN_MESSAGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.PLUGIN_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.common;
|
package net.minestom.server.network.packet.server.common;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record ResourcePackPopPacket(@Nullable UUID id) implements ServerPacket {
|
public record ResourcePackPopPacket(@Nullable UUID id) implements ServerPacket.Configuration, ServerPacket.Play {
|
||||||
|
|
||||||
public ResourcePackPopPacket(@NotNull NetworkBuffer reader) {
|
public ResourcePackPopPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.readOptional(NetworkBuffer.UUID));
|
this(reader.readOptional(NetworkBuffer.UUID));
|
||||||
}
|
}
|
||||||
@ -22,11 +19,12 @@ public record ResourcePackPopPacket(@Nullable UUID id) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_POP_PACKET;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_POP_PACKET;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.RESOURCE_PACK_POP;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.RESOURCE_PACK_POP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,9 @@ package net.minestom.server.network.packet.server.common;
|
|||||||
|
|
||||||
import net.kyori.adventure.resource.ResourcePackInfo;
|
import net.kyori.adventure.resource.ResourcePackInfo;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -24,7 +21,7 @@ public record ResourcePackPushPacket(
|
|||||||
@NotNull String hash,
|
@NotNull String hash,
|
||||||
boolean forced,
|
boolean forced,
|
||||||
@Nullable Component prompt
|
@Nullable Component prompt
|
||||||
) implements ComponentHoldingServerPacket {
|
) implements ServerPacket.Configuration, ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public ResourcePackPushPacket(@NotNull NetworkBuffer reader) {
|
public ResourcePackPushPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(UUID), reader.read(STRING), reader.read(STRING),
|
this(reader.read(UUID), reader.read(STRING), reader.read(STRING),
|
||||||
reader.read(BOOLEAN), reader.readOptional(COMPONENT));
|
reader.read(BOOLEAN), reader.readOptional(COMPONENT));
|
||||||
@ -44,12 +41,13 @@ public record ResourcePackPushPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_PUSH_PACKET;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_PUSH_PACKET;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.RESOURCE_PACK_PUSH;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.RESOURCE_PACK_PUSH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,12 +2,10 @@ package net.minestom.server.network.packet.server.common;
|
|||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.gamedata.tags.Tag;
|
import net.minestom.server.gamedata.tags.Tag;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.CachedPacket;
|
import net.minestom.server.network.packet.server.CachedPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -17,7 +15,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record TagsPacket(@NotNull Map<Tag.BasicType, List<Tag>> tagsMap) implements ServerPacket {
|
public record TagsPacket(
|
||||||
|
@NotNull Map<Tag.BasicType, List<Tag>> tagsMap) implements ServerPacket.Configuration, ServerPacket.Play {
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public static final CachedPacket DEFAULT_TAGS = new CachedPacket(new TagsPacket(MinecraftServer.getTagManager().getTagMap()));
|
public static final CachedPacket DEFAULT_TAGS = new CachedPacket(new TagsPacket(MinecraftServer.getTagManager().getTagMap()));
|
||||||
|
|
||||||
@ -49,12 +48,13 @@ public record TagsPacket(@NotNull Map<Tag.BasicType, List<Tag>> tagsMap) impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_TAGS;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_TAGS;
|
}
|
||||||
case PLAY -> ServerPacketIdentifier.TAGS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
@Override
|
||||||
};
|
public int playId() {
|
||||||
|
return ServerPacketIdentifier.TAGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Tag.BasicType, List<Tag>> readTagsMap(@NotNull NetworkBuffer reader) {
|
private static Map<Tag.BasicType, List<Tag>> readTagsMap(@NotNull NetworkBuffer reader) {
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package net.minestom.server.network.packet.server.configuration;
|
package net.minestom.server.network.packet.server.configuration;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record FinishConfigurationPacket() implements ServerPacket {
|
public record FinishConfigurationPacket() implements ServerPacket.Configuration {
|
||||||
|
|
||||||
public FinishConfigurationPacket(@NotNull NetworkBuffer buffer) {
|
public FinishConfigurationPacket(@NotNull NetworkBuffer buffer) {
|
||||||
this();
|
this();
|
||||||
}
|
}
|
||||||
@ -18,10 +15,7 @@ public record FinishConfigurationPacket() implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_FINISH_CONFIGURATION;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_FINISH_CONFIGURATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.configuration;
|
package net.minestom.server.network.packet.server.configuration;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.NBT;
|
import static net.minestom.server.network.NetworkBuffer.NBT;
|
||||||
|
|
||||||
public record RegistryDataPacket(@NotNull NBTCompound data) implements ServerPacket {
|
public record RegistryDataPacket(@NotNull NBTCompound data) implements ServerPacket.Configuration {
|
||||||
|
|
||||||
public RegistryDataPacket(@NotNull NetworkBuffer buffer) {
|
public RegistryDataPacket(@NotNull NetworkBuffer buffer) {
|
||||||
this((NBTCompound) buffer.read(NBT));
|
this((NBTCompound) buffer.read(NBT));
|
||||||
}
|
}
|
||||||
@ -22,10 +19,7 @@ public record RegistryDataPacket(@NotNull NBTCompound data) implements ServerPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_REGISTRY_DATA;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_REGISTRY_DATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package net.minestom.server.network.packet.server.configuration;
|
package net.minestom.server.network.packet.server.configuration;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.NamespaceID;
|
import net.minestom.server.utils.NamespaceID;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record UpdateEnabledFeaturesPacket(@NotNull Set<NamespaceID> features) implements ServerPacket {
|
public record UpdateEnabledFeaturesPacket(@NotNull Set<NamespaceID> features) implements ServerPacket.Configuration {
|
||||||
public static final int MAX_FEATURES = 1024;
|
public static final int MAX_FEATURES = 1024;
|
||||||
|
|
||||||
public UpdateEnabledFeaturesPacket(@NotNull NetworkBuffer buffer) {
|
public UpdateEnabledFeaturesPacket(@NotNull NetworkBuffer buffer) {
|
||||||
@ -25,11 +23,7 @@ public record UpdateEnabledFeaturesPacket(@NotNull Set<NamespaceID> features) im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int configurationId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CONFIGURATION_UPDATE_ENABLED_FEATURES;
|
||||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_UPDATE_ENABLED_FEATURES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.minestom.server.network.packet.server.login;
|
package net.minestom.server.network.packet.server.login;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE_ARRAY;
|
import static net.minestom.server.network.NetworkBuffer.BYTE_ARRAY;
|
||||||
@ -12,7 +10,7 @@ import static net.minestom.server.network.NetworkBuffer.STRING;
|
|||||||
|
|
||||||
public record EncryptionRequestPacket(@NotNull String serverId,
|
public record EncryptionRequestPacket(@NotNull String serverId,
|
||||||
byte @NotNull [] publicKey,
|
byte @NotNull [] publicKey,
|
||||||
byte @NotNull [] verifyToken) implements ServerPacket {
|
byte @NotNull [] verifyToken) implements ServerPacket.Login {
|
||||||
public EncryptionRequestPacket(@NotNull NetworkBuffer reader) {
|
public EncryptionRequestPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(STRING),
|
this(reader.read(STRING),
|
||||||
reader.read(BYTE_ARRAY),
|
reader.read(BYTE_ARRAY),
|
||||||
@ -27,10 +25,7 @@ public record EncryptionRequestPacket(@NotNull String serverId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int loginId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.LOGIN_ENCRYPTION_REQUEST;
|
||||||
case LOGIN -> ServerPacketIdentifier.LOGIN_ENCRYPTION_REQUEST;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.login;
|
package net.minestom.server.network.packet.server.login;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -14,7 +12,8 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.JSON_COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.JSON_COMPONENT;
|
||||||
|
|
||||||
public record LoginDisconnectPacket(@NotNull Component kickMessage) implements ComponentHoldingServerPacket {
|
public record LoginDisconnectPacket(@NotNull Component kickMessage) implements ServerPacket.Login,
|
||||||
|
ServerPacket.ComponentHolding {
|
||||||
public LoginDisconnectPacket(@NotNull NetworkBuffer reader) {
|
public LoginDisconnectPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(JSON_COMPONENT));
|
this(reader.read(JSON_COMPONENT));
|
||||||
}
|
}
|
||||||
@ -25,11 +24,8 @@ public record LoginDisconnectPacket(@NotNull Component kickMessage) implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int loginId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.LOGIN_DISCONNECT;
|
||||||
case LOGIN -> ServerPacketIdentifier.LOGIN_DISCONNECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.login;
|
package net.minestom.server.network.packet.server.login;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record LoginPluginRequestPacket(int messageId, @NotNull String channel,
|
public record LoginPluginRequestPacket(int messageId, @NotNull String channel,
|
||||||
byte @Nullable [] data) implements ServerPacket {
|
byte @Nullable [] data) implements ServerPacket.Login {
|
||||||
public LoginPluginRequestPacket(@NotNull NetworkBuffer reader) {
|
public LoginPluginRequestPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(STRING),
|
this(reader.read(VAR_INT), reader.read(STRING),
|
||||||
reader.read(RAW_BYTES));
|
reader.read(RAW_BYTES));
|
||||||
@ -27,10 +25,7 @@ public record LoginPluginRequestPacket(int messageId, @NotNull String channel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int loginId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.LOGIN_PLUGIN_REQUEST;
|
||||||
case LOGIN -> ServerPacketIdentifier.LOGIN_PLUGIN_REQUEST;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.minestom.server.network.packet.server.login;
|
package net.minestom.server.network.packet.server.login;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -12,7 +10,8 @@ import java.util.UUID;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record LoginSuccessPacket(@NotNull UUID uuid, @NotNull String username, int properties) implements ServerPacket {
|
public record LoginSuccessPacket(@NotNull UUID uuid, @NotNull String username,
|
||||||
|
int properties) implements ServerPacket.Login {
|
||||||
public LoginSuccessPacket(@NotNull NetworkBuffer reader) {
|
public LoginSuccessPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(NetworkBuffer.UUID), reader.read(STRING), reader.read(VAR_INT));
|
this(reader.read(NetworkBuffer.UUID), reader.read(STRING), reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -25,10 +24,7 @@ public record LoginSuccessPacket(@NotNull UUID uuid, @NotNull String username, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int loginId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.LOGIN_SUCCESS;
|
||||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SUCCESS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.login;
|
package net.minestom.server.network.packet.server.login;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record SetCompressionPacket(int threshold) implements ServerPacket {
|
public record SetCompressionPacket(int threshold) implements ServerPacket.Login {
|
||||||
public SetCompressionPacket(@NotNull NetworkBuffer reader) {
|
public SetCompressionPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT));
|
this(reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record SetCompressionPacket(int threshold) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int loginId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.LOGIN_SET_COMPRESSION;
|
||||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SET_COMPRESSION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record AcknowledgeBlockChangePacket(int sequence) implements ServerPacket {
|
public record AcknowledgeBlockChangePacket(int sequence) implements ServerPacket.Play {
|
||||||
public AcknowledgeBlockChangePacket(@NotNull NetworkBuffer reader) {
|
public AcknowledgeBlockChangePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT));
|
this(reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record AcknowledgeBlockChangePacket(int sequence) implements ServerPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ACKNOWLEDGE_BLOCK_CHANGE;
|
||||||
case PLAY -> ServerPacketIdentifier.ACKNOWLEDGE_BLOCK_CHANGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -15,7 +12,7 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
||||||
|
|
||||||
public record ActionBarPacket(@NotNull Component text) implements ComponentHoldingServerPacket {
|
public record ActionBarPacket(@NotNull Component text) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public ActionBarPacket(@NotNull NetworkBuffer reader) {
|
public ActionBarPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT));
|
this(reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -26,11 +23,8 @@ public record ActionBarPacket(@NotNull Component text) implements ComponentHoldi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ACTION_BAR;
|
||||||
case PLAY -> ServerPacketIdentifier.ACTION_BAR;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,12 +4,10 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.minestom.server.advancements.FrameType;
|
import net.minestom.server.advancements.FrameType;
|
||||||
import net.minestom.server.adventure.ComponentHolder;
|
import net.minestom.server.adventure.ComponentHolder;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
|
|
||||||
public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping> advancementMappings,
|
public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping> advancementMappings,
|
||||||
@NotNull List<String> identifiersToRemove,
|
@NotNull List<String> identifiersToRemove,
|
||||||
@NotNull List<ProgressMapping> progressMappings) implements ComponentHoldingServerPacket {
|
@NotNull List<ProgressMapping> progressMappings) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public static final int MAX_ADVANCEMENTS = Short.MAX_VALUE;
|
public static final int MAX_ADVANCEMENTS = Short.MAX_VALUE;
|
||||||
|
|
||||||
public AdvancementsPacket {
|
public AdvancementsPacket {
|
||||||
@ -47,11 +45,8 @@ public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ADVANCEMENTS;
|
||||||
case PLAY -> ServerPacketIdentifier.ADVANCEMENTS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO is the display-item needed to be updated?
|
// TODO is the display-item needed to be updated?
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||||
|
|
||||||
public record AttachEntityPacket(int attachedEntityId, int holdingEntityId) implements ServerPacket {
|
public record AttachEntityPacket(int attachedEntityId, int holdingEntityId) implements ServerPacket.Play {
|
||||||
public AttachEntityPacket(@NotNull Entity attachedEntity, @Nullable Entity holdingEntity) {
|
public AttachEntityPacket(@NotNull Entity attachedEntity, @Nullable Entity holdingEntity) {
|
||||||
this(attachedEntity.getEntityId(), holdingEntity != null ? holdingEntity.getEntityId() : -1);
|
this(attachedEntity.getEntityId(), holdingEntity != null ? holdingEntity.getEntityId() : -1);
|
||||||
}
|
}
|
||||||
@ -27,10 +25,7 @@ public record AttachEntityPacket(int attachedEntityId, int holdingEntityId) impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ATTACH_ENTITY;
|
||||||
case PLAY -> ServerPacketIdentifier.ATTACH_ENTITY;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,15 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record BlockActionPacket(@NotNull Point blockPosition, byte actionId,
|
public record BlockActionPacket(@NotNull Point blockPosition, byte actionId,
|
||||||
byte actionParam, int blockId) implements ServerPacket {
|
byte actionParam, int blockId) implements ServerPacket.Play {
|
||||||
public BlockActionPacket(Point blockPosition, byte actionId, byte actionParam, Block block) {
|
public BlockActionPacket(Point blockPosition, byte actionId, byte actionParam, Block block) {
|
||||||
this(blockPosition, actionId, actionParam, block.id());
|
this(blockPosition, actionId, actionParam, block.id());
|
||||||
}
|
}
|
||||||
@ -31,10 +29,7 @@ public record BlockActionPacket(@NotNull Point blockPosition, byte actionId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BLOCK_ACTION;
|
||||||
case PLAY -> ServerPacketIdentifier.BLOCK_ACTION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record BlockBreakAnimationPacket(int entityId, @NotNull Point blockPosition,
|
public record BlockBreakAnimationPacket(int entityId, @NotNull Point blockPosition,
|
||||||
byte destroyStage) implements ServerPacket {
|
byte destroyStage) implements ServerPacket.Play {
|
||||||
public BlockBreakAnimationPacket(@NotNull NetworkBuffer reader) {
|
public BlockBreakAnimationPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(BLOCK_POSITION), reader.read(BYTE));
|
this(reader.read(VAR_INT), reader.read(BLOCK_POSITION), reader.read(BYTE));
|
||||||
}
|
}
|
||||||
@ -24,10 +22,7 @@ public record BlockBreakAnimationPacket(int entityId, @NotNull Point blockPositi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BLOCK_BREAK_ANIMATION;
|
||||||
case PLAY -> ServerPacketIdentifier.BLOCK_BREAK_ANIMATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,17 +2,15 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record BlockChangePacket(@NotNull Point blockPosition, int blockStateId) implements ServerPacket {
|
public record BlockChangePacket(@NotNull Point blockPosition, int blockStateId) implements ServerPacket.Play {
|
||||||
public BlockChangePacket(@NotNull Point blockPosition, @NotNull Block block) {
|
public BlockChangePacket(@NotNull Point blockPosition, @NotNull Block block) {
|
||||||
this(blockPosition, block.stateId());
|
this(blockPosition, block.stateId());
|
||||||
}
|
}
|
||||||
@ -28,10 +26,7 @@ public record BlockChangePacket(@NotNull Point blockPosition, int blockStateId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BLOCK_CHANGE;
|
||||||
case PLAY -> ServerPacketIdentifier.BLOCK_CHANGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
@ -13,7 +11,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record BlockEntityDataPacket(@NotNull Point blockPosition, int action,
|
public record BlockEntityDataPacket(@NotNull Point blockPosition, int action,
|
||||||
@Nullable NBTCompound data) implements ServerPacket {
|
@Nullable NBTCompound data) implements ServerPacket.Play {
|
||||||
public BlockEntityDataPacket(@NotNull NetworkBuffer reader) {
|
public BlockEntityDataPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BLOCK_POSITION), reader.read(VAR_INT), (NBTCompound) reader.read(NBT));
|
this(reader.read(BLOCK_POSITION), reader.read(VAR_INT), (NBTCompound) reader.read(NBT));
|
||||||
}
|
}
|
||||||
@ -31,10 +29,7 @@ public record BlockEntityDataPacket(@NotNull Point blockPosition, int action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BLOCK_ENTITY_DATA;
|
||||||
case PLAY -> ServerPacketIdentifier.BLOCK_ENTITY_DATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,10 @@ import net.kyori.adventure.bossbar.BossBar;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.adventure.AdventurePacketConvertor;
|
import net.minestom.server.adventure.AdventurePacketConvertor;
|
||||||
import net.minestom.server.adventure.ComponentHolder;
|
import net.minestom.server.adventure.ComponentHolder;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -19,7 +17,7 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record BossBarPacket(@NotNull UUID uuid, @NotNull Action action) implements ComponentHoldingServerPacket {
|
public record BossBarPacket(@NotNull UUID uuid, @NotNull Action action) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public BossBarPacket(@NotNull NetworkBuffer reader) {
|
public BossBarPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(NetworkBuffer.UUID), switch (reader.read(VAR_INT)) {
|
this(reader.read(NetworkBuffer.UUID), switch (reader.read(VAR_INT)) {
|
||||||
case 0 -> new AddAction(reader);
|
case 0 -> new AddAction(reader);
|
||||||
@ -201,10 +199,7 @@ public record BossBarPacket(@NotNull UUID uuid, @NotNull Action action) implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BOSS_BAR;
|
||||||
case PLAY -> ServerPacketIdentifier.BOSS_BAR;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record BundlePacket() implements ServerPacket {
|
public record BundlePacket() implements ServerPacket.Play {
|
||||||
public BundlePacket(@NotNull NetworkBuffer reader) {
|
public BundlePacket(@NotNull NetworkBuffer reader) {
|
||||||
this();
|
this();
|
||||||
}
|
}
|
||||||
@ -17,10 +15,7 @@ public record BundlePacket() implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.BUNDLE;
|
||||||
case PLAY -> ServerPacketIdentifier.BUNDLE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record CameraPacket(int cameraId) implements ServerPacket {
|
public record CameraPacket(int cameraId) implements ServerPacket.Play {
|
||||||
public CameraPacket(@NotNull NetworkBuffer reader) {
|
public CameraPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT));
|
this(reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -25,10 +23,7 @@ public record CameraPacket(int cameraId) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CAMERA;
|
||||||
case PLAY -> ServerPacketIdentifier.CAMERA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||||
|
|
||||||
public record ChangeGameStatePacket(@NotNull Reason reason, float value) implements ServerPacket {
|
public record ChangeGameStatePacket(@NotNull Reason reason, float value) implements ServerPacket.Play {
|
||||||
public ChangeGameStatePacket(@NotNull NetworkBuffer reader) {
|
public ChangeGameStatePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(Reason.values()[reader.read(BYTE)], reader.read(FLOAT));
|
this(Reason.values()[reader.read(BYTE)], reader.read(FLOAT));
|
||||||
}
|
}
|
||||||
@ -22,11 +20,8 @@ public record ChangeGameStatePacket(@NotNull Reason reason, float value) impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CHANGE_GAME_STATE;
|
||||||
case PLAY -> ServerPacketIdentifier.CHANGE_GAME_STATE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Reason {
|
public enum Reason {
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record ChunkBatchFinishedPacket(int batchSize) implements ServerPacket {
|
public record ChunkBatchFinishedPacket(int batchSize) implements ServerPacket.Play {
|
||||||
|
|
||||||
public ChunkBatchFinishedPacket(@NotNull NetworkBuffer buffer) {
|
public ChunkBatchFinishedPacket(@NotNull NetworkBuffer buffer) {
|
||||||
this(buffer.read(VAR_INT));
|
this(buffer.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -21,10 +18,7 @@ public record ChunkBatchFinishedPacket(int batchSize) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CHUNK_BATCH_FINISHED;
|
||||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_FINISHED;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record ChunkBatchStartPacket() implements ServerPacket {
|
public record ChunkBatchStartPacket() implements ServerPacket.Play {
|
||||||
|
|
||||||
public ChunkBatchStartPacket(@NotNull NetworkBuffer buffer) {
|
public ChunkBatchStartPacket(@NotNull NetworkBuffer buffer) {
|
||||||
this();
|
this();
|
||||||
}
|
}
|
||||||
@ -18,10 +15,7 @@ public record ChunkBatchStartPacket() implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CHUNK_BATCH_START;
|
||||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_START;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.network.packet.server.play.data.ChunkData;
|
import net.minestom.server.network.packet.server.play.data.ChunkData;
|
||||||
import net.minestom.server.network.packet.server.play.data.LightData;
|
import net.minestom.server.network.packet.server.play.data.LightData;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||||
|
|
||||||
public record ChunkDataPacket(int chunkX, int chunkZ,
|
public record ChunkDataPacket(int chunkX, int chunkZ,
|
||||||
@NotNull ChunkData chunkData,
|
@NotNull ChunkData chunkData,
|
||||||
@NotNull LightData lightData) implements ServerPacket {
|
@NotNull LightData lightData) implements ServerPacket.Play {
|
||||||
public ChunkDataPacket(@NotNull NetworkBuffer reader) {
|
public ChunkDataPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(INT), reader.read(INT),
|
this(reader.read(INT), reader.read(INT),
|
||||||
new ChunkData(reader),
|
new ChunkData(reader),
|
||||||
@ -29,10 +27,7 @@ public record ChunkDataPacket(int chunkX, int chunkZ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CHUNK_DATA;
|
||||||
case PLAY -> ServerPacketIdentifier.CHUNK_DATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
||||||
|
|
||||||
public record ClearTitlesPacket(boolean reset) implements ServerPacket {
|
public record ClearTitlesPacket(boolean reset) implements ServerPacket.Play {
|
||||||
public ClearTitlesPacket(@NotNull NetworkBuffer reader) {
|
public ClearTitlesPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BOOLEAN));
|
this(reader.read(BOOLEAN));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record ClearTitlesPacket(boolean reset) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CLEAR_TITLES;
|
||||||
case PLAY -> ServerPacketIdentifier.CLEAR_TITLES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
|
|
||||||
public record CloseWindowPacket(byte windowId) implements ServerPacket {
|
public record CloseWindowPacket(byte windowId) implements ServerPacket.Play {
|
||||||
public CloseWindowPacket(@NotNull NetworkBuffer reader) {
|
public CloseWindowPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE));
|
this(reader.read(BYTE));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record CloseWindowPacket(byte windowId) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CLOSE_WINDOW;
|
||||||
case PLAY -> ServerPacketIdentifier.CLOSE_WINDOW;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record CollectItemPacket(int collectedEntityId, int collectorEntityId, int pickupItemCount)
|
public record CollectItemPacket(int collectedEntityId, int collectorEntityId, int pickupItemCount)
|
||||||
implements ServerPacket {
|
implements ServerPacket.Play {
|
||||||
public CollectItemPacket(@NotNull NetworkBuffer reader) {
|
public CollectItemPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT));
|
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -23,10 +21,7 @@ public record CollectItemPacket(int collectedEntityId, int collectorEntityId, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.COLLECT_ITEM;
|
||||||
case PLAY -> ServerPacketIdentifier.COLLECT_ITEM;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record CraftRecipeResponse(byte windowId, String recipe) implements ServerPacket {
|
public record CraftRecipeResponse(byte windowId, String recipe) implements ServerPacket.Play {
|
||||||
public CraftRecipeResponse(@NotNull NetworkBuffer reader) {
|
public CraftRecipeResponse(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE), reader.read(STRING));
|
this(reader.read(BYTE), reader.read(STRING));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record CraftRecipeResponse(byte windowId, String recipe) implements Serve
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CRAFT_RECIPE_RESPONSE;
|
||||||
case PLAY -> ServerPacketIdentifier.CRAFT_RECIPE_RESPONSE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,7 +10,7 @@ import java.util.List;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record CustomChatCompletionPacket(@NotNull Action action,
|
public record CustomChatCompletionPacket(@NotNull Action action,
|
||||||
@NotNull List<@NotNull String> entries) implements ServerPacket {
|
@NotNull List<@NotNull String> entries) implements ServerPacket.Play {
|
||||||
public static final int MAX_ENTRIES = Short.MAX_VALUE;
|
public static final int MAX_ENTRIES = Short.MAX_VALUE;
|
||||||
|
|
||||||
public CustomChatCompletionPacket {
|
public CustomChatCompletionPacket {
|
||||||
@ -30,11 +28,8 @@ public record CustomChatCompletionPacket(@NotNull Action action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.CUSTOM_CHAT_COMPLETIONS;
|
||||||
case PLAY -> ServerPacketIdentifier.CUSTOM_CHAT_COMPLETIONS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
import static net.minestom.server.network.NetworkBuffer.VECTOR3D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See <a href="https://wiki.vg/Protocol#Damage_Event">https://wiki.vg/Protocol#Damage_Event</a> for more info.
|
* See <a href="https://wiki.vg/Protocol#Damage_Event">https://wiki.vg/Protocol#Damage_Event</a> for more info.
|
||||||
@ -20,18 +19,16 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
* @param sourceDirectId 0 if there is no direct source. For direct attacks (e.g. melee), this is the same as sourceEntityId. For indirect attacks (e.g. projectiles), this is the projectile entity id + 1
|
* @param sourceDirectId 0 if there is no direct source. For direct attacks (e.g. melee), this is the same as sourceEntityId. For indirect attacks (e.g. projectiles), this is the projectile entity id + 1
|
||||||
* @param sourcePos null if there is no source position, otherwise the position of the source
|
* @param sourcePos null if there is no source position, otherwise the position of the source
|
||||||
*/
|
*/
|
||||||
public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos) implements ServerPacket {
|
public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId,
|
||||||
|
@Nullable Point sourcePos) implements ServerPacket.Play {
|
||||||
|
|
||||||
public DamageEventPacket(@NotNull NetworkBuffer reader) {
|
public DamageEventPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT), reader.readOptional(VECTOR3D));
|
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT), reader.readOptional(VECTOR3D));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DAMAGE_EVENT;
|
||||||
case PLAY -> ServerPacketIdentifier.DAMAGE_EVENT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -15,7 +13,7 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record DeathCombatEventPacket(int playerId, @NotNull Component message) implements ComponentHoldingServerPacket {
|
public record DeathCombatEventPacket(int playerId, @NotNull Component message) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public DeathCombatEventPacket(@NotNull NetworkBuffer reader) {
|
public DeathCombatEventPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(COMPONENT));
|
this(reader.read(VAR_INT), reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -27,11 +25,8 @@ public record DeathCombatEventPacket(int playerId, @NotNull Component message) i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DEATH_COMBAT_EVENT;
|
||||||
case PLAY -> ServerPacketIdentifier.DEATH_COMBAT_EVENT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.command.builder.arguments.Argument;
|
import net.minestom.server.command.builder.arguments.Argument;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.registry.StaticProtocolObject;
|
import net.minestom.server.registry.StaticProtocolObject;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -15,7 +13,7 @@ import java.util.function.Function;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record DeclareCommandsPacket(@NotNull List<Node> nodes,
|
public record DeclareCommandsPacket(@NotNull List<Node> nodes,
|
||||||
int rootIndex) implements ServerPacket {
|
int rootIndex) implements ServerPacket.Play {
|
||||||
public static final int MAX_NODES = Short.MAX_VALUE;
|
public static final int MAX_NODES = Short.MAX_VALUE;
|
||||||
|
|
||||||
public DeclareCommandsPacket {
|
public DeclareCommandsPacket {
|
||||||
@ -37,11 +35,8 @@ public record DeclareCommandsPacket(@NotNull List<Node> nodes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DECLARE_COMMANDS;
|
||||||
case PLAY -> ServerPacketIdentifier.DECLARE_COMMANDS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Node implements NetworkBuffer.Writer {
|
public static final class Node implements NetworkBuffer.Writer {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.recipe.RecipeCategory;
|
import net.minestom.server.recipe.RecipeCategory;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -15,7 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implements ServerPacket {
|
public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implements ServerPacket.Play {
|
||||||
public static final int MAX_RECIPES = Short.MAX_VALUE;
|
public static final int MAX_RECIPES = Short.MAX_VALUE;
|
||||||
public static final int MAX_INGREDIENTS = 128;
|
public static final int MAX_INGREDIENTS = 128;
|
||||||
|
|
||||||
@ -51,11 +49,8 @@ public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DECLARE_RECIPES;
|
||||||
case PLAY -> ServerPacketIdentifier.DECLARE_RECIPES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed interface DeclaredRecipe extends NetworkBuffer.Writer
|
public sealed interface DeclaredRecipe extends NetworkBuffer.Writer
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.crypto.MessageSignature;
|
import net.minestom.server.crypto.MessageSignature;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record DeleteChatPacket(@NotNull MessageSignature signature) implements ServerPacket {
|
public record DeleteChatPacket(@NotNull MessageSignature signature) implements ServerPacket.Play {
|
||||||
public DeleteChatPacket(@NotNull NetworkBuffer reader) {
|
public DeleteChatPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(new MessageSignature(reader));
|
this(new MessageSignature(reader));
|
||||||
}
|
}
|
||||||
@ -19,10 +17,7 @@ public record DeleteChatPacket(@NotNull MessageSignature signature) implements S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DELETE_CHAT_MESSAGE;
|
||||||
case PLAY -> ServerPacketIdentifier.DELETE_CHAT_MESSAGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record DestroyEntitiesPacket(@NotNull List<Integer> entityIds) implements ServerPacket {
|
public record DestroyEntitiesPacket(@NotNull List<Integer> entityIds) implements ServerPacket.Play {
|
||||||
public static final int MAX_ENTRIES = Short.MAX_VALUE;
|
public static final int MAX_ENTRIES = Short.MAX_VALUE;
|
||||||
|
|
||||||
public DestroyEntitiesPacket {
|
public DestroyEntitiesPacket {
|
||||||
@ -32,10 +30,7 @@ public record DestroyEntitiesPacket(@NotNull List<Integer> entityIds) implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DESTROY_ENTITIES;
|
||||||
case PLAY -> ServerPacketIdentifier.DESTROY_ENTITIES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record DisplayScoreboardPacket(byte position, String scoreName) implements ServerPacket {
|
public record DisplayScoreboardPacket(byte position, String scoreName) implements ServerPacket.Play {
|
||||||
public DisplayScoreboardPacket(@NotNull NetworkBuffer reader) {
|
public DisplayScoreboardPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE), reader.read(STRING));
|
this(reader.read(BYTE), reader.read(STRING));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record DisplayScoreboardPacket(byte position, String scoreName) implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.DISPLAY_SCOREBOARD;
|
||||||
case PLAY -> ServerPacketIdentifier.DISPLAY_SCOREBOARD;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EffectPacket(int effectId, Point position, int data,
|
public record EffectPacket(int effectId, Point position, int data,
|
||||||
boolean disableRelativeVolume) implements ServerPacket {
|
boolean disableRelativeVolume) implements ServerPacket.Play {
|
||||||
public EffectPacket(@NotNull NetworkBuffer reader) {
|
public EffectPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(INT), reader.read(BLOCK_POSITION), reader.read(INT), reader.read(BOOLEAN));
|
this(reader.read(INT), reader.read(BLOCK_POSITION), reader.read(INT), reader.read(BOOLEAN));
|
||||||
}
|
}
|
||||||
@ -25,10 +23,7 @@ public record EffectPacket(int effectId, Point position, int data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.EFFECT;
|
||||||
case PLAY -> ServerPacketIdentifier.EFFECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record EndCombatEventPacket(int duration) implements ServerPacket {
|
public record EndCombatEventPacket(int duration) implements ServerPacket.Play {
|
||||||
public EndCombatEventPacket(@NotNull NetworkBuffer reader) {
|
public EndCombatEventPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT));
|
this(reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record EndCombatEventPacket(int duration) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.END_COMBAT_EVENT;
|
||||||
case PLAY -> ServerPacketIdentifier.END_COMBAT_EVENT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record EnterCombatEventPacket() implements ServerPacket {
|
public record EnterCombatEventPacket() implements ServerPacket.Play {
|
||||||
public EnterCombatEventPacket(@NotNull NetworkBuffer reader) {
|
public EnterCombatEventPacket(@NotNull NetworkBuffer reader) {
|
||||||
this();
|
this();
|
||||||
}
|
}
|
||||||
@ -18,10 +16,7 @@ public record EnterCombatEventPacket() implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTER_COMBAT_EVENT;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTER_COMBAT_EVENT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record EntityAnimationPacket(int entityId, @NotNull Animation animation) implements ServerPacket {
|
public record EntityAnimationPacket(int entityId, @NotNull Animation animation) implements ServerPacket.Play {
|
||||||
public EntityAnimationPacket(@NotNull NetworkBuffer reader) {
|
public EntityAnimationPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), Animation.values()[reader.read(BYTE)]);
|
this(reader.read(VAR_INT), Animation.values()[reader.read(BYTE)]);
|
||||||
}
|
}
|
||||||
@ -22,11 +20,8 @@ public record EntityAnimationPacket(int entityId, @NotNull Animation animation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_ANIMATION;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_ANIMATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Animation {
|
public enum Animation {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.potion.Potion;
|
import net.minestom.server.potion.Potion;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
@ -13,7 +11,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityEffectPacket(int entityId, @NotNull Potion potion,
|
public record EntityEffectPacket(int entityId, @NotNull Potion potion,
|
||||||
@Nullable NBTCompound factorCodec) implements ServerPacket {
|
@Nullable NBTCompound factorCodec) implements ServerPacket.Play {
|
||||||
public EntityEffectPacket(@NotNull NetworkBuffer reader) {
|
public EntityEffectPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), new Potion(reader),
|
this(reader.read(VAR_INT), new Potion(reader),
|
||||||
reader.read(BOOLEAN) ? (NBTCompound) reader.read(NBT) : null);
|
reader.read(BOOLEAN) ? (NBTCompound) reader.read(NBT) : null);
|
||||||
@ -27,10 +25,7 @@ public record EntityEffectPacket(int entityId, @NotNull Potion potion,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_EFFECT;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_EFFECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.entity.EquipmentSlot;
|
import net.minestom.server.entity.EquipmentSlot;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -21,7 +19,7 @@ import java.util.stream.Collectors;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityEquipmentPacket(int entityId,
|
public record EntityEquipmentPacket(int entityId,
|
||||||
@NotNull Map<EquipmentSlot, ItemStack> equipments) implements ComponentHoldingServerPacket {
|
@NotNull Map<EquipmentSlot, ItemStack> equipments) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public EntityEquipmentPacket {
|
public EntityEquipmentPacket {
|
||||||
equipments = Map.copyOf(equipments);
|
equipments = Map.copyOf(equipments);
|
||||||
if (equipments.isEmpty())
|
if (equipments.isEmpty())
|
||||||
@ -46,11 +44,8 @@ public record EntityEquipmentPacket(int entityId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_EQUIPMENT;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_EQUIPMENT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record EntityHeadLookPacket(int entityId, float yaw) implements ServerPacket {
|
public record EntityHeadLookPacket(int entityId, float yaw) implements ServerPacket.Play {
|
||||||
public EntityHeadLookPacket(@NotNull NetworkBuffer reader) {
|
public EntityHeadLookPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), (reader.read(BYTE) * 360f) / 256f);
|
this(reader.read(VAR_INT), (reader.read(BYTE) * 360f) / 256f);
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record EntityHeadLookPacket(int entityId, float yaw) implements ServerPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_HEAD_LOOK;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_HEAD_LOOK;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.entity.Metadata;
|
import net.minestom.server.entity.Metadata;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -18,7 +16,7 @@ import java.util.function.UnaryOperator;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityMetaDataPacket(int entityId,
|
public record EntityMetaDataPacket(int entityId,
|
||||||
@NotNull Map<Integer, Metadata.Entry<?>> entries) implements ComponentHoldingServerPacket {
|
@NotNull Map<Integer, Metadata.Entry<?>> entries) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public EntityMetaDataPacket {
|
public EntityMetaDataPacket {
|
||||||
entries = Map.copyOf(entries);
|
entries = Map.copyOf(entries);
|
||||||
}
|
}
|
||||||
@ -51,11 +49,8 @@ public record EntityMetaDataPacket(int entityId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_METADATA;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_METADATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityPositionAndRotationPacket(int entityId, short deltaX, short deltaY, short deltaZ,
|
public record EntityPositionAndRotationPacket(int entityId, short deltaX, short deltaY, short deltaZ,
|
||||||
float yaw, float pitch, boolean onGround) implements ServerPacket {
|
float yaw, float pitch, boolean onGround) implements ServerPacket.Play {
|
||||||
public EntityPositionAndRotationPacket(@NotNull NetworkBuffer reader) {
|
public EntityPositionAndRotationPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT),
|
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT),
|
||||||
reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f, reader.read(BOOLEAN));
|
reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f, reader.read(BOOLEAN));
|
||||||
@ -29,11 +27,8 @@ public record EntityPositionAndRotationPacket(int entityId, short deltaX, short
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_POSITION_AND_ROTATION;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION_AND_ROTATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityPositionAndRotationPacket getPacket(int entityId,
|
public static EntityPositionAndRotationPacket getPacket(int entityId,
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityPositionPacket(int entityId, short deltaX, short deltaY, short deltaZ, boolean onGround)
|
public record EntityPositionPacket(int entityId, short deltaX, short deltaY, short deltaZ, boolean onGround)
|
||||||
implements ServerPacket {
|
implements ServerPacket.Play {
|
||||||
|
|
||||||
public EntityPositionPacket(@NotNull NetworkBuffer reader) {
|
public EntityPositionPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT), reader.read(BOOLEAN));
|
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT), reader.read(BOOLEAN));
|
||||||
@ -27,11 +25,8 @@ public record EntityPositionPacket(int entityId, short deltaX, short deltaY, sho
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_POSITION;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -4,11 +4,9 @@ import net.minestom.server.attribute.Attribute;
|
|||||||
import net.minestom.server.attribute.AttributeInstance;
|
import net.minestom.server.attribute.AttributeInstance;
|
||||||
import net.minestom.server.attribute.AttributeModifier;
|
import net.minestom.server.attribute.AttributeModifier;
|
||||||
import net.minestom.server.attribute.AttributeOperation;
|
import net.minestom.server.attribute.AttributeOperation;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -16,7 +14,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityPropertiesPacket(int entityId, List<AttributeInstance> properties) implements ServerPacket {
|
public record EntityPropertiesPacket(int entityId, List<AttributeInstance> properties) implements ServerPacket.Play {
|
||||||
public static final int MAX_ENTRIES = 1024;
|
public static final int MAX_ENTRIES = 1024;
|
||||||
|
|
||||||
public EntityPropertiesPacket {
|
public EntityPropertiesPacket {
|
||||||
@ -61,10 +59,7 @@ public record EntityPropertiesPacket(int entityId, List<AttributeInstance> prope
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_PROPERTIES;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_PROPERTIES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityRotationPacket(int entityId, float yaw, float pitch, boolean onGround) implements ServerPacket {
|
public record EntityRotationPacket(int entityId, float yaw, float pitch, boolean onGround) implements ServerPacket.Play {
|
||||||
public EntityRotationPacket(@NotNull NetworkBuffer reader) {
|
public EntityRotationPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f, reader.read(BOOLEAN));
|
this(reader.read(VAR_INT), reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f, reader.read(BOOLEAN));
|
||||||
}
|
}
|
||||||
@ -23,10 +21,7 @@ public record EntityRotationPacket(int entityId, float yaw, float pitch, boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_ROTATION;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_ROTATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.minestom.server.adventure.AdventurePacketConvertor;
|
import net.minestom.server.adventure.AdventurePacketConvertor;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.utils.validate.Check;
|
import net.minestom.server.utils.validate.Check;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -24,7 +22,7 @@ public record EntitySoundEffectPacket(
|
|||||||
float volume,
|
float volume,
|
||||||
float pitch,
|
float pitch,
|
||||||
long seed
|
long seed
|
||||||
) implements ServerPacket {
|
) implements ServerPacket.Play {
|
||||||
|
|
||||||
public EntitySoundEffectPacket {
|
public EntitySoundEffectPacket {
|
||||||
Check.argCondition(soundEvent == null && soundName == null, "soundEvent and soundName cannot both be null");
|
Check.argCondition(soundEvent == null && soundName == null, "soundEvent and soundName cannot both be null");
|
||||||
@ -92,10 +90,7 @@ public record EntitySoundEffectPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_SOUND_EFFECT;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_SOUND_EFFECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||||
|
|
||||||
public record EntityStatusPacket(int entityId, byte status) implements ServerPacket {
|
public record EntityStatusPacket(int entityId, byte status) implements ServerPacket.Play {
|
||||||
public EntityStatusPacket(@NotNull NetworkBuffer reader) {
|
public EntityStatusPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(INT), reader.read(BYTE));
|
this(reader.read(INT), reader.read(BYTE));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record EntityStatusPacket(int entityId, byte status) implements ServerPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_STATUS;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_STATUS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record EntityTeleportPacket(int entityId, Pos position, boolean onGround) implements ServerPacket {
|
public record EntityTeleportPacket(int entityId, Pos position, boolean onGround) implements ServerPacket.Play {
|
||||||
public EntityTeleportPacket(@NotNull NetworkBuffer reader) {
|
public EntityTeleportPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE),
|
this(reader.read(VAR_INT), new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE),
|
||||||
reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f),
|
reader.read(BYTE) * 360f / 256f, reader.read(BYTE) * 360f / 256f),
|
||||||
@ -29,10 +27,7 @@ public record EntityTeleportPacket(int entityId, Pos position, boolean onGround)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_TELEPORT;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_TELEPORT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.MathUtils;
|
import net.minestom.server.utils.MathUtils;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.SHORT;
|
import static net.minestom.server.network.NetworkBuffer.SHORT;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record EntityVelocityPacket(int entityId, short velocityX, short velocityY,
|
public record EntityVelocityPacket(int entityId, short velocityX, short velocityY,
|
||||||
short velocityZ) implements ServerPacket {
|
short velocityZ) implements ServerPacket.Play {
|
||||||
public EntityVelocityPacket(@NotNull NetworkBuffer reader) {
|
public EntityVelocityPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT));
|
this(reader.read(VAR_INT), reader.read(SHORT), reader.read(SHORT), reader.read(SHORT));
|
||||||
}
|
}
|
||||||
@ -36,10 +34,7 @@ public record EntityVelocityPacket(int entityId, short velocityX, short velocity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.ENTITY_VELOCITY;
|
||||||
case PLAY -> ServerPacketIdentifier.ENTITY_VELOCITY;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.particle.Particle;
|
import net.minestom.server.particle.Particle;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.utils.binary.BinaryWriter;
|
import net.minestom.server.utils.binary.BinaryWriter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ public record ExplosionPacket(double x, double y, double z, float radius,
|
|||||||
@NotNull BlockInteraction blockInteraction,
|
@NotNull BlockInteraction blockInteraction,
|
||||||
int smallParticleId, byte @NotNull [] smallParticleData,
|
int smallParticleId, byte @NotNull [] smallParticleData,
|
||||||
int largeParticleId, byte @NotNull [] largeParticleData,
|
int largeParticleId, byte @NotNull [] largeParticleData,
|
||||||
@NotNull String soundName, boolean hasFixedSoundRange, float soundRange) implements ServerPacket {
|
@NotNull String soundName, boolean hasFixedSoundRange, float soundRange) implements ServerPacket.Play {
|
||||||
private static @NotNull ExplosionPacket fromReader(@NotNull NetworkBuffer reader) {
|
private static @NotNull ExplosionPacket fromReader(@NotNull NetworkBuffer reader) {
|
||||||
double x = reader.read(DOUBLE), y = reader.read(DOUBLE), z = reader.read(DOUBLE);
|
double x = reader.read(DOUBLE), y = reader.read(DOUBLE), z = reader.read(DOUBLE);
|
||||||
float radius = reader.read(FLOAT);
|
float radius = reader.read(FLOAT);
|
||||||
@ -107,11 +105,8 @@ public record ExplosionPacket(double x, double y, double z, float radius,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.EXPLOSION;
|
||||||
case PLAY -> ServerPacketIdentifier.EXPLOSION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BlockInteraction {
|
public enum BlockInteraction {
|
||||||
|
@ -2,17 +2,15 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.coordinate.Vec;
|
import net.minestom.server.coordinate.Vec;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record FacePlayerPacket(FacePosition facePosition,
|
public record FacePlayerPacket(FacePosition facePosition,
|
||||||
Point target, int entityId, FacePosition entityFacePosition) implements ServerPacket {
|
Point target, int entityId, FacePosition entityFacePosition) implements ServerPacket.Play {
|
||||||
public FacePlayerPacket(@NotNull NetworkBuffer reader) {
|
public FacePlayerPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(FacePosition.values()[reader.read(VAR_INT)],
|
this(FacePosition.values()[reader.read(VAR_INT)],
|
||||||
new Vec(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE)),
|
new Vec(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE)),
|
||||||
@ -35,11 +33,8 @@ public record FacePlayerPacket(FacePosition facePosition,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.FACE_PLAYER;
|
||||||
case PLAY -> ServerPacketIdentifier.FACE_PLAYER;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FacePosition {
|
public enum FacePosition {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
|
|
||||||
public record HeldItemChangePacket(byte slot) implements ServerPacket {
|
public record HeldItemChangePacket(byte slot) implements ServerPacket.Play {
|
||||||
public HeldItemChangePacket(@NotNull NetworkBuffer reader) {
|
public HeldItemChangePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE));
|
this(reader.read(BYTE));
|
||||||
}
|
}
|
||||||
@ -20,10 +18,7 @@ public record HeldItemChangePacket(byte slot) implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.HELD_ITEM_CHANGE;
|
||||||
case PLAY -> ServerPacketIdentifier.HELD_ITEM_CHANGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record HitAnimationPacket(int entityId, float yaw) implements ServerPacket {
|
public record HitAnimationPacket(int entityId, float yaw) implements ServerPacket.Play {
|
||||||
|
|
||||||
public HitAnimationPacket(@NotNull NetworkBuffer reader) {
|
public HitAnimationPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(FLOAT));
|
this(reader.read(VAR_INT), reader.read(FLOAT));
|
||||||
@ -23,10 +21,7 @@ public record HitAnimationPacket(int entityId, float yaw) implements ServerPacke
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.HIT_ANIMATION;
|
||||||
case PLAY -> ServerPacketIdentifier.HIT_ANIMATION;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
@ -12,7 +10,7 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
public record InitializeWorldBorderPacket(double x, double z,
|
public record InitializeWorldBorderPacket(double x, double z,
|
||||||
double oldDiameter, double newDiameter, long speed,
|
double oldDiameter, double newDiameter, long speed,
|
||||||
int portalTeleportBoundary, int warningTime,
|
int portalTeleportBoundary, int warningTime,
|
||||||
int warningBlocks) implements ServerPacket {
|
int warningBlocks) implements ServerPacket.Play {
|
||||||
public InitializeWorldBorderPacket(@NotNull NetworkBuffer reader) {
|
public InitializeWorldBorderPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(DOUBLE), reader.read(DOUBLE),
|
this(reader.read(DOUBLE), reader.read(DOUBLE),
|
||||||
reader.read(DOUBLE), reader.read(DOUBLE),
|
reader.read(DOUBLE), reader.read(DOUBLE),
|
||||||
@ -32,10 +30,7 @@ public record InitializeWorldBorderPacket(double x, double z,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.INITIALIZE_WORLD_BORDER;
|
||||||
case PLAY -> ServerPacketIdentifier.INITIALIZE_WORLD_BORDER;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.network.packet.server.play.data.DeathLocation;
|
import net.minestom.server.network.packet.server.play.data.DeathLocation;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -20,7 +18,7 @@ public record JoinGamePacket(
|
|||||||
boolean doLimitedCrafting,
|
boolean doLimitedCrafting,
|
||||||
String dimensionType, String world, long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
String dimensionType, String world, long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
||||||
boolean isDebug, boolean isFlat, DeathLocation deathLocation, int portalCooldown
|
boolean isDebug, boolean isFlat, DeathLocation deathLocation, int portalCooldown
|
||||||
) implements ServerPacket {
|
) implements ServerPacket.Play {
|
||||||
public static final int MAX_WORLDS = Short.MAX_VALUE;
|
public static final int MAX_WORLDS = Short.MAX_VALUE;
|
||||||
|
|
||||||
public JoinGamePacket {
|
public JoinGamePacket {
|
||||||
@ -79,11 +77,8 @@ public record JoinGamePacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.JOIN_GAME;
|
||||||
case PLAY -> ServerPacketIdentifier.JOIN_GAME;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -15,7 +13,7 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
|
|
||||||
public record MapDataPacket(int mapId, byte scale, boolean locked,
|
public record MapDataPacket(int mapId, byte scale, boolean locked,
|
||||||
boolean trackingPosition, @NotNull List<Icon> icons,
|
boolean trackingPosition, @NotNull List<Icon> icons,
|
||||||
@Nullable MapDataPacket.ColorContent colorContent) implements ServerPacket {
|
@Nullable MapDataPacket.ColorContent colorContent) implements ServerPacket.Play {
|
||||||
public static final int MAX_ICONS = 1024;
|
public static final int MAX_ICONS = 1024;
|
||||||
|
|
||||||
public MapDataPacket {
|
public MapDataPacket {
|
||||||
@ -65,11 +63,8 @@ public record MapDataPacket(int mapId, byte scale, boolean locked,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.MAP_DATA;
|
||||||
case PLAY -> ServerPacketIdentifier.MAP_DATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Icon(int type, byte x, byte z, byte direction,
|
public record Icon(int type, byte x, byte z, byte direction,
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) implements ServerPacket {
|
public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) implements ServerPacket.Play {
|
||||||
public MultiBlockChangePacket(int chunkX, int section, int chunkZ,
|
public MultiBlockChangePacket(int chunkX, int section, int chunkZ,
|
||||||
long[] blocks) {
|
long[] blocks) {
|
||||||
this(((long) (chunkX & 0x3FFFFF) << 42) | (section & 0xFFFFF) | ((long) (chunkZ & 0x3FFFFF) << 20), blocks);
|
this(((long) (chunkX & 0x3FFFFF) << 42) | (section & 0xFFFFF) | ((long) (chunkZ & 0x3FFFFF) << 20), blocks);
|
||||||
@ -26,10 +24,7 @@ public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.MULTI_BLOCK_CHANGE;
|
||||||
case PLAY -> ServerPacketIdentifier.MULTI_BLOCK_CHANGE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record NbtQueryResponsePacket(int transactionId, NBTCompound data) implements ServerPacket {
|
public record NbtQueryResponsePacket(int transactionId, NBTCompound data) implements ServerPacket.Play {
|
||||||
public NbtQueryResponsePacket(@NotNull NetworkBuffer reader) {
|
public NbtQueryResponsePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), (NBTCompound) reader.read(NBT));
|
this(reader.read(VAR_INT), (NBTCompound) reader.read(NBT));
|
||||||
}
|
}
|
||||||
@ -27,10 +25,7 @@ public record NbtQueryResponsePacket(int transactionId, NBTCompound data) implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.NBT_QUERY_RESPONSE;
|
||||||
case PLAY -> ServerPacketIdentifier.NBT_QUERY_RESPONSE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket {
|
public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket.Play {
|
||||||
public OpenBookPacket(@NotNull NetworkBuffer reader) {
|
public OpenBookPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.readEnum(Player.Hand.class));
|
this(reader.readEnum(Player.Hand.class));
|
||||||
}
|
}
|
||||||
@ -19,10 +17,7 @@ public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.OPEN_BOOK;
|
||||||
case PLAY -> ServerPacketIdentifier.OPEN_BOOK;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record OpenHorseWindowPacket(byte windowId, int slotCount, int entityId) implements ServerPacket {
|
public record OpenHorseWindowPacket(byte windowId, int slotCount, int entityId) implements ServerPacket.Play {
|
||||||
public OpenHorseWindowPacket(@NotNull NetworkBuffer reader) {
|
public OpenHorseWindowPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE), reader.read(VAR_INT), reader.read(INT));
|
this(reader.read(BYTE), reader.read(VAR_INT), reader.read(INT));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record OpenHorseWindowPacket(byte windowId, int slotCount, int entityId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.OPEN_HORSE_WINDOW;
|
||||||
case PLAY -> ServerPacketIdentifier.OPEN_HORSE_WINDOW;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
||||||
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
||||||
|
|
||||||
public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText) implements ServerPacket {
|
public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText) implements ServerPacket.Play {
|
||||||
public OpenSignEditorPacket(@NotNull NetworkBuffer reader) {
|
public OpenSignEditorPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BLOCK_POSITION), reader.read(BOOLEAN));
|
this(reader.read(BLOCK_POSITION), reader.read(BOOLEAN));
|
||||||
}
|
}
|
||||||
@ -23,10 +21,7 @@ public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.OPEN_SIGN_EDITOR;
|
||||||
case PLAY -> ServerPacketIdentifier.OPEN_SIGN_EDITOR;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -17,7 +15,7 @@ import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record OpenWindowPacket(int windowId, int windowType,
|
public record OpenWindowPacket(int windowId, int windowType,
|
||||||
@NotNull Component title) implements ComponentHoldingServerPacket {
|
@NotNull Component title) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public OpenWindowPacket(@NotNull NetworkBuffer reader) {
|
public OpenWindowPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(COMPONENT));
|
this(reader.read(VAR_INT), reader.read(VAR_INT), reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -30,11 +28,8 @@ public record OpenWindowPacket(int windowId, int windowType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.OPEN_WINDOW;
|
||||||
case PLAY -> ServerPacketIdentifier.OPEN_WINDOW;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.particle.Particle;
|
import net.minestom.server.particle.Particle;
|
||||||
import net.minestom.server.particle.data.ParticleData;
|
import net.minestom.server.particle.data.ParticleData;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.utils.validate.Check;
|
import net.minestom.server.utils.validate.Check;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record ParticlePacket(int particleId, boolean longDistance, double x, double y, double z, float offsetX, float offsetY, float offsetZ, float maxSpeed, int particleCount, @Nullable ParticleData data) implements ServerPacket {
|
public record ParticlePacket(int particleId, boolean longDistance, double x, double y, double z, float offsetX, float offsetY, float offsetZ, float maxSpeed, int particleCount, @Nullable ParticleData data) implements ServerPacket.Play {
|
||||||
private ParticlePacket(ParticlePacket copy) {
|
private ParticlePacket(ParticlePacket copy) {
|
||||||
this(copy.particleId, copy.longDistance, copy.x, copy.y, copy.z, copy.offsetX, copy.offsetY, copy.offsetZ, copy.maxSpeed, copy.particleCount, copy.data);
|
this(copy.particleId, copy.longDistance, copy.x, copy.y, copy.z, copy.offsetX, copy.offsetY, copy.offsetZ, copy.maxSpeed, copy.particleCount, copy.data);
|
||||||
}
|
}
|
||||||
@ -66,10 +64,7 @@ public record ParticlePacket(int particleId, boolean longDistance, double x, dou
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PARTICLE;
|
||||||
case PLAY -> ServerPacketIdentifier.PARTICLE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||||
|
|
||||||
public record PlayerAbilitiesPacket(byte flags, float flyingSpeed, float walkingSpeed) implements ServerPacket {
|
public record PlayerAbilitiesPacket(byte flags, float flyingSpeed, float walkingSpeed) implements ServerPacket.Play {
|
||||||
public static final byte FLAG_INVULNERABLE = 0x01;
|
public static final byte FLAG_INVULNERABLE = 0x01;
|
||||||
public static final byte FLAG_FLYING = 0x02;
|
public static final byte FLAG_FLYING = 0x02;
|
||||||
public static final byte FLAG_ALLOW_FLYING = 0x04;
|
public static final byte FLAG_ALLOW_FLYING = 0x04;
|
||||||
@ -28,10 +26,7 @@ public record PlayerAbilitiesPacket(byte flags, float flyingSpeed, float walking
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_ABILITIES;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_ABILITIES;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.crypto.FilterMask;
|
import net.minestom.server.crypto.FilterMask;
|
||||||
import net.minestom.server.crypto.SignedMessageBody;
|
import net.minestom.server.crypto.SignedMessageBody;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ public record PlayerChatMessagePacket(UUID sender, int index, byte @Nullable []
|
|||||||
SignedMessageBody.@NotNull Packed messageBody,
|
SignedMessageBody.@NotNull Packed messageBody,
|
||||||
@Nullable Component unsignedContent, FilterMask filterMask,
|
@Nullable Component unsignedContent, FilterMask filterMask,
|
||||||
int msgTypeId, Component msgTypeName,
|
int msgTypeId, Component msgTypeName,
|
||||||
@Nullable Component msgTypeTarget) implements ComponentHoldingServerPacket {
|
@Nullable Component msgTypeTarget) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public PlayerChatMessagePacket(@NotNull NetworkBuffer reader) {
|
public PlayerChatMessagePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(UUID), reader.read(VAR_INT), reader.readOptional(r -> r.readBytes(256)),
|
this(reader.read(UUID), reader.read(VAR_INT), reader.readOptional(r -> r.readBytes(256)),
|
||||||
new SignedMessageBody.Packed(reader),
|
new SignedMessageBody.Packed(reader),
|
||||||
@ -50,11 +48,8 @@ public record PlayerChatMessagePacket(UUID sender, int index, byte @Nullable []
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_CHAT;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_CHAT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record PlayerInfoRemovePacket(@NotNull List<@NotNull UUID> uuids) implements ServerPacket {
|
public record PlayerInfoRemovePacket(@NotNull List<@NotNull UUID> uuids) implements ServerPacket.Play {
|
||||||
public static final int MAX_ENTRIES = 1024;
|
public static final int MAX_ENTRIES = 1024;
|
||||||
|
|
||||||
public PlayerInfoRemovePacket(@NotNull UUID uuid) {
|
public PlayerInfoRemovePacket(@NotNull UUID uuid) {
|
||||||
@ -31,10 +29,7 @@ public record PlayerInfoRemovePacket(@NotNull List<@NotNull UUID> uuids) impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_INFO_REMOVE;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_REMOVE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.crypto.ChatSession;
|
import net.minestom.server.crypto.ChatSession;
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.network.player.GameProfile;
|
import net.minestom.server.network.player.GameProfile;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public final class PlayerInfoUpdatePacket implements ServerPacket {
|
public final class PlayerInfoUpdatePacket implements ServerPacket.Play {
|
||||||
public static final int MAX_ENTRIES = 1024;
|
public static final int MAX_ENTRIES = 1024;
|
||||||
|
|
||||||
private final @NotNull EnumSet<@NotNull Action> actions;
|
private final @NotNull EnumSet<@NotNull Action> actions;
|
||||||
@ -75,11 +73,8 @@ public final class PlayerInfoUpdatePacket implements ServerPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_INFO_UPDATE;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_UPDATE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull EnumSet<Action> actions() {
|
public @NotNull EnumSet<Action> actions() {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -16,7 +14,7 @@ import java.util.function.UnaryOperator;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
||||||
|
|
||||||
public record PlayerListHeaderAndFooterPacket(@NotNull Component header,
|
public record PlayerListHeaderAndFooterPacket(@NotNull Component header,
|
||||||
@NotNull Component footer) implements ComponentHoldingServerPacket {
|
@NotNull Component footer) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public PlayerListHeaderAndFooterPacket(@NotNull NetworkBuffer reader) {
|
public PlayerListHeaderAndFooterPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT), reader.read(COMPONENT));
|
this(reader.read(COMPONENT), reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -38,10 +36,7 @@ public record PlayerListHeaderAndFooterPacket(@NotNull Component header,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_LIST_HEADER_AND_FOOTER;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_LIST_HEADER_AND_FOOTER;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record PlayerPositionAndLookPacket(Pos position, byte flags, int teleportId) implements ServerPacket {
|
public record PlayerPositionAndLookPacket(Pos position, byte flags, int teleportId) implements ServerPacket.Play {
|
||||||
public PlayerPositionAndLookPacket(@NotNull NetworkBuffer reader) {
|
public PlayerPositionAndLookPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE), reader.read(FLOAT), reader.read(FLOAT)),
|
this(new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE), reader.read(FLOAT), reader.read(FLOAT)),
|
||||||
reader.read(BYTE), reader.read(VAR_INT));
|
reader.read(BYTE), reader.read(VAR_INT));
|
||||||
@ -30,10 +28,7 @@ public record PlayerPositionAndLookPacket(Pos position, byte flags, int teleport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.PLAYER_POSITION_AND_LOOK;
|
||||||
case PLAY -> ServerPacketIdentifier.PLAYER_POSITION_AND_LOOK;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,16 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.potion.PotionEffect;
|
import net.minestom.server.potion.PotionEffect;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record RemoveEntityEffectPacket(int entityId, @NotNull PotionEffect potionEffect) implements ServerPacket {
|
public record RemoveEntityEffectPacket(int entityId, @NotNull PotionEffect potionEffect) implements ServerPacket.Play {
|
||||||
public RemoveEntityEffectPacket(@NotNull NetworkBuffer reader) {
|
public RemoveEntityEffectPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), Objects.requireNonNull(PotionEffect.fromId(reader.read(VAR_INT))));
|
this(reader.read(VAR_INT), Objects.requireNonNull(PotionEffect.fromId(reader.read(VAR_INT))));
|
||||||
}
|
}
|
||||||
@ -24,10 +22,7 @@ public record RemoveEntityEffectPacket(int entityId, @NotNull PotionEffect potio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.REMOVE_ENTITY_EFFECT;
|
||||||
case PLAY -> ServerPacketIdentifier.REMOVE_ENTITY_EFFECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record ResetScorePacket(@NotNull String owner, @Nullable String objective) implements ServerPacket {
|
public record ResetScorePacket(@NotNull String owner, @Nullable String objective) implements ServerPacket.Play {
|
||||||
|
|
||||||
public ResetScorePacket(@NotNull NetworkBuffer reader) {
|
public ResetScorePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(STRING), reader.readOptional(STRING));
|
this(reader.read(STRING), reader.readOptional(STRING));
|
||||||
@ -23,10 +21,7 @@ public record ResetScorePacket(@NotNull String owner, @Nullable String objective
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.RESET_SCORE;
|
||||||
case PLAY -> ServerPacketIdentifier.RESET_SCORE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.network.packet.server.play.data.DeathLocation;
|
import net.minestom.server.network.packet.server.play.data.DeathLocation;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
@ -16,7 +14,7 @@ public record RespawnPacket(
|
|||||||
long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
long hashedSeed, GameMode gameMode, GameMode previousGameMode,
|
||||||
boolean isDebug, boolean isFlat, DeathLocation deathLocation,
|
boolean isDebug, boolean isFlat, DeathLocation deathLocation,
|
||||||
int portalCooldown, int copyData
|
int portalCooldown, int copyData
|
||||||
) implements ServerPacket {
|
) implements ServerPacket.Play {
|
||||||
public static final int COPY_NONE = 0x0;
|
public static final int COPY_NONE = 0x0;
|
||||||
public static final int COPY_ATTRIBUTES = 0x1;
|
public static final int COPY_ATTRIBUTES = 0x1;
|
||||||
public static final int COPY_METADATA = 0x2;
|
public static final int COPY_METADATA = 0x2;
|
||||||
@ -46,10 +44,7 @@ public record RespawnPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.RESPAWN;
|
||||||
case PLAY -> ServerPacketIdentifier.RESPAWN;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.scoreboard.Sidebar;
|
import net.minestom.server.scoreboard.Sidebar;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -20,7 +18,7 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
public record ScoreboardObjectivePacket(@NotNull String objectiveName, byte mode,
|
public record ScoreboardObjectivePacket(@NotNull String objectiveName, byte mode,
|
||||||
@Nullable Component objectiveValue,
|
@Nullable Component objectiveValue,
|
||||||
@Nullable Type type,
|
@Nullable Type type,
|
||||||
@Nullable Sidebar.NumberFormat numberFormat) implements ComponentHoldingServerPacket {
|
@Nullable Sidebar.NumberFormat numberFormat) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public ScoreboardObjectivePacket(@NotNull NetworkBuffer reader) {
|
public ScoreboardObjectivePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(read(reader));
|
this(read(reader));
|
||||||
}
|
}
|
||||||
@ -57,11 +55,8 @@ public record ScoreboardObjectivePacket(@NotNull String objectiveName, byte mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SCOREBOARD_OBJECTIVE;
|
||||||
case PLAY -> ServerPacketIdentifier.SCOREBOARD_OBJECTIVE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.STRING;
|
import static net.minestom.server.network.NetworkBuffer.STRING;
|
||||||
|
|
||||||
public record SelectAdvancementTabPacket(@Nullable String identifier) implements ServerPacket {
|
public record SelectAdvancementTabPacket(@Nullable String identifier) implements ServerPacket.Play {
|
||||||
public SelectAdvancementTabPacket(@NotNull NetworkBuffer reader) {
|
public SelectAdvancementTabPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.readOptional(STRING));
|
this(reader.readOptional(STRING));
|
||||||
}
|
}
|
||||||
@ -21,10 +19,7 @@ public record SelectAdvancementTabPacket(@Nullable String identifier) implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
|
||||||
case PLAY -> ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record ServerDataPacket(@Nullable Component motd, byte @Nullable [] iconBase64,
|
public record ServerDataPacket(@Nullable Component motd, byte @Nullable [] iconBase64,
|
||||||
boolean enforcesSecureChat) implements ServerPacket {
|
boolean enforcesSecureChat) implements ServerPacket.Play {
|
||||||
public ServerDataPacket(@NotNull NetworkBuffer reader) {
|
public ServerDataPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT), reader.readOptional(BYTE_ARRAY),
|
this(reader.read(COMPONENT), reader.readOptional(BYTE_ARRAY),
|
||||||
reader.read(BOOLEAN));
|
reader.read(BOOLEAN));
|
||||||
@ -26,10 +24,7 @@ public record ServerDataPacket(@Nullable Component motd, byte @Nullable [] iconB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SERVER_DATA;
|
||||||
case PLAY -> ServerPacketIdentifier.SERVER_DATA;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.world.Difficulty;
|
import net.minestom.server.world.Difficulty;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
||||||
|
|
||||||
public record ServerDifficultyPacket(@NotNull Difficulty difficulty, boolean locked) implements ServerPacket {
|
public record ServerDifficultyPacket(@NotNull Difficulty difficulty, boolean locked) implements ServerPacket.Play {
|
||||||
public ServerDifficultyPacket(@NotNull NetworkBuffer reader) {
|
public ServerDifficultyPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.readEnum(Difficulty.class), reader.read(BOOLEAN));
|
this(reader.readEnum(Difficulty.class), reader.read(BOOLEAN));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record ServerDifficultyPacket(@NotNull Difficulty difficulty, boolean loc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SERVER_DIFFICULTY;
|
||||||
case PLAY -> ServerPacketIdentifier.SERVER_DIFFICULTY;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record SetCooldownPacket(int itemId, int cooldownTicks) implements ServerPacket {
|
public record SetCooldownPacket(int itemId, int cooldownTicks) implements ServerPacket.Play {
|
||||||
public SetCooldownPacket(@NotNull NetworkBuffer reader) {
|
public SetCooldownPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(VAR_INT));
|
this(reader.read(VAR_INT), reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -21,10 +19,7 @@ public record SetCooldownPacket(int itemId, int cooldownTicks) implements Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_COOLDOWN;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_COOLDOWN;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record SetExperiencePacket(float percentage, int level, int totalExperience) implements ServerPacket {
|
public record SetExperiencePacket(float percentage, int level, int totalExperience) implements ServerPacket.Play {
|
||||||
public SetExperiencePacket(@NotNull NetworkBuffer reader) {
|
public SetExperiencePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(FLOAT), reader.read(VAR_INT), reader.read(VAR_INT));
|
this(reader.read(FLOAT), reader.read(VAR_INT), reader.read(VAR_INT));
|
||||||
}
|
}
|
||||||
@ -23,10 +21,7 @@ public record SetExperiencePacket(float percentage, int level, int totalExperien
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_EXPERIENCE;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_EXPERIENCE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,7 +10,7 @@ import java.util.List;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||||
|
|
||||||
public record SetPassengersPacket(int vehicleEntityId,
|
public record SetPassengersPacket(int vehicleEntityId,
|
||||||
@NotNull List<Integer> passengersId) implements ServerPacket {
|
@NotNull List<Integer> passengersId) implements ServerPacket.Play {
|
||||||
public static final int MAX_PASSENGERS = 16384;
|
public static final int MAX_PASSENGERS = 16384;
|
||||||
|
|
||||||
public SetPassengersPacket {
|
public SetPassengersPacket {
|
||||||
@ -30,10 +28,7 @@ public record SetPassengersPacket(int vehicleEntityId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_PASSENGERS;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_PASSENGERS;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -18,7 +16,7 @@ import java.util.function.UnaryOperator;
|
|||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record SetSlotPacket(byte windowId, int stateId, short slot,
|
public record SetSlotPacket(byte windowId, int stateId, short slot,
|
||||||
@NotNull ItemStack itemStack) implements ComponentHoldingServerPacket {
|
@NotNull ItemStack itemStack) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public SetSlotPacket(@NotNull NetworkBuffer reader) {
|
public SetSlotPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(BYTE), reader.read(VAR_INT), reader.read(SHORT),
|
this(reader.read(BYTE), reader.read(VAR_INT), reader.read(SHORT),
|
||||||
reader.read(ITEM));
|
reader.read(ITEM));
|
||||||
@ -33,11 +31,8 @@ public record SetSlotPacket(byte windowId, int stateId, short slot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_SLOT;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_SLOT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.*;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
|
|
||||||
public record SetTickStatePacket(float tickRate, boolean isFrozen) implements ServerPacket {
|
public record SetTickStatePacket(float tickRate, boolean isFrozen) implements ServerPacket.Play {
|
||||||
|
|
||||||
public SetTickStatePacket(@NotNull NetworkBuffer reader) {
|
public SetTickStatePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(FLOAT), reader.read(BOOLEAN));
|
this(reader.read(FLOAT), reader.read(BOOLEAN));
|
||||||
@ -22,10 +20,7 @@ public record SetTickStatePacket(float tickRate, boolean isFrozen) implements Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.TICK_STATE;
|
||||||
case PLAY -> ServerPacketIdentifier.TICK_STATE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -15,7 +13,7 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
||||||
|
|
||||||
public record SetTitleSubTitlePacket(@NotNull Component subtitle) implements ComponentHoldingServerPacket {
|
public record SetTitleSubTitlePacket(@NotNull Component subtitle) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public SetTitleSubTitlePacket(@NotNull NetworkBuffer reader) {
|
public SetTitleSubTitlePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT));
|
this(reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -26,11 +24,8 @@ public record SetTitleSubTitlePacket(@NotNull Component subtitle) implements Com
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_TITLE_SUBTITLE;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_SUBTITLE;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket.ComponentHolding;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -15,7 +13,7 @@ import java.util.function.UnaryOperator;
|
|||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
||||||
|
|
||||||
public record SetTitleTextPacket(@NotNull Component title) implements ComponentHoldingServerPacket {
|
public record SetTitleTextPacket(@NotNull Component title) implements ServerPacket.Play, ServerPacket.ComponentHolding {
|
||||||
public SetTitleTextPacket(@NotNull NetworkBuffer reader) {
|
public SetTitleTextPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(COMPONENT));
|
this(reader.read(COMPONENT));
|
||||||
}
|
}
|
||||||
@ -26,11 +24,8 @@ public record SetTitleTextPacket(@NotNull Component title) implements ComponentH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_TITLE_TEXT;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TEXT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||||
|
|
||||||
public record SetTitleTimePacket(int fadeIn, int stay, int fadeOut) implements ServerPacket {
|
public record SetTitleTimePacket(int fadeIn, int stay, int fadeOut) implements ServerPacket.Play {
|
||||||
public SetTitleTimePacket(@NotNull NetworkBuffer reader) {
|
public SetTitleTimePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(INT), reader.read(INT), reader.read(INT));
|
this(reader.read(INT), reader.read(INT), reader.read(INT));
|
||||||
}
|
}
|
||||||
@ -22,10 +20,7 @@ public record SetTitleTimePacket(int fadeIn, int stay, int fadeOut) implements S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SET_TITLE_TIME;
|
||||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TIME;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ package net.minestom.server.network.packet.server.play;
|
|||||||
import net.kyori.adventure.sound.Sound.Source;
|
import net.kyori.adventure.sound.Sound.Source;
|
||||||
import net.minestom.server.adventure.AdventurePacketConvertor;
|
import net.minestom.server.adventure.AdventurePacketConvertor;
|
||||||
import net.minestom.server.coordinate.Point;
|
import net.minestom.server.coordinate.Point;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.sound.SoundEvent;
|
import net.minestom.server.sound.SoundEvent;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.utils.validate.Check;
|
import net.minestom.server.utils.validate.Check;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -27,7 +25,7 @@ public record SoundEffectPacket(
|
|||||||
float volume,
|
float volume,
|
||||||
float pitch,
|
float pitch,
|
||||||
long seed
|
long seed
|
||||||
) implements ServerPacket {
|
) implements ServerPacket.Play {
|
||||||
|
|
||||||
public SoundEffectPacket {
|
public SoundEffectPacket {
|
||||||
Check.argCondition(soundEvent == null && soundName == null, "soundEvent and soundName cannot both be null");
|
Check.argCondition(soundEvent == null && soundName == null, "soundEvent and soundName cannot both be null");
|
||||||
@ -100,10 +98,7 @@ public record SoundEffectPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SOUND_EFFECT;
|
||||||
case PLAY -> ServerPacketIdentifier.SOUND_EFFECT;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.network.ConnectionState;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -14,7 +12,7 @@ import static net.minestom.server.network.NetworkBuffer.*;
|
|||||||
|
|
||||||
public record SpawnEntityPacket(int entityId, @NotNull UUID uuid, int type,
|
public record SpawnEntityPacket(int entityId, @NotNull UUID uuid, int type,
|
||||||
@NotNull Pos position, float headRot, int data,
|
@NotNull Pos position, float headRot, int data,
|
||||||
short velocityX, short velocityY, short velocityZ) implements ServerPacket {
|
short velocityX, short velocityY, short velocityZ) implements ServerPacket.Play {
|
||||||
public SpawnEntityPacket(@NotNull NetworkBuffer reader) {
|
public SpawnEntityPacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(VAR_INT), reader.read(UUID), reader.read(VAR_INT),
|
this(reader.read(VAR_INT), reader.read(UUID), reader.read(VAR_INT),
|
||||||
new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE),
|
new Pos(reader.read(DOUBLE), reader.read(DOUBLE), reader.read(DOUBLE),
|
||||||
@ -44,10 +42,7 @@ public record SpawnEntityPacket(int entityId, @NotNull UUID uuid, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId(@NotNull ConnectionState state) {
|
public int playId() {
|
||||||
return switch (state) {
|
return ServerPacketIdentifier.SPAWN_ENTITY;
|
||||||
case PLAY -> ServerPacketIdentifier.SPAWN_ENTITY;
|
|
||||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user