use of net.kyori.adventure.text.TextComponent in project Prism-Bukkit by prism.
the class WandCommand method sendWandStatus.
static void sendWandStatus(final CommandSender sender, @PropertyKey(resourceBundle = "languages.message") String wandStatusMessageKey, final boolean status, final String wandType, final String parameters) {
final TextComponent state;
if (status) {
state = Il8nHelper.getMessage("enabled").color(NamedTextColor.GREEN);
} else {
state = Il8nHelper.getMessage("disabled").color(NamedTextColor.RED);
}
TextComponent out = Prism.messenger.playerHeaderMsg(Il8nHelper.getMessage(wandStatusMessageKey).replaceText(Pattern.compile("<status>"), builder -> Component.text().append(state)));
if (status) {
out.append(Component.newline()).append(Il8nHelper.getMessage("wand-item-type").replaceText(Pattern.compile("<itemType>"), builder -> Component.text().content(wandType)).replaceText(Pattern.compile("<parameters"), builder -> Component.text().content(parameters)));
}
Prism.messenger.sendMessage(sender, out);
}
use of net.kyori.adventure.text.TextComponent in project Prism-Bukkit by prism.
the class HelpCommand method help.
/**
* Displays help.
*
* @param s CommandSender
*/
protected void help(CommandSender s) {
Audience sender = Prism.getAudiences().sender(s);
if (failed) {
sender.sendMessage(Identity.nil(), Prism.messenger.playerHeaderMsg(Il8nHelper.getMessage("prism-disabled-header").color(NamedTextColor.GOLD)).append(Component.newline()).append(Prism.messenger.playerMsg(Il8nHelper.getMessage("prism-disabled-content")).color(NamedTextColor.GOLD)).append(Component.newline()).append(Prism.messenger.playerSubduedHeaderMsg(Il8nHelper.getMessage("discord", ":").color(NamedTextColor.WHITE).append(Component.text(Il8nHelper.getRawMessage("discord-url"))))).append(Component.newline()).append(Prism.messenger.playerSubduedHeaderMsg(Il8nHelper.getMessage("wiki", ":").color(NamedTextColor.WHITE).append(Component.text(Il8nHelper.getRawMessage("wiki-url"))))));
return;
}
TextComponent component = Prism.messenger.playerHeaderMsg(Component.text("--- Basic Usage ---").color(NamedTextColor.GOLD)).append(Component.newline()).append(Prism.messenger.playerSubduedHeaderMsg(Il8nHelper.getMessage("help-extended-message"))).append(Component.newline());
Stream<SubCommand> stream = Prism.getInstance().getCommands().getSubCommands().values().stream().distinct();
for (SubCommand command : stream.collect(Collectors.toList())) {
if (command.getHelp().length > 1) {
int i = 0;
for (String message : command.getHelp()) {
if (i == 0) {
component = component.append(Prism.messenger.playerHelp(Arrays.toString(command.getAliases()), message).clickEvent(ClickEvent.openUrl(command.getWebLink()))).append(Component.newline());
} else {
component = component.append(Prism.messenger.playerHelp(" |- ", message).clickEvent(ClickEvent.openUrl(command.getWebLink()))).append(Component.newline());
}
i++;
}
} else {
component = component.append(Prism.messenger.playerHelp(Arrays.toString(command.getAliases()), command.getHelp()[0]).clickEvent(ClickEvent.openUrl(command.getWebLink()))).append(Component.newline());
}
}
sender.sendMessage(Identity.nil(), component);
}
use of net.kyori.adventure.text.TextComponent in project Prism-Bukkit by prism.
the class UseMonitor method incrementCount.
/**
* Maintain use alert message history.
* Increments the number of times the player has caused a particular alert.
* If the count is below the threshold, the alert will be sent.
*
* @param playername Player causing the alert
* @param msg Alert message
* @param alertPerm Players with this permission will receive the alert
*/
protected void incrementCount(String playername, String msg, String alertPerm) {
int count = 0;
String key = playername + msg;
if (countedEvents.containsKey(key)) {
count = countedEvents.get(key);
}
count++;
countedEvents.put(key, count);
TextComponent out = Component.text(playername + " " + msg).color(NamedTextColor.GRAY);
if (count == 5) {
out = out.append(Component.text(" - pausing warnings.").color(NamedTextColor.GRAY));
}
if (count <= 5) {
// Alert staff
plugin.alertPlayers(null, out, alertPerm);
// Log to console
if (plugin.getConfig().getBoolean("prism.alerts.uses.log-to-console")) {
Prism.log(PlainComponentSerializer.plain().serialize(out));
}
// Log to commands
List<String> commands = plugin.getConfig().getStringList("prism.alerts.uses.log-commands");
MiscUtils.dispatchAlert(msg, commands);
}
}
Aggregations