|
4 | 4 | import com.mojang.serialization.Codec;
|
5 | 5 | import com.mojang.serialization.DataResult;
|
6 | 6 | import com.mojang.serialization.MapCodec;
|
| 7 | +import java.net.URI; |
7 | 8 | import java.util.Collections;
|
8 | 9 | import java.util.List;
|
9 | 10 | import java.util.Map;
|
@@ -92,16 +93,16 @@ public final class AdventureCodecs {
|
92 | 93 | * Click
|
93 | 94 | */
|
94 | 95 | static final MapCodec<ClickEvent> OPEN_URL_CODEC = mapCodec((instance) -> instance.group(
|
95 |
| - Codec.STRING.fieldOf("url").forGetter(a -> !a.value().contains("://") ? "https://" + a.value() : a.value()) |
96 |
| - ).apply(instance, ClickEvent::openUrl)); |
| 96 | + ExtraCodecs.UNTRUSTED_URI.fieldOf("url").forGetter(a -> URI.create(!a.value().contains("://") ? "https://" + a.value() : a.value())) |
| 97 | + ).apply(instance, (url) -> ClickEvent.openUrl(url.toString()))); |
97 | 98 | static final MapCodec<ClickEvent> OPEN_FILE_CODEC = mapCodec((instance) -> instance.group(
|
98 | 99 | Codec.STRING.fieldOf("path").forGetter(ClickEvent::value)
|
99 | 100 | ).apply(instance, ClickEvent::openFile));
|
100 | 101 | static final MapCodec<ClickEvent> RUN_COMMAND_CODEC = mapCodec((instance) -> instance.group(
|
101 |
| - Codec.STRING.fieldOf("command").forGetter(ClickEvent::value) |
| 102 | + ExtraCodecs.CHAT_STRING.fieldOf("command").forGetter(ClickEvent::value) |
102 | 103 | ).apply(instance, ClickEvent::runCommand));
|
103 | 104 | static final MapCodec<ClickEvent> SUGGEST_COMMAND_CODEC = mapCodec((instance) -> instance.group(
|
104 |
| - Codec.STRING.fieldOf("command").forGetter(ClickEvent::value) |
| 105 | + ExtraCodecs.CHAT_STRING.fieldOf("command").forGetter(ClickEvent::value) |
105 | 106 | ).apply(instance, ClickEvent::suggestCommand));
|
106 | 107 | static final MapCodec<ClickEvent> CHANGE_PAGE_CODEC = mapCodec((instance) -> instance.group(
|
107 | 108 | ExtraCodecs.POSITIVE_INT.fieldOf("page").forGetter(a -> Integer.parseInt(a.value()))
|
|
0 commit comments