forked from chipmunkmc/chipmunkbot
Minor fix to netmsg
This commit is contained in:
parent
888f16782e
commit
ec0d1c8a93
1 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue