sync mutes from proxy to server
This commit is contained in:
@@ -13,6 +13,7 @@ dependencies {
|
||||
exclude("net.kyori")
|
||||
exclude("net.kyori.examination")
|
||||
}
|
||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.alttd.chat.database.DatabaseConnection;
|
||||
import com.alttd.velocitychat.handlers.ChatHandler;
|
||||
import com.alttd.velocitychat.handlers.ServerHandler;
|
||||
import com.alttd.velocitychat.listeners.ChatListener;
|
||||
import com.alttd.velocitychat.listeners.LiteBansListener;
|
||||
import com.alttd.velocitychat.listeners.ProxyPlayerListener;
|
||||
import com.alttd.velocitychat.listeners.PluginMessageListener;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
@@ -31,7 +32,7 @@ import java.nio.file.Path;
|
||||
@Plugin(id = "chatplugin", name = "ChatPlugin", version = "1.0.0",
|
||||
description = "A chat plugin for Altitude Minecraft Server",
|
||||
authors = {"destro174", "teri"},
|
||||
dependencies = {@Dependency(id = "luckperms")}
|
||||
dependencies = {@Dependency(id = "luckperms"), @Dependency(id = "litebans")}
|
||||
)
|
||||
public class VelocityChat {
|
||||
|
||||
@@ -65,6 +66,7 @@ public class VelocityChat {
|
||||
chatHandler = new ChatHandler();
|
||||
server.getEventManager().register(this, new ChatListener());
|
||||
server.getEventManager().register(this, new ProxyPlayerListener());
|
||||
new LiteBansListener().init(); // init the litebans api listeners
|
||||
String[] channels = Config.MESSAGECHANNEL.split(":");// todo add a check for this?
|
||||
channelIdentifier = MinecraftChannelIdentifier.create(channels[0], channels[1]);
|
||||
server.getChannelRegistrar().register(channelIdentifier);
|
||||
|
||||
@@ -156,4 +156,11 @@ public class ChatHandler {
|
||||
.filter(p -> !ignoredPlayers.contains(p.getUniqueId()))
|
||||
.forEach(p -> p.sendMessage(message));
|
||||
}
|
||||
|
||||
public void mutePlayer(String uuid, boolean muted) {
|
||||
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||
buf.writeUTF("chatpunishments");
|
||||
buf.writeUTF(uuid);
|
||||
buf.writeBoolean(muted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.alttd.velocitychat.listeners;
|
||||
|
||||
import com.alttd.velocitychat.VelocityChat;
|
||||
import litebans.api.Entry;
|
||||
import litebans.api.Events;
|
||||
|
||||
public class LiteBansListener extends Events.Listener {
|
||||
|
||||
public void init() {
|
||||
Events.get().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entryAdded(Entry entry) {
|
||||
if (!entry.getType().equals("mute")) return;
|
||||
String uuid = entry.getUuid();
|
||||
if (uuid == null) return; // sanity check
|
||||
VelocityChat.getPlugin().getChatHandler().mutePlayer(uuid, entry.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entryRemoved(Entry entry) {
|
||||
if (!entry.getType().equals("mute")) return;
|
||||
String uuid = entry.getUuid();
|
||||
if (uuid == null) return; // sanity check
|
||||
VelocityChat.getPlugin().getChatHandler().mutePlayer(uuid, entry.isActive());
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.velocitypowered.api.event.connection.LoginEvent;
|
||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import litebans.api.Events;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
@@ -102,4 +103,5 @@ public class ProxyPlayerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user