mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
send hello from minosoft chat message, refactor protocol (release name, etc)
This commit is contained in:
parent
7bb3353ad1
commit
f47b88d319
@ -98,7 +98,7 @@ public class Connection {
|
|||||||
network.startPacketThread();
|
network.startPacketThread();
|
||||||
startHandlingThread();
|
startHandlingThread();
|
||||||
ConnectionState next = ((reason == ConnectionReason.CONNECT) ? ConnectionState.LOGIN : ConnectionState.STATUS);
|
ConnectionState next = ((reason == ConnectionReason.CONNECT) ? ConnectionState.LOGIN : ConnectionState.STATUS);
|
||||||
network.sendPacket(new PacketHandshake(getHost(), getPort(), next, (next == ConnectionState.STATUS) ? -1 : getVersion().getVersion()));
|
network.sendPacket(new PacketHandshake(getHost(), getPort(), next, (next == ConnectionState.STATUS) ? -1 : getVersion().getVersionNumber()));
|
||||||
// after sending it, switch to next state
|
// after sending it, switch to next state
|
||||||
setConnectionState(next);
|
setConnectionState(next);
|
||||||
break;
|
break;
|
||||||
@ -209,7 +209,7 @@ public class Connection {
|
|||||||
serverVersion = buffer.readString();
|
serverVersion = buffer.readString();
|
||||||
toSend.writeString(clientVersion);
|
toSend.writeString(clientVersion);
|
||||||
}
|
}
|
||||||
Log.info(String.format("Server is running \"%s\", connected with %s", serverVersion, getVersion().getName()));
|
Log.info(String.format("Server is running \"%s\", connected with %s", serverVersion, getVersion().getVersionString()));
|
||||||
|
|
||||||
getPluginChannelHandler().sendRawData(DefaultPluginChannels.MC_BRAND.getIdentifier().get(version), toSend);
|
getPluginChannelHandler().sendRawData(DefaultPluginChannels.MC_BRAND.getIdentifier().get(version), toSend);
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@ public class PacketBlockAction implements ClientboundPacket {
|
|||||||
case VERSION_1_9_4:
|
case VERSION_1_9_4:
|
||||||
case VERSION_1_10:
|
case VERSION_1_10:
|
||||||
// that's the only difference here
|
// that's the only difference here
|
||||||
if (buffer.getVersion().getVersion() >= ProtocolVersion.VERSION_1_8.getVersion()) {
|
if (buffer.getVersion().getVersionNumber() >= ProtocolVersion.VERSION_1_8.getVersionNumber()) {
|
||||||
position = buffer.readPosition();
|
position = buffer.readPosition();
|
||||||
} else {
|
} else {
|
||||||
position = buffer.readBlockPositionShort();
|
position = buffer.readBlockPositionShort();
|
||||||
|
@ -77,7 +77,7 @@ public class PacketMapData implements ClientboundPacket {
|
|||||||
case VERSION_1_10: {
|
case VERSION_1_10: {
|
||||||
mapId = buffer.readVarInt();
|
mapId = buffer.readVarInt();
|
||||||
scale = buffer.readByte();
|
scale = buffer.readByte();
|
||||||
if (buffer.getVersion().getVersion() >= ProtocolVersion.VERSION_1_9_4.getVersion()) {
|
if (buffer.getVersion().getVersionNumber() >= ProtocolVersion.VERSION_1_9_4.getVersionNumber()) {
|
||||||
boolean trackPosition = buffer.readBoolean();
|
boolean trackPosition = buffer.readBoolean();
|
||||||
}
|
}
|
||||||
int pinCount = buffer.readVarInt();
|
int pinCount = buffer.readVarInt();
|
||||||
|
@ -67,7 +67,7 @@ public class PacketSpawnObject implements ClientboundPacket {
|
|||||||
int data = buffer.readInt();
|
int data = buffer.readInt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (buffer.getVersion().getVersion() >= ProtocolVersion.VERSION_1_8.getVersion()) {
|
if (buffer.getVersion().getVersionNumber() >= ProtocolVersion.VERSION_1_8.getVersionNumber()) {
|
||||||
// velocity present AND metadata
|
// velocity present AND metadata
|
||||||
|
|
||||||
Velocity velocity = null;
|
Velocity velocity = null;
|
||||||
|
@ -44,7 +44,7 @@ public class PacketHandshake implements ServerboundPacket {
|
|||||||
public OutPacketBuffer write(ProtocolVersion version) {
|
public OutPacketBuffer write(ProtocolVersion version) {
|
||||||
// no version checking, is the same in all versions (1.7.x - 1.15.2)
|
// no version checking, is the same in all versions (1.7.x - 1.15.2)
|
||||||
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.HANDSHAKING_HANDSHAKE));
|
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.HANDSHAKING_HANDSHAKE));
|
||||||
buffer.writeVarInt((nextState == ConnectionState.STATUS ? -1 : version.getVersion())); // get best protocol version
|
buffer.writeVarInt((nextState == ConnectionState.STATUS ? -1 : version.getVersionNumber())); // get best protocol version
|
||||||
buffer.writeString(address);
|
buffer.writeString(address);
|
||||||
buffer.writeShort((short) port);
|
buffer.writeShort((short) port);
|
||||||
buffer.writeVarInt(nextState.getId());
|
buffer.writeVarInt(nextState.getId());
|
||||||
|
@ -175,7 +175,7 @@ public class InByteBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockPosition readPosition() {
|
public BlockPosition readPosition() {
|
||||||
if (version.getVersion() >= ProtocolVersion.VERSION_1_14_4.getVersion()) {
|
if (version.getVersionNumber() >= ProtocolVersion.VERSION_1_14_4.getVersionNumber()) {
|
||||||
// changed in 1.14, thanks for the explanation @Sainan
|
// changed in 1.14, thanks for the explanation @Sainan
|
||||||
Long raw = readLong();
|
Long raw = readLong();
|
||||||
int x = (int) (raw >> 38);
|
int x = (int) (raw >> 38);
|
||||||
|
@ -153,7 +153,7 @@ public class OutByteBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writePosition(BlockPosition location) {
|
public void writePosition(BlockPosition location) {
|
||||||
if (version.getVersion() >= ProtocolVersion.VERSION_1_14_4.getVersion()) {
|
if (version.getVersionNumber() >= ProtocolVersion.VERSION_1_14_4.getVersionNumber()) {
|
||||||
writeLong((((long) (location.getX() & 0x3FFFFFF) << 38) | ((long) (location.getZ() & 0x3FFFFFF) << 12) | (long) (location.getY() & 0xFFF)));
|
writeLong((((long) (location.getX() & 0x3FFFFFF) << 38) | ((long) (location.getZ() & 0x3FFFFFF) << 12) | (long) (location.getY() & 0xFFF)));
|
||||||
} else {
|
} else {
|
||||||
writeLong((((long) location.getX() & 0x3FFFFFF) << 38) | (((long) location.getZ() & 0x3FFFFFF)) | ((long) location.getY() & 0xFFF) << 26);
|
writeLong((((long) location.getX() & 0x3FFFFFF) << 38) | (((long) location.getZ() & 0x3FFFFFF)) | ((long) location.getY() & 0xFFF) << 26);
|
||||||
|
@ -67,7 +67,7 @@ public class PacketHandler {
|
|||||||
case GET_VERSION:
|
case GET_VERSION:
|
||||||
// reconnect...
|
// reconnect...
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
Log.info(String.format("Server is running on version %s, reconnecting...", connection.getVersion().getName()));
|
Log.info(String.format("Server is running on version %s, reconnecting...", connection.getVersion().getVersionString()));
|
||||||
break;
|
break;
|
||||||
case CONNECT:
|
case CONNECT:
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -95,6 +95,7 @@ public class PacketHandler {
|
|||||||
connection.getPlayer().setPlayer(new OtherPlayer(pkg.getEntityId(), connection.getPlayer().getPlayerName(), connection.getPlayer().getPlayerUUID(), null, null, null, (short) 0, (short) 0, (short) 0, null));
|
connection.getPlayer().setPlayer(new OtherPlayer(pkg.getEntityId(), connection.getPlayer().getPlayerName(), connection.getPlayer().getPlayerUUID(), null, null, null, (short) 0, (short) 0, (short) 0, null));
|
||||||
connection.getPlayer().getWorld().setHardcore(pkg.isHardcore());
|
connection.getPlayer().getWorld().setHardcore(pkg.isHardcore());
|
||||||
connection.getPlayer().getWorld().setDimension(pkg.getDimension());
|
connection.getPlayer().getWorld().setDimension(pkg.getDimension());
|
||||||
|
connection.getSender().sendChatMessage("I am alive! ~ Minosoft");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketLoginDisconnect pkg) {
|
public void handle(PacketLoginDisconnect pkg) {
|
||||||
|
@ -164,6 +164,6 @@ public abstract class Protocol implements ProtocolInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getProtocolVersion();
|
return getProtocolVersionNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,9 @@
|
|||||||
package de.bixilon.minosoft.protocol.protocol;
|
package de.bixilon.minosoft.protocol.protocol;
|
||||||
|
|
||||||
public interface ProtocolInterface {
|
public interface ProtocolInterface {
|
||||||
String getName();
|
String getVersionString();
|
||||||
|
|
||||||
int getProtocolVersion();
|
int getProtocolVersionNumber();
|
||||||
|
|
||||||
|
String getReleaseName(); // Minecraft + getReleaseName() + Update
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public enum ProtocolVersion {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
for (ProtocolVersion v : values()) {
|
for (ProtocolVersion v : values()) {
|
||||||
versionMapping.put(v.getVersion(), v);
|
versionMapping.put(v.getVersionNumber(), v);
|
||||||
}
|
}
|
||||||
versionMappingArray = new ProtocolVersion[values().length];
|
versionMappingArray = new ProtocolVersion[values().length];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -43,25 +43,23 @@ public enum ProtocolVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final int version;
|
|
||||||
final Protocol protocol;
|
final Protocol protocol;
|
||||||
|
|
||||||
ProtocolVersion(Protocol protocol) {
|
ProtocolVersion(Protocol protocol) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
this.version = protocol.getProtocolVersion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolVersion byId(int protocolNumber) {
|
public static ProtocolVersion byId(int protocolNumber) {
|
||||||
for (ProtocolVersion v : values()) {
|
for (ProtocolVersion v : values()) {
|
||||||
if (v.getVersion() == protocolNumber) {
|
if (v.getVersionNumber() == protocolNumber) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersion() {
|
public int getVersionNumber() {
|
||||||
return version;
|
return protocol.getProtocolVersionNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Protocol getProtocol() {
|
public Protocol getProtocol() {
|
||||||
@ -72,8 +70,12 @@ public enum ProtocolVersion {
|
|||||||
return protocol.getPacketCommand(p);
|
return protocol.getPacketCommand(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return protocol.getName();
|
return protocol.getVersionString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReleaseName() {
|
||||||
|
return protocol.getReleaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,13 +130,17 @@ public class Protocol_1_10 extends Protocol {
|
|||||||
serverboundPacketMapping.put(Packets.Serverbound.PLAY_USE_ITEM, 0x1D);
|
serverboundPacketMapping.put(Packets.Serverbound.PLAY_USE_ITEM, 0x1D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 210;
|
return 210;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.10.x";
|
return "1.10.x";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Frostburn";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,17 @@ public class Protocol_1_11_2 extends Protocol {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 316;
|
return 316;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.11.2";
|
return "1.11.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Exploration";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,18 @@ public class Protocol_1_12_2 extends Protocol {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 340;
|
return 340;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.12.2";
|
return "1.12.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "World of Color";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,17 @@ public class Protocol_1_13_2 extends Protocol {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.13.2";
|
return "1.13.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Aquatic";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,17 @@ public class Protocol_1_14_4 extends Protocol {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 498;
|
return 498;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.14.4";
|
return "1.14.4";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Village and Pillage";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,17 @@ public class Protocol_1_15_2 extends Protocol {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 578;
|
return 578;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.15.2";
|
return "1.15.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Buzzy Bees";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,12 +113,18 @@ public class Protocol_1_7_10 extends Protocol {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.7.10";
|
return "1.7.10";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Realms";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,17 @@ public class Protocol_1_8 extends Protocol {
|
|||||||
clientboundPacketMapping.put(Packets.Clientbound.PLAY_NBT_QUERY_RESPONSE, 0x49);
|
clientboundPacketMapping.put(Packets.Clientbound.PLAY_NBT_QUERY_RESPONSE, 0x49);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 47;
|
return 47;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.8.x";
|
return "1.8.x";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Bountiful";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,13 +136,17 @@ public class Protocol_1_9_4 extends Protocol {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersionNumber() {
|
||||||
return 110;
|
return 110;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getVersionString() {
|
||||||
return "1.9.4";
|
return "1.9.4";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReleaseName() {
|
||||||
|
return "Combat";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user