|
89 | 89 | import com.mojang.brigadier.suggestion.Suggestions; |
90 | 90 | import com.mojang.brigadier.tree.CommandNode; |
91 | 91 | import com.mojang.logging.LogUtils; |
92 | | -import com.mojang.serialization.codecs.RecordCodecBuilder; |
93 | 92 |
|
94 | 93 | import dev.jorel.commandapi.CommandAPI; |
95 | 94 | import dev.jorel.commandapi.CommandAPIHandler; |
|
114 | 113 | import net.kyori.adventure.text.Component; |
115 | 114 | import net.kyori.adventure.text.format.NamedTextColor; |
116 | 115 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; |
| 116 | +import net.md_5.bungee.api.chat.BaseComponent; |
| 117 | +import net.md_5.bungee.chat.ComponentSerializer; |
117 | 118 | import net.minecraft.advancements.AdvancementHolder; |
118 | 119 | import net.minecraft.advancements.critereon.MinMaxBounds; |
119 | 120 | import net.minecraft.commands.CommandBuildContext; |
|
125 | 126 | import net.minecraft.commands.arguments.ComponentArgument; |
126 | 127 | import net.minecraft.commands.arguments.DimensionArgument; |
127 | 128 | import net.minecraft.commands.arguments.EntityArgument; |
| 129 | +import net.minecraft.commands.arguments.MessageArgument; |
128 | 130 | import net.minecraft.commands.arguments.ParticleArgument; |
129 | 131 | import net.minecraft.commands.arguments.RangeArgument; |
130 | 132 | import net.minecraft.commands.arguments.ResourceArgument; |
|
133 | 135 | import net.minecraft.commands.arguments.ScoreboardSlotArgument; |
134 | 136 | import net.minecraft.commands.arguments.blocks.BlockPredicateArgument; |
135 | 137 | import net.minecraft.commands.arguments.blocks.BlockStateArgument; |
136 | | -import net.minecraft.commands.arguments.blocks.BlockStateParser; |
137 | 138 | import net.minecraft.commands.arguments.coordinates.BlockPosArgument; |
138 | 139 | import net.minecraft.commands.arguments.coordinates.ColumnPosArgument; |
139 | 140 | import net.minecraft.commands.arguments.coordinates.Vec2Argument; |
|
149 | 150 | import net.minecraft.commands.synchronization.ArgumentUtils; |
150 | 151 | import net.minecraft.core.BlockPos; |
151 | 152 | import net.minecraft.core.HolderLookup.Provider; |
152 | | -import net.minecraft.core.RegistryAccess.Frozen; |
153 | 153 | import net.minecraft.core.component.DataComponentMap; |
154 | 154 | import net.minecraft.core.component.TypedDataComponent; |
155 | 155 | import net.minecraft.core.particles.BlockParticleOption; |
@@ -243,6 +243,12 @@ public final ArgumentType<?> _ArgumentBlockPredicate() { |
243 | 243 | public final ArgumentType<?> _ArgumentBlockState() { |
244 | 244 | return BlockStateArgument.block(COMMAND_BUILD_CONTEXT); |
245 | 245 | } |
| 246 | + |
| 247 | + @Differs(from = "1.20.4", by = "Now needs a command build context") |
| 248 | + @Override |
| 249 | + public ArgumentType<?> _ArgumentChatComponent() { |
| 250 | + return ComponentArgument.textComponent(COMMAND_BUILD_CONTEXT); |
| 251 | + } |
246 | 252 |
|
247 | 253 | @Override |
248 | 254 | public final ArgumentType<?> _ArgumentEnchantment() { |
@@ -435,6 +441,12 @@ public Advancement getAdvancement(CommandContext<CommandSourceStack> cmdCtx, Str |
435 | 441 | throws CommandSyntaxException { |
436 | 442 | return ResourceLocationArgument.getAdvancement(cmdCtx, key).toBukkit(); |
437 | 443 | } |
| 444 | + |
| 445 | + @Differs(from = "1.20.4", by = "Serializer.toJson now needs a Provider") |
| 446 | + @Override |
| 447 | + public Component getAdventureChat(CommandContext<CommandSourceStack> cmdCtx, String key) throws CommandSyntaxException { |
| 448 | + return GsonComponentSerializer.gson().deserialize(Serializer.toJson(MessageArgument.getMessage(cmdCtx, key), Provider.create(Stream.of()))); |
| 449 | + } |
438 | 450 |
|
439 | 451 | @Override |
440 | 452 | public NamedTextColor getAdventureChatColor(CommandContext<CommandSourceStack> cmdCtx, String key) { |
@@ -493,6 +505,12 @@ public CommandSourceStack getBrigadierSourceFromCommandSender( |
493 | 505 | return VanillaCommandWrapper.getListener(sender.getSource()); |
494 | 506 | } |
495 | 507 |
|
| 508 | + @Differs(from = "1.20.4", by = "Serializer.toJson now needs a Provider") |
| 509 | + @Override |
| 510 | + public final BaseComponent[] getChat(CommandContext<CommandSourceStack> cmdCtx, String key) throws CommandSyntaxException { |
| 511 | + return ComponentSerializer.parse(Serializer.toJson(MessageArgument.getMessage(cmdCtx, key), Provider.create(Stream.of()))); |
| 512 | + } |
| 513 | + |
496 | 514 | @Override |
497 | 515 | public final World getDimension(CommandContext<CommandSourceStack> cmdCtx, String key) |
498 | 516 | throws CommandSyntaxException { |
|
0 commit comments