diff --git a/src/main/java/io/singularitynet/Client/VereyaModClient.java b/src/main/java/io/singularitynet/Client/VereyaModClient.java index 2bd6955..720fa25 100644 --- a/src/main/java/io/singularitynet/Client/VereyaModClient.java +++ b/src/main/java/io/singularitynet/Client/VereyaModClient.java @@ -1,5 +1,6 @@ package io.singularitynet.Client; +import io.singularitynet.MessagePayloadC2S; import io.singularitynet.MessagePayloadS2C; import io.singularitynet.MissionHandlers.MissionBehaviour; import io.singularitynet.SidesMessageHandler; diff --git a/src/main/java/io/singularitynet/MessagePayloadS2C.java b/src/main/java/io/singularitynet/MessagePayloadS2C.java index 5731d97..931551d 100644 --- a/src/main/java/io/singularitynet/MessagePayloadS2C.java +++ b/src/main/java/io/singularitynet/MessagePayloadS2C.java @@ -19,11 +19,11 @@ public void encode(PacketByteBuf buf, VereyaMessage message) { } }; - public static final Id ID = new Id<>(NetworkConstants.SERVER2CLIENT); + public static final CustomPayload.Id ID = new CustomPayload.Id<>(NetworkConstants.SERVER2CLIENT); public static final PacketCodec CODEC = PacketCodec.tuple(PACKET_CODEC, MessagePayloadC2S::msg, MessagePayloadC2S::new); @Override - public Id getId() { + public CustomPayload.Id getId() { return ID; } } diff --git a/src/main/java/io/singularitynet/Server/VereyaModServer.java b/src/main/java/io/singularitynet/Server/VereyaModServer.java index 811c2a0..43358cd 100644 --- a/src/main/java/io/singularitynet/Server/VereyaModServer.java +++ b/src/main/java/io/singularitynet/Server/VereyaModServer.java @@ -32,6 +32,7 @@ import net.minecraft.server.MinecraftServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.jmx.Server; import java.util.HashMap; import java.util.Map; @@ -59,8 +60,8 @@ public void onInitialize() { instance = this; PayloadTypeRegistry.playC2S().register(MessagePayloadC2S.ID, MessagePayloadC2S.CODEC); // register the instance for messages from Client to the Server - ServerPlayNetworking.registerGlobalReceiver(MessagePayloadS2C.ID, (payload, context) -> { - SidesMessageHandler.onMessage(payload, context); + ServerPlayNetworking.registerGlobalReceiver(MessagePayloadC2S.ID, (payload, context) -> { + SidesMessageHandler.client2server.onMessage(payload, context); }); ServerLifecycleEvents.SERVER_STARTED.register((MinecraftServer server) -> { Logger LOGGER = LogManager.getLogger(); diff --git a/src/main/java/io/singularitynet/SidesMessageHandler.java b/src/main/java/io/singularitynet/SidesMessageHandler.java index e536764..1bbc8d6 100644 --- a/src/main/java/io/singularitynet/SidesMessageHandler.java +++ b/src/main/java/io/singularitynet/SidesMessageHandler.java @@ -69,19 +69,19 @@ public static void onMessage(MessagePayloadC2S payload, ServerPlayNetworking.Con final VereyaMessage message = payload.msg(); final List interestedParties = getMessageListeners(message); if (interestedParties == null) return; - context.player().server.execute(() -> { + context.server().execute(() -> { for (IVereyaMessageListener l : interestedParties) { // If the message's uid is set (ie non-zero), then use it to ensure that only the matching listener receives this message. // Otherwise, let all listeners who are interested get a look. // if (message.uid == 0 || System.identityHashCode(l) == message.uid) // l.onMessage(message.messageType, message.data); - l.onMessage(message.getMessageType(), message.getData()); + l.onMessage(message.getMessageType(), message.getData(), context.player()); } }); } - public void onMessage(MessagePayloadC2S payload, ClientPlayNetworking.Context context) { + public void onMessage(MessagePayloadS2C payload, ClientPlayNetworking.Context context) { final VereyaMessage message = payload.msg(); final List interestedParties = getMessageListeners(message); if (interestedParties == null) return;