mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 23:42:35 -04:00
packet: send chat message
This commit is contained in:
parent
338eb8ff4a
commit
2b8ae91a22
@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
|||||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.handshaking.PacketHandshake;
|
import de.bixilon.minosoft.protocol.packets.serverbound.handshaking.PacketHandshake;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketLoginStart;
|
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketLoginStart;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketChatMessage;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusPing;
|
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusPing;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusRequest;
|
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusRequest;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ConnectionState;
|
import de.bixilon.minosoft.protocol.protocol.ConnectionState;
|
||||||
@ -153,4 +154,8 @@ public class Connection {
|
|||||||
public void setPlayer(Player player) {
|
public void setPlayer(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendChatMessage(String message) {
|
||||||
|
sendPacket(new PacketChatMessage(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
|
public class PacketChatMessage implements ServerboundPacket {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
public PacketChatMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutPacketBuffer write(ProtocolVersion v) {
|
||||||
|
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CHAT_MESSAGE));
|
||||||
|
switch (v) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
buffer.writeString(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Sending Chat message: %s", message));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user