Skip to content

Commit

Permalink
Add PlaceholderAPI support for discord -> in-game message format.
Browse files Browse the repository at this point in the history
  • Loading branch information
RezzedUp committed Feb 4, 2020
1 parent f125005 commit f6deed8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -7,7 +7,7 @@
<groupId>com.rezzedup</groupId>
<artifactId>discordsrv-staff-chat</artifactId>
<name>DiscordSRV-Staff-Chat</name>
<version>1.3.0</version>
<version>1.3.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14-R0.1-SNAPSHOT</version>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--
Expand All @@ -53,7 +53,7 @@
<dependency>
<groupId>com.discordsrv</groupId>
<artifactId>discordsrv</artifactId>
<version>1.18.0</version>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
<!--
Expand Down
Expand Up @@ -186,6 +186,13 @@ public void submitMessageFromDiscord(User author, Message message)

// Emoji Unicode -> Alias (library included with DiscordSRV)
String text = EmojiParser.parseToAliases(event.getText());
String format = getConfig().getString("discord-message-format");

if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
{
// Update format's PAPI placeholders before inserting the message.
format = PlaceholderAPI.setPlaceholders(null, format);
}

MappedPlaceholder placholders = new MappedPlaceholder();

Expand All @@ -194,7 +201,7 @@ public void submitMessageFromDiscord(User author, Message message)
placholders.map("nickname", "displayname").to(message.getGuild().getMember(author)::getNickname);
placholders.map("discriminator", "discrim").to(author::getDiscriminator);

updatePlaceholdersThenAnnounceInGame(getConfig().getString("discord-message-format"), placholders);
updatePlaceholdersThenAnnounceInGame(format, placholders);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Expand Up @@ -37,7 +37,7 @@
#

#
# *If* PlaceholderAPI is installed, the in-game format will also utilize those.
# *If* PlaceholderAPI is installed, both in-game and discord formats will also utilize them.
# That plugin is not necessary for the existing placeholders in this config, however.
#

Expand Down

0 comments on commit f6deed8

Please sign in to comment.