mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
print server brand, function in Protocol::getName
This commit is contained in:
parent
1702c8ac14
commit
d98c6f511e
@ -31,4 +31,12 @@ public class PacketPluginMessageReceived implements ClientboundPacket {
|
|||||||
public void handle(PacketHandler h) {
|
public void handle(PacketHandler h) {
|
||||||
h.handle(this);
|
h.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusPong;
|
|||||||
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusResponse;
|
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusResponse;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketEncryptionResponse;
|
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketEncryptionResponse;
|
||||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketKeepAliveResponse;
|
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketKeepAliveResponse;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketPluginMessageSended;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -78,6 +79,14 @@ public class PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketPluginMessageReceived pkg) {
|
public void handle(PacketPluginMessageReceived pkg) {
|
||||||
|
if (pkg.getChannel().equals("MC|Brand")) {
|
||||||
|
// server brand received
|
||||||
|
Log.info(String.format("Server is running %s on version %s", new String(pkg.getData()), connection.getVersion().getName()));
|
||||||
|
|
||||||
|
// send back own brand
|
||||||
|
// ToDo option to toggle for minosoft or original minecraft
|
||||||
|
connection.sendPacket(new PacketPluginMessageSended("MC|Brand", "Minosoft".getBytes()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketSpawnLocation pkg) {
|
public void handle(PacketSpawnLocation pkg) {
|
||||||
|
@ -17,6 +17,8 @@ public interface Protocol {
|
|||||||
|
|
||||||
int getPacketCommand(Packets.Serverbound p);
|
int getPacketCommand(Packets.Serverbound p);
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
Packets.Clientbound getPacketByCommand(ConnectionState s, int command);
|
Packets.Clientbound getPacketByCommand(ConnectionState s, int command);
|
||||||
|
|
||||||
static Class<? extends ClientboundPacket> getPacketByPacket(Packets.Clientbound p) {
|
static Class<? extends ClientboundPacket> getPacketByPacket(Packets.Clientbound p) {
|
||||||
|
@ -3,8 +3,8 @@ package de.bixilon.minosoft.protocol.protocol;
|
|||||||
public enum ProtocolVersion {
|
public enum ProtocolVersion {
|
||||||
VERSION_1_7_10(new Protocol_1_7_10());
|
VERSION_1_7_10(new Protocol_1_7_10());
|
||||||
|
|
||||||
private int version;
|
private final int version;
|
||||||
private Protocol protocol;
|
private final Protocol protocol;
|
||||||
|
|
||||||
ProtocolVersion(Protocol protocol) {
|
ProtocolVersion(Protocol protocol) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
@ -23,4 +23,8 @@ public enum ProtocolVersion {
|
|||||||
return protocol.getPacketCommand(p);
|
return protocol.getPacketCommand(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return protocol.getName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,11 @@ public class Protocol_1_7_10 implements Protocol {
|
|||||||
return serverboundPacketMapping.get(p);
|
return serverboundPacketMapping.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "1.7.10";
|
||||||
|
}
|
||||||
|
|
||||||
public Packets.Clientbound getPacketByCommand(ConnectionState s, int command) {
|
public Packets.Clientbound getPacketByCommand(ConnectionState s, int command) {
|
||||||
for (Map.Entry<Packets.Clientbound, Integer> set : clientboundPacketMapping.entrySet()) {
|
for (Map.Entry<Packets.Clientbound, Integer> set : clientboundPacketMapping.entrySet()) {
|
||||||
if (set.getValue() == command && set.getKey().name().startsWith(s.name())) {
|
if (set.getValue() == command && set.getKey().name().startsWith(s.name())) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user