mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
fabric: Fix channel identifier not being set correctly, Close #366
This commit is contained in:
2 files changed
+14
-5
No files matched your search
@@ -430,12 +430,12 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
||||
ServerPlayNetworking.registerGlobalReceiver(new Identifier("bungeecord", "main"), this);
|
||||
}
|
||||
|
||||
// When a plugin message is received by the server
|
||||
// When the server receives a plugin message
|
||||
@Override
|
||||
public void receive(@NotNull MinecraftServer server, @NotNull ServerPlayerEntity player,
|
||||
@NotNull ServerPlayNetworkHandler handler, @NotNull PacketByteBuf buf, @NotNull PacketSender responseSender) {
|
||||
if (broker != null && broker instanceof PluginMessageBroker pluginMessenger
|
||||
&& getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) {
|
||||
@NotNull ServerPlayNetworkHandler handler, @NotNull PacketByteBuf buf,
|
||||
@NotNull PacketSender responseSender) {
|
||||
if (broker != null && broker instanceof PluginMessageBroker pluginMessenger && getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) {
|
||||
pluginMessenger.onReceive(PluginMessageBroker.BUNGEE_CHANNEL_ID, FabricUser.adapt(this, player), buf.readByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class FabricUser extends OnlineUser {
|
||||
public void sendPluginMessage(@NotNull String channel, byte[] message) {
|
||||
final PacketByteBuf buf = PacketByteBufs.create();
|
||||
buf.writeBytes(message);
|
||||
final CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(Identifier.tryParse(channel), buf);
|
||||
final CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(parseIdentifier(channel), buf);
|
||||
player.networkHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -152,4 +152,13 @@ public class FabricUser extends OnlineUser {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Identifier parseIdentifier(@NotNull String channel) {
|
||||
if (channel.equals("BungeeCord")) {
|
||||
return new Identifier("bungeecord", "main");
|
||||
}
|
||||
return Optional.ofNullable(Identifier.tryParse(channel))
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid channel name: " + channel));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user