diff --git a/api/src/main/java/com/alttd/chat/config/Config.java b/api/src/main/java/com/alttd/chat/config/Config.java index 4b4c7f0..697e554 100755 --- a/api/src/main/java/com/alttd/chat/config/Config.java +++ b/api/src/main/java/com/alttd/chat/config/Config.java @@ -177,6 +177,7 @@ public final class Config { public static List REPLYCOMMANDALIASES = new ArrayList<>(); public static String MESSAGESENDER = " >(Me -> ) "; public static String MESSAGERECIEVER = " >( on -> Me) "; + public static String MESSAGESPY = "( -> ) "; private static void messageCommand() { MESSAGECOMMANDALIASES.clear(); REPLYCOMMANDALIASES.clear(); @@ -184,6 +185,7 @@ public final class Config { REPLYCOMMANDALIASES = getList("commands.reply.aliases", Lists.newArrayList("r")); MESSAGESENDER = getString("commands.message.sender-message", MESSAGESENDER); MESSAGERECIEVER = getString("commands.message.reciever-message", MESSAGERECIEVER); + MESSAGESPY = getString("commands.message.spy-message", MESSAGESPY); } public static String GCFORMAT = " >to Global: "; diff --git a/api/src/main/java/com/alttd/chat/database/Queries.java b/api/src/main/java/com/alttd/chat/database/Queries.java index e6b2e1a..9a8e4b1 100755 --- a/api/src/main/java/com/alttd/chat/database/Queries.java +++ b/api/src/main/java/com/alttd/chat/database/Queries.java @@ -68,10 +68,10 @@ public class Queries { * returns the UUID of all players this player has ignored. * * @param uuid the player who ignored the other players - * @return LinkedList + * @return List */ - public static LinkedList getIgnoredUsers(UUID uuid) { - LinkedList uuids = new LinkedList<>(); + public static List getIgnoredUsers(UUID uuid) { + List uuids = new ArrayList<>(); String query = "SELECT * FROM ignored_users WHERE uuid = ?"; try { @@ -387,8 +387,8 @@ public class Queries { //----------------------------------------- - public static LinkedList getMails(UUID uuid) { - LinkedList mails = new LinkedList<>(); + public static List getMails(UUID uuid) { + List mails = new ArrayList<>(); String query = "SELECT * FROM mails where uuid = ?"; try { diff --git a/api/src/main/java/com/alttd/chat/objects/ChatUser.java b/api/src/main/java/com/alttd/chat/objects/ChatUser.java index e972b62..e66b4e8 100755 --- a/api/src/main/java/com/alttd/chat/objects/ChatUser.java +++ b/api/src/main/java/com/alttd/chat/objects/ChatUser.java @@ -4,7 +4,8 @@ import com.alttd.chat.database.Queries; import com.alttd.chat.util.Utility; import net.kyori.adventure.text.Component; -import java.util.LinkedList; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; public class ChatUser { @@ -20,9 +21,9 @@ public class ChatUser { private String replyTarget; // reply target for use in /msg i don't mind setting this to null on login, feedback? private long gcCooldown; // the time when they last used gc, is used for the cooldown, i wouldn't save this, but setting this to the login time means they can't use gc for 30 seconds after logging in - private LinkedList 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 LinkedList 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 LinkedList 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 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 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 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? public ChatUser(UUID uuid, int partyId, boolean toggledChat, boolean toggleGc) { this.uuid = uuid; @@ -45,7 +46,7 @@ public class ChatUser { gcCooldown = System.currentTimeMillis(); // players can't use gc for 30 seconds after logging in if we use this? mails = Queries.getMails(uuid); ignoredPlayers = Queries.getIgnoredUsers(uuid); - ignoredBy = new LinkedList<>(); // todo load ignoredPlayers + ignoredBy = new ArrayList<>(); // todo load ignoredPlayers } public UUID getUuid() { @@ -104,7 +105,7 @@ public class ChatUser { this.replyTarget = replyTarget; } - public LinkedList getMails() { + public List getMails() { return mails; } @@ -112,7 +113,7 @@ public class ChatUser { mails.add(mail); } - public LinkedList getIgnoredPlayers() { + public List getIgnoredPlayers() { return ignoredPlayers; } @@ -124,7 +125,7 @@ public class ChatUser { ignoredPlayers.remove(uuid); } - public LinkedList getIgnoredBy() { + public List getIgnoredBy() { return ignoredBy; } diff --git a/galaxy/src/main/java/com/alttd/chat/commands/Ignore.java b/galaxy/src/main/java/com/alttd/chat/commands/Ignore.java index 7f09cd3..a052ad2 100755 --- a/galaxy/src/main/java/com/alttd/chat/commands/Ignore.java +++ b/galaxy/src/main/java/com/alttd/chat/commands/Ignore.java @@ -39,9 +39,9 @@ public class Ignore implements CommandExecutor { if(!chatUser.getIgnoredPlayers().contains(target)) { chatUser.addIgnoredPlayers(target); Queries.ignoreUser(((Player) sender).getUniqueId(), target); - sender.sendMessage("You have turned ignored " + targetName + "."); // TODO load from config and minimessage + sender.sendMessage("You have ignored " + targetName + "."); // TODO load from config and minimessage } else { - sender.sendMessage("You have already ignored " + targetName + "."); // TODO load from config and minimessage + sender.sendMessage("You have ignored " + targetName + "."); // TODO load from config and minimessage } } }.runTaskAsynchronously(ChatPlugin.getInstance()); diff --git a/galaxy/src/main/java/com/alttd/chat/commands/Unignore.java b/galaxy/src/main/java/com/alttd/chat/commands/Unignore.java index 07a9e1a..9b9cde0 100755 --- a/galaxy/src/main/java/com/alttd/chat/commands/Unignore.java +++ b/galaxy/src/main/java/com/alttd/chat/commands/Unignore.java @@ -33,7 +33,7 @@ public class Unignore implements CommandExecutor { ChatUser chatUser = ChatUserManager.getChatUser(((Player) sender).getUniqueId()); if(chatUser.getIgnoredPlayers().contains(target)) { chatUser.removeIgnoredPlayers(target); - Queries.ignoreUser(((Player) sender).getUniqueId(), target); + Queries.unIgnoreUser(((Player) sender).getUniqueId(), target); sender.sendMessage("You no longer ignore " + targetName + "."); // TODO load from config and minimessage } else { sender.sendMessage("You don't have " + targetName + " ignored."); // TODO load from config and minimessage diff --git a/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java b/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java index 3fde0e3..0af69ca 100755 --- a/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java +++ b/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java @@ -7,6 +7,7 @@ import com.alttd.chat.objects.ChatUser; import com.alttd.chat.util.ALogger; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -23,11 +24,28 @@ public class PluginMessage implements PluginMessageListener { } ByteArrayDataInput in = ByteStreams.newDataInput(bytes); String subChannel = in.readUTF(); + UUID uuid;String target; Player p; switch (subChannel) { - case "privatemessage": - UUID uuid = UUID.fromString(in.readUTF()); - String target = in.readUTF(); - Player p = Bukkit.getPlayer(uuid); + case "privatemessagesend": + uuid = UUID.fromString(in.readUTF()); + target = in.readUTF(); + p = Bukkit.getPlayer(uuid); + if(p != null) { + ChatUser user = ChatUserManager.getChatUser(uuid); + user.setReplyTarget(target); + p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF())); + Component spymessage = GsonComponentSerializer.gson().deserialize(in.readUTF()); + for(Player pl : Bukkit.getOnlinePlayers()) { + if(pl.hasPermission("chat.social-spy")) { // todo add a toggle for social spy + pl.sendMessage(spymessage); + } + } + } + break; + case "privatemessagesreceived": + uuid = UUID.fromString(in.readUTF()); + target = in.readUTF(); + p = Bukkit.getPlayer(uuid); if(p != null) { ChatUser user = ChatUserManager.getChatUser(uuid); user.setReplyTarget(target); diff --git a/velocity/dependency-reduced-pom.xml b/velocity/dependency-reduced-pom.xml index 2cfdbd6..889ca45 100644 --- a/velocity/dependency-reduced-pom.xml +++ b/velocity/dependency-reduced-pom.xml @@ -21,8 +21,8 @@ maven-compiler-plugin 3.8.1 - 16 - 16 + 11 + 11 diff --git a/velocity/pom.xml b/velocity/pom.xml index 9c17322..3096e25 100755 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -28,8 +28,8 @@ maven-compiler-plugin 3.8.1 - 16 - 16 + 11 + 11 diff --git a/velocity/src/main/java/com/alttd/chat/handlers/ChatHandler.java b/velocity/src/main/java/com/alttd/chat/handlers/ChatHandler.java index 207eeae..f784374 100755 --- a/velocity/src/main/java/com/alttd/chat/handlers/ChatHandler.java +++ b/velocity/src/main/java/com/alttd/chat/handlers/ChatHandler.java @@ -47,23 +47,24 @@ public class ChatHandler { ServerConnection serverConnection; if(player.getCurrentServer().isPresent() && player2.getCurrentServer().isPresent()) { // redirect to the sender + String spyMessage = GsonComponentSerializer.gson().serialize(miniMessage.parse(Config.MESSAGESPY, templates)); serverConnection = player.getCurrentServer().get(); Component component = miniMessage.parse(Config.MESSAGESENDER, templates); ByteArrayDataOutput buf = ByteStreams.newDataOutput(); - buf.writeUTF("privatemessage"); + buf.writeUTF("privatemessagesend"); buf.writeUTF(player.getUniqueId().toString()); buf.writeUTF(player2.getUsername()); buf.writeUTF(GsonComponentSerializer.gson().serialize(component)); + buf.writeUTF(spyMessage); serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray()); //redirect to the receiver serverConnection = player2.getCurrentServer().get(); component = miniMessage.parse(Config.MESSAGERECIEVER, templates); buf = ByteStreams.newDataOutput(); - buf.writeUTF("privatemessage"); + buf.writeUTF("privatemessagesreceived"); buf.writeUTF(player2.getUniqueId().toString()); buf.writeUTF(player.getUsername()); - buf.writeUTF(GsonComponentSerializer.gson().serialize(component)); serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray()); }