Skip to content

Commit

Permalink
add context.full_text to player chats event
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 11, 2019
1 parent 77ced23 commit 3b993a8
Showing 1 changed file with 14 additions and 2 deletions.
Expand Up @@ -39,6 +39,7 @@ public class ChatScriptEvent extends BukkitScriptEvent implements Listener {
// @Context
// <context.message> returns the player's message as an Element.
// <context.format> returns the chat message's raw format.
// <context.full_text> returns the full text of the chat message (ie, the written message with the format applied to it).
// <context.recipients> returns a list of all players that will receive the chat.
//
// @Determine
Expand Down Expand Up @@ -160,13 +161,24 @@ public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(player, null);
}

public String getMessage() {
return pcEvent != null ? pcEvent.getMessage() : apcEvent.getMessage();
}

public String getFormat() {
return pcEvent != null ? pcEvent.getFormat() : apcEvent.getFormat();
}

@Override
public ObjectTag getContext(String name) {
if (name.equals("message")) {
return new ElementTag(pcEvent != null ? pcEvent.getMessage() : apcEvent.getMessage());
return new ElementTag(getMessage());
}
else if (name.equals("format")) {
return new ElementTag(pcEvent != null ? pcEvent.getFormat() : apcEvent.getFormat());
return new ElementTag(getFormat());
}
else if (name.equals("full_text")) {
return new ElementTag(String.format(getFormat(), player.getPlayerEntity().getDisplayName(), getMessage()));
}
if (name.equals("recipients")) {
ListTag list = new ListTag();
Expand Down

0 comments on commit 3b993a8

Please sign in to comment.