some tweaks
This commit is contained in:
parent
ec9b474f72
commit
9674503170
|
|
@ -177,6 +177,7 @@ public final class Config {
|
|||
public static List<String> REPLYCOMMANDALIASES = new ArrayList<>();
|
||||
public static String MESSAGESENDER = "<hover:show_text:Click to reply><click:suggest_command:/msg <receivername> ><light_purple>(Me -> <gray><receiver></gray>)</hover> <message>";
|
||||
public static String MESSAGERECIEVER = "<hover:show_text:Click to reply><click:suggest_command:/msg <sendername> ><light_purple>(<gray><sender></gray> on <server> -> Me)</hover> <message>";
|
||||
public static String MESSAGESPY = "<gray>(<gray><sendername></gray> -> <receivername>) <message>";
|
||||
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 = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message>";
|
||||
|
|
|
|||
|
|
@ -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<UUID>
|
||||
* @return List<UUID>
|
||||
*/
|
||||
public static LinkedList<UUID> getIgnoredUsers(UUID uuid) {
|
||||
LinkedList<UUID> uuids = new LinkedList<>();
|
||||
public static List<UUID> getIgnoredUsers(UUID uuid) {
|
||||
List<UUID> uuids = new ArrayList<>();
|
||||
String query = "SELECT * FROM ignored_users WHERE uuid = ?";
|
||||
|
||||
try {
|
||||
|
|
@ -387,8 +387,8 @@ public class Queries {
|
|||
|
||||
//-----------------------------------------
|
||||
|
||||
public static LinkedList<Mail> getMails(UUID uuid) {
|
||||
LinkedList<Mail> mails = new LinkedList<>();
|
||||
public static List<Mail> getMails(UUID uuid) {
|
||||
List<Mail> mails = new ArrayList<>();
|
||||
String query = "SELECT * FROM mails where uuid = ?";
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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<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 LinkedList<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 LinkedList<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<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> 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<Mail> getMails() {
|
||||
public List<Mail> getMails() {
|
||||
return mails;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +113,7 @@ public class ChatUser {
|
|||
mails.add(mail);
|
||||
}
|
||||
|
||||
public LinkedList<UUID> getIgnoredPlayers() {
|
||||
public List<UUID> getIgnoredPlayers() {
|
||||
return ignoredPlayers;
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ public class ChatUser {
|
|||
ignoredPlayers.remove(uuid);
|
||||
}
|
||||
|
||||
public LinkedList<UUID> getIgnoredBy() {
|
||||
public List<UUID> getIgnoredBy() {
|
||||
return ignoredBy;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user