mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
placeholder for executed command for bukkit and waterfall version
This commit is contained in:
+23
@@ -6,6 +6,10 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -133,4 +137,23 @@ public class CWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message component for a command denied message
|
||||
* @param inputCommandString command that was denied as string
|
||||
* @param message raw message to display
|
||||
* @return parsed message component
|
||||
*/
|
||||
public static Component getParsedErrorMessage(String inputCommandString, String message) {
|
||||
MiniMessage miniMessage = MiniMessage.builder()
|
||||
.tags(TagResolver.builder()
|
||||
.resolvers(StandardTags.defaults(), commandContentResolver(inputCommandString))
|
||||
.build())
|
||||
.build();
|
||||
return miniMessage.deserialize(message);
|
||||
}
|
||||
|
||||
private static TagResolver commandContentResolver(String rawCommand) {
|
||||
return TagResolver.resolver("command", (context, builder) -> Tag.selfClosingInserting(Component.text(rawCommand)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user