mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Allow staff to spy on whispers/messages
This commit is contained in:
1 parent
61a054bc58
commit
91b8548631
5 files changed
+53
-5
No files matched your search
@@ -40,4 +40,21 @@ public class SpyChannelCommand extends BaseCommand {
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("whispers")
|
||||
public void whispersCommand(Player player) {
|
||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||
|
||||
String message;
|
||||
|
||||
if (user.isSpyingWhispers()) {
|
||||
user.setSpyingWhispers(false);
|
||||
message = simpleChat.getConfig().getString("language.spy-whispers-off");
|
||||
} else {
|
||||
user.setSpyingWhispers(true);
|
||||
message = simpleChat.getConfig().getString("language.spy-whispers-on");
|
||||
}
|
||||
|
||||
user.sendMessage(MiniMessage.get().parse(message, "br", "\n"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,9 @@ public interface ChatUser extends Audience {
|
||||
|
||||
UserChannelSettings getChannelSettings(ChatChannel channel);
|
||||
|
||||
void setSpyingWhispers(boolean spyingWhispers);
|
||||
boolean isSpyingWhispers();
|
||||
|
||||
void setMuted(boolean muted);
|
||||
boolean isMuted();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MySQLUserService extends UserService {
|
||||
|
||||
try {
|
||||
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
|
||||
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN)");
|
||||
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
|
||||
|
||||
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_channel_settings (uuid CHAR(36), channel CHAR(16), spying BOOLEAN, ignored BOOLEAN, color TINYTEXT, PRIMARY KEY (uuid, channel))");
|
||||
|
||||
@@ -116,6 +116,7 @@ public class MySQLUserService extends UserService {
|
||||
user.setSelectedChannel(simpleChat.getChannel(users.getString("channel")));
|
||||
user.setMuted(users.<Boolean>get("muted"));
|
||||
user.setShadowMuted(users.<Boolean>get("shadowmuted"));
|
||||
user.setSpyingWhispers(users.<Boolean>get("spyingwhispers"));
|
||||
|
||||
for (DbRow channelSetting : channelSettings) {
|
||||
ChatChannel chatChannel = simpleChat.getChannel(channelSetting.getString("channel"));
|
||||
@@ -157,10 +158,10 @@ public class MySQLUserService extends UserService {
|
||||
}
|
||||
|
||||
simpleChat.getLogger().info("Saving user data!");
|
||||
stm.executeUpdateQuery("INSERT INTO sc_users (uuid, channel, muted, shadowmuted) VALUES (?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE channel = ?, muted = ?, shadowmuted = ?",
|
||||
user.getUUID().toString(), selectedName, user.isMuted(), user.isShadowMuted(),
|
||||
selectedName, user.isMuted(), user.isShadowMuted());
|
||||
stm.executeUpdateQuery("INSERT INTO sc_users (uuid, channel, muted, shadowmuted, spyingwhispers) VALUES (?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE channel = ?, muted = ?, shadowmuted = ?, spyingwhispers = ?",
|
||||
user.getUUID().toString(), selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers(),
|
||||
selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers());
|
||||
|
||||
simpleChat.getLogger().info("Saving user channel settings!");
|
||||
// Save user channel settings
|
||||
|
||||
@@ -29,6 +29,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
||||
private List<UUID> ignoredUsers = new ArrayList<>();
|
||||
private boolean muted = false;
|
||||
private boolean shadowMuted = false;
|
||||
private boolean spyingWhispers = false;
|
||||
|
||||
private transient UUID replyTarget = null;
|
||||
|
||||
@@ -163,6 +164,16 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
||||
return channelSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpyingWhispers(boolean spyingWhispers) {
|
||||
this.spyingWhispers = spyingWhispers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpyingWhispers() {
|
||||
return spyingWhispers;
|
||||
}
|
||||
|
||||
public void sendMessage(ChatUser sender, String message) {
|
||||
if (isIgnoringUser(sender) || sender.isIgnoringUser(this)) {
|
||||
return;
|
||||
@@ -220,6 +231,19 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
||||
} else if (sender.isOnline()) {
|
||||
simpleChat.getPluginMessageManager().sendComponentToPlayer(sender, this, toPlayerComponent, fromPlayerComponent);
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||
|
||||
if (user.getUUID().equals(sender.getUUID()) || user.getUUID().equals(getUUID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.sendMessage(MiniMessage.get().parse(simpleChat.getConfig().getString("language.spy-whispers"), "br", "\n",
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName));
|
||||
}
|
||||
}
|
||||
|
||||
private void syncToRedis() {
|
||||
|
||||
Reference in new issue
Block a user