diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java index ee561cf..d004a41 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java @@ -8,6 +8,10 @@ import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument; import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; import static com.mojang.brigadier.arguments.StringArgumentType.getString; import com.mojang.brigadier.context.CommandContext; +import com.github.steveice10.packetlib.Session; +import com.github.steveice10.packetlib.packet.PacketProtocol; +import com.github.steveice10.mc.protocol.MinecraftProtocol; +import com.github.steveice10.mc.protocol.data.ProtocolState; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -38,6 +42,11 @@ public class NetMsgCommand extends Command { for (Client remote : source.client().allClients()) { if (!(remote instanceof ChipmunkBot)) continue; // ? Is this optimal? + + final Session session = remote.session(); + final PacketProtocol protocol = session.getPacketProtocol(); + if (!session.isConnected() || (protocol instanceof MinecraftProtocol && ((MinecraftProtocol) protocol).getState() != ProtocolState.GAME)) continue; + ((ChipmunkBot) remote).chat().tellraw(message); }