Serverübergreifender Chat als Velocity-Plugin
This commit is contained in:
commit
cbc7ffe4fb
18 files changed
+1362
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package eu.mhsl.craftattack.chatbridge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
@Plugin(
|
||||
id = "chat-bridge",
|
||||
name = "chat-bridge",
|
||||
version = "1.0.0",
|
||||
description = "Serverübergreifender Chat: öffentlicher Chat, /msg, Adminchat, Mute und Join/Leave",
|
||||
authors = {"MHSL"},
|
||||
dependencies = {@Dependency(id = "luckperms")}
|
||||
)
|
||||
public final class ChatBridge {
|
||||
/** Backend → Proxy: Rang-Prefixe aus spawn ({@code "prefix"}, danach Adventure-JSON oder leer). */
|
||||
static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("craftattack", "chat");
|
||||
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final Path dataDirectory;
|
||||
|
||||
@Inject
|
||||
public ChatBridge(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialize(ProxyInitializeEvent event) {
|
||||
Config config;
|
||||
try {
|
||||
config = Config.load(this.dataDirectory);
|
||||
} catch (Exception e) {
|
||||
this.logger.error("Konfiguration ungültig, chat-bridge ist aus", e);
|
||||
return;
|
||||
}
|
||||
|
||||
Names names = new Names(config);
|
||||
Mutes mutes = new Mutes(LuckPermsProvider.get());
|
||||
Chat chat = new Chat(this.proxy, this.logger, config, names, mutes);
|
||||
PrivateMessages privateMessages = new PrivateMessages(this.proxy, this.logger, config, names, chat);
|
||||
|
||||
this.proxy.getChannelRegistrar().register(CHANNEL);
|
||||
this.proxy.getEventManager().register(this, new ChatListener(this, this.proxy, this.logger, names, chat, privateMessages));
|
||||
Commands.register(this, this.proxy, this.logger, config, names, chat, privateMessages, mutes);
|
||||
|
||||
this.logger.info("chat-bridge aktiv, Kürzel {}, ohne Silencer {}", config.serverTags(), config.unsilencedServers());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user