Archived
0

Chat message

This commit is contained in:
2018-06-24 14:25:34 +03:00
parent 31fed3a823
commit cb45d2c8a1
9 changed files with 84 additions and 8 deletions

View File

@@ -5,17 +5,23 @@
package mc.core.network.proto_1_12_2.netty.handlers;
import io.netty.channel.Channel;
import mc.core.chat.ChatProcessor;
import mc.core.network.proto_1_12_2.TeleportManager;
import mc.core.network.proto_1_12_2.packets.ChatMessageClientPacket;
import mc.core.network.proto_1_12_2.packets.ClientSettingsPacket;
import mc.core.network.proto_1_12_2.packets.PlayerPositionAndLookPacket;
import mc.core.network.proto_1_12_2.packets.TeleportConfirmPacket;
import mc.core.player.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static mc.core.network.proto_1_12_2.netty.NettyServer.ATTR_PLAYER;
@Component
public class PlayHandler extends AbstractStateHandler implements PlayStateHandler {
@Autowired
private ChatProcessor chatProcessor;
private TeleportManager teleport = TeleportManager.getInstance();
@Handler
@@ -49,4 +55,12 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
player.getLocation().set(packet.getLocation());
player.getLook().set(packet.getLook());
}
@Handler
public void onChat(Channel channel, ChatMessageClientPacket packet) {
chatProcessor.process(
channel.attr(ATTR_PLAYER).get(),
packet.getMessage()
);
}
}

View File

@@ -6,8 +6,10 @@ package mc.core.network.proto_1_12_2.netty.wrappers;
import io.netty.channel.Channel;
import lombok.RequiredArgsConstructor;
import mc.core.chat.MessageType;
import mc.core.network.NetChannel;
import mc.core.network.SCPacket;
import mc.core.network.proto_1_12_2.packets.ChatMessageServerPacket;
import mc.core.network.proto_1_12_2.packets.KeepAlivePacket;
import mc.core.network.proto_1_12_2.packets.TimeUpdatePacket;
import mc.core.text.Text;
@@ -30,8 +32,8 @@ public class WrapperNetChannel implements NetChannel {
}
@Override
public void sendChatMessage(Text text) {
public void sendChatMessage(Text text, MessageType type) {
writeAndFlush(new ChatMessageServerPacket(text, type));
}
@Override