progress
This commit is contained in:
@@ -71,6 +71,12 @@
|
||||
<version>4.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
||||
+2
-2
@@ -95,8 +95,8 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
<scope>runtime</scope>
|
||||
<version>8.0.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.alttd.chat.handlers.ServerHandler;
|
||||
import com.alttd.chat.listeners.ChatListener;
|
||||
import com.alttd.chat.listeners.ProxyPlayerListener;
|
||||
import com.alttd.chat.listeners.PluginMessageListener;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@@ -19,8 +18,6 @@ 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.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
@@ -54,8 +51,7 @@ public class VelocityChat {
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
new ALogger(logger);
|
||||
//Config.init(getDataDirectory());
|
||||
ALogger.init(logger);
|
||||
chatAPI = new ChatImplementation();
|
||||
|
||||
serverHandler = new ServerHandler();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GlobalAdminChat {
|
||||
.executes(context -> {
|
||||
VelocityChat.getPlugin().getChatHandler().globalAdminChat(context.getSource(), context.getArgument("message", String.class));
|
||||
return 1;
|
||||
}) // TODO call in the same way as gc?
|
||||
})
|
||||
)
|
||||
.executes(context -> 0)
|
||||
.build();
|
||||
|
||||
@@ -15,29 +15,29 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
||||
public class GlobalChat {
|
||||
|
||||
public GlobalChat(ProxyServer proxyServer) {
|
||||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("globalchat")
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.globalchat"))// TODO permission system? load permissions from config?
|
||||
.requires(ctx -> ctx instanceof Player) // players only can use this
|
||||
.then(RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument("message", StringArgumentType.greedyString())
|
||||
.executes(context -> {
|
||||
VelocityChat.getPlugin().getChatHandler().globalChat((Player) context.getSource(), context.getArgument("message", String.class));
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
.executes(context -> 0) // todo info message /usage
|
||||
.build();
|
||||
|
||||
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
|
||||
|
||||
CommandMeta.Builder metaBuilder = proxyServer.getCommandManager().metaBuilder(brigadierCommand);
|
||||
|
||||
for (String alias : Config.GCALIAS) {
|
||||
metaBuilder.aliases(alias);
|
||||
}
|
||||
CommandMeta meta = metaBuilder.build();
|
||||
|
||||
proxyServer.getCommandManager().register(meta, brigadierCommand);
|
||||
// LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
// .<CommandSource>literal("globalchat")
|
||||
// .requires(ctx -> ctx.hasPermission("command.proxy.globalchat"))// TODO permission system? load permissions from config?
|
||||
// .requires(ctx -> ctx instanceof Player) // players only can use this
|
||||
// .then(RequiredArgumentBuilder
|
||||
// .<CommandSource, String>argument("message", StringArgumentType.greedyString())
|
||||
// .executes(context -> {
|
||||
// VelocityChat.getPlugin().getChatHandler().globalChat((Player) context.getSource(), context.getArgument("message", String.class));
|
||||
// return 1;
|
||||
// })
|
||||
// )
|
||||
// .executes(context -> 0) // todo info message /usage
|
||||
// .build();
|
||||
//
|
||||
// BrigadierCommand brigadierCommand = new BrigadierCommand(command);
|
||||
//
|
||||
// CommandMeta.Builder metaBuilder = proxyServer.getCommandManager().metaBuilder(brigadierCommand);
|
||||
//
|
||||
// for (String alias : Config.GCALIAS) {
|
||||
// metaBuilder.aliases(alias);
|
||||
// }
|
||||
// CommandMeta meta = metaBuilder.build();
|
||||
//
|
||||
// proxyServer.getCommandManager().register(meta, brigadierCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,52 +2,19 @@ package com.alttd.chat.handlers;
|
||||
|
||||
import com.alttd.chat.VelocityChat;
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatHandler {
|
||||
|
||||
public void globalChat(Player player, String message) {
|
||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
if(user == null) return;
|
||||
MiniMessage miniMessage = MiniMessage.get();
|
||||
if(!user.isGcOn()) {
|
||||
player.sendMessage(miniMessage.parse(Config.GCNOTENABLED));// GC IS OFF INFORM THEM ABOUT THIS and cancel
|
||||
return;
|
||||
}
|
||||
|
||||
message = Utility.parseColors(message);
|
||||
if(!player.hasPermission("chat.format")) // Todo PR fix for '<3' to minimessage
|
||||
message = miniMessage.stripTokens(message);
|
||||
|
||||
message = RegexManager.replaceText(message); // this filters the message TODO should staff be able to bypass filters?
|
||||
|
||||
List<Template> templates = new ArrayList<>(List.of(
|
||||
Template.of("sender", user.getDisplayName()),
|
||||
Template.of("prefix", user.getPrefix()),
|
||||
Template.of("message", message),
|
||||
Template.of("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")
|
||||
/*,Template.of("[i]", itemComponent(sender.getInventory().getItemInMainHand()))*/ //Todo move this into ChatFilters
|
||||
));
|
||||
|
||||
Component component = miniMessage.parse(Config.GCFORMAT, templates);
|
||||
|
||||
VelocityChat.getPlugin().getServerHandler().sendGlobalChat(component);
|
||||
|
||||
}
|
||||
|
||||
public void privateMessage(CommandSource commandSource, Player recipient, String message) {
|
||||
// todo get the chatUserinstance of both players and or console - @teri should console be able to /msg?
|
||||
String senderName;
|
||||
@@ -92,9 +59,7 @@ public class ChatHandler {
|
||||
}
|
||||
|
||||
public void globalAdminChat(String message) {
|
||||
MiniMessage miniMessage = MiniMessage.get();
|
||||
|
||||
Component component = miniMessage.parse(Config.GACFORMAT);
|
||||
Component component = GsonComponentSerializer.gson().deserialize(message);
|
||||
|
||||
VelocityChat.getPlugin().getProxy().getAllPlayers().stream().filter(target -> target.hasPermission("command.proxy.globaladminchat")/*TODO permission*/).forEach(target -> {
|
||||
target.sendMessage(component);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.alttd.chat.data.ServerWrapper;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -36,10 +37,12 @@ public class ServerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGlobalChat(Component message) {
|
||||
public void sendGlobalChat(String message) {
|
||||
Component component = GsonComponentSerializer.gson().deserialize(message);
|
||||
|
||||
servers.stream()
|
||||
.filter(serverWrapper -> serverWrapper.globalChat())
|
||||
.forEach(serverWrapper -> serverWrapper.getRegisteredServer().sendMessage(message));
|
||||
.forEach(serverWrapper -> serverWrapper.getRegisteredServer().sendMessage(component));
|
||||
}
|
||||
|
||||
public List<ServerWrapper> getServers()
|
||||
|
||||
@@ -33,8 +33,7 @@ public class PluginMessageListener {
|
||||
VelocityChat.getPlugin().getLogger().info("server " + event.getSource());
|
||||
switch (channel) {
|
||||
case "globalchat":
|
||||
// todo this is obsolete
|
||||
//VelocityChat.getPlugin().getServerHandler().sendGlobalChat(in.readUTF());
|
||||
VelocityChat.getPlugin().getServerHandler().sendGlobalChat(in.readUTF());
|
||||
break;
|
||||
case "globaladminchat":
|
||||
VelocityChat.getPlugin().getChatHandler().globalAdminChat(in.readUTF());
|
||||
|
||||
Reference in New Issue
Block a user