diff --git a/src/main/java/net/minestom/server/command/builder/arguments/ArgumentType.java b/src/main/java/net/minestom/server/command/builder/arguments/ArgumentType.java
index 7322c5d38..4df154b4c 100644
--- a/src/main/java/net/minestom/server/command/builder/arguments/ArgumentType.java
+++ b/src/main/java/net/minestom/server/command/builder/arguments/ArgumentType.java
@@ -107,11 +107,12 @@ public class ArgumentType {
// Minecraft specific arguments
/**
- * @deprecated Use {@link #TextColor} for colors and {@link #TextDecoration} for styles.
+ * @deprecated Use {@link ArgumentTextColor} for colors, {@link ArgumentTextDecoration} for styles, {@link ArgumentColor} for raw colors,
+ * {@link ArgumentDyeColor} for dye colors and {@link ArgumentTeamFormat} for team formats
*/
@Deprecated
- public static ArgumentColor Color(@NotNull String id) {
- return new ArgumentColor(id);
+ public static ArgumentChatColor ChatColor(@NotNull String id) {
+ return new ArgumentChatColor(id);
}
public static ArgumentTextColor TextColor(@NotNull String id) {
@@ -122,6 +123,18 @@ public class ArgumentType {
return new ArgumentTextDecoration(id);
}
+ public static ArgumentColor Color(@NotNull String id) {
+ return new ArgumentColor(id);
+ }
+
+ public static ArgumentDyeColor DyeColor(@NotNull String id) {
+ return new ArgumentDyeColor(id);
+ }
+
+ public static ArgumentTeamFormat TeamFormat(@NotNull String id) {
+ return new ArgumentTeamFormat(id);
+ }
+
/**
* @see ArgumentTime
*/
diff --git a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentChatColor.java b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentChatColor.java
new file mode 100644
index 000000000..6dea09d7e
--- /dev/null
+++ b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentChatColor.java
@@ -0,0 +1,43 @@
+package net.minestom.server.command.builder.arguments.minecraft;
+
+import net.minestom.server.chat.ChatColor;
+import net.minestom.server.command.builder.NodeMaker;
+import net.minestom.server.command.builder.arguments.Argument;
+import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
+import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Represents an argument which will give you a {@link ChatColor}.
+ *
+ * Example: red, white, reset
+ * @deprecated Use {@link ArgumentTextColor} for colors, {@link ArgumentTextDecoration} for styles, {@link ArgumentColor} for raw colors,
+ * {@link ArgumentDyeColor} for dye colors and {@link ArgumentTeamFormat} for team formats
+ */
+@Deprecated
+public class ArgumentChatColor extends Argument {
+
+ public static final int UNDEFINED_COLOR = -2;
+
+ public ArgumentChatColor(String id) {
+ super(id);
+ }
+
+ @NotNull
+ @Override
+ public ChatColor parse(@NotNull String input) throws ArgumentSyntaxException {
+ final ChatColor color = ChatColor.fromName(input);
+ if (color == ChatColor.NO_COLOR)
+ throw new ArgumentSyntaxException("Undefined color", input, UNDEFINED_COLOR);
+
+ return color;
+ }
+
+ @Override
+ public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
+ DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
+ argumentNode.parser = "minecraft:chat_color";
+
+ nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
+ }
+}
diff --git a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentColor.java b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentColor.java
index da8a9c320..b8701d9e0 100644
--- a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentColor.java
+++ b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentColor.java
@@ -1,6 +1,7 @@
package net.minestom.server.command.builder.arguments.minecraft;
-import net.minestom.server.chat.ChatColor;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.minestom.server.color.Color;
import net.minestom.server.command.builder.NodeMaker;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
@@ -8,28 +9,26 @@ import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.jetbrains.annotations.NotNull;
/**
- * Represents an argument which will give you a {@link ChatColor}.
- *
- * Example: red, white, reset
- * @deprecated Use {@link ArgumentTextColor} for colors and {@link ArgumentTextDecoration} for styles.
+ * Represents an argument that will give you a {@link Color}. Input is parsed
+ * first as a hex string ({@code #int}), then as a CSS hex string ({@code #rrggbb} or
+ * {@code #rgb}), then as an integer and finally as a named text colour. The values for
+ * the named text colours can be found in {@link NamedTextColor}.
+ *
+ * This class is essentially a wrapper around {@link ArgumentTextColor}.
*/
-@Deprecated
-public class ArgumentColor extends Argument {
+public class ArgumentColor extends Argument {
+ private final ArgumentTextColor argumentTextColor;
- public static final int UNDEFINED_COLOR = -2;
+ public static int UNDEFINED_COLOR = ArgumentTextColor.UNDEFINED_COLOR;
- public ArgumentColor(String id) {
+ public ArgumentColor(@NotNull String id) {
super(id);
+ argumentTextColor = new ArgumentTextColor(id);
}
- @NotNull
@Override
- public ChatColor parse(@NotNull String input) throws ArgumentSyntaxException {
- final ChatColor color = ChatColor.fromName(input);
- if (color == ChatColor.NO_COLOR)
- throw new ArgumentSyntaxException("Undefined color", input, UNDEFINED_COLOR);
-
- return color;
+ public @NotNull Color parse(@NotNull String input) throws ArgumentSyntaxException {
+ return new Color(this.argumentTextColor.parse(input));
}
@Override
diff --git a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentDyeColor.java b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentDyeColor.java
new file mode 100644
index 000000000..f703194f4
--- /dev/null
+++ b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentDyeColor.java
@@ -0,0 +1,32 @@
+package net.minestom.server.command.builder.arguments.minecraft;
+
+import net.minestom.server.color.DyeColor;
+import net.minestom.server.command.builder.NodeMaker;
+import net.minestom.server.command.builder.arguments.Argument;
+import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * An argument that returns a {@link DyeColor} from the name of the dye color.
+ */
+public class ArgumentDyeColor extends Argument {
+ public static int UNDEFINED_DYE_COLOR = -2;
+
+ public ArgumentDyeColor(@NotNull String id) {
+ super(id);
+ }
+
+ @Override
+ public @NotNull DyeColor parse(@NotNull String input) throws ArgumentSyntaxException {
+ try {
+ return DyeColor.valueOf(input.toUpperCase().replace(' ', '_').trim());
+ } catch (IllegalArgumentException ignored) {
+ throw new ArgumentSyntaxException("Undefined dye color", input, UNDEFINED_DYE_COLOR);
+ }
+ }
+
+ @Override
+ public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
+
+ }
+}
diff --git a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTeamFormat.java b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTeamFormat.java
new file mode 100644
index 000000000..dbadeafc8
--- /dev/null
+++ b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTeamFormat.java
@@ -0,0 +1,40 @@
+package net.minestom.server.command.builder.arguments.minecraft;
+
+import net.minestom.server.color.TeamFormat;
+import net.minestom.server.command.builder.NodeMaker;
+import net.minestom.server.command.builder.arguments.Argument;
+import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
+import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * An argument that will give you a {@link TeamFormat} from it's name or the int code.
+ */
+public class ArgumentTeamFormat extends Argument {
+ public static final int UNDEFINED_TEAM_FORMAT = -2;
+
+ public ArgumentTeamFormat(@NotNull String id) {
+ super(id);
+ }
+
+ @Override
+ public @NotNull TeamFormat parse(@NotNull String input) throws ArgumentSyntaxException {
+ try {
+ return TeamFormat.valueOf(input.toUpperCase().trim().replace(' ', '_'));
+ } catch (IllegalArgumentException ignored) {
+ try {
+ return TeamFormat.values()[Integer.parseInt(input)];
+ } catch (NumberFormatException | ArrayIndexOutOfBoundsException alsoIgnored) {
+ throw new ArgumentSyntaxException("Undefined team format!", input, UNDEFINED_TEAM_FORMAT);
+ }
+ }
+ }
+
+ @Override
+ public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
+ DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
+ argumentNode.parser = "minecraft:team_format";
+
+ nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
+ }
+}
diff --git a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTextColor.java b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTextColor.java
index 6c4328084..6d8cfb272 100644
--- a/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTextColor.java
+++ b/src/main/java/net/minestom/server/command/builder/arguments/minecraft/ArgumentTextColor.java
@@ -25,7 +25,7 @@ public class ArgumentTextColor extends Argument {
@Override
public @NotNull TextColor parse(@NotNull String input) throws ArgumentSyntaxException {
- TextColor textColor = null;
+ TextColor textColor;
// first try standard hex
textColor = TextColor.fromHexString(input);
@@ -58,7 +58,7 @@ public class ArgumentTextColor extends Argument {
@Override
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
- argumentNode.parser = "minecraft:text_decoration";
+ argumentNode.parser = "minecraft:text_color";
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
}