Skip to content

Commit

Permalink
Optimize imports and delete command declaration packet
Browse files Browse the repository at this point in the history
  • Loading branch information
MiGoYAm committed Dec 10, 2021
1 parent 3dfa56e commit 6d2ff1a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 79 deletions.
5 changes: 4 additions & 1 deletion src/main/java/ru/nanit/limbo/configuration/LimboConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import ru.nanit.limbo.server.data.*;
import ru.nanit.limbo.util.Colors;

import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.timeout.ReadTimeoutHandler;
import ru.nanit.limbo.connection.pipeline.VarIntFrameDecoder;
import ru.nanit.limbo.connection.pipeline.PacketDecoder;
import ru.nanit.limbo.connection.pipeline.PacketEncoder;
import ru.nanit.limbo.connection.pipeline.VarIntFrameDecoder;
import ru.nanit.limbo.connection.pipeline.VarIntLengthEncoder;
import ru.nanit.limbo.server.LimboServer;

Expand Down
11 changes: 3 additions & 8 deletions src/main/java/ru/nanit/limbo/connection/ClientConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import ru.nanit.limbo.LimboConstants;
import ru.nanit.limbo.connection.pipeline.PacketDecoder;
import ru.nanit.limbo.connection.pipeline.PacketEncoder;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PreEncodedPacket;
import ru.nanit.limbo.protocol.packets.PacketHandshake;
import ru.nanit.limbo.protocol.packets.login.*;
import ru.nanit.limbo.protocol.packets.play.*;
import ru.nanit.limbo.connection.pipeline.PacketDecoder;
import ru.nanit.limbo.connection.pipeline.PacketEncoder;
import ru.nanit.limbo.protocol.packets.PacketHandshake;
import ru.nanit.limbo.protocol.packets.status.PacketStatusPing;
import ru.nanit.limbo.protocol.packets.status.PacketStatusRequest;
import ru.nanit.limbo.protocol.packets.status.PacketStatusResponse;
Expand All @@ -33,7 +33,6 @@
import java.net.SocketAddress;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

Expand Down Expand Up @@ -404,16 +403,12 @@ public static void initPackets(LimboServer server) {
info.setGameMode(server.getConfig().getGameMode());
info.setUuid(uuid);

PacketDeclareCommands declareCommands = new PacketDeclareCommands();
declareCommands.setCommands(Collections.singletonList("limbo"));

PACKET_LOGIN_SUCCESS = PreEncodedPacket.of(loginSuccess);
PACKET_JOIN_GAME = PreEncodedPacket.of(joinGame);
PACKET_PLUGIN_MESSAGE = PreEncodedPacket.of(pluginMessage);
PACKET_PLAYER_ABILITIES = PreEncodedPacket.of(playerAbilities);
PACKET_PLAYER_POS = PreEncodedPacket.of(positionAndLook);
PACKET_PLAYER_INFO = PreEncodedPacket.of(info);
PACKET_DECLARE_COMMANDS = PreEncodedPacket.of(declareCommands);

if (server.getConfig().isUseJoinMessage()) {
PacketChatMessage joinMessage = new PacketChatMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import ru.nanit.limbo.protocol.*;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.Packet;
import ru.nanit.limbo.protocol.registry.State;
import ru.nanit.limbo.protocol.registry.Version;
import ru.nanit.limbo.util.Logger;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.nanit.limbo.protocol.packets.status;

import ru.nanit.limbo.protocol.*;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketIn;
import ru.nanit.limbo.protocol.registry.Version;

public class PacketStatusRequest implements PacketIn {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.nanit.limbo.protocol.packets.status;

import ru.nanit.limbo.protocol.*;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketOut;
import ru.nanit.limbo.protocol.registry.Version;
import ru.nanit.limbo.server.LimboServer;

Expand Down
13 changes: 3 additions & 10 deletions src/main/java/ru/nanit/limbo/protocol/registry/State.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package ru.nanit.limbo.protocol.registry;

import ru.nanit.limbo.protocol.Packet;
import ru.nanit.limbo.protocol.packets.*;
import ru.nanit.limbo.protocol.packets.PacketHandshake;
import ru.nanit.limbo.protocol.packets.login.*;
import ru.nanit.limbo.protocol.packets.play.*;
import ru.nanit.limbo.protocol.packets.status.PacketStatusPing;
import ru.nanit.limbo.protocol.packets.status.PacketStatusRequest;
import ru.nanit.limbo.protocol.packets.status.PacketStatusResponse;

import static ru.nanit.limbo.protocol.registry.Version.*;

import java.util.*;
import java.util.function.Supplier;

import static ru.nanit.limbo.protocol.registry.Version.*;

public enum State {

HANDSHAKING(0) {
Expand Down Expand Up @@ -70,13 +70,6 @@ public enum State {
map(0x0F, V1_17, V1_18)
);

clientBound.register(PacketDeclareCommands::new,
map(0x11, V1_13, V1_14_4),
map(0x12, V1_15, V1_15_2),
map(0x11, V1_16, V1_16_1),
map(0x10, V1_16_2, V1_16_4),
map(0x12, V1_17, V1_18)
);
clientBound.register(PacketJoinGame::new,
map(0x01, V1_8, V1_8),
map(0x23, V1_9, V1_12_2),
Expand Down

0 comments on commit 6d2ff1a

Please sign in to comment.