-
-
Notifications
You must be signed in to change notification settings - Fork 135
NBT Component Serializer #1084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Codestech1
wants to merge
87
commits into
KyoriPowered:main/4
Choose a base branch
from
Codestech1:feat/nbt-text-serializer
base: main/4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
NBT Component Serializer #1084
Changes from 21 commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
29c997a
feat: basic component serializing to nbt (without styling)
Codestech1 34a381a
feat: serialize component children and types
Codestech1 5bb4c5a
misc: i'm too lazy to name this commit, but it fixes and adds a lot o…
Codestech1 97809cf
chore: remove useless gson serializer
Codestech1 1c750c3
chore: add support for legacy item tags
Codestech1 92ea881
feat: component deserialization
Codestech1 9858a9f
fix: translatable component arguments aren't deserializing
Codestech1 4c7b00c
fix: legacy hover events aren't serialized properly
Codestech1 0a52c01
fix: serializing show entity as a legacy hover event throws an except…
Codestech1 a020c0a
misc: split the style serialization and deserialization to other class
Codestech1 a39a101
feat: add an emit rgb flag
Codestech1 8e74088
feat: add a builder for the nbt component serializer
Codestech1 f96ca38
chore: add a non-null requirement to NBTComponentSerializerImpl.Build…
Codestech1 bba80fb
feat: nbt component providers
Codestech1 0ec4d53
chore: add remaining serializer options to builder
Codestech1 e8b5efd
chore: cleanup
Codestech1 f8427a0
chore: add javadocs to and simplify NBTSerializerOptions and add lice…
Codestech1 8c43bac
chore: add javadocs for public classes
Codestech1 2f4c78c
chore: add tests
Codestech1 2021707
fix: hover events are not serialized properly, feat: add a test for h…
Codestech1 9021233
feat: add a test for click event
Codestech1 c7f406a
chore: resolve requested changes
Codestech1 cc298cb
feat: add a possibility to (de)-serialize a style without a component
Codestech1 8996ab0
chore: simplify serializing text colors with TextColor#toString
Codestech1 43c34aa
Merge branch 'KyoriPowered:main/4' into feat/nbt-text-serializer
Codestech1 da4737c
Merge branch 'KyoriPowered:main/4' into feat/nbt-text-serializer
Codestech1 c5e3525
feat: shadow color serializing
Codestech1 6e77a33
chore: update all `@since` tags to use version 4.24.0
Codestech1 95bd146
chore: update ClickEventSerializer to support the latest format
Codestech1 847b477
chore: create ShowItemSerializer for future use in StyleSerializer to…
Codestech1 8cc7c47
misc: fix double colon in JSON ShowItemSerializer
Codestech1 5591b42
chore: update ShowEntitySerializer to support the latest format
Codestech1 f955ef6
chore: update HoverEventSerializer to support the latest format
Codestech1 473e199
chore: add missing options to the NBTSerializerOptions
Codestech1 7d90b2f
chore: apply new serializing system of click events and hover events …
Codestech1 1500a14
chore: update StyleSerializer fields to support the latest format
Codestech1 5214303
chore: serialize and deserialize text decorations in loops
Codestech1 bf2092f
chore: ensure order of serializing and use ComponentTreeConstants in …
Codestech1 b2e6cd1
chore: do not serialize or deserialize "type" fields of components as…
Codestech1 2c10acd
chore: remove serialize/deserialize data sources TODO
Codestech1 7dc38e1
feat: add an option for emitting default nbt component interpret value
Codestech1 69e2a3f
chore: remove redundant cast in NBTSerializerUtils#getRequiredTag
Codestech1 a45a90c
chore: fix spacing in NBTSerializerUtils
Codestech1 7f7ccd5
chore: vanilla-like component children serializing
Codestech1 3cb553e
chore: vanilla-like translatable component arguments serializing
Codestech1 a85d088
chore: add missing license headers and update to 2025
Codestech1 1a948f2
chore: use TextDecoration#values for style decoration serialization (…
Codestech1 ad8d730
chore: use option schema for NBT serializer options instead
Codestech1 619a62a
feat: deserializing components from list binary tags
Codestech1 923905c
feat: deserialize and serialize legacy additional data of show item h…
Codestech1 0a354ce
chore: make the code consistent
Codestech1 15c63b6
feat: initial versioned option state with options for 23w40a
Codestech1 cd4a440
feat: support plain string show-item hover events in deserialization
Codestech1 6674ca9
feat: add 24w09a version to the versioned option state
Codestech1 3eb33f2
feat: add 24w44a version to the versioned option state
Codestech1 7d7b6b4
feat: add 25w02a version to the versioned option state
Codestech1 4a36ed3
chore: remove unneeded options
Codestech1 f6b30be
chore: replace ClickEventSerializer#deserializeCamel and ClickEventSe…
Codestech1 67e5711
chore: add TODO messages about show_text field names in HoverEventSer…
Codestech1 310d841
chore: review whether the serialization matches Minecraft 23w40a and …
Codestech1 8b0c247
chore: remove all previous tests
Codestech1 fee8bd0
feat: text component serialization test
Codestech1 bac65e1
chore: use ComponentTreeConstants instead for field names in TextComp…
Codestech1 0ab8662
feat: translatable component serialization test
Codestech1 514f23f
chore: make TextComponentTest package-private
Codestech1 bf1d2ab
feat: keybind component serialization test
Codestech1 ab6ae46
feat: score component serialization test
Codestech1 0b1d3ad
feat: selector component serialization test
Codestech1 dd6fcd1
feat: block NBT component serialization test
Codestech1 44c7953
feat: entity NBT component serialization test
Codestech1 904748a
feat: storage NBT component serialization test
Codestech1 0d2d83c
feat: component style serialization test, chore: use jetbrains not-nu…
Codestech1 bcafca4
feat: add a test for deserializing component from lists, fix: deseria…
Codestech1 7a6d5ce
feat: show entity serialization test
Codestech1 5e22119
feat: show item serialization test
Codestech1 fac131f
chore: cleanup tests
Codestech1 f61a594
feat: legacy hover event deserializing
Codestech1 736b5d0
chore: replace Key serialization with KeySerializer
Codestech1 1b335f2
chore: resolve TODOs
Codestech1 e4cee93
chore: cleanup
Codestech1 1ef87f0
chore: fix style of the main module
Codestech1 f64f2f5
chore: fix style of the test module
Codestech1 d82991a
fix: spotless task is failing
Codestech1 b6e307c
fix: lists are not serialized as arrays when it is possible (vanilla …
Codestech1 7a6f3b9
fix(nbt): TagStringWriter does not write compound entries in vanilla …
Codestech1 a87c34a
chore: replace NBTSerializerOptions#SHADOW_COLOR_MODE with NBTSeriali…
Codestech1 96146cc
fix: optimized lists are emitted on 25w04a and above
Codestech1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id("adventure.common-conventions") | ||
} | ||
|
||
dependencies { | ||
api(libs.option) | ||
api(projects.adventureApi) | ||
api(projects.adventureNbt) | ||
} | ||
|
||
applyJarMetadata("net.kyori.adventure.text.serializer.nbt") |
113 changes: 113 additions & 0 deletions
113
...lizer-nbt/src/main/java/net/kyori/adventure/text/serializer/nbt/ClickEventSerializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* This file is part of adventure, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2017-2024 KyoriPowered | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package net.kyori.adventure.text.serializer.nbt; | ||
|
||
import net.kyori.adventure.nbt.CompoundBinaryTag; | ||
import net.kyori.adventure.text.event.ClickEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
final class ClickEventSerializer { | ||
|
||
private static final String ACTION = "action"; | ||
private static final String VALUE = "value"; | ||
|
||
private static final String CLICK_EVENT_OPEN_URL = "open_url"; | ||
private static final String CLICK_EVENT_OPEN_FILE = "open_file"; | ||
private static final String CLICK_EVENT_RUN_COMMAND = "run_command"; | ||
private static final String CLICK_EVENT_SUGGEST_COMMAND = "suggest_command"; | ||
private static final String CLICK_EVENT_CHANGE_PAGE = "change_page"; | ||
private static final String CLICK_EVENT_COPY_TO_CLIPBOARD = "copy_to_clipboard"; | ||
|
||
private ClickEventSerializer() { | ||
} | ||
|
||
static @Nullable ClickEvent deserialize(@NotNull CompoundBinaryTag tag) { | ||
ClickEvent.Action action; | ||
String actionString = tag.getString(ACTION); | ||
|
||
if (actionString.isEmpty()) { | ||
return null; | ||
} | ||
|
||
switch (actionString) { | ||
case CLICK_EVENT_OPEN_URL: | ||
action = ClickEvent.Action.OPEN_URL; | ||
break; | ||
case CLICK_EVENT_OPEN_FILE: | ||
action = ClickEvent.Action.OPEN_FILE; | ||
break; | ||
case CLICK_EVENT_RUN_COMMAND: | ||
action = ClickEvent.Action.RUN_COMMAND; | ||
break; | ||
case CLICK_EVENT_SUGGEST_COMMAND: | ||
action = ClickEvent.Action.SUGGEST_COMMAND; | ||
break; | ||
case CLICK_EVENT_CHANGE_PAGE: | ||
action = ClickEvent.Action.CHANGE_PAGE; | ||
break; | ||
case CLICK_EVENT_COPY_TO_CLIPBOARD: | ||
action = ClickEvent.Action.COPY_TO_CLIPBOARD; | ||
break; | ||
default: | ||
return null; | ||
} | ||
|
||
return ClickEvent.clickEvent(action, tag.getString(VALUE)); | ||
} | ||
|
||
static @NotNull CompoundBinaryTag serialize(@NotNull ClickEvent event) { | ||
ClickEvent.Action action = event.action(); | ||
String actionString; | ||
|
||
switch (action) { | ||
case OPEN_URL: | ||
actionString = CLICK_EVENT_OPEN_URL; | ||
break; | ||
case OPEN_FILE: | ||
actionString = CLICK_EVENT_OPEN_FILE; | ||
break; | ||
case RUN_COMMAND: | ||
actionString = CLICK_EVENT_RUN_COMMAND; | ||
break; | ||
case SUGGEST_COMMAND: | ||
actionString = CLICK_EVENT_SUGGEST_COMMAND; | ||
break; | ||
case CHANGE_PAGE: | ||
actionString = CLICK_EVENT_CHANGE_PAGE; | ||
break; | ||
case COPY_TO_CLIPBOARD: | ||
actionString = CLICK_EVENT_COPY_TO_CLIPBOARD; | ||
break; | ||
default: | ||
// Never called, but needed for proper compilation | ||
throw new IllegalStateException("Unknown click event action: " + action); | ||
} | ||
|
||
return CompoundBinaryTag.builder() | ||
.putString(ACTION, actionString) | ||
.putString(VALUE, event.value()) | ||
.build(); | ||
} | ||
} |
207 changes: 207 additions & 0 deletions
207
...lizer-nbt/src/main/java/net/kyori/adventure/text/serializer/nbt/HoverEventSerializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
/* | ||
* This file is part of adventure, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2017-2024 KyoriPowered | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package net.kyori.adventure.text.serializer.nbt; | ||
|
||
import net.kyori.adventure.key.Key; | ||
import net.kyori.adventure.nbt.BinaryTag; | ||
import net.kyori.adventure.nbt.CompoundBinaryTag; | ||
import net.kyori.adventure.nbt.StringBinaryTag; | ||
import net.kyori.adventure.nbt.api.BinaryTagHolder; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.event.DataComponentValue; | ||
import net.kyori.adventure.text.event.HoverEvent; | ||
import net.kyori.option.OptionState; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
final class HoverEventSerializer { | ||
|
||
private static final String HOVER_EVENT_ACTION = "action"; | ||
private static final String HOVER_EVENT_CONTENTS = "contents"; | ||
@Deprecated | ||
Codestech1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private static final String HOVER_EVENT_VALUE = "value"; | ||
|
||
private static final String HOVER_EVENT_SHOW_TEXT = "show_text"; | ||
private static final String HOVER_EVENT_SHOW_ITEM = "show_item"; | ||
private static final String HOVER_EVENT_SHOW_ENTITY = "show_entity"; | ||
@Deprecated | ||
private static final String HOVER_EVENT_SHOW_ACHIEVEMENT = "show_achievement"; | ||
|
||
private static final String SHOW_ITEM_ID = "id"; | ||
private static final String SHOW_ITEM_COUNT = "count"; | ||
private static final String SHOW_ITEM_COMPONENTS = "components"; | ||
@Deprecated | ||
private static final String SHOW_ITEM_TAG = "tag"; | ||
|
||
private static final String SHOW_ENTITY_TYPE = "type"; | ||
private static final String SHOW_ENTITY_ID = "id"; | ||
private static final String SHOW_ENTITY_NAME = "name"; | ||
|
||
private HoverEventSerializer() { | ||
} | ||
|
||
static @NotNull HoverEvent<?> deserialize(@NotNull CompoundBinaryTag compound, @NotNull NBTComponentSerializerImpl serializer) { | ||
String actionString = compound.getString(HOVER_EVENT_ACTION); | ||
HoverEvent.Action<?> action = HoverEvent.Action.NAMES.valueOrThrow(actionString); | ||
Class<?> actionType = action.type(); | ||
|
||
BinaryTag contents = compound.get(HOVER_EVENT_CONTENTS); | ||
if (contents == null) { | ||
contents = compound.get(HOVER_EVENT_VALUE); | ||
if (contents == null) { | ||
throw new IllegalArgumentException("The hover event doesn't contain any contents"); | ||
} | ||
} | ||
|
||
if (Component.class.isAssignableFrom(actionType)) { | ||
return HoverEvent.showText(serializer.deserialize(contents)); | ||
} else if (HoverEvent.ShowItem.class.isAssignableFrom(actionType)) { | ||
CompoundBinaryTag showItemContents = (CompoundBinaryTag) contents; | ||
|
||
Key itemId = Key.key(showItemContents.getString(SHOW_ITEM_ID)); | ||
int itemCount = showItemContents.getInt(SHOW_ITEM_COUNT); | ||
|
||
BinaryTag components = showItemContents.get(SHOW_ITEM_COMPONENTS); | ||
BinaryTag tag = showItemContents.get(SHOW_ITEM_TAG); | ||
|
||
if (components != null) { | ||
CompoundBinaryTag componentsCompound = (CompoundBinaryTag) components; | ||
Map<Key, DataComponentValue> componentValues = new HashMap<>(); | ||
|
||
for (String string : componentsCompound.keySet()) { | ||
BinaryTag value = componentsCompound.get(string); | ||
if (value == null) continue; | ||
componentValues.put(Key.key(string), NBTDataComponentValue.nbtDataComponentValue(value)); | ||
} | ||
|
||
return HoverEvent.showItem(itemId, itemCount, componentValues); | ||
} else if (tag != null) { | ||
BinaryTagHolder holder = BinaryTagHolder.binaryTagHolder(((StringBinaryTag) tag).value()); | ||
return HoverEvent.showItem(itemId, itemCount, holder); | ||
} else { | ||
return HoverEvent.showItem(itemId, itemCount); | ||
} | ||
} else if (HoverEvent.ShowEntity.class.isAssignableFrom(actionType)) { | ||
CompoundBinaryTag showEntityContents = (CompoundBinaryTag) contents; | ||
|
||
Key entityType = Key.key(showEntityContents.getString(SHOW_ENTITY_TYPE)); | ||
UUID entityId = UUID.fromString(showEntityContents.getString(SHOW_ENTITY_ID)); | ||
|
||
BinaryTag entityName = showEntityContents.get(SHOW_ENTITY_NAME); | ||
|
||
if (entityName != null) { | ||
return HoverEvent.showEntity(entityType, entityId, serializer.deserialize(entityName)); | ||
} else { | ||
return HoverEvent.showEntity(entityType, entityId); | ||
} | ||
} else if (String.class.isAssignableFrom(actionType)) { | ||
return HoverEvent.showAchievement(((StringBinaryTag) contents).value()); | ||
} else { | ||
// Never called, but needed for proper compilation | ||
throw new IllegalArgumentException("Unknown hover event"); | ||
} | ||
} | ||
|
||
static <V> @Nullable CompoundBinaryTag serialize(@NotNull HoverEvent<V> event, @NotNull NBTComponentSerializerImpl serializer) { | ||
OptionState flags = serializer.flags(); | ||
HoverEvent.Action<V> action = event.action(); | ||
|
||
NBTSerializerOptions.HoverEventValueMode hoverMode = flags.value(NBTSerializerOptions.EMIT_HOVER_EVENT_TYPE); | ||
|
||
if (action == HoverEvent.Action.SHOW_ACHIEVEMENT) { | ||
if (hoverMode == NBTSerializerOptions.HoverEventValueMode.MODERN_ONLY) { | ||
return null; | ||
} | ||
|
||
return CompoundBinaryTag.builder() | ||
.putString(HOVER_EVENT_ACTION, HOVER_EVENT_SHOW_ACHIEVEMENT) | ||
.putString(HOVER_EVENT_VALUE, (String) event.value()) | ||
.build(); | ||
} | ||
|
||
BinaryTag contents; | ||
String actionString; | ||
|
||
if (action == HoverEvent.Action.SHOW_TEXT) { | ||
contents = serializer.serialize((Component) event.value()); | ||
actionString = HOVER_EVENT_SHOW_TEXT; | ||
} else if (action == HoverEvent.Action.SHOW_ITEM) { | ||
HoverEvent.ShowItem item = (HoverEvent.ShowItem) event.value(); | ||
|
||
CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder() | ||
.putString(SHOW_ITEM_ID, item.item().asString()) | ||
.putInt(SHOW_ITEM_COUNT, item.count()); | ||
|
||
Map<Key, NBTDataComponentValue> components = item.dataComponentsAs(NBTDataComponentValue.class); | ||
NBTSerializerOptions.ShowItemHoverDataMode dataMode = flags.value(NBTSerializerOptions.SHOW_ITEM_HOVER_DATA_MODE); | ||
|
||
if (!components.isEmpty() && dataMode != NBTSerializerOptions.ShowItemHoverDataMode.EMIT_LEGACY_NBT) { | ||
CompoundBinaryTag.Builder dataComponentsBuilder = CompoundBinaryTag.builder(); | ||
|
||
for (Map.Entry<Key, NBTDataComponentValue> entry : components.entrySet()) { | ||
dataComponentsBuilder.put(entry.getKey().asString(), entry.getValue().binaryTag()); | ||
} | ||
|
||
builder.put(SHOW_ITEM_COMPONENTS, dataComponentsBuilder.build()); | ||
} else if (dataMode != NBTSerializerOptions.ShowItemHoverDataMode.EMIT_DATA_COMPONENTS) { | ||
BinaryTagHolder holder = item.nbt(); | ||
if (holder != null) { | ||
builder.putString(SHOW_ITEM_TAG, holder.string()); | ||
} | ||
} | ||
|
||
contents = builder.build(); | ||
actionString = HOVER_EVENT_SHOW_ITEM; | ||
} else if (action == HoverEvent.Action.SHOW_ENTITY) { | ||
if (hoverMode == NBTSerializerOptions.HoverEventValueMode.LEGACY_ONLY) { | ||
return null; | ||
} | ||
|
||
HoverEvent.ShowEntity item = (HoverEvent.ShowEntity) event.value(); | ||
|
||
CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder() | ||
.putString(SHOW_ENTITY_TYPE, item.type().asString()) | ||
.putString(SHOW_ENTITY_ID, item.id().toString()); | ||
|
||
Component customName = item.name(); | ||
if (customName != null) { | ||
builder.put(SHOW_ENTITY_NAME, serializer.serialize(customName)); | ||
} | ||
|
||
contents = builder.build(); | ||
actionString = HOVER_EVENT_SHOW_ENTITY; | ||
} else { | ||
throw new IllegalArgumentException("Don't know how to serialize " + event + " as a HoverEvent"); | ||
} | ||
|
||
return CompoundBinaryTag.builder() | ||
.putString(HOVER_EVENT_ACTION, actionString) | ||
.put(hoverMode == NBTSerializerOptions.HoverEventValueMode.LEGACY_ONLY ? HOVER_EVENT_VALUE : HOVER_EVENT_CONTENTS, contents) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.