mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 06:28:49 +00:00
Fix global player list propagation
This commit is contained in:
8 files changed
+51
-25
No files matched your search
@@ -6,7 +6,6 @@ import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -30,8 +29,8 @@ public abstract class Broker {
|
||||
* @param receiver The user who received the message, if a receiver exists
|
||||
* @param message The message
|
||||
*/
|
||||
protected void handle(@Nullable OnlineUser receiver, @NotNull Message message) {
|
||||
if (message.getSourceServer().equals(getServer()) || receiver == null) {
|
||||
protected void handle(@NotNull OnlineUser receiver, @NotNull Message message) {
|
||||
if (message.getSourceServer().equals(getServer())) {
|
||||
return;
|
||||
}
|
||||
switch (message.getType()) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.network;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,6 +31,7 @@ public class Message {
|
||||
@Expose
|
||||
private String sender;
|
||||
@Expose
|
||||
@SerializedName("source_server")
|
||||
private String sourceServer;
|
||||
|
||||
private Message(@NotNull Type type, @NotNull Scope scope, @NotNull String target, @NotNull Payload payload) {
|
||||
@@ -127,6 +129,12 @@ public class Message {
|
||||
|
||||
@NotNull
|
||||
public Message build() {
|
||||
if (type == null) {
|
||||
throw new IllegalStateException("Message type must be set");
|
||||
}
|
||||
if (target == null) {
|
||||
throw new IllegalStateException("Message target must be set");
|
||||
}
|
||||
return new Message(type, scope, target, payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ public class RedisBroker extends PluginMessageBroker {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.getTarget().equals(plugin.getServerName())) {
|
||||
if (message.getTarget().equals(plugin.getServerName())
|
||||
|| message.getTarget().equals(Message.TARGET_ALL)) {
|
||||
plugin.getOnlineUsers().stream()
|
||||
.findAny()
|
||||
.ifPresent(receiver -> handle(receiver, message));
|
||||
|
||||
Reference in new issue
Block a user