diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..217a7dc
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,50 @@
+name: Build
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Prepare Project
+ uses: actions/checkout@v3
+ with:
+ ref: 'main'
+
+ - name: Set up JDK 8
+ uses: actions/setup-java@v3
+ with:
+ java-version: '8'
+ distribution: 'temurin'
+ cache: maven
+
+ - name: Build with Maven
+ run: |
+ mvn -B install --file pom.xml
+ echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: 'v${{ env.PROJECT_VERSION }}'
+ release_name: ChatEmojis
+ draft: false
+ prerelease: false
+
+ - name: Upload Release Asset
+ id: upload-release-asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: './target/ChatEmojis-${{ env.PROJECT_VERSION }}.jar'
+ asset_name: 'ChatEmojis-${{ env.PROJECT_VERSION }}.jar'
+ asset_content_type: 'application/java-archive'
\ No newline at end of file
diff --git a/README.md b/README.md
index e109e57..67b7c0e 100644
--- a/README.md
+++ b/README.md
@@ -28,8 +28,9 @@ Grouped emojis permission needs to include the path to the group (ex. `chatemoji
If you still don't understand how to get emoji-specific permission- as a server operator you're able to hover over the emoji (in the `/emoji` list) to view the permission node for that specific emoji.
# Dependencies
-ChatEmojis does not hard-depend on any other plugins.
-**PlaceholderAPI** is a soft-dependency which means it's **NOT** required for ChatEmojis to work. If you'd like to use placeholders in your emojis, you're able to do so by also installing PlaceholderAPI.
+ChatEmojis does not hard-depend on any other plugins; Meaning **none** of these dependencies are required for ChatEmojis to work.
+- **[PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/)** is used for placeholder parsing.
+- **[EssentialsX](https://www.spigotmc.org/resources/essentialsx.9089/)** is used for parsing emoticons in direct messages.
Please note that if you are using PlaceholderAPI, you must also install the PlaceholderAPI Extension corresponding to the placeholder you're trying to access, more about this can be found [here](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders).
diff --git a/pom.xml b/pom.xml
index ee3fcde..99b4023 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.rmjtromp
ChatEmojis
- 2.3.1
+ 2.3.2
jar
ChatEmojis
@@ -82,6 +82,14 @@
placeholderapi
https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+ essentials-releases
+ https://repo.essentialsx.net/releases/
+
+
+ paper-repo
+ https://papermc.io/repo/repository/maven-public/
+
@@ -97,6 +105,18 @@
2.10.9
provided
+
+ net.essentialsx
+ EssentialsX
+ 2.19.0
+ provided
+
+
+ org.bstats
+ bstats-bukkit
+
+
+
org.projectlombok
diff --git a/src/main/java/com/rmjtromp/chatemojis/ChatEmojis.java b/src/main/java/com/rmjtromp/chatemojis/ChatEmojis.java
index 71d6cf5..1aaae95 100644
--- a/src/main/java/com/rmjtromp/chatemojis/ChatEmojis.java
+++ b/src/main/java/com/rmjtromp/chatemojis/ChatEmojis.java
@@ -14,14 +14,6 @@
import org.bukkit.ChatColor;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.SignChangeEvent;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerEditBookEvent;
-import org.bukkit.event.server.PluginDisableEvent;
-import org.bukkit.event.server.PluginEnableEvent;
-import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@@ -38,9 +30,9 @@ public final class ChatEmojis extends JavaPlugin {
static final Pattern NAME_PATTERN = Pattern.compile("(?<=\\.)?([^.]+?)$", Pattern.CASE_INSENSITIVE);
private final Config config;
- private EmojiGroup emojis = null;
+ EmojiGroup emojis = null;
private static ChatEmojis plugin;
- private boolean papiIsLoaded = false;
+ boolean papiIsLoaded = false;
public final ConfigurationReference useOnSigns, useInBooks;
private SettingsWindow settingsWindow = null;
@@ -68,45 +60,7 @@ public void onEnable() {
settingsWindow = new SettingsWindow(this);
papiIsLoaded = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
- getServer().getPluginManager().registerEvents(new Listener() {
-
- @EventHandler
- public void onPlayerChat(AsyncPlayerChatEvent e) {
- String resetColor = ChatColor.RESET + ChatColor.getLastColors(e.getMessage());
- e.setMessage(emojis.parse(e.getPlayer(), resetColor, e.getMessage(), false));
- }
-
- @EventHandler
- public void onPluginEnable(PluginEnableEvent e) {
- if(e.getPlugin().getName().equals("PlaceholderAPI")) papiIsLoaded = true;
- }
-
- @EventHandler
- public void onPluginDisable(PluginDisableEvent e) {
- if(e.getPlugin().getName().equals("PlaceholderAPI")) papiIsLoaded = false;
- }
-
- @EventHandler
- public void onSignChange(SignChangeEvent e) {
- if(Boolean.TRUE.equals(useOnSigns.getValue())) {
- for(int i = 0; i < e.getLines().length; i++) {
- e.setLine(i, emojis.parse(e.getPlayer(), ChatColor.RESET + ChatColor.getLastColors(e.getLine(i)), e.getLine(i), false));
- }
- }
- }
-
- @EventHandler
- public void onPlayerBookEdit(PlayerEditBookEvent e) {
- if(Boolean.TRUE.equals(useInBooks.getValue())) {
- List newContent = new ArrayList<>();
- BookMeta meta = e.getNewBookMeta();
- meta.getPages().forEach(string -> newContent.add(emojis.parse(e.getPlayer(), ChatColor.RESET + ChatColor.getLastColors(string), string, false)));
- meta.setPages(newContent);
- e.setNewBookMeta(meta);
- }
- }
-
- }, this);
+ getServer().getPluginManager().registerEvents(new PluginListeners(), this);
getCommand("emoji").setExecutor((sender, command, label, args) -> {
if(sender.hasPermission("chatemojis.command") || sender.hasPermission("chatemojis.list")) {
@@ -179,10 +133,6 @@ public Config getConfig() {
return config;
}
- boolean isPapiLoaded() {
- return papiIsLoaded;
- }
-
static ChatEmojis getInstance() {
return plugin;
}
diff --git a/src/main/java/com/rmjtromp/chatemojis/Emoji.java b/src/main/java/com/rmjtromp/chatemojis/Emoji.java
index cab39c5..2599984 100644
--- a/src/main/java/com/rmjtromp/chatemojis/Emoji.java
+++ b/src/main/java/com/rmjtromp/chatemojis/Emoji.java
@@ -194,9 +194,9 @@ public String parse(@NotNull Player player, @NotNull String resetColor, @NotNull
Matcher matcher = getPattern().matcher(message);
while(matcher.find()) {
if(getEmojis().size() > 1) {
- message = matcher.replaceFirst(ChatColor.RESET + (!plugin.isPapiLoaded() ? getEmoji() : PlaceholderAPI.setPlaceholders(player, getEmoji())) + resetColor);
+ message = matcher.replaceFirst(ChatColor.RESET + (!plugin.papiIsLoaded ? getEmoji() : PlaceholderAPI.setPlaceholders(player, getEmoji())) + resetColor);
matcher = getPattern().matcher(message);
- } else message = matcher.replaceAll(ChatColor.RESET + (!plugin.isPapiLoaded() ? getEmoji() : PlaceholderAPI.setPlaceholders(player, getEmoji())) + resetColor);
+ } else message = matcher.replaceAll(ChatColor.RESET + (!plugin.papiIsLoaded ? getEmoji() : PlaceholderAPI.setPlaceholders(player, getEmoji())) + resetColor);
}
}
return message;
diff --git a/src/main/java/com/rmjtromp/chatemojis/PluginListeners.java b/src/main/java/com/rmjtromp/chatemojis/PluginListeners.java
new file mode 100644
index 0000000..f47addc
--- /dev/null
+++ b/src/main/java/com/rmjtromp/chatemojis/PluginListeners.java
@@ -0,0 +1,93 @@
+package com.rmjtromp.chatemojis;
+
+import com.earth2me.essentials.User;
+import net.ess3.api.events.PrivateMessagePreSendEvent;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.SignChangeEvent;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerEditBookEvent;
+import org.bukkit.event.server.PluginDisableEvent;
+import org.bukkit.event.server.PluginEnableEvent;
+import org.bukkit.inventory.meta.BookMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class PluginListeners implements Listener {
+
+ private static final ChatEmojis PLUGIN = ChatEmojis.getInstance();
+
+ private final Listener ESSENTIALS_LISTENER = new Listener() {
+
+ @EventHandler(ignoreCancelled = true)
+ public void onPrivateMessagePreSend(PrivateMessagePreSendEvent e) {
+ if(e.getSender() instanceof User) {
+ Player sender = ((User) e.getSender()).getBase();
+ String resetColor = ChatColor.RESET + ChatColor.getLastColors(e.getMessage());
+ e.setMessage(PLUGIN.emojis.parse(sender, resetColor, e.getMessage(), false));
+ }
+ }
+
+ };
+
+ @EventHandler(ignoreCancelled = true)
+ public void onPlayerChat(AsyncPlayerChatEvent e) {
+ String resetColor = ChatColor.RESET + ChatColor.getLastColors(e.getMessage());
+ e.setMessage(PLUGIN.emojis.parse(e.getPlayer(), resetColor, e.getMessage(), false));
+ }
+
+ @EventHandler
+ public void onPluginEnable(PluginEnableEvent e) {
+ switch(e.getPlugin().getName()) {
+ case "PlaceholderAPI":
+ PLUGIN.papiIsLoaded = true;
+ break;
+ case "Essentials":
+ PLUGIN.getServer().getPluginManager().registerEvents(ESSENTIALS_LISTENER, PLUGIN);
+ break;
+ }
+ }
+
+ @EventHandler
+ public void onPluginDisable(PluginDisableEvent e) {
+ switch(e.getPlugin().getName()) {
+ case "PlaceholderAPI":
+ PLUGIN.papiIsLoaded = false;
+ break;
+ case "Essentials":
+ HandlerList.unregisterAll(ESSENTIALS_LISTENER);
+ break;
+ }
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onSignChange(SignChangeEvent e) {
+ if(Boolean.TRUE.equals(PLUGIN.useOnSigns.getValue())) {
+ for(int i = 0; i < e.getLines().length; i++) {
+ String line = e.getLine(i);
+ assert line != null;
+ String resetColor = ChatColor.RESET + ChatColor.getLastColors(line);
+ e.setLine(i, PLUGIN.emojis.parse(e.getPlayer(), resetColor, line, false));
+ }
+ }
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onPlayerBookEdit(PlayerEditBookEvent e) {
+ if(Boolean.TRUE.equals(PLUGIN.useInBooks.getValue())) {
+ List newContent = new ArrayList<>();
+ BookMeta meta = e.getNewBookMeta();
+ meta.getPages().forEach(string -> {
+ String resetColor = ChatColor.RESET + ChatColor.getLastColors(string);
+ newContent.add(PLUGIN.emojis.parse(e.getPlayer(), resetColor, string, false));
+ });
+ meta.setPages(newContent);
+ e.setNewBookMeta(meta);
+ }
+ }
+
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 8ea1fb5..a22f8ac 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,7 +3,7 @@ version: ${project.version}
main: com.rmjtromp.chatemojis.ChatEmojis
api-version: 1.13
authors: [ RMJTromp ]
-soft-depend: [ PlaceholderAPI ]
+soft-depend: [ PlaceholderAPI, Essentials ]
commands:
emoji: