Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
MessageBuilder: add a check clickable message
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 14, 2023
1 parent 61d1c0c commit 94b39d9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/net/flectone/messages/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public class MessageBuilder {
private final ItemStack itemStack;
private final String command;

private final boolean clickable;

public MessageBuilder(@NotNull String command, @NotNull String text, @Nullable ItemStack itemStack, boolean clickable) {
this.itemStack = itemStack;
this.command = command;
this.clickable = clickable;

String pingPrefix = locale.getString("chat.ping.prefix");

Expand Down Expand Up @@ -136,7 +139,12 @@ public BaseComponent[] build(@NotNull String format, @NotNull CommandSender reci
ComponentBuilder componentBuilder = new ComponentBuilder();

String[] formats = ObjectUtil.formatString(format, recipient, sender).split("<message>");
componentBuilder.append(new FPlayerComponent(recipient, sender, formats[0]).get());

FComponent fComponent = this.clickable && sender instanceof Player
? new FPlayerComponent(recipient, sender, formats[0])
: new FComponent(formats[0]);

componentBuilder.append(fComponent.get());

String color = ChatColor.getLastColors(formats[0]);

Expand Down

0 comments on commit 94b39d9

Please sign in to comment.