Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repositories {
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url 'https://repo.xenondevs.xyz/releases' }
maven { url 'https://repo.maven.apache.org/maven2/' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
}

dependencies {
Expand All @@ -38,7 +39,7 @@ dependencies {
implementation 'com.github.Anon8281:UniversalScheduler:0.1.6'


compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly 'io.lettuce:lettuce-core:6.5.3.RELEASE'
compileOnly 'org.jetbrains:annotations:24.1.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
package dev.unnm3d.redischat.chat.listeners;

import dev.unnm3d.redischat.RedisChat;
import io.papermc.paper.event.player.AsyncChatEvent;
import lombok.Getter;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

@Getter
public enum ChatListenerWithPriority {
LOWEST(new ChatListener() {
@EventHandler(priority = EventPriority.LOWEST)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
}),
LOW(new ChatListener() {
@EventHandler(priority = EventPriority.LOW)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
}),
NORMAL(new ChatListener() {
@EventHandler(priority = EventPriority.NORMAL)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
}),
HIGH(new ChatListener() {
@EventHandler(priority = EventPriority.HIGH)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
}),
HIGHEST(new ChatListener() {
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
}),
MONITOR(new ChatListener() {
@EventHandler(priority = EventPriority.MONITOR)
public void onChat(AsyncPlayerChatEvent event) {
public void onChat(AsyncChatEvent event) {
listenChat(event);
}
});
Expand All @@ -57,10 +58,10 @@ public void onChat(AsyncPlayerChatEvent event) {
private abstract static class ChatListener implements Listener {
private final RedisChat plugin = RedisChat.getInstance();

public void listenChat(AsyncPlayerChatEvent event) {
public void listenChat(AsyncChatEvent event) {
if (event.isCancelled()) return;
event.setCancelled(true);
plugin.getChannelManager().outgoingMessage(event.getPlayer(), event.getMessage());
plugin.getChannelManager().outgoingMessage(event.getPlayer(), PlainTextComponentSerializer.plainText().serialize(event.message()));
}
}
}