sync mutes from proxy to server
This commit is contained in:
parent
41ac24fd74
commit
eb31a141d0
|
|
@ -26,6 +26,7 @@ public class ChatUser {
|
||||||
private List<Mail> mails; // mails aren't finalized yet, so for now a table sender, reciever, sendtime, readtime(if emtpy mail isn't read yet?, could also do a byte to control this), the actual message
|
private List<Mail> mails; // mails aren't finalized yet, so for now a table sender, reciever, sendtime, readtime(if emtpy mail isn't read yet?, could also do a byte to control this), the actual message
|
||||||
private List<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player?
|
private List<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player?
|
||||||
private List<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player?
|
private List<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player?
|
||||||
|
private boolean isMuted;
|
||||||
|
|
||||||
public ChatUser(UUID uuid, int partyId, Channel toggledChannel) {
|
public ChatUser(UUID uuid, int partyId, Channel toggledChannel) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
|
@ -49,6 +50,7 @@ public class ChatUser {
|
||||||
ignoredPlayers = Queries.getIgnoredUsers(uuid);
|
ignoredPlayers = Queries.getIgnoredUsers(uuid);
|
||||||
ignoredBy = new ArrayList<>(); // todo load ignoredPlayers
|
ignoredBy = new ArrayList<>(); // todo load ignoredPlayers
|
||||||
spy = true;
|
spy = true;
|
||||||
|
isMuted = false; // TODO load from db
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
|
|
@ -146,4 +148,13 @@ public class ChatUser {
|
||||||
public void toggleSpy() {
|
public void toggleSpy() {
|
||||||
this.spy = !spy;
|
this.spy = !spy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMuted() {
|
||||||
|
return isMuted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMuted(boolean muted) {
|
||||||
|
this.isMuted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api")) // API
|
implementation(project(":api")) // API
|
||||||
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") // Galaxy
|
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") // Galaxy
|
||||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5")
|
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5") // move to proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,18 @@ import com.alttd.chat.ChatPlugin;
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.managers.ChatUserManager;
|
import com.alttd.chat.managers.ChatUserManager;
|
||||||
import com.alttd.chat.managers.RegexManager;
|
import com.alttd.chat.managers.RegexManager;
|
||||||
import com.alttd.chat.objects.channels.CustomChannel;
|
|
||||||
import com.alttd.chat.objects.ChatUser;
|
import com.alttd.chat.objects.ChatUser;
|
||||||
import com.alttd.chat.objects.Party;
|
import com.alttd.chat.objects.Party;
|
||||||
|
import com.alttd.chat.objects.channels.CustomChannel;
|
||||||
import com.alttd.chat.util.GalaxyUtility;
|
import com.alttd.chat.util.GalaxyUtility;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import litebans.api.Database;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -254,7 +252,10 @@ public class ChatHandler {
|
||||||
// Start - move these to util
|
// Start - move these to util
|
||||||
|
|
||||||
private boolean isMuted(Player player, String message, String prefix) {
|
private boolean isMuted(Player player, String message, String prefix) {
|
||||||
if (Database.get().isPlayerMuted(player.getUniqueId(), null) || (ChatPlugin.getInstance().serverMuted() && !player.hasPermission("chat.bypass-server-muted"))) {
|
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||||
|
if (user == null) return false;
|
||||||
|
if (user.isMuted() || (ChatPlugin.getInstance().serverMuted() && !player.hasPermission("chat.bypass-server-muted"))) {
|
||||||
|
// if (Database.get().isPlayerMuted(player.getUniqueId(), null) || (ChatPlugin.getInstance().serverMuted() && !player.hasPermission("chat.bypass-server-muted"))) {
|
||||||
GalaxyUtility.sendBlockedNotification(prefix, player, message, "");
|
GalaxyUtility.sendBlockedNotification(prefix, player, message, "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,13 @@ public class PluginMessage implements PluginMessageListener {
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
ChatPlugin.getInstance().ReloadConfig();
|
ChatPlugin.getInstance().ReloadConfig();
|
||||||
break;
|
break;
|
||||||
|
case "chatpunishments":
|
||||||
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
|
boolean mute = in.readBoolean();
|
||||||
|
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||||
|
if (user == null) return;
|
||||||
|
user.setMuted(mute);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ dependencies {
|
||||||
exclude("net.kyori")
|
exclude("net.kyori")
|
||||||
exclude("net.kyori.examination")
|
exclude("net.kyori.examination")
|
||||||
}
|
}
|
||||||
|
compileOnly("com.gitlab.ruany:LiteBansAPI:0.3.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.alttd.chat.database.DatabaseConnection;
|
||||||
import com.alttd.velocitychat.handlers.ChatHandler;
|
import com.alttd.velocitychat.handlers.ChatHandler;
|
||||||
import com.alttd.velocitychat.handlers.ServerHandler;
|
import com.alttd.velocitychat.handlers.ServerHandler;
|
||||||
import com.alttd.velocitychat.listeners.ChatListener;
|
import com.alttd.velocitychat.listeners.ChatListener;
|
||||||
|
import com.alttd.velocitychat.listeners.LiteBansListener;
|
||||||
import com.alttd.velocitychat.listeners.ProxyPlayerListener;
|
import com.alttd.velocitychat.listeners.ProxyPlayerListener;
|
||||||
import com.alttd.velocitychat.listeners.PluginMessageListener;
|
import com.alttd.velocitychat.listeners.PluginMessageListener;
|
||||||
import com.alttd.chat.util.ALogger;
|
import com.alttd.chat.util.ALogger;
|
||||||
|
|
@ -31,7 +32,7 @@ import java.nio.file.Path;
|
||||||
@Plugin(id = "chatplugin", name = "ChatPlugin", version = "1.0.0",
|
@Plugin(id = "chatplugin", name = "ChatPlugin", version = "1.0.0",
|
||||||
description = "A chat plugin for Altitude Minecraft Server",
|
description = "A chat plugin for Altitude Minecraft Server",
|
||||||
authors = {"destro174", "teri"},
|
authors = {"destro174", "teri"},
|
||||||
dependencies = {@Dependency(id = "luckperms")}
|
dependencies = {@Dependency(id = "luckperms"), @Dependency(id = "litebans")}
|
||||||
)
|
)
|
||||||
public class VelocityChat {
|
public class VelocityChat {
|
||||||
|
|
||||||
|
|
@ -65,6 +66,7 @@ public class VelocityChat {
|
||||||
chatHandler = new ChatHandler();
|
chatHandler = new ChatHandler();
|
||||||
server.getEventManager().register(this, new ChatListener());
|
server.getEventManager().register(this, new ChatListener());
|
||||||
server.getEventManager().register(this, new ProxyPlayerListener());
|
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?
|
String[] channels = Config.MESSAGECHANNEL.split(":");// todo add a check for this?
|
||||||
channelIdentifier = MinecraftChannelIdentifier.create(channels[0], channels[1]);
|
channelIdentifier = MinecraftChannelIdentifier.create(channels[0], channels[1]);
|
||||||
server.getChannelRegistrar().register(channelIdentifier);
|
server.getChannelRegistrar().register(channelIdentifier);
|
||||||
|
|
|
||||||
|
|
@ -156,4 +156,11 @@ public class ChatHandler {
|
||||||
.filter(p -> !ignoredPlayers.contains(p.getUniqueId()))
|
.filter(p -> !ignoredPlayers.contains(p.getUniqueId()))
|
||||||
.forEach(p -> p.sendMessage(message));
|
.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.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import litebans.api.Events;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
|
|
||||||
|
|
@ -102,4 +103,5 @@ public class ProxyPlayerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user