mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-20 07:02:32 +01:00
chore: use common function to generate invalid state errors
(cherry picked from commit 7e47136f28
)
This commit is contained in:
parent
aea1872f4b
commit
fad5537017
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -27,9 +28,9 @@ public record DisconnectPacket(@NotNull Component message) implements ComponentH
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DISCONNECT;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_DISCONNECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.DISCONNECT;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.LONG;
|
||||
@ -21,9 +22,9 @@ public record KeepAlivePacket(long id) implements ServerPacket {
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.KEEP_ALIVE;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_KEEP_ALIVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.KEEP_ALIVE;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||
@ -21,9 +22,9 @@ public record PingPacket(int id) implements ServerPacket {
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PING;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PING;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.PING;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.RAW_BYTES;
|
||||
@ -24,9 +25,9 @@ public record PluginMessagePacket(String channel, byte[] data) implements Server
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLUGIN_MESSAGE;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_PLUGIN_MESSAGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.PLUGIN_MESSAGE;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ 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.resourcepack.ResourcePack;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -48,9 +49,9 @@ public record ResourcePackSendPacket(
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.RESOURCE_PACK_SEND;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_RESOURCE_PACK_SEND;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.RESOURCE_PACK_SEND;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.CachedPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -50,9 +51,9 @@ public record TagsPacket(@NotNull Map<Tag.BasicType, List<Tag>> tagsMap) impleme
|
||||
@Override
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TAGS;
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_TAGS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
case PLAY -> ServerPacketIdentifier.TAGS;
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -21,7 +22,7 @@ public record FinishConfigurationPacket() implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_FINISH_CONFIGURATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
@ -24,7 +25,7 @@ public record RegistryDataPacket(@NotNull NBTCompound data) implements ServerPac
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_REGISTRY_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
@ -26,7 +27,7 @@ public record UpdateEnabledFeaturesPacket(@NotNull Set<NamespaceID> features) im
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case CONFIGURATION -> ServerPacketIdentifier.CONFIGURATION_UPDATE_ENABLED_FEATURES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.CONFIGURATION);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE_ARRAY;
|
||||
@ -29,7 +30,7 @@ public record EncryptionRequestPacket(@NotNull String serverId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_ENCRYPTION_REQUEST;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ComponentHoldingServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -27,7 +28,7 @@ public record LoginDisconnectPacket(@NotNull Component kickMessage) implements C
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_DISCONNECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -29,7 +30,7 @@ public record LoginPluginRequestPacket(int messageId, @NotNull String channel,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_PLUGIN_REQUEST;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -28,7 +29,7 @@ public record LoginSuccessPacket(@NotNull UUID uuid, @NotNull String username, i
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SUCCESS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -22,7 +23,7 @@ public record SetCompressionPacket(int threshold) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case LOGIN -> ServerPacketIdentifier.LOGIN_SET_COMPRESSION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.LOGIN);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -22,7 +23,7 @@ public record AcknowledgeBlockChangePacket(int sequence) implements ServerPacket
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ACKNOWLEDGE_BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -28,7 +29,7 @@ public record ActionBarPacket(@NotNull Component text) implements ComponentHoldi
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ACTION_BAR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -47,7 +48,7 @@ public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ADVANCEMENTS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -29,7 +30,7 @@ public record AttachEntityPacket(int attachedEntityId, int holdingEntityId) impl
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ATTACH_ENTITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -33,7 +34,7 @@ public record BlockActionPacket(@NotNull Point blockPosition, byte actionId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_ACTION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -26,7 +27,7 @@ public record BlockBreakAnimationPacket(int entityId, @NotNull Point blockPositi
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_BREAK_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
||||
@ -30,7 +31,7 @@ public record BlockChangePacket(@NotNull Point blockPosition, int blockStateId)
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
@ -33,7 +34,7 @@ public record BlockEntityDataPacket(@NotNull Point blockPosition, int action,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BLOCK_ENTITY_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -203,7 +204,7 @@ public record BossBarPacket(@NotNull UUID uuid, @NotNull Action action) implemen
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.BOSS_BAR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -27,7 +28,7 @@ public record CameraPacket(int cameraId) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CAMERA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record ChangeGameStatePacket(@NotNull Reason reason, float value) impleme
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHANGE_GAME_STATE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -23,7 +24,7 @@ public record ChunkBatchFinishedPacket(int batchSize) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_FINISHED;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record ChunkBatchStartPacket() implements ServerPacket {
|
||||
@ -20,7 +21,7 @@ public record ChunkBatchStartPacket() implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_BATCH_START;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
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.LightData;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||
@ -31,7 +32,7 @@ public record ChunkDataPacket(int chunkX, int chunkZ,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CHUNK_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
|
||||
@ -22,7 +23,7 @@ public record ClearTitlesPacket(boolean reset) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CLEAR_TITLES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -22,7 +23,7 @@ public record CloseWindowPacket(byte windowId) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CLOSE_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -25,7 +26,7 @@ public record CollectItemPacket(int collectedEntityId, int collectorEntityId, in
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.COLLECT_ITEM;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record CraftRecipeResponse(byte windowId, String recipe) implements Serve
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CRAFT_RECIPE_RESPONSE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -30,7 +31,7 @@ public record CustomChatCompletionPacket(@NotNull Action action,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.CUSTOM_CHAT_COMPLETIONS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -29,7 +30,7 @@ public record DamageEventPacket(int targetEntityId, int damageTypeId, int source
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DAMAGE_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -29,7 +30,7 @@ public record DeathCombatEventPacket(int playerId, @NotNull Component message) i
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DEATH_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.registry.ProtocolObject;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -37,7 +38,7 @@ public record DeclareCommandsPacket(@NotNull List<Node> nodes,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DECLARE_COMMANDS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.recipe.RecipeCategory;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -50,7 +51,7 @@ public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implem
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DECLARE_RECIPES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record DeleteChatPacket(@NotNull MessageSignature signature) implements ServerPacket {
|
||||
@ -21,7 +22,7 @@ public record DeleteChatPacket(@NotNull MessageSignature signature) implements S
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DELETE_CHAT_MESSAGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -32,7 +33,7 @@ public record DestroyEntitiesPacket(@NotNull List<Integer> entityIds) implements
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DESTROY_ENTITIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record DisplayScoreboardPacket(byte position, String scoreName) implement
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.DISPLAY_SCOREBOARD;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -27,7 +28,7 @@ public record EffectPacket(int effectId, Point position, int data,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -22,7 +23,7 @@ public record EndCombatEventPacket(int duration) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.END_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record EnterCombatEventPacket() implements ServerPacket {
|
||||
@ -20,7 +21,7 @@ public record EnterCombatEventPacket() implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTER_COMBAT_EVENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record EntityAnimationPacket(int entityId, @NotNull Animation animation)
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.potion.Potion;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
@ -29,7 +30,7 @@ public record EntityEffectPacket(int entityId, @NotNull Potion potion,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -48,7 +49,7 @@ public record EntityEquipmentPacket(int entityId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_EQUIPMENT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record EntityHeadLookPacket(int entityId, float yaw) implements ServerPac
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_HEAD_LOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -53,7 +54,7 @@ public record EntityMetaDataPacket(int entityId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_METADATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -31,7 +32,7 @@ public record EntityPositionAndRotationPacket(int entityId, short deltaX, short
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION_AND_ROTATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -29,7 +30,7 @@ public record EntityPositionPacket(int entityId, short deltaX, short deltaY, sho
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_POSITION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -61,7 +62,7 @@ public record EntityPropertiesPacket(int entityId, List<AttributeInstance> prope
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_PROPERTIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -25,7 +26,7 @@ public record EntityRotationPacket(int entityId, float yaw, float pitch, boolean
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_ROTATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.sound.SoundEvent;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -94,7 +95,7 @@ public record EntitySoundEffectPacket(
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_SOUND_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -24,7 +25,7 @@ public record EntityStatusPacket(int entityId, byte status) implements ServerPac
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_STATUS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -31,7 +32,7 @@ public record EntityTeleportPacket(int entityId, Pos position, boolean onGround)
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_TELEPORT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.SHORT;
|
||||
@ -38,7 +39,7 @@ public record EntityVelocityPacket(int entityId, short velocityX, short velocity
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.ENTITY_VELOCITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -33,7 +34,7 @@ public record ExplosionPacket(double x, double y, double z, float radius, byte @
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.EXPLOSION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -37,7 +38,7 @@ public record FacePlayerPacket(FacePosition facePosition,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.FACE_PLAYER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -22,7 +23,7 @@ public record HeldItemChangePacket(byte slot) implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.HELD_ITEM_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||
@ -25,7 +26,7 @@ public record HitAnimationPacket(int entityId, float yaw) implements ServerPacke
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.HIT_ANIMATION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -34,7 +35,7 @@ public record InitializeWorldBorderPacket(double x, double z,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.INITIALIZE_WORLD_BORDER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
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.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
@ -80,7 +81,7 @@ public record JoinGamePacket(
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.JOIN_GAME;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -65,7 +66,7 @@ public record MapDataPacket(int mapId, byte scale, boolean locked,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.MAP_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -28,7 +29,7 @@ public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) i
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.MULTI_BLOCK_CHANGE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
@ -29,7 +30,7 @@ public record NbtQueryResponsePacket(int transactionId, NBTCompound data) implem
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.NBT_QUERY_RESPONSE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket {
|
||||
@ -21,7 +22,7 @@ public record OpenBookPacket(@NotNull Player.Hand hand) implements ServerPacket
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_BOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -24,7 +25,7 @@ public record OpenHorseWindowPacket(byte windowId, int slotCount, int entityId)
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_HORSE_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
||||
@ -25,7 +26,7 @@ public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText)
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_SIGN_EDITOR;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -32,7 +33,7 @@ public record OpenWindowPacket(int windowId, int windowType,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.OPEN_WINDOW;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -39,7 +40,7 @@ public record ParticlePacket(int particleId, boolean longDistance,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PARTICLE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BYTE;
|
||||
@ -30,7 +31,7 @@ public record PlayerAbilitiesPacket(byte flags, float flyingSpeed, float walking
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_ABILITIES;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -52,7 +53,7 @@ public record PlayerChatMessagePacket(UUID sender, int index, byte @Nullable []
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_CHAT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -31,7 +32,7 @@ public record PlayerInfoRemovePacket(@NotNull List<@NotNull UUID> uuids) impleme
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_REMOVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -74,7 +75,7 @@ public final class PlayerInfoUpdatePacket implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_INFO_UPDATE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -40,7 +41,7 @@ public record PlayerListHeaderAndFooterPacket(@NotNull Component header,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_LIST_HEADER_AND_FOOTER;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -32,7 +33,7 @@ public record PlayerPositionAndLookPacket(Pos position, byte flags, int teleport
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.PLAYER_POSITION_AND_LOOK;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -26,7 +27,7 @@ public record RemoveEntityEffectPacket(int entityId, @NotNull PotionEffect potio
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.REMOVE_ENTITY_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.network.packet.server.play.data.DeathLocation;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -48,7 +49,7 @@ public record RespawnPacket(
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.RESPAWN;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -54,7 +55,7 @@ public record ScoreboardObjectivePacket(@NotNull String objectiveName, byte mode
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SCOREBOARD_OBJECTIVE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -23,7 +24,7 @@ public record SelectAdvancementTabPacket(@Nullable String identifier) implements
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -28,7 +29,7 @@ public record ServerDataPacket(@Nullable Component motd, byte @Nullable [] iconB
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SERVER_DATA;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.world.Difficulty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -24,7 +25,7 @@ public record ServerDifficultyPacket(@NotNull Difficulty difficulty, boolean loc
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SERVER_DIFFICULTY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
||||
@ -23,7 +24,7 @@ public record SetCooldownPacket(int itemId, int cooldownTicks) implements Server
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_COOLDOWN;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.FLOAT;
|
||||
@ -25,7 +26,7 @@ public record SetExperiencePacket(float percentage, int level, int totalExperien
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_EXPERIENCE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -30,7 +31,7 @@ public record SetPassengersPacket(int vehicleEntityId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_PASSENGERS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -35,7 +36,7 @@ public record SetSlotPacket(byte windowId, int stateId, short slot,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_SLOT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -28,7 +29,7 @@ public record SetTitleSubTitlePacket(@NotNull Component subtitle) implements Com
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_SUBTITLE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -28,7 +29,7 @@ public record SetTitleTextPacket(@NotNull Component title) implements ComponentH
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TEXT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.INT;
|
||||
@ -24,7 +25,7 @@ public record SetTitleTimePacket(int fadeIn, int stay, int fadeOut) implements S
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SET_TITLE_TIME;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.sound.SoundEvent;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -102,7 +103,7 @@ public record SoundEffectPacket(
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SOUND_EFFECT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -46,7 +47,7 @@ public record SpawnEntityPacket(int entityId, @NotNull UUID uuid, int type,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_ENTITY;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.*;
|
||||
@ -29,7 +30,7 @@ public record SpawnExperienceOrbPacket(int entityId,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_EXPERIENCE_ORB;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
|
||||
@ -25,7 +26,7 @@ public record SpawnPositionPacket(@NotNull Point position, float angle) implemen
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SPAWN_POSITION;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -17,7 +18,7 @@ public record StartConfigurationPacket() implements ServerPacket {
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.START_CONFIGURATION_PACKET;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.statistic.StatisticCategory;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@ -29,7 +30,7 @@ public record StatisticsPacket(@NotNull List<Statistic> statistics) implements S
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.STATISTICS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -45,7 +46,7 @@ public record StopSoundPacket(byte flags, @Nullable Sound.Source source,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.STOP_SOUND;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -30,7 +31,7 @@ public record SystemChatPacket(@NotNull Component message, boolean overlay) impl
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.SYSTEM_CHAT;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ 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.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -39,7 +40,7 @@ public record TabCompletePacket(int transactionId, int start, int length,
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TAB_COMPLETE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ 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.utils.PacketUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -220,7 +221,7 @@ public record TeamsPacket(String teamName, Action action) implements ComponentHo
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TEAMS;
|
||||
default -> throw new IllegalArgumentException();
|
||||
default -> PacketUtils.invalidPacketState(getClass(), state, ConnectionState.PLAY);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minestom.server.network.NetworkBuffer.LONG;
|
||||
@ -23,7 +24,7 @@ public record TimeUpdatePacket(long worldAge, long timeOfDay) implements ServerP
|
||||
public int getId(@NotNull ConnectionState state) {
|
||||
return switch (state) {
|
||||
case PLAY -> ServerPacketIdentifier.TIME_UPDATE;
|
||||
default -> throw new IllegalArgumentException();
|
||||
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