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

@@ -79,7 +79,9 @@ public class CommanderChatProcessor extends SimpleChatProcessor {
String[] args = message.substring(idx).split(" ");
commands.get(command).execute(player, args);
} else {
player.getChannel().sendChatMessage(UNKNOW_COMMAND_MSG.apply("command", command));
player.getChannel().sendChatMessage(
UNKNOW_COMMAND_MSG.apply("command", command),
MessageType.SYSTEM_MESSAGE);
}
} else {
super.process(player, message);

View File

@@ -0,0 +1,18 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2018-06-24
*/
package mc.core.chat;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Getter
public enum MessageType {
CHAT_MESSAGE(0), // chat box
SYSTEM_MESSAGE(1), // chat box
GAME_INFO(2); // above hotbar
private final int id;
}

View File

@@ -5,6 +5,7 @@
package mc.core.network;
import lombok.RequiredArgsConstructor;
import mc.core.chat.MessageType;
import mc.core.player.Player;
import mc.core.text.Text;
@@ -25,8 +26,8 @@ public class BroadcastNetChannel implements NetChannel {
}
@Override
public void sendChatMessage(final Text text) {
playerStream.forEach(player -> player.getChannel().sendChatMessage(text));
public void sendChatMessage(final Text text, final MessageType type) {
playerStream.forEach(player -> player.getChannel().sendChatMessage(text, type));
}
@Override

View File

@@ -4,12 +4,16 @@
*/
package mc.core.network;
import mc.core.chat.MessageType;
import mc.core.text.Text;
public interface NetChannel {
void sendKeepAlive();
void sendTimeUpdate(long time, long age);
void sendChatMessage(Text text);
default void sendChatMessage(Text text) {
sendChatMessage(text, MessageType.CHAT_MESSAGE);
}
void sendChatMessage(Text text, MessageType type);
void writeAndFlush(SCPacket pkt);
void write(SCPacket pkt);