mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 04:28:21 +01:00
PacketUtils comment
This commit is contained in:
parent
2d009e19a7
commit
47045252e5
@ -52,9 +52,9 @@ public class NettyServer {
|
||||
channel = NioServerSocketChannel.class;
|
||||
}
|
||||
|
||||
bootstrap = new ServerBootstrap();
|
||||
bootstrap.group(boss, worker);
|
||||
bootstrap.channel(channel);
|
||||
bootstrap = new ServerBootstrap()
|
||||
.group(boss, worker)
|
||||
.channel(channel);
|
||||
|
||||
bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
protected void initChannel(@NotNull SocketChannel ch) {
|
||||
|
@ -10,7 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Class used to write packets.
|
||||
* Utils class for packets. Including writing a {@link ServerPacket} into a {@link ByteBuf}
|
||||
* for network processing.
|
||||
*/
|
||||
public final class PacketUtils {
|
||||
|
||||
@ -18,7 +19,15 @@ public final class PacketUtils {
|
||||
|
||||
}
|
||||
|
||||
public static void sendGroupedPacket(Collection<Player> players, ServerPacket packet) {
|
||||
/**
|
||||
* Sends a {@link ServerPacket} to multiple players. Mostly used for convenience.
|
||||
* <p>
|
||||
* Be aware that this will cause the send packet listeners to be given the exact same packet object.
|
||||
*
|
||||
* @param players the players to send the packet to
|
||||
* @param packet the packet to send to the players
|
||||
*/
|
||||
public static void sendGroupedPacket(@NotNull Collection<Player> players, @NotNull ServerPacket packet) {
|
||||
for (Player player : players) {
|
||||
player.getPlayerConnection().sendPacket(packet);
|
||||
}
|
||||
@ -31,7 +40,6 @@ public final class PacketUtils {
|
||||
* @param packet the packet to write into {@code buf}
|
||||
*/
|
||||
public static void writePacket(@NotNull ByteBuf buf, @NotNull ServerPacket packet) {
|
||||
|
||||
final ByteBuf packetBuffer = getPacketBuffer(packet);
|
||||
|
||||
writePacket(buf, packetBuffer, packet.getId());
|
||||
|
@ -11,6 +11,7 @@ import net.minestom.server.utils.NBTUtils;
|
||||
import net.minestom.server.utils.SerializerUtils;
|
||||
import net.minestom.server.utils.Utils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTException;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTReader;
|
||||
@ -29,7 +30,7 @@ public class BinaryReader extends InputStream {
|
||||
private final ByteBuf buffer;
|
||||
private final NBTReader nbtReader = new NBTReader(this, false);
|
||||
|
||||
public BinaryReader(ByteBuf buffer) {
|
||||
public BinaryReader(@NotNull ByteBuf buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class BinaryWriter extends OutputStream {
|
||||
private final NBTWriter nbtWriter = new NBTWriter(this, false);
|
||||
|
||||
/**
|
||||
* Creates a {@link BinaryWriter} with a custom initial capacity.
|
||||
* Creates a {@link BinaryWriter} using a heap buffer with a custom initial capacity.
|
||||
*
|
||||
* @param initialCapacity the initial capacity of the binary writer
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user