Fix code formatting

This commit is contained in:
md_5 2023-10-28 12:57:16 +11:00
parent 9cdb2ba3ea
commit e5c80d0044
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
7 changed files with 27 additions and 23 deletions

View File

@ -455,8 +455,8 @@ public final class ComponentBuilder
} }
/** /**
* Returns the component built by this builder. If this builder is * Returns the component built by this builder. If this builder is empty, an
* empty, an empty text component will be returned. * empty text component will be returned.
* *
* @return the component * @return the component
*/ */
@ -478,8 +478,8 @@ public final class ComponentBuilder
* <p> * <p>
* <strong>NOTE:</strong> {@link #build()} is preferred as it will * <strong>NOTE:</strong> {@link #build()} is preferred as it will
* consolidate all components into a single BaseComponent with extra * consolidate all components into a single BaseComponent with extra
* contents as opposed to an array of components which is non-standard * contents as opposed to an array of components which is non-standard and
* and may result in unexpected behavior. * may result in unexpected behavior.
* *
* @return the created components * @return the created components
*/ */

View File

@ -43,7 +43,7 @@ public final class ItemTag
private final int level; private final int level;
private final int id; private final int id;
} }
*/ */
private ItemTag(String nbt) private ItemTag(String nbt)
{ {

View File

@ -26,7 +26,10 @@ public class Text extends Content
public Text(BaseComponent value) public Text(BaseComponent value)
{ {
// For legacy serialization reasons, this has to be an array of components // For legacy serialization reasons, this has to be an array of components
this( new BaseComponent[]{value} ); this( new BaseComponent[]
{
value
} );
} }
public Text(String value) public Text(String value)

View File

@ -44,16 +44,17 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
/** /**
* Parse a JSON-compliant String as an array of base components. The input * Parse a JSON-compliant String as an array of base components. The input
* can be one of either an array of components, or a single component object. * can be one of either an array of components, or a single component
* If the input is an array, each component will be parsed individually and * object. If the input is an array, each component will be parsed
* returned in the order that they were parsed. If the input is a single * individually and returned in the order that they were parsed. If the
* component object, a single-valued array with the component will be returned. * input is a single component object, a single-valued array with the
* component will be returned.
* <p> * <p>
* <strong>NOTE:</strong> {@link #deserialize(String)} is preferred as it will * <strong>NOTE:</strong> {@link #deserialize(String)} is preferred as it
* parse only one component as opposed to an array of components which is non- * will parse only one component as opposed to an array of components which
* standard behavior. This method is still appropriate for parsing multiple * is non- standard behavior. This method is still appropriate for parsing
* components at once, although such use case is rarely (if at all) exhibited * multiple components at once, although such use case is rarely (if at all)
* in vanilla Minecraft. * exhibited in vanilla Minecraft.
* *
* @param json the component json to parse * @param json the component json to parse
* @return an array of all parsed components * @return an array of all parsed components

View File

@ -561,8 +561,7 @@ public class ComponentsTest
this.testBuilder( this.testBuilder(
ComponentBuilder::create, ComponentBuilder::create,
BaseComponent::toPlainText, BaseComponent::toPlainText,
ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD + "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
BaseComponent::toLegacyText BaseComponent::toLegacyText
); );
} }
@ -574,8 +573,7 @@ public class ComponentsTest
ComponentBuilder::build, ComponentBuilder::build,
(component) -> BaseComponent.toPlainText( component ), (component) -> BaseComponent.toPlainText( component ),
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component // An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
ChatColor.WHITE.toString() + ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD ChatColor.WHITE.toString() + ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD + "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
(component) -> BaseComponent.toLegacyText( component ) (component) -> BaseComponent.toLegacyText( component )
); );
} }
@ -830,8 +828,8 @@ public class ComponentsTest
String test2 = componentSerializer.apply( componentBuilder.apply( builder ) ); String test2 = componentSerializer.apply( componentBuilder.apply( builder ) );
assertEquals( assertEquals(
"{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"}," "{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},"
+ "{\"color\":\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"}," + "{\"color\":\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"},"
+ "{\"color\":\"white\",\"text\":\"rrrr\"}],\"text\":\"\"}", + "{\"color\":\"white\",\"text\":\"rrrr\"}],\"text\":\"\"}",
test2 ); test2 );
} }

View File

@ -7,7 +7,8 @@ import io.netty.handler.codec.MessageToMessageEncoder;
import java.util.List; import java.util.List;
/** /**
* Prepend length of the message as a Varint21 using an extra buffer for the length, avoiding copying packet data * Prepend length of the message as a Varint21 using an extra buffer for the
* length, avoiding copying packet data
*/ */
@ChannelHandler.Sharable @ChannelHandler.Sharable
public class Varint21LengthFieldExtraBufPrepender extends MessageToMessageEncoder<ByteBuf> public class Varint21LengthFieldExtraBufPrepender extends MessageToMessageEncoder<ByteBuf>

View File

@ -6,7 +6,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
/** /**
* Prepend length of the message as a Varint21 by writing length and data to a new buffer * Prepend length of the message as a Varint21 by writing length and data to a
* new buffer
*/ */
@ChannelHandler.Sharable @ChannelHandler.Sharable
public class Varint21LengthFieldPrepender extends MessageToByteEncoder<ByteBuf> public class Varint21LengthFieldPrepender extends MessageToByteEncoder<ByteBuf>