Optimize imports

This commit is contained in:
AlexProgrammerDE 2024-04-28 14:55:47 +02:00
parent 400f1b48a0
commit beb00d647f
213 changed files with 710 additions and 605 deletions

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.network.example;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.packet.Packet;
import io.netty.buffer.ByteBuf;
public class PingPacket implements Packet {
private final String id;

View file

@ -16,7 +16,7 @@ public class PingServerTest {
KeyGenerator gen = KeyGenerator.getInstance("AES");
gen.init(128);
key = gen.generateKey();
} catch(NoSuchAlgorithmException e) {
} catch (NoSuchAlgorithmException e) {
System.err.println("AES algorithm not supported, exiting...");
return;
}

View file

@ -1,5 +1,6 @@
package org.geysermc.mcprotocollib.network.example;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.Server;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.codec.BasePacketCodecHelper;
@ -11,7 +12,6 @@ import org.geysermc.mcprotocollib.network.crypt.PacketEncryption;
import org.geysermc.mcprotocollib.network.packet.DefaultPacketHeader;
import org.geysermc.mcprotocollib.network.packet.PacketHeader;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.buffer.ByteBuf;
import javax.crypto.SecretKey;
import java.security.GeneralSecurityException;

View file

@ -5,22 +5,9 @@ import com.github.steveice10.mc.auth.exception.request.RequestException;
import com.github.steveice10.mc.auth.service.AuthenticationService;
import com.github.steveice10.mc.auth.service.MojangAuthenticationService;
import com.github.steveice10.mc.auth.service.SessionService;
import org.geysermc.mcprotocollib.protocol.MinecraftConstants;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.protocol.ServerLoginHandler;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo;
import org.geysermc.mcprotocollib.protocol.data.status.PlayerInfo;
import org.geysermc.mcprotocollib.protocol.data.status.ServerStatusInfo;
import org.geysermc.mcprotocollib.protocol.data.status.VersionInfo;
import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerInfoBuilder;
import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerInfoHandler;
import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerPingTimeHandler;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.geysermc.mcprotocollib.network.ProxyInfo;
import org.geysermc.mcprotocollib.network.Server;
import org.geysermc.mcprotocollib.network.Session;
@ -33,9 +20,18 @@ import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.tcp.TcpClientSession;
import org.geysermc.mcprotocollib.network.tcp.TcpServer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.geysermc.mcprotocollib.protocol.MinecraftConstants;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo;
import org.geysermc.mcprotocollib.protocol.data.status.PlayerInfo;
import org.geysermc.mcprotocollib.protocol.data.status.ServerStatusInfo;
import org.geysermc.mcprotocollib.protocol.data.status.VersionInfo;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import java.net.Proxy;
import java.nio.charset.StandardCharsets;

View file

@ -1,9 +1,19 @@
package org.geysermc.mcprotocollib.network;
import org.geysermc.mcprotocollib.network.event.server.*;
import org.geysermc.mcprotocollib.network.event.server.ServerBoundEvent;
import org.geysermc.mcprotocollib.network.event.server.ServerClosedEvent;
import org.geysermc.mcprotocollib.network.event.server.ServerClosingEvent;
import org.geysermc.mcprotocollib.network.event.server.ServerEvent;
import org.geysermc.mcprotocollib.network.event.server.ServerListener;
import org.geysermc.mcprotocollib.network.event.server.SessionAddedEvent;
import org.geysermc.mcprotocollib.network.event.server.SessionRemovedEvent;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public abstract class AbstractServer implements Server {
@ -59,13 +69,13 @@ public abstract class AbstractServer implements Server {
@Override
public <T> T getGlobalFlag(Flag<T> flag, T def) {
Object value = this.flags.get(flag.key());
if(value == null) {
if (value == null) {
return def;
}
try {
return flag.cast(value);
} catch(ClassCastException e) {
} catch (ClassCastException e) {
throw new IllegalStateException("Tried to get flag \"" + flag.key() + "\" as the wrong type. Actual type: " + value.getClass().getName());
}
}
@ -91,7 +101,7 @@ public abstract class AbstractServer implements Server {
}
protected void callEvent(ServerEvent event) {
for(ServerListener listener : this.listeners) {
for (ServerListener listener : this.listeners) {
event.call(listener);
}
}
@ -108,7 +118,7 @@ public abstract class AbstractServer implements Server {
public void removeSession(Session session) {
this.sessions.remove(session);
if(session.isConnected()) {
if (session.isConnected()) {
session.disconnect("Connection closed.");
}
@ -129,7 +139,7 @@ public abstract class AbstractServer implements Server {
public AbstractServer bind(boolean wait, Runnable callback) {
this.bindImpl(wait, () -> {
callEvent(new ServerBoundEvent(AbstractServer.this));
if(callback != null) {
if (callback != null) {
callback.run();
}
});
@ -152,15 +162,15 @@ public abstract class AbstractServer implements Server {
@Override
public void close(boolean wait, Runnable callback) {
this.callEvent(new ServerClosingEvent(this));
for(Session session : this.getSessions()) {
if(session.isConnected()) {
for (Session session : this.getSessions()) {
if (session.isConnected()) {
session.disconnect("Server closed.");
}
}
this.closeImpl(wait, () -> {
callEvent(new ServerClosedEvent(AbstractServer.this));
if(callback != null) {
if (callback != null) {
callback.run();
}
});

View file

@ -15,7 +15,7 @@ public class ProxyInfo {
/**
* Creates a new unauthenticated ProxyInfo instance.
*
* @param type Type of proxy.
* @param type Type of proxy.
* @param address Network address of the proxy.
*/
public ProxyInfo(Type type, SocketAddress address) {
@ -27,7 +27,7 @@ public class ProxyInfo {
/**
* Creates a new authenticated ProxyInfo instance.
*
* @param type Type of proxy.
* @param type Type of proxy.
* @param address Network address of the proxy.
* @param username Username to authenticate with.
* @param password Password to authenticate with.

View file

@ -132,7 +132,7 @@ public interface Server {
/**
* Binds the listener to its host and port.
*
* @param wait Whether to wait for the listener to finish binding.
* @param wait Whether to wait for the listener to finish binding.
* @param callback Callback to call when the listener has finished binding.
* @return The server.
*/
@ -153,7 +153,7 @@ public interface Server {
/**
* Closes the listener.
*
* @param wait Whether to wait for the listener to finish closing.
* @param wait Whether to wait for the listener to finish closing.
* @param callback Callback to call when the listener has finished closing.
*/
void close(boolean wait, Runnable callback);

View file

@ -1,13 +1,13 @@
package org.geysermc.mcprotocollib.network;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.crypt.PacketEncryption;
import org.geysermc.mcprotocollib.network.event.session.SessionEvent;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.net.SocketAddress;
import java.util.List;
@ -270,7 +270,7 @@ public interface Session {
* Disconnects the session.
*
* @param reason Reason for disconnecting.
* @param cause Throwable responsible for disconnecting.
* @param cause Throwable responsible for disconnecting.
*/
void disconnect(@Nullable String reason, Throwable cause);
@ -285,7 +285,7 @@ public interface Session {
* Disconnects the session.
*
* @param reason Reason for disconnecting.
* @param cause Throwable responsible for disconnecting.
* @param cause Throwable responsible for disconnecting.
*/
void disconnect(@Nullable Component reason, Throwable cause);
}

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.codec;
import org.geysermc.mcprotocollib.network.packet.Packet;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.packet.Packet;
/**
* Represents a definition of a packet with various

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.codec;
import org.geysermc.mcprotocollib.network.packet.Packet;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.packet.Packet;
public interface PacketSerializer<T extends Packet, H extends PacketCodecHelper> {

View file

@ -23,10 +23,10 @@ public interface PacketEncryption {
/**
* Decrypts the given data.
*
* @param input Input data to decrypt.
* @param inputOffset Offset of the data to start decrypting at.
* @param inputLength Length of the data to be decrypted.
* @param output Array to output decrypted data to.
* @param input Input data to decrypt.
* @param inputOffset Offset of the data to start decrypting at.
* @param inputLength Length of the data to be decrypted.
* @param output Array to output decrypted data to.
* @param outputOffset Offset of the output array to start at.
* @return The number of bytes stored in the output array.
* @throws Exception If an error occurs.
@ -36,10 +36,10 @@ public interface PacketEncryption {
/**
* Encrypts the given data.
*
* @param input Input data to encrypt.
* @param inputOffset Offset of the data to start encrypting at.
* @param inputLength Length of the data to be encrypted.
* @param output Array to output encrypted data to.
* @param input Input data to encrypt.
* @param inputOffset Offset of the data to start encrypting at.
* @param inputLength Length of the data to be encrypted.
* @param output Array to output encrypted data to.
* @param outputOffset Offset of the output array to start at.
* @return The number of bytes stored in the output array.
* @throws Exception If an error occurs.

View file

@ -13,7 +13,7 @@ public class SessionAddedEvent implements ServerEvent {
/**
* Creates a new SessionAddedEvent instance.
*
* @param server Server the session is being added to.
* @param server Server the session is being added to.
* @param session Session being added.
*/
public SessionAddedEvent(Server server, Session session) {

View file

@ -13,7 +13,7 @@ public class SessionRemovedEvent implements ServerEvent {
/**
* Creates a new SessionRemovedEvent instance.
*
* @param server Server the session is being removed from.
* @param server Server the session is being removed from.
* @param session Session being removed.
*/
public SessionRemovedEvent(Server server, Session session) {

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.event.session;
import org.geysermc.mcprotocollib.network.Session;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.network.Session;
/**
* Called when the session is disconnected.
@ -15,8 +15,8 @@ public class DisconnectedEvent implements SessionEvent {
* Creates a new DisconnectedEvent instance.
*
* @param session Session being disconnected.
* @param reason Reason for the session to disconnect.
* @param cause Throwable that caused the disconnect.
* @param reason Reason for the session to disconnect.
* @param cause Throwable that caused the disconnect.
*/
public DisconnectedEvent(Session session, Component reason, Throwable cause) {
this.session = session;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.event.session;
import org.geysermc.mcprotocollib.network.Session;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.network.Session;
/**
* Called when the session is about to disconnect.
@ -15,8 +15,8 @@ public class DisconnectingEvent implements SessionEvent {
* Creates a new DisconnectingEvent instance.
*
* @param session Session being disconnected.
* @param reason Reason for the session to disconnect.
* @param cause Throwable that caused the disconnect.
* @param reason Reason for the session to disconnect.
* @param cause Throwable that caused the disconnect.
*/
public DisconnectingEvent(Session session, Component reason, Throwable cause) {
this.session = session;

View file

@ -14,7 +14,7 @@ public class PacketErrorEvent implements SessionEvent {
* Creates a new SessionErrorEvent instance.
*
* @param session Session that the error came from.
* @param cause Cause of the error.
* @param cause Cause of the error.
*/
public PacketErrorEvent(Session session, Throwable cause) {
this.session = session;

View file

@ -15,7 +15,7 @@ public class PacketSendingEvent implements SessionEvent {
* Creates a new PacketSendingEvent instance.
*
* @param session Session sending the packet.
* @param packet Packet being sent.
* @param packet Packet being sent.
*/
public PacketSendingEvent(Session session, Packet packet) {
this.session = session;
@ -42,7 +42,7 @@ public class PacketSendingEvent implements SessionEvent {
public <T extends Packet> T getPacket() {
try {
return (T) this.packet;
} catch(ClassCastException e) {
} catch (ClassCastException e) {
throw new IllegalStateException("Tried to get packet as the wrong type. Actual type: " + this.packet.getClass().getName());
}
}

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.event.session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
/**
* An adapter for picking session events to listen for.

View file

@ -10,7 +10,8 @@ public class TransportHelper {
}
public static TransportMethod determineTransportMethod() {
if (isClassAvailable("io.netty.incubator.channel.uring.IOUring") && IOUring.isAvailable()) return TransportMethod.IO_URING;
if (isClassAvailable("io.netty.incubator.channel.uring.IOUring") && IOUring.isAvailable())
return TransportMethod.IO_URING;
if (isClassAvailable("io.netty.channel.epoll.Epoll") && Epoll.isAvailable()) return TransportMethod.EPOLL;
if (isClassAvailable("io.netty.channel.kqueue.KQueue") && KQueue.isAvailable()) return TransportMethod.KQUEUE;
return TransportMethod.NIO;

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.network.packet;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
import io.netty.buffer.ByteBuf;
public class BufferedPacket implements Packet, PacketSerializer<BufferedPacket, PacketCodecHelper> {
private final Class<? extends Packet> packetClass;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.packet;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
/**
* The default packet header, using a varint packet length and id.
@ -19,13 +19,13 @@ public class DefaultPacketHeader implements PacketHeader {
@Override
public int getLengthSize(int length) {
if((length & -128) == 0) {
if ((length & -128) == 0) {
return 1;
} else if((length & -16384) == 0) {
} else if ((length & -16384) == 0) {
return 2;
} else if((length & -2097152) == 0) {
} else if ((length & -2097152) == 0) {
return 3;
} else if((length & -268435456) == 0) {
} else if ((length & -268435456) == 0) {
return 4;
} else {
return 5;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network.packet;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
/**
* The header of a protocol's packets.
@ -32,9 +32,9 @@ public interface PacketHeader {
/**
* Reads the length of a packet from the given input.
*
* @param buf Buffer to read from.
* @param buf Buffer to read from.
* @param codecHelper The codec helper.
* @param available Number of packet bytes available after the length.
* @param available Number of packet bytes available after the length.
* @return The resulting packet length.
*/
int readLength(ByteBuf buf, PacketCodecHelper codecHelper, int available);
@ -42,16 +42,16 @@ public interface PacketHeader {
/**
* Writes the length of a packet to the given output.
*
* @param buf Buffer to write to.
* @param buf Buffer to write to.
* @param codecHelper The codec helper.
* @param length Length to write.
* @param length Length to write.
*/
void writeLength(ByteBuf buf, PacketCodecHelper codecHelper, int length);
/**
* Reads the ID of a packet from the given input.
*
* @param buf Buffer to read from.
* @param buf Buffer to read from.
* @param codecHelper The codec helper.
* @return The resulting packet ID, or -1 if the packet should not be read yet.
*/
@ -60,9 +60,9 @@ public interface PacketHeader {
/**
* Writes the ID of a packet to the given output.
*
* @param buf Buffer to write to.
* @param buf Buffer to write to.
* @param codecHelper The codec helper.
* @param packetId Packet ID to write.
* @param packetId Packet ID to write.
*/
void writePacketId(ByteBuf buf, PacketCodecHelper codecHelper, int packetId);
}

View file

@ -1,13 +1,13 @@
package org.geysermc.mcprotocollib.network.packet;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
import org.geysermc.mcprotocollib.network.Server;
import org.geysermc.mcprotocollib.network.Session;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.geysermc.mcprotocollib.network.Server;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
import java.util.IdentityHashMap;
import java.util.Map;
@ -56,7 +56,7 @@ public abstract class PacketProtocol {
/**
* Called when a server session is created with this protocol.
*
* @param server The server that the session belongs to.
* @param server The server that the session belongs to.
* @param session The created session.
*/
public abstract void newServerSession(Server server, Session session);
@ -74,8 +74,8 @@ public abstract class PacketProtocol {
/**
* Registers a packet to this protocol as both serverbound and clientbound.
*
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param serializer The packet serializer.
* @throws IllegalArgumentException If the packet fails a test creation when being registered as serverbound.
*/
@ -98,8 +98,8 @@ public abstract class PacketProtocol {
/**
* Registers a serverbound packet to this protocol.
*
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param serializer The packet serializer.
* @throws IllegalArgumentException If the packet fails a test creation.
*/
@ -120,8 +120,8 @@ public abstract class PacketProtocol {
/**
* Registers a clientbound packet to this protocol.
*
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param id Id to register the packet to.
* @param packet Packet to register.
* @param serializer The packet serializer.
*/
public final <T extends Packet, H extends PacketCodecHelper> void registerClientbound(int id, Class<T> packet, PacketSerializer<T, H> serializer) {
@ -141,8 +141,8 @@ public abstract class PacketProtocol {
/**
* Creates a new instance of a clientbound packet with the given id and read the clientbound input.
*
* @param id Id of the packet to create.
* @param buf The buffer to read the packet from.
* @param id Id of the packet to create.
* @param buf The buffer to read the packet from.
* @param codecHelper The codec helper.
* @return The created packet.
* @throws IllegalArgumentException If the packet ID is not registered.
@ -166,7 +166,7 @@ public abstract class PacketProtocol {
*/
public int getClientboundId(Class<? extends Packet> packetClass) {
Integer packetId = this.clientboundIds.get(packetClass);
if(packetId == null) {
if (packetId == null) {
throw new IllegalArgumentException("Unregistered clientbound packet class: " + packetClass.getName());
}
@ -190,6 +190,7 @@ public abstract class PacketProtocol {
/**
* Gets the packet class for a packet id.
*
* @param id The packet id.
* @return The registered packet's class
* @throws IllegalArgumentException If the packet ID is not registered.
@ -206,8 +207,8 @@ public abstract class PacketProtocol {
/**
* Creates a new instance of a serverbound packet with the given id and read the serverbound input.
*
* @param id Id of the packet to create.
* @param buf The buffer to read the packet from.
* @param id Id of the packet to create.
* @param buf The buffer to read the packet from.
* @param codecHelper The codec helper.
* @return The created packet.
* @throws IllegalArgumentException If the packet ID is not registered.
@ -255,6 +256,7 @@ public abstract class PacketProtocol {
/**
* Gets the packet class for a packet id.
*
* @param id The packet id.
* @return The registered packet's class
* @throws IllegalArgumentException If the packet ID is not registered.

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.network.tcp;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundBundlePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDelimiterPacket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,21 +1,25 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.BuiltinFlags;
import org.geysermc.mcprotocollib.network.ProxyInfo;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.helper.TransportHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.AddressedEnvelope;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollDatagramChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.*;
import io.netty.channel.kqueue.KQueueDatagramChannel;
import io.netty.channel.kqueue.KQueueEventLoopGroup;
import io.netty.channel.kqueue.KQueueSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.dns.DefaultDnsQuestion;
@ -38,8 +42,16 @@ import io.netty.incubator.channel.uring.IOUringSocketChannel;
import io.netty.resolver.dns.DnsNameResolver;
import io.netty.resolver.dns.DnsNameResolverBuilder;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.geysermc.mcprotocollib.network.BuiltinFlags;
import org.geysermc.mcprotocollib.network.ProxyInfo;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.helper.TransportHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import java.net.*;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
@ -82,7 +94,7 @@ public class TcpClientSession extends TcpSession {
@Override
public void connect(boolean wait, boolean transferring) {
if(this.disconnected) {
if (this.disconnected) {
throw new IllegalStateException("Session has already been disconnected.");
}
@ -144,7 +156,7 @@ public class TcpClientSession extends TcpSession {
exceptionCaught(null, futureListener.cause());
}
});
} catch(Throwable t) {
} catch (Throwable t) {
exceptionCaught(null, t);
}
}
@ -162,7 +174,7 @@ public class TcpClientSession extends TcpSession {
System.out.println("[PacketLib] Attempting SRV lookup for \"" + name + "\".");
}
if(getFlag(BuiltinFlags.ATTEMPT_SRV_RESOLVE, true) && (!this.host.matches(IP_REGEX) && !this.host.equalsIgnoreCase("localhost"))) {
if (getFlag(BuiltinFlags.ATTEMPT_SRV_RESOLVE, true) && (!this.host.matches(IP_REGEX) && !this.host.equalsIgnoreCase("localhost"))) {
AddressedEnvelope<DnsResponse, InetSocketAddress> envelope = null;
try (DnsNameResolver resolver = new DnsNameResolverBuilder(EVENT_LOOP_GROUP.next())
.channelType(DATAGRAM_CHANNEL_CLASS)
@ -205,7 +217,7 @@ public class TcpClientSession extends TcpSession {
}
}
} else if(debug) {
} else if (debug) {
System.out.println("[PacketLib] Not resolving SRV record for " + this.host);
}
@ -226,7 +238,7 @@ public class TcpClientSession extends TcpSession {
}
private void addProxy(ChannelPipeline pipeline) {
if(proxy != null) {
if (proxy != null) {
switch (proxy.getType()) {
case HTTP -> {
if (proxy.isAuthenticated()) {
@ -310,16 +322,16 @@ public class TcpClientSession extends TcpSession {
}
Runtime.getRuntime().addShutdownHook(new Thread(
() -> EVENT_LOOP_GROUP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
() -> EVENT_LOOP_GROUP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
}
protected static ThreadFactory newThreadFactory() {
// Create a new daemon thread. When the last non daemon thread ends
// the runtime environment will call the shutdown hooks. One of the
// hooks will try to shut down the event loop group which will
// normally lead to the thread exiting. If not, it will be forcibly
// killed after SHUTDOWN_TIMEOUT_MS along with the other
// daemon threads as the runtime exits.
return new DefaultThreadFactory(TcpClientSession.class, true);
// Create a new daemon thread. When the last non daemon thread ends
// the runtime environment will call the shutdown hooks. One of the
// hooks will try to shut down the event loop group which will
// normally lead to the thread exiting. If not, it will be forcibly
// killed after SHUTDOWN_TIMEOUT_MS along with the other
// daemon threads as the runtime exits.
return new DefaultThreadFactory(TcpClientSession.class, true);
}
}

View file

@ -1,14 +1,14 @@
package org.geysermc.mcprotocollib.network.tcp;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.event.session.PacketErrorEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import java.util.List;

View file

@ -1,12 +1,12 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.Session;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.EncoderException;
import org.geysermc.mcprotocollib.network.Session;
import java.util.List;
import java.util.zip.Deflater;
@ -40,7 +40,7 @@ public class TcpPacketCompression extends ByteToMessageCodec<ByteBuf> {
if (readable > MAX_UNCOMPRESSED_SIZE) {
throw new EncoderException("Packet too big: size of " + readable + " is larger than the protocol maximum of " + MAX_UNCOMPRESSED_SIZE + ".");
}
if(readable < this.session.getCompressionThreshold()) {
if (readable < this.session.getCompressionThreshold()) {
this.session.getCodecHelper().writeVarInt(out, 0);
out.writeBytes(in);
} else {
@ -49,7 +49,7 @@ public class TcpPacketCompression extends ByteToMessageCodec<ByteBuf> {
this.session.getCodecHelper().writeVarInt(out, bytes.length);
this.deflater.setInput(bytes, 0, readable);
this.deflater.finish();
while(!this.deflater.finished()) {
while (!this.deflater.finished()) {
int length = this.deflater.deflate(this.buf);
out.writeBytes(this.buf, 0, length);
}

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.crypt.PacketEncryption;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import org.geysermc.mcprotocollib.network.crypt.PacketEncryption;
import java.util.List;
@ -21,7 +21,7 @@ public class TcpPacketEncryptor extends ByteToMessageCodec<ByteBuf> {
int length = in.readableBytes();
byte[] bytes = this.getBytes(in);
int outLength = this.encryption.getEncryptOutputSize(length);
if( this.encryptedArray.length < outLength) {
if (this.encryptedArray.length < outLength) {
this.encryptedArray = new byte[outLength];
}

View file

@ -1,11 +1,11 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.Session;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import io.netty.handler.codec.CorruptedFrameException;
import org.geysermc.mcprotocollib.network.Session;
import java.util.List;

View file

@ -1,13 +1,16 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.AbstractServer;
import org.geysermc.mcprotocollib.network.BuiltinFlags;
import org.geysermc.mcprotocollib.network.helper.TransportHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.*;
import io.netty.channel.kqueue.KQueueEventLoopGroup;
import io.netty.channel.kqueue.KQueueServerSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
@ -16,6 +19,10 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
import io.netty.util.concurrent.Future;
import org.geysermc.mcprotocollib.network.AbstractServer;
import org.geysermc.mcprotocollib.network.BuiltinFlags;
import org.geysermc.mcprotocollib.network.helper.TransportHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import java.net.InetSocketAddress;
import java.util.function.Supplier;
@ -36,7 +43,7 @@ public class TcpServer extends AbstractServer {
@Override
public void bindImpl(boolean wait, final Runnable callback) {
if(this.group != null || this.channel != null) {
if (this.group != null || this.channel != null) {
return;
}
@ -89,26 +96,26 @@ public class TcpServer extends AbstractServer {
}
}).group(this.group).localAddress(this.getHost(), this.getPort()).bind();
if(wait) {
if (wait) {
try {
future.sync();
} catch(InterruptedException e) {
} catch (InterruptedException e) {
}
channel = future.channel();
if(callback != null) {
if (callback != null) {
callback.run();
}
} else {
future.addListener((ChannelFutureListener) future1 -> {
if(future1.isSuccess()) {
if (future1.isSuccess()) {
channel = future1.channel();
if(callback != null) {
if (callback != null) {
callback.run();
}
} else {
System.err.println("[ERROR] Failed to asynchronously bind connection listener.");
if(future1.cause() != null) {
if (future1.cause() != null) {
future1.cause().printStackTrace();
}
}
@ -118,27 +125,27 @@ public class TcpServer extends AbstractServer {
@Override
public void closeImpl(boolean wait, final Runnable callback) {
if(this.channel != null) {
if(this.channel.isOpen()) {
if (this.channel != null) {
if (this.channel.isOpen()) {
ChannelFuture future = this.channel.close();
if(wait) {
if (wait) {
try {
future.sync();
} catch(InterruptedException e) {
} catch (InterruptedException e) {
}
if(callback != null) {
if (callback != null) {
callback.run();
}
} else {
future.addListener((ChannelFutureListener) future1 -> {
if(future1.isSuccess()) {
if(callback != null) {
if (future1.isSuccess()) {
if (callback != null) {
callback.run();
}
} else {
System.err.println("[ERROR] Failed to asynchronously close connection listener.");
if(future1.cause() != null) {
if (future1.cause() != null) {
future1.cause().printStackTrace();
}
}
@ -149,18 +156,18 @@ public class TcpServer extends AbstractServer {
this.channel = null;
}
if(this.group != null) {
if (this.group != null) {
Future<?> future = this.group.shutdownGracefully();
if(wait) {
if (wait) {
try {
future.sync();
} catch(InterruptedException e) {
} catch (InterruptedException e) {
}
} else {
future.addListener(future1 -> {
if(!future1.isSuccess() && getGlobalFlag(BuiltinFlags.PRINT_DEBUG, false)) {
if (!future1.isSuccess() && getGlobalFlag(BuiltinFlags.PRINT_DEBUG, false)) {
System.err.println("[ERROR] Failed to asynchronously close connection listener.");
if(future1.cause() != null) {
if (future1.cause() != null) {
future1.cause().printStackTrace();
}
}

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.network.tcp;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.channel.ChannelHandlerContext;
import org.geysermc.mcprotocollib.network.Flag;
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import java.util.HashMap;
import java.util.Map;
@ -33,7 +33,7 @@ public class TcpServerSession extends TcpSession {
@Override
public boolean hasFlag(Flag<?> flag) {
if(super.hasFlag(flag)) {
if (super.hasFlag(flag)) {
return true;
}
@ -43,7 +43,7 @@ public class TcpServerSession extends TcpSession {
@Override
public <T> T getFlag(Flag<T> flag, T def) {
T ret = super.getFlag(flag, null);
if(ret != null) {
if (ret != null) {
return ret;
}

View file

@ -1,5 +1,21 @@
package org.geysermc.mcprotocollib.network.tcp;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ConnectTimeoutException;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutException;
import io.netty.handler.timeout.WriteTimeoutHandler;
import io.netty.util.concurrent.DefaultThreadFactory;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.network.Flag;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.crypt.PacketEncryption;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
@ -10,15 +26,6 @@ import org.geysermc.mcprotocollib.network.event.session.SessionEvent;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import io.netty.channel.*;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutException;
import io.netty.handler.timeout.WriteTimeoutHandler;
import io.netty.util.concurrent.DefaultThreadFactory;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.network.Flag;
import java.net.ConnectException;
import java.net.SocketAddress;
@ -252,7 +259,7 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
@Override
public void send(Packet packet) {
if(this.channel == null) {
if (this.channel == null) {
return;
}
@ -262,7 +269,7 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
if (!sendingEvent.isCancelled()) {
final Packet toSend = sendingEvent.getPacket();
this.channel.writeAndFlush(toSend).addListener((ChannelFutureListener) future -> {
if(future.isSuccess()) {
if (future.isSuccess()) {
callPacketSent(toSend);
} else {
exceptionCaught(null, future.cause());
@ -314,7 +321,7 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
// daemon threads and their interaction with the runtime.
PACKET_EVENT_LOOP = new DefaultEventLoopGroup(new DefaultThreadFactory(this.getClass(), true));
Runtime.getRuntime().addShutdownHook(new Thread(
() -> PACKET_EVENT_LOOP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
() -> PACKET_EVENT_LOOP.shutdownGracefully(SHUTDOWN_QUIET_PERIOD_MS, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)));
}
return PACKET_EVENT_LOOP.next();
}

View file

@ -103,7 +103,7 @@ public class MinecraftProtocol extends PacketProtocol {
/**
* Constructs a new MinecraftProtocol instance for logging in using offline mode.
*
* @param codec The packet codec to use.
* @param codec The packet codec to use.
* @param username Username to use.
*/
public MinecraftProtocol(@NonNull PacketCodec codec, @NonNull String username) {
@ -113,7 +113,7 @@ public class MinecraftProtocol extends PacketProtocol {
/**
* Constructs a new MinecraftProtocol instance for logging in.
*
* @param profile GameProfile to use.
* @param profile GameProfile to use.
* @param accessToken Access token to use, or null if using offline mode.
*/
public MinecraftProtocol(@NonNull GameProfile profile, String accessToken) {
@ -123,8 +123,8 @@ public class MinecraftProtocol extends PacketProtocol {
/**
* Constructs a new MinecraftProtocol instance for logging in.
*
* @param codec The packet codec to use.
* @param profile GameProfile to use.
* @param codec The packet codec to use.
* @param profile GameProfile to use.
* @param accessToken Access token to use, or null if using offline mode.
*/
public MinecraftProtocol(@NonNull PacketCodec codec, @NonNull GameProfile profile, String accessToken) {

View file

@ -103,7 +103,8 @@ public class ServerListener extends SessionAdapter {
session.disconnect("Outdated client! Please use " + protocol.getCodec().getMinecraftVersion() + ".");
}
}
default -> throw new UnsupportedOperationException("Invalid client intent: " + intentionPacket.getIntent());
default ->
throw new UnsupportedOperationException("Invalid client intent: " + intentionPacket.getIntent());
}
}
} else if (protocol.getState() == ProtocolState.LOGIN) {

View file

@ -1,9 +1,23 @@
package org.geysermc.mcprotocollib.protocol.codec;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.google.gson.JsonElement;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import org.cloudburstmc.nbt.*;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import org.cloudburstmc.nbt.NBTInputStream;
import org.cloudburstmc.nbt.NBTOutputStream;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.mcprotocollib.network.codec.BasePacketCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
@ -27,10 +41,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOp
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ArmadilloState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.SnifferState;
@ -40,6 +50,10 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.player.BlockBreakSta
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo;
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.PaintingType;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.level.LightUpdateData;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType;
@ -68,29 +82,23 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.sound.SoundCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
import org.geysermc.mcprotocollib.protocol.data.game.statistic.StatisticCategory;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.network.codec.BasePacketCodecHelper;
import com.google.gson.JsonElement;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
import static org.cloudburstmc.nbt.NbtType.byClass;
@RequiredArgsConstructor
public class MinecraftCodecHelper extends BasePacketCodecHelper {
private static final int POSITION_X_SIZE = 38;

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.codec;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
import io.netty.buffer.ByteBuf;
import lombok.RequiredArgsConstructor;
import org.geysermc.mcprotocollib.network.codec.PacketDefinition;
import org.geysermc.mcprotocollib.network.codec.PacketSerializer;
@RequiredArgsConstructor
public class MinecraftPacketSerializer<T extends MinecraftPacket> implements PacketSerializer<T, MinecraftCodecHelper> {

View file

@ -14,7 +14,6 @@ import org.cloudburstmc.nbt.NbtType;
import org.jetbrains.annotations.Contract;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -26,21 +25,21 @@ import java.util.UUID;
public class NbtComponentSerializer {
private static final Set<String> BOOLEAN_TYPES = Set.of(
"interpret",
"bold",
"italic",
"underlined",
"strikethrough",
"obfuscated"
"interpret",
"bold",
"italic",
"underlined",
"strikethrough",
"obfuscated"
);
// Order is important
private static final List<Pair<String, String>> COMPONENT_TYPES = List.of(
new Pair<>("text", "text"),
new Pair<>("translatable", "translate"),
new Pair<>("score", "score"),
new Pair<>("selector", "selector"),
new Pair<>("keybind", "keybind"),
new Pair<>("nbt", "nbt")
new Pair<>("text", "text"),
new Pair<>("translatable", "translate"),
new Pair<>("score", "score"),
new Pair<>("selector", "selector"),
new Pair<>("keybind", "keybind"),
new Pair<>("nbt", "nbt")
);
private NbtComponentSerializer() {
@ -161,9 +160,9 @@ public class NbtComponentSerializer {
/**
* Converts a json object entry to a tag entry.
*
* @param key key of the entry
* @param key key of the entry
* @param value value of the entry
* @param tag the resulting compound tag
* @param tag the resulting compound tag
*/
private static void convertObjectEntry(final String key, final JsonElement value, final NbtMapBuilder tag) {
if ((key.equals("contents")) && value.isJsonObject()) {

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.codec;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import java.util.EnumMap;
import java.util.function.Supplier;

View file

@ -15,7 +15,7 @@ public interface PacketFactory<T extends Packet, H extends PacketCodecHelper> {
/**
* Constructs a new {@link Packet}.
*
* @param buf the input buffer
* @param buf the input buffer
* @param codecHelper the codec helper
* @return a new packet from the input
*/

View file

@ -1,12 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game;
import com.github.steveice10.mc.auth.data.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import java.security.PublicKey;
import java.util.UUID;
@ -23,7 +23,7 @@ public class PlayerListEntry {
private UUID sessionId;
private long expiresAt;
private @Nullable PublicKey publicKey;
private byte @Nullable[] keySignature;
private byte @Nullable [] keySignature;
public PlayerListEntry(UUID profileId) {
this(profileId, null, false, 0, GameMode.SURVIVAL, null, null, 0, null, null);

View file

@ -1,11 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.advancement;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import java.util.List;

View file

@ -1,16 +1,16 @@
package org.geysermc.mcprotocollib.protocol.data.game.chat;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
@Data
@AllArgsConstructor
public class MessageSignature {
private final int id;
private final byte @Nullable[] messageSignature;
private final byte @Nullable [] messageSignature;
public static MessageSignature read(ByteBuf in, MinecraftCodecHelper helper) {
int id = helper.readVarInt(in) - 1;

View file

@ -1,6 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.chunk;
import lombok.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
@ -32,7 +36,7 @@ public class BitStorage {
};
@Getter
private final long @NonNull[] data;
private final long @NonNull [] data;
@Getter
private final int bitsPerEntry;
@Getter
@ -48,7 +52,7 @@ public class BitStorage {
this(bitsPerEntry, size, null);
}
public BitStorage(int bitsPerEntry, int size, long @Nullable[] data) {
public BitStorage(int bitsPerEntry, int size, long @Nullable [] data) {
if (bitsPerEntry < 1 || bitsPerEntry > 32) {
throw new IllegalArgumentException("bitsPerEntry must be between 1 and 32, inclusive.");
}

View file

@ -1,6 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game.chunk;
import lombok.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@Data
@Setter(AccessLevel.NONE)

View file

@ -1,7 +1,17 @@
package org.geysermc.mcprotocollib.protocol.data.game.chunk;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.*;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.GlobalPalette;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.ListPalette;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.MapPalette;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.Palette;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.PaletteType;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.palette.SingletonPalette;
@Getter
@Setter

View file

@ -1,11 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.chunk.palette;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import java.util.Arrays;

View file

@ -1,12 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game.chunk.palette;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import java.util.Arrays;

View file

@ -32,6 +32,7 @@ public interface Palette {
/**
* Creates a copy of this palette.
* This performs a deep copy of the palette's internal data.
*
* @return The palette's copy.
*/
Palette copy();

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.command;
import org.geysermc.mcprotocollib.protocol.data.game.command.properties.CommandProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.command.properties.CommandProperties;
import java.util.OptionalInt;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.command;
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
import java.util.HashMap;
import java.util.Locale;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.command.properties;
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
@Data
public class ResourceProperties implements CommandProperties {

View file

@ -3,12 +3,8 @@ package org.geysermc.mcprotocollib.protocol.data.game.entity.attribute;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
public interface AttributeType {
String getIdentifier();

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import io.netty.buffer.ByteBuf;
public class BooleanMetadataType extends MetadataType<Boolean> {
private final BooleanReader primitiveReader;
@ -23,7 +23,7 @@ public class BooleanMetadataType extends MetadataType<Boolean> {
}
public void writeMetadataPrimitive(ByteBuf output, boolean value) {
this.primitiveWriter.writePrimitive(output, value);
this.primitiveWriter.writePrimitive(output, value);
}
@FunctionalInterface

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import io.netty.buffer.ByteBuf;
public class ByteMetadataType extends MetadataType<Byte> {
private final ByteReader primitiveReader;

View file

@ -1,11 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import java.util.Objects;

View file

@ -1,11 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
@Data
@AllArgsConstructor

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
import io.netty.buffer.ByteBuf;
public class FloatMetadataType extends MetadataType<Float> {
private final FloatReader primitiveReader;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import io.netty.buffer.ByteBuf;
public class IntMetadataType extends MetadataType<Integer> {
private final IntReader primitiveReader;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.LongEntityMetadata;
import io.netty.buffer.ByteBuf;
public class LongMetadataType extends MetadataType<Long> {
private final LongReader primitiveReader;

View file

@ -1,5 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
@ -12,12 +18,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.PaintingType;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import java.util.OptionalInt;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.BooleanMetadataType;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class BooleanEntityMetadata extends EntityMetadata<Boolean, BooleanMetadataType> {
private final boolean value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ByteMetadataType;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class ByteEntityMetadata extends EntityMetadata<Byte, ByteMetadataType> {
private final byte value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.FloatMetadataType;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class FloatEntityMetadata extends EntityMetadata<Float, FloatMetadataType> {
private final float value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.IntMetadataType;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class IntEntityMetadata extends EntityMetadata<Integer, IntMetadataType> {
private final int value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.LongMetadataType;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class LongEntityMetadata extends EntityMetadata<Long, LongMetadataType> {
private final long value;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
import lombok.NonNull;
public class ObjectEntityMetadata<T> extends EntityMetadata<T, MetadataType<T>> {
private final T value;

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.player;
import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEventValue;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEventValue;
public enum GameMode implements GameEventValue {
SURVIVAL,

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.entity.player;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
@Data
@AllArgsConstructor

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.inventory;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
@Data
@AllArgsConstructor

View file

@ -54,7 +54,7 @@ public enum EnchantmentTableProperty implements ContainerProperty {
/**
* Packs enchantment type and level into one integer as used for the ENCHANTMENT_SLOT_X properties.
*
* @param type Id of the enchantment
* @param type Id of the enchantment
* @param level Level of the enchantment
* @return Packed value
* @see #getEnchantmentType(int)

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.item;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
@Data
@AllArgsConstructor

View file

@ -17,7 +17,7 @@ public class AdventureModePredicate {
@AllArgsConstructor
public static class BlockPredicate {
private final @Nullable String location;
private final int @Nullable[] holders;
private final int @Nullable [] holders;
private final @Nullable List<PropertyMatcher> properties;
private final @Nullable NbtMap nbt;
}

View file

@ -1,10 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
public record ArmorTrim(Holder<TrimMaterial> material, Holder<TrimPattern> pattern, boolean showInTooltip) {
public record TrimMaterial(String assetName, int ingredientId, float itemModelIndex,

View file

@ -1,9 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.jetbrains.annotations.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
@Data
@AllArgsConstructor

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.BooleanDataComponent;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.BooleanDataComponent;
public class BooleanComponentType extends DataComponentType<Boolean> {
protected final BooleanReader primitiveReader;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.ObjectDataComponent;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.ObjectDataComponent;
import java.util.Objects;
@ -36,7 +36,7 @@ public abstract class DataComponent<V, T extends DataComponentType<V>> {
if (this == o) {
return true;
}
if (!(o instanceof DataComponent<?,?>)) {
if (!(o instanceof DataComponent<?, ?>)) {
return false;
}
DataComponent<?, ?> that = (DataComponent<?, ?>) o;

View file

@ -1,6 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import com.github.steveice10.mc.auth.data.GameProfile;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.nbt.NbtList;
import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
@ -9,9 +12,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.BooleanDataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.IntDataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.ObjectDataComponent;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import java.util.ArrayList;
import java.util.List;
@ -162,7 +162,8 @@ public class DataComponentType<T> {
}
private static Writer<Unit> unitWriter() {
return (helper, output, value) -> {};
return (helper, output, value) -> {
};
}
public static DataComponentType<?> read(ByteBuf in, MinecraftCodecHelper helper) {

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
@Data
@AllArgsConstructor

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.IntDataComponent;
import io.netty.buffer.ByteBuf;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.IntDataComponent;
public class IntComponentType extends DataComponentType<Integer> {
protected final IntReader primitiveReader;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation;
import java.util.List;
import java.util.UUID;

View file

@ -1,6 +1,11 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import com.github.steveice10.mc.auth.data.GameProfile;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.nbt.NbtList;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
@ -9,11 +14,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOp
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.CustomSound;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.kyori.adventure.text.Component;
import java.util.ArrayList;
import java.util.Collections;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos;
import org.jetbrains.annotations.Nullable;
@Data

View file

@ -17,7 +17,7 @@ public class ToolData {
@AllArgsConstructor
public static class Rule {
private final @Nullable String location;
private final int @Nullable[] holders;
private final int @Nullable [] holders;
private final @Nullable Float speed;
private final @Nullable Boolean correctForDrops;
}

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.BooleanComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemCodecHelper;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class BooleanDataComponent extends DataComponent<Boolean, BooleanComponentType> {
private final Boolean value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component.type;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.IntComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemCodecHelper;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;
public class IntDataComponent extends DataComponent<Integer, IntComponentType> {

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component.type;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import lombok.NonNull;
public class ObjectDataComponent<T> extends DataComponent<T, DataComponentType<T>> {
private final T value;

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.level;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import java.util.ArrayList;
import java.util.BitSet;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.block.value;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
@Data
@AllArgsConstructor

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.block.value;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.WobbleStyle;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.WobbleStyle;
@Data
@AllArgsConstructor

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.block.value;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
@Data
@AllArgsConstructor

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.event;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
@Data
@AllArgsConstructor

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.event;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import lombok.Value;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import java.util.EnumSet;
import java.util.Set;

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.event;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
@Data
@AllArgsConstructor

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.particle;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
@Data
@AllArgsConstructor

View file

@ -1,8 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.particle;
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.PositionSource;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.PositionSource;
@Data
@AllArgsConstructor

View file

@ -1,10 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
@Data
@AllArgsConstructor

View file

@ -1,9 +1,9 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.data.RecipeData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.data.RecipeData;
@Data
@AllArgsConstructor

View file

@ -1,12 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe.data;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.CraftingBookCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.CraftingBookCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
@Data
@AllArgsConstructor

View file

@ -1,12 +1,12 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe.data;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.CraftingBookCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.CraftingBookCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
@Data
@AllArgsConstructor

Some files were not shown because too many files have changed in this diff Show more