From 8e99a4c5bf0f6770644124d2af173e47bb9992a1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 19 Jul 2025 10:43:44 +1000 Subject: [PATCH] Cleanup some formatting --- .../bungee/api/connection/Connection.java | 6 ++++-- .../bungee/api/connection/ProxiedPlayer.java | 1 + .../md_5/bungee/api/plugin/PluginManager.java | 3 +-- .../md_5/bungee/api/chat/BaseComponent.java | 5 +++-- .../bungee/api/dialog/DialogListDialog.java | 3 ++- .../bungee/api/dialog/ServerLinksDialog.java | 3 ++- .../api/dialog/action/RunCommandAction.java | 4 ++-- .../main/java/net/md_5/bungee/nbt/Tag.java | 21 +++++++++---------- .../channel/BungeeChannelInitializer.java | 7 +++++-- .../netty/LengthPrependerAndCompressor.java | 4 +++- .../bungee/chat/ClickEventSerializer.java | 3 ++- .../chat/VersionedComponentSerializer.java | 2 +- .../serializer/dialog/DialogSerializer.java | 1 + 13 files changed, 37 insertions(+), 26 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/connection/Connection.java b/api/src/main/java/net/md_5/bungee/api/connection/Connection.java index 392490d1..a953c553 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/Connection.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/Connection.java @@ -87,8 +87,10 @@ public interface Connection /** * Queue a packet to this connection. - * If the packet is not registered for the connections current encoder protocol, it will be queued until it is, - * otherwise it will be sent immediately. + * + * If the packet is not registered for the connections current encoder + * protocol, it will be queued until it is, otherwise it will be sent + * immediately. * * @param packet the packet to be queued * @throws UnsupportedOperationException if used for a PendingConnection diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index 1c0714f4..35956272 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -386,6 +386,7 @@ public interface ProxiedPlayer extends Connection, CommandSender /** * Gets the client brand of this player. + * * If the player has not sent a brand packet yet, it will return null. * * @return the brand of the client, or null if not received yet diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index b159456f..b16fda4a 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -474,8 +474,7 @@ public final class PluginManager { for ( Method method : listener.getClass().getDeclaredMethods() ) { - Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ), - "Listener %s has registered using deprecated subscribe annotation! Please update to @EventHandler.", listener ); + Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ), "Listener %s has registered using deprecated subscribe annotation! Please update to @EventHandler.", listener ); } eventBus.register( listener ); listenersByPlugin.put( plugin, listener ); diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java b/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java index 6ea86841..aebb3e13 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java @@ -313,8 +313,9 @@ public abstract class BaseComponent } /** - * Returns the shadow color of this component. This uses the parent's shadow color if this - * component doesn't have one. null is returned if no shadow color is found. + * Returns the shadow color of this component. This uses the parent's shadow + * color if this component doesn't have one. null is returned if no shadow + * color is found. * * @return the shadow color of this component */ diff --git a/dialog/src/main/java/net/md_5/bungee/api/dialog/DialogListDialog.java b/dialog/src/main/java/net/md_5/bungee/api/dialog/DialogListDialog.java index 3d9ef06e..b3ee98a4 100644 --- a/dialog/src/main/java/net/md_5/bungee/api/dialog/DialogListDialog.java +++ b/dialog/src/main/java/net/md_5/bungee/api/dialog/DialogListDialog.java @@ -38,7 +38,8 @@ public final class DialogListDialog implements Dialog */ private Integer columns; /** - * The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024). + * The width of the dialog buttons (default: 150, minimum: 1, maximum: + * 1024). */ @SerializedName("button_width") private Integer buttonWidth; diff --git a/dialog/src/main/java/net/md_5/bungee/api/dialog/ServerLinksDialog.java b/dialog/src/main/java/net/md_5/bungee/api/dialog/ServerLinksDialog.java index b348eeb9..a67494b7 100644 --- a/dialog/src/main/java/net/md_5/bungee/api/dialog/ServerLinksDialog.java +++ b/dialog/src/main/java/net/md_5/bungee/api/dialog/ServerLinksDialog.java @@ -37,7 +37,8 @@ public final class ServerLinksDialog implements Dialog */ private Integer columns; /** - * The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024). + * The width of the dialog buttons (default: 150, minimum: 1, maximum: + * 1024). */ @SerializedName("button_width") private Integer buttonWidth; diff --git a/dialog/src/main/java/net/md_5/bungee/api/dialog/action/RunCommandAction.java b/dialog/src/main/java/net/md_5/bungee/api/dialog/action/RunCommandAction.java index 2c2ad24a..06709f17 100644 --- a/dialog/src/main/java/net/md_5/bungee/api/dialog/action/RunCommandAction.java +++ b/dialog/src/main/java/net/md_5/bungee/api/dialog/action/RunCommandAction.java @@ -6,8 +6,8 @@ import lombok.ToString; import lombok.experimental.Accessors; /** - * Executes a command. If the command requires a permission - * higher than 0, a confirmation dialog will be shown by the client. + * Executes a command. If the command requires a permission higher than 0, a + * confirmation dialog will be shown by the client. */ @Data @Accessors(fluent = true) diff --git a/nbt/src/main/java/net/md_5/bungee/nbt/Tag.java b/nbt/src/main/java/net/md_5/bungee/nbt/Tag.java index 9c2ead4b..60cd917c 100644 --- a/nbt/src/main/java/net/md_5/bungee/nbt/Tag.java +++ b/nbt/src/main/java/net/md_5/bungee/nbt/Tag.java @@ -81,9 +81,8 @@ public interface Tag void write(DataOutput output) throws IOException; /** - * Reads a {@link Tag} from the given {@link DataInput}, - * based on the specified tag type, with limitations of the - * {@link NBTLimiter}. + * Reads a {@link Tag} from the given {@link DataInput}, based on the + * specified tag type, with limitations of the {@link NBTLimiter}. * * @param id the nbt type * @param input the input to read from @@ -104,8 +103,8 @@ public interface Tag } /** - * Reads a {@link NamedTag} from the given {@link DataInput}, - * with limitations of the {@link NBTLimiter}. + * Reads a {@link NamedTag} from the given {@link DataInput}, with + * limitations of the {@link NBTLimiter}. * * @param input the data input to read from * @param limiter the limiter for this read operation @@ -120,8 +119,8 @@ public interface Tag } /** - * Serializes the given {@link TypedTag} into a byte array. - * This is the inverse operation of {@link #fromByteArray(byte[])}. + * Serializes the given {@link TypedTag} into a byte array. This is the + * inverse operation of {@link #fromByteArray(byte[])}. * * @param tag the tag to convert * @return the serialized byte array @@ -137,8 +136,8 @@ public interface Tag } /** - * Deserializes the given byte array into a {@link TypedTag}. - * This is the inverse operation of {@link #toByteArray(TypedTag)}. + * Deserializes the given byte array into a {@link TypedTag}. This is the + * inverse operation of {@link #toByteArray(TypedTag)}. * * @param data the byte array to read from * @return the deserialized {@link TypedTag} @@ -150,8 +149,8 @@ public interface Tag } /** - * Deserializes the given byte array into a {@link TypedTag}, - * with limitations of the {@link NBTLimiter}. + * Deserializes the given byte array into a {@link TypedTag}, with + * limitations of the {@link NBTLimiter}. * * @param data the byte array to read from * @param limiter the limiter for this read operation diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/channel/BungeeChannelInitializer.java b/protocol/src/main/java/net/md_5/bungee/protocol/channel/BungeeChannelInitializer.java index 7ab45349..d0dcfc53 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/channel/BungeeChannelInitializer.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/channel/BungeeChannelInitializer.java @@ -7,8 +7,11 @@ import lombok.Getter; import lombok.NoArgsConstructor; /** - * This class hold a netty channel initializer that calls the given {@link ChannelAcceptor}. - * Use {@link BungeeChannelInitializer#create(ChannelAcceptor)} to create a new instance. + * This class hold a netty channel initializer that calls the given + * {@link ChannelAcceptor}. + * + * Use {@link BungeeChannelInitializer#create(ChannelAcceptor)} to create a new + * instance. *

* Please note that this API is unsafe and doesn't provide any guarantees about * the stability of the channel pipeline or the API itself. Use at your own diff --git a/proxy/src/main/java/net/md_5/bungee/netty/LengthPrependerAndCompressor.java b/proxy/src/main/java/net/md_5/bungee/netty/LengthPrependerAndCompressor.java index 90e535c4..817bb1c0 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/LengthPrependerAndCompressor.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/LengthPrependerAndCompressor.java @@ -13,10 +13,12 @@ import net.md_5.bungee.protocol.DefinedPacket; /** * prepends length of message and optionally compresses message beforehand *
- * combining these operations allows to keep space infront of compressed data for length varint + * combining these operations allows to keep space infront of compressed data + * for length varint */ public class LengthPrependerAndCompressor extends MessageToMessageEncoder { + // reasonable to not support length varints > 4 byte (268435455 byte > 268MB) // if ever changed to smaller than 4, also change varintSize method to check for that private static final byte MAX_SUPPORTED_VARINT_LENGTH_LEN = 4; diff --git a/serializer/src/main/java/net/md_5/bungee/chat/ClickEventSerializer.java b/serializer/src/main/java/net/md_5/bungee/chat/ClickEventSerializer.java index d60deadf..f2a72450 100644 --- a/serializer/src/main/java/net/md_5/bungee/chat/ClickEventSerializer.java +++ b/serializer/src/main/java/net/md_5/bungee/chat/ClickEventSerializer.java @@ -20,11 +20,12 @@ public class ClickEventSerializer public static final ClickEventSerializer NEW = new ClickEventSerializer( ClickType.NEW ); public static final ClickEventSerializer DIALOG = new ClickEventSerializer( ClickType.DIALOG ); // + private final ClickType type; + public enum ClickType { OLD, NEW, DIALOG; } - private final ClickType type; public ClickEvent deserialize(JsonObject clickEvent, JsonDeserializationContext context) throws JsonParseException { diff --git a/serializer/src/main/java/net/md_5/bungee/chat/VersionedComponentSerializer.java b/serializer/src/main/java/net/md_5/bungee/chat/VersionedComponentSerializer.java index f651bd22..60ac3fe3 100644 --- a/serializer/src/main/java/net/md_5/bungee/chat/VersionedComponentSerializer.java +++ b/serializer/src/main/java/net/md_5/bungee/chat/VersionedComponentSerializer.java @@ -265,7 +265,7 @@ public class VersionedComponentSerializer implements JsonDeserializer, JsonSerializer

{ + private static final ThreadLocal> serializedDialogs = new ThreadLocal<>(); private static final BiMap> TYPES; private final VersionedComponentSerializer serializer;