Expose HexColor argument type (#12833)

This commit is contained in:
caramel
2025-07-13 00:41:21 +09:00
committed by GitHub
parent 76fb5060c1
commit fcfc6c3fe8
3 changed files with 20 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.GameMode;
import org.bukkit.HeightMap;
import org.bukkit.NamespacedKey;
@@ -167,6 +168,15 @@ public final class ArgumentTypes {
return provider().namedColor();
}
/**
* A hex color argument.
*
* @return argument
*/
public static ArgumentType<TextColor> hexColor() {
return provider().hexColor();
}
/**
* A component argument.
*

View File

@@ -20,6 +20,7 @@ import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.GameMode;
import org.bukkit.HeightMap;
import org.bukkit.NamespacedKey;
@@ -65,6 +66,8 @@ interface VanillaArgumentProvider {
ArgumentType<NamedTextColor> namedColor();
ArgumentType<TextColor> hexColor();
ArgumentType<Component> component();
ArgumentType<Style> style();

View File

@@ -39,6 +39,7 @@ import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.ColorArgument;
@@ -49,6 +50,7 @@ import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.GameModeArgument;
import net.minecraft.commands.arguments.GameProfileArgument;
import net.minecraft.commands.arguments.HeightmapTypeArgument;
import net.minecraft.commands.arguments.HexColorArgument;
import net.minecraft.commands.arguments.MessageArgument;
import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
import net.minecraft.commands.arguments.RangeArgument;
@@ -205,6 +207,11 @@ public class VanillaArgumentProviderImpl implements VanillaArgumentProvider {
);
}
@Override
public ArgumentType<TextColor> hexColor() {
return this.wrap(HexColorArgument.hexColor(), TextColor::color);
}
@Override
public ArgumentType<Component> component() {
return this.wrap(ComponentArgument.textComponent(PaperCommands.INSTANCE.getBuildContext()), PaperAdventure::asAdventure);