mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
throw IllegalArgumentException on wrong ConnectionState
(cherry picked from commit 2643c4dec3cb7a5960e88fd662cddd81ff39fbfc)
(cherry picked from commit 01ca4969d8
)
This commit is contained in:
parent
1b286979c5
commit
aea1872f4b
@ -5,6 +5,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public final class ServerPacketIdentifier {
|
||||
private static final AtomicInteger PLAY_ID = new AtomicInteger(0);
|
||||
|
||||
public static final int STATUS_RESPONSE = 0x00;
|
||||
public static final int STATUS_PONG = 0x01;
|
||||
|
||||
public static final int LOGIN_DISCONNECT = 0x00;
|
||||
public static final int LOGIN_ENCRYPTION_REQUEST = 0x01;
|
||||
public static final int LOGIN_SUCCESS = 0x02;
|
||||
|
@ -26,7 +26,11 @@ public record DisconnectPacket(@NotNull Component message) implements ComponentH
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.DISCONNECT : ServerPacketIdentifier.CONFIGURATION_DISCONNECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DISCONNECT;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_DISCONNECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,10 @@ public record KeepAlivePacket(long id) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.KEEP_ALIVE : ServerPacketIdentifier.CONFIGURATION_KEEP_ALIVE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.KEEP_ALIVE;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_KEEP_ALIVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,10 @@ public record PingPacket(int id) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.PING : ServerPacketIdentifier.CONFIGURATION_PING;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PING;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PING;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,11 @@ public record PluginMessagePacket(String channel, byte[] data) implements Server
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.PLUGIN_MESSAGE : ServerPacketIdentifier.CONFIGURATION_PLUGIN_MESSAGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLUGIN_MESSAGE;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PLUGIN_MESSAGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,11 @@ public record ResourcePackSendPacket(
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.RESOURCE_PACK_SEND : ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_SEND;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.RESOURCE_PACK_SEND;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_SEND;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +49,11 @@ public record TagsPacket(@NotNull Map<Tag.BasicType, List<Tag>> tagsMap) impleme
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return state == ConnectionState.PLAY ? ServerPacketIdentifier.TAGS : ServerPacketIdentifier.CONFIGURATION_TAGS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TAGS;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_TAGS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
private static Map<Tag.BasicType, List<Tag>> readTagsMap(@NotNull NetworkBuffer reader) {
|
||||
|
@ -19,7 +19,10 @@ public record FinishConfigurationPacket() implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CONFIGURATION_FINISH_CONFIGURATION;
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_FINISH_CONFIGURATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,9 @@ public record RegistryDataPacket(@NotNull NBTCompound data) implements ServerPac
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CONFIGURATION_REGISTRY_DATA;
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_REGISTRY_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ public record UpdateEnabledFeaturesPacket(@NotNull Set<NamespaceID> features) im
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CONFIGURATION_UPDATE_ENABLED_FEATURES;
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_UPDATE_ENABLED_FEATURES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ public record EncryptionRequestPacket(@NotNull String serverId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.LOGIN_ENCRYPTION_REQUEST;
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_ENCRYPTION_REQUEST;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,10 @@ public record LoginDisconnectPacket(@NotNull Component kickMessage) implements C
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.LOGIN_DISCONNECT;
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_DISCONNECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,9 @@ public record LoginPluginRequestPacket(int messageId, @NotNull String channel,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.LOGIN_PLUGIN_REQUEST;
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_PLUGIN_REQUEST;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ public record LoginSuccessPacket(@NotNull UUID uuid, @NotNull String username, i
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.LOGIN_SUCCESS;
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SUCCESS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,9 @@ public record SetCompressionPacket(int threshold) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.LOGIN_SET_COMPRESSION;
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SET_COMPRESSION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public record AcknowledgeBlockChangePacket(int sequence) implements ServerPacket
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ACKNOWLEDGE_BLOCK_CHANGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ACKNOWLEDGE_BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ public record ActionBarPacket(@NotNull Component text) implements ComponentHoldi
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ACTION_BAR;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ACTION_BAR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,10 @@ public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ADVANCEMENTS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ADVANCEMENTS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
// TODO is the display-item needed to be updated?
|
||||
|
@ -27,6 +27,9 @@ public record AttachEntityPacket(int attachedEntityId, int holdingEntityId) impl
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ATTACH_ENTITY;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ATTACH_ENTITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public record BlockActionPacket(@NotNull Point blockPosition, byte actionId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.BLOCK_ACTION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_ACTION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ public record BlockBreakAnimationPacket(int entityId, @NotNull Point blockPositi
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.BLOCK_BREAK_ANIMATION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_BREAK_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
@ -28,6 +28,9 @@ public record BlockChangePacket(@NotNull Point blockPosition, int blockStateId)
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.BLOCK_CHANGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public record BlockEntityDataPacket(@NotNull Point blockPosition, int action,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.BLOCK_ENTITY_DATA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_ENTITY_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -201,6 +201,9 @@ public record BossBarPacket(@NotNull UUID uuid, @NotNull Action action) implemen
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.BOSS_BAR;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BOSS_BAR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ public record CameraPacket(int cameraId) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CAMERA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CAMERA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,10 @@ public record ChangeGameStatePacket(@NotNull Reason reason, float value) impleme
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CHANGE_GAME_STATE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHANGE_GAME_STATE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public enum Reason {
|
||||
|
@ -21,6 +21,9 @@ public record ChunkBatchFinishedPacket(int batchSize) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CHUNK_BATCH_FINISHED;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_FINISHED;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public record ChunkBatchStartPacket() implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CHUNK_BATCH_START;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_START;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ public record ChunkDataPacket(int chunkX, int chunkZ,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CHUNK_DATA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
@ -20,6 +20,9 @@ public record ClearTitlesPacket(boolean reset) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CLEAR_TITLES;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CLEAR_TITLES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public record CloseWindowPacket(byte windowId) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CLOSE_WINDOW;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CLOSE_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record CollectItemPacket(int collectedEntityId, int collectorEntityId, in
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.COLLECT_ITEM;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.COLLECT_ITEM;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public record CraftRecipeResponse(byte windowId, String recipe) implements Serve
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CRAFT_RECIPE_RESPONSE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CRAFT_RECIPE_RESPONSE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,10 @@ public record CustomChatCompletionPacket(@NotNull Action action,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.CUSTOM_CHAT_COMPLETIONS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CUSTOM_CHAT_COMPLETIONS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
|
@ -27,7 +27,10 @@ public record DamageEventPacket(int targetEntityId, int damageTypeId, int source
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DAMAGE_EVENT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DAMAGE_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,10 @@ public record DeathCombatEventPacket(int playerId, @NotNull Component message) i
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DEATH_COMBAT_EVENT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DEATH_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,7 +35,10 @@ public record DeclareCommandsPacket(@NotNull List<Node> nodes,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DECLARE_COMMANDS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DECLARE_COMMANDS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public static final class Node implements NetworkBuffer.Writer {
|
||||
|
@ -48,7 +48,10 @@ public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implem
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DECLARE_RECIPES;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DECLARE_RECIPES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public sealed interface DeclaredRecipe extends NetworkBuffer.Writer
|
||||
|
@ -19,6 +19,9 @@ public record DeleteChatPacket(@NotNull MessageSignature signature) implements S
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DELETE_CHAT_MESSAGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DELETE_CHAT_MESSAGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ public record DestroyEntitiesPacket(@NotNull List<Integer> entityIds) implements
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DESTROY_ENTITIES;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DESTROY_ENTITIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public record DisplayScoreboardPacket(byte position, String scoreName) implement
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.DISPLAY_SCOREBOARD;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DISPLAY_SCOREBOARD;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ public record EffectPacket(int effectId, Point position, int data,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.EFFECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public record EndCombatEventPacket(int duration) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.END_COMBAT_EVENT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.END_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public record EnterCombatEventPacket() implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTER_COMBAT_EVENT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTER_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,10 @@ public record EntityAnimationPacket(int entityId, @NotNull Animation animation)
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_ANIMATION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public enum Animation {
|
||||
|
@ -27,6 +27,9 @@ public record EntityEffectPacket(int entityId, @NotNull Potion potion,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_EFFECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,10 @@ public record EntityEquipmentPacket(int entityId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_EQUIPMENT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_EQUIPMENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,9 @@ public record EntityHeadLookPacket(int entityId, float yaw) implements ServerPac
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_HEAD_LOOK;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_HEAD_LOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,10 @@ public record EntityMetaDataPacket(int entityId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_METADATA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_METADATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,10 @@ public record EntityPositionAndRotationPacket(int entityId, short deltaX, short
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_POSITION_AND_ROTATION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION_AND_ROTATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public static EntityPositionAndRotationPacket getPacket(int entityId,
|
||||
|
@ -27,7 +27,10 @@ public record EntityPositionPacket(int entityId, short deltaX, short deltaY, sho
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_POSITION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -59,6 +59,9 @@ public record EntityPropertiesPacket(int entityId, List<AttributeInstance> prope
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_PROPERTIES;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_PROPERTIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record EntityRotationPacket(int entityId, float yaw, float pitch, boolean
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_ROTATION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_ROTATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ public record EntitySoundEffectPacket(
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_SOUND_EFFECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_SOUND_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public record EntityStatusPacket(int entityId, byte status) implements ServerPac
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_STATUS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_STATUS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ public record EntityTeleportPacket(int entityId, Pos position, boolean onGround)
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_TELEPORT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_TELEPORT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public record EntityVelocityPacket(int entityId, short velocityX, short velocity
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.ENTITY_VELOCITY;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_VELOCITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public record ExplosionPacket(double x, double y, double z, float radius, byte @
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.EXPLOSION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.EXPLOSION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,10 @@ public record FacePlayerPacket(FacePosition facePosition,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.FACE_PLAYER;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.FACE_PLAYER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public enum FacePosition {
|
||||
|
@ -20,6 +20,9 @@ public record HeldItemChangePacket(byte slot) implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.HELD_ITEM_CHANGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.HELD_ITEM_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record HitAnimationPacket(int entityId, float yaw) implements ServerPacke
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.HIT_ANIMATION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.HIT_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ public record InitializeWorldBorderPacket(double x, double z,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.INITIALIZE_WORLD_BORDER;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.INITIALIZE_WORLD_BORDER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,10 @@ public record JoinGamePacket(
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.JOIN_GAME;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.JOIN_GAME;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,10 @@ public record MapDataPacket(int mapId, byte scale, boolean locked,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.MAP_DATA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.MAP_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public record Icon(int type, byte x, byte z, byte direction,
|
||||
|
@ -26,6 +26,9 @@ public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) i
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.MULTI_BLOCK_CHANGE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.MULTI_BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ public record NbtQueryResponsePacket(int transactionId, NBTCompound data) implem
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.NBT_QUERY_RESPONSE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.NBT_QUERY_RESPONSE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.OPEN_BOOK;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_BOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public record OpenHorseWindowPacket(byte windowId, int slotCount, int entityId)
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.OPEN_HORSE_WINDOW;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_HORSE_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText)
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.OPEN_SIGN_EDITOR;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_SIGN_EDITOR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,10 @@ public record OpenWindowPacket(int windowId, int windowType,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.OPEN_WINDOW;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,6 +37,9 @@ public record ParticlePacket(int particleId, boolean longDistance,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PARTICLE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PARTICLE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ public record PlayerAbilitiesPacket(byte flags, float flyingSpeed, float walking
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_ABILITIES;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_ABILITIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,10 @@ public record PlayerChatMessagePacket(UUID sender, int index, byte @Nullable []
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_CHAT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_CHAT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +29,9 @@ public record PlayerInfoRemovePacket(@NotNull List<@NotNull UUID> uuids) impleme
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_INFO_REMOVE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_REMOVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,10 @@ public final class PlayerInfoUpdatePacket implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_INFO_UPDATE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_UPDATE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public @NotNull EnumSet<Action> actions() {
|
||||
|
@ -38,6 +38,9 @@ public record PlayerListHeaderAndFooterPacket(@NotNull Component header,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_LIST_HEADER_AND_FOOTER;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_LIST_HEADER_AND_FOOTER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ public record PlayerPositionAndLookPacket(Pos position, byte flags, int teleport
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.PLAYER_POSITION_AND_LOOK;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_POSITION_AND_LOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
@ -24,6 +24,9 @@ public record RemoveEntityEffectPacket(int entityId, @NotNull PotionEffect potio
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.REMOVE_ENTITY_EFFECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.REMOVE_ENTITY_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ public record RespawnPacket(
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.RESPAWN;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.RESPAWN;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,10 @@ public record ScoreboardObjectivePacket(@NotNull String objectiveName, byte mode
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SCOREBOARD_OBJECTIVE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SCOREBOARD_OBJECTIVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,9 @@ public record SelectAdvancementTabPacket(@Nullable String identifier) implements
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ public record ServerDataPacket(@Nullable Component motd, byte @Nullable [] iconB
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SERVER_DATA;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SERVER_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public record ServerDifficultyPacket(@NotNull Difficulty difficulty, boolean loc
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SERVER_DIFFICULTY;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SERVER_DIFFICULTY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ public record SetCooldownPacket(int itemId, int cooldownTicks) implements Server
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_COOLDOWN;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_COOLDOWN;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record SetExperiencePacket(float percentage, int level, int totalExperien
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_EXPERIENCE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_EXPERIENCE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ public record SetPassengersPacket(int vehicleEntityId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_PASSENGERS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_PASSENGERS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,10 @@ public record SetSlotPacket(byte windowId, int stateId, short slot,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_SLOT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_SLOT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,10 @@ public record SetTitleSubTitlePacket(@NotNull Component subtitle) implements Com
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_TITLE_SUBTITLE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_SUBTITLE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,10 @@ public record SetTitleTextPacket(@NotNull Component title) implements ComponentH
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_TITLE_TEXT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TEXT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,9 @@ public record SetTitleTimePacket(int fadeIn, int stay, int fadeOut) implements S
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SET_TITLE_TIME;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TIME;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,9 @@ public record SoundEffectPacket(
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SOUND_EFFECT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SOUND_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ public record SpawnEntityPacket(int entityId, @NotNull UUID uuid, int type,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SPAWN_ENTITY;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_ENTITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ public record SpawnExperienceOrbPacket(int entityId,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SPAWN_EXPERIENCE_ORB;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_EXPERIENCE_ORB;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public record SpawnPositionPacket(@NotNull Point position, float angle) implemen
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SPAWN_POSITION;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_POSITION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ public record StartConfigurationPacket() implements ServerPacket {
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.START_CONFIGURATION_PACKET;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.START_CONFIGURATION_PACKET;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,10 @@ public record StatisticsPacket(@NotNull List<Statistic> statistics) implements S
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.STATISTICS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.STATISTICS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public record Statistic(@NotNull StatisticCategory category,
|
||||
|
@ -43,6 +43,9 @@ public record StopSoundPacket(byte flags, @Nullable Sound.Source source,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.STOP_SOUND;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.STOP_SOUND;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,10 @@ public record SystemChatPacket(@NotNull Component message, boolean overlay) impl
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.SYSTEM_CHAT;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SYSTEM_CHAT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,10 @@ public record TabCompletePacket(int transactionId, int start, int length,
|
||||
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.TAB_COMPLETE;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TAB_COMPLETE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,7 +218,10 @@ public record TeamsPacket(String teamName, Action action) implements ComponentHo
|
||||
*/
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return ServerPacketIdentifier.TEAMS;
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TEAMS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user