geforkt von Mirrors/Velocity
Commit
d62f2622ea
@ -87,7 +87,7 @@ public class ServerConnection implements MinecraftConnectionAssociation {
|
||||
private void startHandshake() {
|
||||
// Initiate a handshake.
|
||||
Handshake handshake = new Handshake();
|
||||
handshake.setNextStatus(2); // login
|
||||
handshake.setNextStatus(StateRegistry.LOGIN_ID);
|
||||
handshake.setProtocolVersion(proxyPlayer.getConnection().getProtocolVersion());
|
||||
if (VelocityServer.getServer().getConfiguration().getIpForwardingMode() == IPForwardingMode.LEGACY) {
|
||||
handshake.setServerAddress(createBungeeForwardingAddress());
|
||||
|
@ -257,13 +257,16 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
if (packet instanceof ScoreboardObjective) {
|
||||
ScoreboardObjective so = (ScoreboardObjective) packet;
|
||||
if (so.getMode() == 0) {
|
||||
Objective o = new Objective(so.getId());
|
||||
o.setDisplayName(so.getDisplayName());
|
||||
o.setType(so.getType());
|
||||
serverScoreboard.getObjectives().put(so.getId(), o);
|
||||
} else {
|
||||
serverScoreboard.getObjectives().remove(so.getId());
|
||||
switch (so.getMode()) {
|
||||
case ScoreboardObjective.ADD:
|
||||
Objective o = new Objective(so.getId());
|
||||
o.setDisplayName(so.getDisplayName());
|
||||
o.setType(so.getType());
|
||||
serverScoreboard.getObjectives().put(so.getId(), o);
|
||||
break;
|
||||
case ScoreboardObjective.REMOVE:
|
||||
serverScoreboard.getObjectives().remove(so.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,11 +277,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
return;
|
||||
}
|
||||
switch (sss.getAction()) {
|
||||
case 0:
|
||||
case ScoreboardSetScore.CHANGE:
|
||||
Score score = new Score(sss.getEntity(), sss.getValue());
|
||||
objective.getScores().put(sss.getEntity(), score);
|
||||
break;
|
||||
case 1:
|
||||
case ScoreboardSetScore.REMOVE:
|
||||
objective.getScores().remove(sss.getEntity());
|
||||
break;
|
||||
}
|
||||
@ -287,12 +290,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (packet instanceof ScoreboardTeam) {
|
||||
ScoreboardTeam st = (ScoreboardTeam) packet;
|
||||
switch (st.getMode()) {
|
||||
case 0:
|
||||
case ScoreboardTeam.ADD:
|
||||
// TODO: Preserve other team information? We might not need to...
|
||||
Team team = new Team(st.getId());
|
||||
serverScoreboard.getTeams().put(st.getId(), team);
|
||||
break;
|
||||
case 1:
|
||||
case ScoreboardTeam.REMOVE:
|
||||
serverScoreboard.getTeams().remove(st.getId());
|
||||
break;
|
||||
}
|
||||
@ -304,21 +307,21 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
for (Score score : objective.getScores().values()) {
|
||||
ScoreboardSetScore sss = new ScoreboardSetScore();
|
||||
sss.setObjective(objective.getId());
|
||||
sss.setAction((byte) 1);
|
||||
sss.setAction(ScoreboardSetScore.REMOVE);
|
||||
sss.setEntity(score.getTarget());
|
||||
player.getConnection().delayedWrite(sss);
|
||||
}
|
||||
|
||||
ScoreboardObjective so = new ScoreboardObjective();
|
||||
so.setId(objective.getId());
|
||||
so.setMode((byte) 1);
|
||||
so.setMode(ScoreboardObjective.REMOVE);
|
||||
player.getConnection().delayedWrite(so);
|
||||
}
|
||||
|
||||
for (Team team : serverScoreboard.getTeams().values()) {
|
||||
ScoreboardTeam st = new ScoreboardTeam();
|
||||
st.setId(team.getId());
|
||||
st.setMode((byte) 1);
|
||||
st.setMode(ScoreboardTeam.REMOVE);
|
||||
player.getConnection().delayedWrite(st);
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,12 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
Handshake handshake = (Handshake) packet;
|
||||
switch (handshake.getNextStatus()) {
|
||||
case 1:
|
||||
// Status protocol
|
||||
case StateRegistry.STATUS_ID:
|
||||
connection.setState(StateRegistry.STATUS);
|
||||
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||
connection.setSessionHandler(new StatusSessionHandler(connection));
|
||||
break;
|
||||
case 2:
|
||||
case StateRegistry.LOGIN_ID:
|
||||
connection.setState(StateRegistry.LOGIN);
|
||||
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
|
||||
|
@ -124,6 +124,8 @@ public enum StateRegistry {
|
||||
}
|
||||
};
|
||||
|
||||
public static final int STATUS_ID = 1;
|
||||
public static final int LOGIN_ID = 2;
|
||||
public final PacketRegistry CLIENTBOUND = new PacketRegistry(ProtocolConstants.Direction.CLIENTBOUND, this);
|
||||
public final PacketRegistry SERVERBOUND = new PacketRegistry(ProtocolConstants.Direction.SERVERBOUND, this);
|
||||
|
||||
|
@ -8,12 +8,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BossBar implements MinecraftPacket {
|
||||
public static final int ADD = 0;
|
||||
public static final int REMOVE = 1;
|
||||
public static final int UPDATE_PERCENT = 2;
|
||||
public static final int UPDATE_NAME = 3;
|
||||
public static final int UPDATE_STYLE = 4;
|
||||
public static final int UPDATE_PROPERTIES = 5;
|
||||
private UUID uuid;
|
||||
private int action;
|
||||
private String title;
|
||||
private float health;
|
||||
private String name;
|
||||
private float percent;
|
||||
private int color;
|
||||
private int divisions;
|
||||
private int overlay;
|
||||
private short flags;
|
||||
|
||||
public UUID getUuid() {
|
||||
@ -32,20 +38,20 @@ public class BossBar implements MinecraftPacket {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return health;
|
||||
public float getPercent() {
|
||||
return percent;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
public void setPercent(float percent) {
|
||||
this.percent = percent;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
@ -56,12 +62,12 @@ public class BossBar implements MinecraftPacket {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getDivisions() {
|
||||
return divisions;
|
||||
public int getOverlay() {
|
||||
return overlay;
|
||||
}
|
||||
|
||||
public void setDivisions(int divisions) {
|
||||
this.divisions = divisions;
|
||||
public void setOverlay(int overlay) {
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public short getFlags() {
|
||||
@ -77,10 +83,10 @@ public class BossBar implements MinecraftPacket {
|
||||
return "BossBar{" +
|
||||
"uuid=" + uuid +
|
||||
", action=" + action +
|
||||
", title='" + title + '\'' +
|
||||
", health=" + health +
|
||||
", name='" + name + '\'' +
|
||||
", percent=" + percent +
|
||||
", color=" + color +
|
||||
", divisions=" + divisions +
|
||||
", overlay=" + overlay +
|
||||
", flags=" + flags +
|
||||
'}';
|
||||
}
|
||||
@ -90,26 +96,26 @@ public class BossBar implements MinecraftPacket {
|
||||
this.uuid = ProtocolUtils.readUuid(buf);
|
||||
this.action = ProtocolUtils.readVarInt(buf);
|
||||
switch (action) {
|
||||
case 0: // add
|
||||
this.title = ProtocolUtils.readString(buf);
|
||||
this.health = buf.readFloat();
|
||||
case ADD:
|
||||
this.name = ProtocolUtils.readString(buf);
|
||||
this.percent = buf.readFloat();
|
||||
this.color = ProtocolUtils.readVarInt(buf);
|
||||
this.divisions = ProtocolUtils.readVarInt(buf);
|
||||
this.overlay = ProtocolUtils.readVarInt(buf);
|
||||
this.flags = buf.readUnsignedByte();
|
||||
break;
|
||||
case 1: // remove
|
||||
case REMOVE:
|
||||
break;
|
||||
case 2: // set health
|
||||
this.health = buf.readFloat();
|
||||
case UPDATE_PERCENT:
|
||||
this.percent = buf.readFloat();
|
||||
break;
|
||||
case 3: // update title
|
||||
this.title = ProtocolUtils.readString(buf);
|
||||
case UPDATE_NAME:
|
||||
this.name = ProtocolUtils.readString(buf);
|
||||
break;
|
||||
case 4: // update style
|
||||
case UPDATE_STYLE:
|
||||
this.color = ProtocolUtils.readVarInt(buf);
|
||||
this.divisions = ProtocolUtils.readVarInt(buf);
|
||||
this.overlay = ProtocolUtils.readVarInt(buf);
|
||||
break;
|
||||
case 5:
|
||||
case UPDATE_PROPERTIES:
|
||||
this.flags = buf.readUnsignedByte();
|
||||
break;
|
||||
}
|
||||
@ -120,26 +126,26 @@ public class BossBar implements MinecraftPacket {
|
||||
ProtocolUtils.writeUuid(buf, uuid);
|
||||
ProtocolUtils.writeVarInt(buf, action);
|
||||
switch (action) {
|
||||
case 0: // add
|
||||
ProtocolUtils.writeString(buf, title);
|
||||
buf.writeFloat(health);
|
||||
case ADD:
|
||||
ProtocolUtils.writeString(buf, name);
|
||||
buf.writeFloat(percent);
|
||||
ProtocolUtils.writeVarInt(buf, color);
|
||||
ProtocolUtils.writeVarInt(buf, divisions);
|
||||
ProtocolUtils.writeVarInt(buf, overlay);
|
||||
buf.writeByte(flags);
|
||||
break;
|
||||
case 1: // remove
|
||||
case REMOVE:
|
||||
break;
|
||||
case 2: // set health
|
||||
buf.writeFloat(health);
|
||||
case UPDATE_PERCENT:
|
||||
buf.writeFloat(percent);
|
||||
break;
|
||||
case 3: // update title
|
||||
ProtocolUtils.writeString(buf, title);
|
||||
case UPDATE_NAME:
|
||||
ProtocolUtils.writeString(buf, name);
|
||||
break;
|
||||
case 4: // update style
|
||||
case UPDATE_STYLE:
|
||||
ProtocolUtils.writeVarInt(buf, color);
|
||||
ProtocolUtils.writeVarInt(buf, divisions);
|
||||
ProtocolUtils.writeVarInt(buf, overlay);
|
||||
break;
|
||||
case 5:
|
||||
case UPDATE_PROPERTIES:
|
||||
buf.writeByte(flags);
|
||||
break;
|
||||
}
|
||||
|
@ -9,15 +9,16 @@ import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
|
||||
public class Chat implements MinecraftPacket {
|
||||
public static final byte CHAT = (byte) 0;
|
||||
private String message;
|
||||
private byte position;
|
||||
private byte type;
|
||||
|
||||
public Chat() {
|
||||
}
|
||||
|
||||
public Chat(String message, byte position) {
|
||||
public Chat(String message, byte type) {
|
||||
this.message = message;
|
||||
this.position = position;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
@ -28,19 +29,19 @@ public class Chat implements MinecraftPacket {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public byte getPosition() {
|
||||
return position;
|
||||
public byte getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setPosition(byte position) {
|
||||
this.position = position;
|
||||
public void setType(byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chat{" +
|
||||
"message='" + message + '\'' +
|
||||
", position=" + position +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ public class Chat implements MinecraftPacket {
|
||||
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
message = ProtocolUtils.readString(buf);
|
||||
if (direction == ProtocolConstants.Direction.CLIENTBOUND) {
|
||||
position = buf.readByte();
|
||||
type = buf.readByte();
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,16 +57,16 @@ public class Chat implements MinecraftPacket {
|
||||
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
ProtocolUtils.writeString(buf, message);
|
||||
if (direction == ProtocolConstants.Direction.CLIENTBOUND) {
|
||||
buf.writeByte(position);
|
||||
buf.writeByte(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Chat create(Component component) {
|
||||
return create(component, (byte) 0);
|
||||
return create(component, CHAT);
|
||||
}
|
||||
|
||||
public static Chat create(Component component, byte pos) {
|
||||
public static Chat create(Component component, byte type) {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
return new Chat(ComponentSerializers.JSON.serialize(component), pos);
|
||||
return new Chat(ComponentSerializers.JSON.serialize(component), type);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import io.netty.buffer.ByteBuf;
|
||||
public class ClientSettings implements MinecraftPacket {
|
||||
private String locale;
|
||||
private byte viewDistance;
|
||||
private int chatMode;
|
||||
private int chatVisibility;
|
||||
private boolean chatColors;
|
||||
private short skinParts;
|
||||
private int mainHand;
|
||||
@ -29,12 +29,12 @@ public class ClientSettings implements MinecraftPacket {
|
||||
this.viewDistance = viewDistance;
|
||||
}
|
||||
|
||||
public int getChatMode() {
|
||||
return chatMode;
|
||||
public int getChatVisibility() {
|
||||
return chatVisibility;
|
||||
}
|
||||
|
||||
public void setChatMode(int chatMode) {
|
||||
this.chatMode = chatMode;
|
||||
public void setChatVisibility(int chatVisibility) {
|
||||
this.chatVisibility = chatVisibility;
|
||||
}
|
||||
|
||||
public boolean isChatColors() {
|
||||
@ -66,7 +66,7 @@ public class ClientSettings implements MinecraftPacket {
|
||||
return "ClientSettings{" +
|
||||
"locale='" + locale + '\'' +
|
||||
", viewDistance=" + viewDistance +
|
||||
", chatMode=" + chatMode +
|
||||
", chatVisibility=" + chatVisibility +
|
||||
", chatColors=" + chatColors +
|
||||
", skinParts=" + skinParts +
|
||||
", mainHand=" + mainHand +
|
||||
@ -77,7 +77,7 @@ public class ClientSettings implements MinecraftPacket {
|
||||
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
this.locale = ProtocolUtils.readString(buf, 16);
|
||||
this.viewDistance = buf.readByte();
|
||||
this.chatMode = ProtocolUtils.readVarInt(buf);
|
||||
this.chatVisibility = ProtocolUtils.readVarInt(buf);
|
||||
this.chatColors = buf.readBoolean();
|
||||
this.skinParts = buf.readUnsignedByte();
|
||||
this.mainHand = ProtocolUtils.readVarInt(buf);
|
||||
@ -87,7 +87,7 @@ public class ClientSettings implements MinecraftPacket {
|
||||
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
ProtocolUtils.writeString(buf, locale);
|
||||
buf.writeByte(viewDistance);
|
||||
ProtocolUtils.writeVarInt(buf, chatMode);
|
||||
ProtocolUtils.writeVarInt(buf, chatVisibility);
|
||||
buf.writeBoolean(chatColors);
|
||||
buf.writeByte(skinParts);
|
||||
ProtocolUtils.writeVarInt(buf, mainHand);
|
||||
|
@ -9,6 +9,9 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.text.Component;
|
||||
|
||||
public class ScoreboardObjective implements MinecraftPacket {
|
||||
public static final byte ADD = (byte) 0;
|
||||
public static final byte REMOVE = (byte) 1;
|
||||
public static final byte CHANGE = (byte) 2;
|
||||
private String id;
|
||||
private byte mode;
|
||||
private Component displayName;
|
||||
@ -60,7 +63,7 @@ public class ScoreboardObjective implements MinecraftPacket {
|
||||
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
this.id = ProtocolUtils.readString(buf, 16);
|
||||
this.mode = buf.readByte();
|
||||
if (this.mode != 1) {
|
||||
if (this.mode != REMOVE) {
|
||||
this.displayName = ProtocolUtils.readScoreboardTextComponent(buf, protocolVersion);
|
||||
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_13) {
|
||||
this.type = ScoreboardProtocolUtil.getMode(ProtocolUtils.readVarInt(buf));
|
||||
@ -74,7 +77,7 @@ public class ScoreboardObjective implements MinecraftPacket {
|
||||
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
ProtocolUtils.writeString(buf, id);
|
||||
buf.writeByte(mode);
|
||||
if (this.mode != 1) {
|
||||
if (this.mode != REMOVE) {
|
||||
ProtocolUtils.writeScoreboardTextComponent(buf, protocolVersion, displayName);
|
||||
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_13) {
|
||||
ProtocolUtils.writeVarInt(buf, type.ordinal());
|
||||
|
@ -6,6 +6,8 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ScoreboardSetScore implements MinecraftPacket {
|
||||
public static final byte CHANGE = (byte) 0;
|
||||
public static final byte REMOVE = (byte) 1;
|
||||
private String entity;
|
||||
private byte action;
|
||||
private String objective;
|
||||
@ -58,7 +60,7 @@ public class ScoreboardSetScore implements MinecraftPacket {
|
||||
this.entity = ProtocolUtils.readString(buf, 40);
|
||||
this.action = buf.readByte();
|
||||
this.objective = ProtocolUtils.readString(buf, 16);
|
||||
if (this.action != 1) {
|
||||
if (this.action != REMOVE) {
|
||||
value = ProtocolUtils.readVarInt(buf);
|
||||
}
|
||||
}
|
||||
@ -68,7 +70,7 @@ public class ScoreboardSetScore implements MinecraftPacket {
|
||||
ProtocolUtils.writeString(buf, entity);
|
||||
buf.writeByte(action);
|
||||
ProtocolUtils.writeString(buf, objective);
|
||||
if (this.action != 1) {
|
||||
if (this.action != REMOVE) {
|
||||
ProtocolUtils.writeVarInt(buf, value);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScoreboardTeam implements MinecraftPacket {
|
||||
public static final byte ADD = (byte) 0;
|
||||
public static final byte REMOVE = (byte) 1;
|
||||
public static final byte UPDATE = (byte) 2;
|
||||
public static final byte ADD_PLAYER = (byte) 3;
|
||||
public static final byte REMOVE_PLAYER = (byte) 4;
|
||||
private String id;
|
||||
private byte mode;
|
||||
|
||||
@ -124,8 +129,8 @@ public class ScoreboardTeam implements MinecraftPacket {
|
||||
this.mode = buf.readByte();
|
||||
|
||||
switch (mode) {
|
||||
case 0: // create
|
||||
case 2: // update
|
||||
case ADD:
|
||||
case UPDATE:
|
||||
this.displayName = ProtocolUtils.readScoreboardTextComponent(buf, protocolVersion);
|
||||
if (protocolVersion <= ProtocolConstants.MINECRAFT_1_12_2) {
|
||||
this.prefix = ProtocolUtils.readScoreboardTextComponent(buf, protocolVersion);
|
||||
@ -140,14 +145,14 @@ public class ScoreboardTeam implements MinecraftPacket {
|
||||
this.prefix = ProtocolUtils.readScoreboardTextComponent(buf, protocolVersion);
|
||||
this.suffix = ProtocolUtils.readScoreboardTextComponent(buf, protocolVersion);
|
||||
}
|
||||
if (mode == 0) {
|
||||
if (mode == ADD) {
|
||||
this.entities = readEntities(buf);
|
||||
}
|
||||
break;
|
||||
case 1: // remove
|
||||
case REMOVE: // remove
|
||||
break;
|
||||
case 3: // add player
|
||||
case 4: // remove player
|
||||
case ADD_PLAYER: // add player
|
||||
case REMOVE_PLAYER: // remove player
|
||||
this.entities = readEntities(buf);
|
||||
break;
|
||||
}
|
||||
@ -158,8 +163,8 @@ public class ScoreboardTeam implements MinecraftPacket {
|
||||
ProtocolUtils.writeString(buf, id);
|
||||
buf.writeByte(mode);
|
||||
switch (mode) {
|
||||
case 0: // create
|
||||
case 2: // update
|
||||
case ADD:
|
||||
case UPDATE:
|
||||
ProtocolUtils.writeScoreboardTextComponent(buf, protocolVersion, displayName);
|
||||
if (protocolVersion <= ProtocolConstants.MINECRAFT_1_12_2) {
|
||||
ProtocolUtils.writeScoreboardTextComponent(buf, protocolVersion, prefix);
|
||||
@ -175,14 +180,14 @@ public class ScoreboardTeam implements MinecraftPacket {
|
||||
} else {
|
||||
buf.writeByte(color);
|
||||
}
|
||||
if (mode == 0) {
|
||||
if (mode == ADD) {
|
||||
writeEntities(buf, entities);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case REMOVE:
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case ADD_PLAYER:
|
||||
case REMOVE_PLAYER:
|
||||
writeEntities(buf, entities);
|
||||
break;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren