auto commit

This commit is contained in:
destro174
2021-07-27 18:46:58 +02:00
parent 04ac327365
commit 0891e252f9
25 changed files with 362 additions and 70 deletions
-6
View File
@@ -71,12 +71,6 @@
<version>4.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>11</maven.compiler.target>
-1
View File
@@ -96,7 +96,6 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
@@ -96,4 +96,8 @@ public class VelocityChat {
public ServerHandler getServerHandler() {
return serverHandler;
}
public ChannelIdentifier getChannelIdentifier() {
return channelIdentifier;
}
}
@@ -5,9 +5,14 @@ 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.objects.Mail;
import com.alttd.chat.util.Utility;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
@@ -33,15 +38,50 @@ public class ChatHandler {
List<Template> templates = new ArrayList<>(List.of(
Template.of("sender", senderUser.getDisplayName()),
Template.of("sendername", player.getUsername()),
Template.of("receiver", targetUser.getDisplayName()),
Template.of("message", message),
Template.of("receivername", player2.getUsername()),
Template.of("message", GsonComponentSerializer.gson().deserialize(message)),
Template.of("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")));
Component senderMessage = miniMessage.parse(Config.MESSAGESENDER, templates);
Component receiverMessage = miniMessage.parse(Config.MESSAGERECIEVER, templates);
ServerConnection serverConnection;
if(player.getCurrentServer().isPresent() && player2.getCurrentServer().isPresent()) {
// redirect to the sender
serverConnection = player.getCurrentServer().get();
Component component = miniMessage.parse(Config.MESSAGESENDER, templates);
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
buf.writeUTF("privatemessage");
buf.writeUTF(player.getUniqueId().toString());
buf.writeUTF(player2.getUsername());
buf.writeUTF(GsonComponentSerializer.gson().serialize(component));
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
player.sendMessage(senderMessage);
player2.sendMessage(receiverMessage);
//redirect to the receiver
serverConnection = player2.getCurrentServer().get();
component = miniMessage.parse(Config.MESSAGERECIEVER, templates);
buf = ByteStreams.newDataOutput();
buf.writeUTF("privatemessage");
buf.writeUTF(player2.getUniqueId().toString());
buf.writeUTF(player.getUsername());
buf.writeUTF(GsonComponentSerializer.gson().serialize(component));
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
}
// ChatUser targetUser = ChatUserManager.getChatUser(player2.getUniqueId());
//
// MiniMessage miniMessage = MiniMessage.get();
//
// List<Template> templates = new ArrayList<>(List.of(
// Template.of("sender", senderUser.getDisplayName()),
// Template.of("receiver", targetUser.getDisplayName()),
// Template.of("message", message),
// Template.of("server", player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "Altitude")));
//
// Component senderMessage = miniMessage.parse(Config.MESSAGESENDER, templates);
// Component receiverMessage = miniMessage.parse(Config.MESSAGERECIEVER, templates);
//
// player.sendMessage(senderMessage);
// player2.sendMessage(receiverMessage);
}
public void globalAdminChat(String message) {
@@ -82,6 +122,15 @@ public class ChatHandler {
* / mail send playerA,playerB,playerC message
*/
public void sendMail(CommandSource commandSource, String recipient, String message) {
UUID uuid;
if (commandSource instanceof Player) {
uuid = ((Player) commandSource).getUniqueId();
} else {
uuid = Config.CONSOLEUUID;
}
Optional<Player> optionalPlayer = VelocityChat.getPlugin().getProxy().getPlayer(recipient);
//Mail mail = new Mail()
// todo construct the mail and notify the player if online?
}
@@ -38,7 +38,7 @@ public class PluginMessageListener {
case "globaladminchat":
VelocityChat.getPlugin().getChatHandler().globalAdminChat(in.readUTF());
break;
case "privatemessage":
case "privatemessage": // TODO redirect this to the server that player is on
VelocityChat.getPlugin().getChatHandler().privateMessage(in.readUTF(), in.readUTF(), in.readUTF());
break;
default: