Skip to content

Commit 2d94c19

Browse files
committed
Adds CommandAPIBukkit#failWithAdventureComponent(ComponentLike) for CommandAPI#577
1 parent ee5907b commit 2d94c19

File tree

1 file changed

+12
-0
lines changed
  • commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi

1 file changed

+12
-0
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkit.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.logging.Level;
2121
import java.util.logging.Logger;
2222

23+
import net.kyori.adventure.text.ComponentLike;
2324
import org.bukkit.Bukkit;
2425
import org.bukkit.ChatColor;
2526
import org.bukkit.Keyed;
@@ -580,6 +581,17 @@ public static WrapperCommandSyntaxException failWithBaseComponents(BaseComponent
580581
public static WrapperCommandSyntaxException failWithAdventureComponent(Component message) {
581582
return CommandAPI.failWithMessage(BukkitTooltip.messageFromAdventureComponent(message));
582583
}
584+
585+
/**
586+
* Forces a command to return a success value of 0
587+
*
588+
* @param message Description of the error message, formatted as an adventure chat component
589+
* @return a {@link WrapperCommandSyntaxException} that wraps Brigadier's
590+
* {@link CommandSyntaxException}
591+
*/
592+
public static WrapperCommandSyntaxException failWithAdventureComponent(ComponentLike message) {
593+
return CommandAPI.failWithMessage(BukkitTooltip.messageFromAdventureComponent(message.asComponent()));
594+
}
583595

584596
/**
585597
* Initializes the CommandAPI's implementation of an NBT API. If you are shading

0 commit comments

Comments
 (0)