mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Add option to disable message forwarding
This commit is contained in:
1 parent
d7910751be
commit
4ce7ef3211
3 files changed
+58
-7
No files matched your search
@@ -4,6 +4,7 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.channels.ChatChannel;
|
||||
import net.draycia.carbon.messaging.impl.BungeeMessageService;
|
||||
import net.draycia.carbon.messaging.impl.EmptyMessageService;
|
||||
import net.draycia.carbon.messaging.impl.RedisMessageService;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@@ -23,12 +24,28 @@ public class MessageManager {
|
||||
this.carbonChat = carbonChat;
|
||||
this.gsonSerializer = carbonChat.getAdventureManager().getAudiences().gsonSerializer();
|
||||
|
||||
if (carbonChat.getConfig().getBoolean("redis.enabled")) {
|
||||
carbonChat.getLogger().info("Using Redis for message forwarding!");
|
||||
this.messageService = new RedisMessageService(carbonChat);
|
||||
} else {
|
||||
carbonChat.getLogger().info("Using Bungee Plugin Messaging for message forwarding!");
|
||||
this.messageService = new BungeeMessageService(carbonChat);
|
||||
String messageSystem = carbonChat.getConfig().getString("message-system", "none");
|
||||
|
||||
if (messageSystem == null) {
|
||||
messageSystem = "none";
|
||||
}
|
||||
|
||||
switch(messageSystem.toLowerCase()) {
|
||||
case "bungee":
|
||||
carbonChat.getLogger().info("Using Bungee Plugin Messaging for message forwarding!");
|
||||
messageService = new BungeeMessageService(carbonChat);
|
||||
break;
|
||||
case "redis":
|
||||
carbonChat.getLogger().info("Using Redis for message forwarding!");
|
||||
messageService = new RedisMessageService(carbonChat);
|
||||
break;
|
||||
case "none":
|
||||
messageService = new EmptyMessageService();
|
||||
break;
|
||||
default:
|
||||
carbonChat.getLogger().info("Invalid message service selected! Disabling syncing until next restart!");
|
||||
messageService = new EmptyMessageService();
|
||||
break;
|
||||
}
|
||||
|
||||
this.registerDefaultListeners();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.draycia.carbon.messaging.impl;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.messaging.MessageService;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EmptyMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
public void registerMessageListener(String key, BiConsumer<ChatUser, ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(String key) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String key, UUID uuid, Consumer<ByteArrayDataOutput> consumer) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,8 +137,13 @@ storage:
|
||||
hostname: 'localhost'
|
||||
port: 3306
|
||||
|
||||
# Options:
|
||||
# 'bungee' - Uses bungee plugin messaging, requires BungeeCord or another proxy which supports it (Velocity!)
|
||||
# 'redis' - Uses redis for cross server syncing, does not require a server proxy
|
||||
# 'none' - Do not sync anything cross server, this is the default
|
||||
message-system: 'none'
|
||||
|
||||
redis:
|
||||
enabled: false
|
||||
host: 'localhost'
|
||||
port: 6379
|
||||
#password: 'password'
|
||||
|
||||
Reference in new issue
Block a user