Search in sources :

Example 1 with ActionType

use of me.botsko.prism.api.actions.ActionType in project Prism-Bukkit by prism.

the class ActionMessage method getRawMessage.

/**
 * Here, we don't use formatting or anything, we just use a regular message raw.
 * This will automatically show extended information, as this can be passed to a
 * paste service.
 *
 * @return String
 */
public String getRawMessage() {
    String format1 = "<prefix> <handlerId> <target> <actor> <extendedInfo><actorNice> <count>" + " <timeDiff> <location>";
    ActionType action = handler.getActionType();
    return PlainComponentSerializer.plain().serialize(getMainMessage(action, format1));
}
Also used : ActionType(me.botsko.prism.api.actions.ActionType)

Example 2 with ActionType

use of me.botsko.prism.api.actions.ActionType in project Prism-Bukkit by prism.

the class ActionMessage method getMainMessage.

private TextComponent getMainMessage(ActionType action, String format1) {
    final TextColor highlight = NamedTextColor.DARK_AQUA;
    TextComponent out = Component.text().content(format1).build();
    Component result = out.replaceFirstText(Pattern.compile("<prefix>"), builder -> getPosNegPrefix()).replaceFirstText(Pattern.compile("<index>"), builder -> builder.content("[" + index + "] ").color(NamedTextColor.GRAY)).replaceFirstText(Pattern.compile("<target>"), builder -> Component.text().content(handler.getSourceName()).color(highlight)).replaceFirstText(Pattern.compile("<description>"), builder -> Component.text().content(getDescription((ActionTypeImpl) action)).color(NamedTextColor.WHITE)).replaceFirstText(Pattern.compile("<actorNice>"), builder -> getActor((ActionTypeImpl) action, highlight)).replaceFirstText(Pattern.compile("<actor>"), builder -> Component.text().content(action.getName())).replaceFirstText(Pattern.compile("<extendedInfo>"), builder -> Component.text().append(getExtendedInfo())).replaceFirstText(Pattern.compile("<timeDiff>"), builder -> Component.text().append(getTimeDiff())).replaceFirstText(Pattern.compile("<count>"), builder -> Component.text().append(getCount())).replaceFirstText(Pattern.compile("<actionType>"), builder -> Component.text().content("(a:" + action.getShortName() + ")").color(NamedTextColor.GRAY)).replaceFirstText(Pattern.compile("<handlerId>"), builder -> Component.text(handler.getId()).toBuilder().color(NamedTextColor.GRAY));
    return Component.text().content("").append(result).hoverEvent(HoverEvent.showText(Component.text("Click to teleport").color(NamedTextColor.DARK_AQUA))).clickEvent(ClickEvent.runCommand("/pr tp " + index)).build();
}
Also used : TextComponent(net.kyori.adventure.text.TextComponent) TextComponent(net.kyori.adventure.text.TextComponent) TextColor(net.kyori.adventure.text.format.TextColor) Handler(me.botsko.prism.api.actions.Handler) ClickEvent(net.kyori.adventure.text.event.ClickEvent) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) ActionType(me.botsko.prism.api.actions.ActionType) Utilities(me.botsko.prism.utils.block.Utilities) Location(org.bukkit.Location) Component(net.kyori.adventure.text.Component) Pattern(java.util.regex.Pattern) HoverEvent(net.kyori.adventure.text.event.HoverEvent) PlainComponentSerializer(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer) Material(org.bukkit.Material) TextColor(net.kyori.adventure.text.format.TextColor) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) TextComponent(net.kyori.adventure.text.TextComponent) Component(net.kyori.adventure.text.Component)

Example 3 with ActionType

use of me.botsko.prism.api.actions.ActionType in project Prism-Bukkit by prism.

the class ActionMessage method getMessage.

/**
 * Get the message.
 *
 * @return String[]
 */
public TextComponent getMessage() {
    String format1 = "<prefix> <index> <target> <description> <actorNice> <extendedInfo><count> <timeDiff> <actionType>";
    String format2 = "-<handlerId>- <dateTime> - <location>";
    ActionType action = handler.getActionType();
    TextComponent out = getMainMessage(action, format1);
    if (showExtended) {
        out = out.append(Component.newline());
        Component line2 = Component.text().content(format2).build().replaceFirstText(Pattern.compile("<handlerId>"), builder -> Component.text(handler.getId()).toBuilder().color(NamedTextColor.GRAY)).replaceFirstText(Pattern.compile("<dateTime>"), builder -> Component.text().content(handler.getDisplayDate() + " " + handler.getDisplayTime())).replaceFirstText(Pattern.compile("<location>"), builder -> Component.text().content(getFormattedLocation()));
        out = out.append(line2);
    }
    return out;
}
Also used : TextComponent(net.kyori.adventure.text.TextComponent) TextComponent(net.kyori.adventure.text.TextComponent) TextColor(net.kyori.adventure.text.format.TextColor) Handler(me.botsko.prism.api.actions.Handler) ClickEvent(net.kyori.adventure.text.event.ClickEvent) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) ActionType(me.botsko.prism.api.actions.ActionType) Utilities(me.botsko.prism.utils.block.Utilities) Location(org.bukkit.Location) Component(net.kyori.adventure.text.Component) Pattern(java.util.regex.Pattern) HoverEvent(net.kyori.adventure.text.event.HoverEvent) PlainComponentSerializer(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer) Material(org.bukkit.Material) ActionType(me.botsko.prism.api.actions.ActionType) TextComponent(net.kyori.adventure.text.TextComponent) Component(net.kyori.adventure.text.Component)

Aggregations

ActionType (me.botsko.prism.api.actions.ActionType)3 Pattern (java.util.regex.Pattern)2 Handler (me.botsko.prism.api.actions.Handler)2 Utilities (me.botsko.prism.utils.block.Utilities)2 Component (net.kyori.adventure.text.Component)2 TextComponent (net.kyori.adventure.text.TextComponent)2 ClickEvent (net.kyori.adventure.text.event.ClickEvent)2 HoverEvent (net.kyori.adventure.text.event.HoverEvent)2 NamedTextColor (net.kyori.adventure.text.format.NamedTextColor)2 TextColor (net.kyori.adventure.text.format.TextColor)2 PlainComponentSerializer (net.kyori.adventure.text.serializer.plain.PlainComponentSerializer)2 Location (org.bukkit.Location)2 Material (org.bukkit.Material)2