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 13f1738..e76c4ff 100755 --- a/api/src/main/java/com/alttd/chat/objects/ChatUser.java +++ b/api/src/main/java/com/alttd/chat/objects/ChatUser.java @@ -22,7 +22,7 @@ public class ChatUser { //private boolean toggleGc; // should be saved, this toggles if the player can see and use global chat 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 boolean spy; 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? @@ -48,6 +48,7 @@ public class ChatUser { mails = Queries.getMails(uuid); ignoredPlayers = Queries.getIgnoredUsers(uuid); ignoredBy = new ArrayList<>(); // todo load ignoredPlayers + spy = true; } public UUID getUuid() { @@ -137,4 +138,12 @@ public class ChatUser { public void setGcCooldown(long time) { this.gcCooldown = time; } + + public boolean isSpy() { + return spy; + } + + public void toggleSpy() { + this.spy = !spy; + } } diff --git a/galaxy/src/main/java/com/alttd/chat/commands/Spy.java b/galaxy/src/main/java/com/alttd/chat/commands/Spy.java index 21dccd9..b23c7db 100755 --- a/galaxy/src/main/java/com/alttd/chat/commands/Spy.java +++ b/galaxy/src/main/java/com/alttd/chat/commands/Spy.java @@ -25,9 +25,9 @@ public class Spy implements CommandExecutor { @Override public void run() { UUID uuid = ((Player) sender).getUniqueId(); - Utility.flipPermission(uuid, Config.SPYPERMISSION); - //Queries.setGlobalChatState(chatUser.isGcOn(), chatUser.getUuid()); - sender.sendMessage(MiniMessage.get().parse("You have turned spy " + (!Utility.hasPermission(uuid, Config.GCPERMISSION) ? "on." : "off."))); // TODO load from config and minimessage + ChatUser user = ChatUserManager.getChatUser(uuid); + user.toggleSpy(); + sender.sendMessage(MiniMessage.get().parse("You have turned spy " + (user.isSpy() ? "on." : "off."))); // TODO load from config and minimessage } }.runTaskAsynchronously(ChatPlugin.getInstance()); return false; diff --git a/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java b/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java index a7251bf..0383e74 100755 --- a/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java +++ b/galaxy/src/main/java/com/alttd/chat/handler/ChatHandler.java @@ -72,7 +72,7 @@ public class ChatHandler { sendPrivateMessage(player, target, "privatemessage", component); Component spymessage = miniMessage.parse(Config.MESSAGESPY, templates); for(Player pl : Bukkit.getOnlinePlayers()) { - if(pl.hasPermission(Config.SPYPERMISSION) && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) { // todo add a toggle for social spy + if(pl.hasPermission(Config.SPYPERMISSION) && ChatUserManager.getChatUser(pl.getUniqueId()).isSpy() && !pl.equals(player) && !pl.getName().equalsIgnoreCase(target)) { // todo add a toggle for social spy pl.sendMessage(spymessage); } } 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 c3e3f3a..4d53460 100755 --- a/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java +++ b/galaxy/src/main/java/com/alttd/chat/listeners/PluginMessage.java @@ -39,10 +39,13 @@ public class PluginMessage implements PluginMessageListener { String target = in.readUTF(); Player p = Bukkit.getPlayer(uuid); if (p != null) { - p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF())); - p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config - ChatUser user = ChatUserManager.getChatUser(uuid); - user.setReplyTarget(target); + ChatUser chatUser = ChatUserManager.getChatUser(uuid); + if (!chatUser.getIgnoredPlayers().contains(uuid)) { + p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF())); + p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config + ChatUser user = ChatUserManager.getChatUser(uuid); + user.setReplyTarget(target); + } } break; } @@ -51,9 +54,12 @@ public class PluginMessage implements PluginMessageListener { String target = in.readUTF(); Player p = Bukkit.getPlayer(uuid); if (p != null) { - p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF())); - ChatUser user = ChatUserManager.getChatUser(uuid); - user.setReplyTarget(target); + ChatUser chatUser = ChatUserManager.getChatUser(uuid); + if (!chatUser.getIgnoredPlayers().contains(uuid)) { + p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF())); + ChatUser user = ChatUserManager.getChatUser(uuid); + user.setReplyTarget(target); + } } break; } diff --git a/galaxy/src/main/resources/plugin.yml b/galaxy/src/main/resources/plugin.yml index 46d2050..f85306e 100755 --- a/galaxy/src/main/resources/plugin.yml +++ b/galaxy/src/main/resources/plugin.yml @@ -15,7 +15,7 @@ commands: aliases: togglegc message: permission: command.message - aliases: msg + aliases: [msg, tell] reply: permission: command.message aliases: r