mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Cross server whispering bug fixes
This commit is contained in:
1 parent
16d98d35cc
commit
2fb43df8ad
4 files changed
+34
-18
No files matched your search
@@ -22,6 +22,10 @@ public class MessageCommand extends BaseCommand {
|
||||
@Default
|
||||
@CommandCompletion("@players")
|
||||
public void baseCommand(Player player, ChatUser targetUser, String... args) {
|
||||
if (args.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatUser sender = simpleChat.getUserService().wrap(player);
|
||||
targetUser.sendMessage(sender, String.join(" ", args));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ public class ReplyCommand extends BaseCommand {
|
||||
|
||||
@Default
|
||||
public void baseCommand(Player player, String... args) {
|
||||
if (args.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||
ChatUser targetUser = simpleChat.getUserService().wrap(user.getReplyTarget());
|
||||
|
||||
|
||||
@@ -144,16 +144,22 @@ public class PluginMessageManager implements PluginMessageListener {
|
||||
api.forward("ALL", "simplechat:component", msg.toByteArray());
|
||||
}
|
||||
|
||||
public void sendComponentToPlayer(Player sender, ChatUser target, Component component) {
|
||||
public void sendComponentToPlayer(ChatUser sender, ChatUser target, Component toComponent, Component fromComponent) {
|
||||
api.getPlayerList("ALL").whenComplete((result, error) -> {
|
||||
if (!result.contains(target.asOfflinePlayer().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(toComponent);
|
||||
|
||||
if (sender.isShadowMuted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayDataOutput msg = ByteStreams.newDataOutput();
|
||||
|
||||
msg.writeUTF(target.getUUID().toString());
|
||||
msg.writeUTF(MiniMessage.get().serialize(component));
|
||||
msg.writeUTF(MiniMessage.get().serialize(fromComponent));
|
||||
|
||||
api.forward("ALL", "simplechat:whisper", msg.toByteArray());
|
||||
});
|
||||
|
||||
@@ -171,28 +171,30 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
||||
Component fromPlayerComponent = MiniMessage.get().parse(fromPlayerFormat, "message", message,
|
||||
"sender", sender.asOfflinePlayer().getName());
|
||||
|
||||
sender.sendMessage(toPlayerComponent);
|
||||
|
||||
if (sender.isShadowMuted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isOnline()) {
|
||||
this.sendMessage(fromPlayerComponent);
|
||||
if (sender.isOnline()) {
|
||||
sender.sendMessage(toPlayerComponent);
|
||||
|
||||
sender.setReplyTarget(this);
|
||||
this.setReplyTarget(sender);
|
||||
if (sender.isShadowMuted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (simpleChat.getConfig().getBoolean("pings.on-whisper")) {
|
||||
Key key = Key.of(simpleChat.getConfig().getString("pings.sound"));
|
||||
Sound.Source source = Sound.Source.valueOf(simpleChat.getConfig().getString("pings.source"));
|
||||
float volume = (float)simpleChat.getConfig().getDouble("pings.volume");
|
||||
float pitch = (float)simpleChat.getConfig().getDouble("pings.pitch");
|
||||
this.sendMessage(fromPlayerComponent);
|
||||
|
||||
this.playSound(Sound.of(key, source, volume, pitch));
|
||||
sender.setReplyTarget(this);
|
||||
this.setReplyTarget(sender);
|
||||
|
||||
if (simpleChat.getConfig().getBoolean("pings.on-whisper")) {
|
||||
Key key = Key.of(simpleChat.getConfig().getString("pings.sound"));
|
||||
Sound.Source source = Sound.Source.valueOf(simpleChat.getConfig().getString("pings.source"));
|
||||
float volume = (float)simpleChat.getConfig().getDouble("pings.volume");
|
||||
float pitch = (float)simpleChat.getConfig().getDouble("pings.pitch");
|
||||
|
||||
this.playSound(Sound.of(key, source, volume, pitch));
|
||||
}
|
||||
}
|
||||
} else if (sender.isOnline()) {
|
||||
simpleChat.getPluginMessageManager().sendComponentToPlayer(sender.asPlayer(), this, fromPlayerComponent);
|
||||
simpleChat.getPluginMessageManager().sendComponentToPlayer(sender, this, toPlayerComponent, fromPlayerComponent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user