Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Resend viaversion team when removed from the current team
Dieser Commit ist enthalten in:
Ursprung
4a2bcf6fde
Commit
daac2baf8e
@ -132,20 +132,33 @@ public class PlayerPackets {
|
|||||||
String[] players = wrapper.read(Type.STRING_ARRAY); // Players
|
String[] players = wrapper.read(Type.STRING_ARRAY); // Players
|
||||||
final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||||
String myName = wrapper.user().get(ProtocolInfo.class).getUsername();
|
String myName = wrapper.user().get(ProtocolInfo.class).getUsername();
|
||||||
|
String teamName = wrapper.get(Type.STRING, 0);
|
||||||
for (String player : players) {
|
for (String player : players) {
|
||||||
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
|
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
|
||||||
if (mode == 4) {
|
if (mode == 4) {
|
||||||
// since removing add to auto team
|
// since removing add to auto team
|
||||||
entityTracker.sendTeamPacket(true, false);
|
entityTracker.sendTeamPacket(true, false);
|
||||||
|
entityTracker.setCurrentTeam("viaversion");
|
||||||
} else {
|
} else {
|
||||||
// since adding remove from auto team
|
// since adding remove from auto team
|
||||||
entityTracker.sendTeamPacket(false, true);
|
entityTracker.sendTeamPacket(false, true);
|
||||||
|
entityTracker.setCurrentTeam(teamName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrapper.write(Type.STRING_ARRAY, players);
|
wrapper.write(Type.STRING_ARRAY, players);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == 1) { // Remove team
|
||||||
|
final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||||
|
String teamName = wrapper.get(Type.STRING, 0);
|
||||||
|
if (entityTracker.isAutoTeam()
|
||||||
|
&& teamName.equals(entityTracker.getCurrentTeam())) {
|
||||||
|
// team was removed
|
||||||
|
entityTracker.sendTeamPacket(true, false);
|
||||||
|
entityTracker.setCurrentTeam("viaversion");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -190,6 +203,19 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Scoreboard will be cleared when join game is received
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
if (Via.getConfig().isAutoTeam()) {
|
||||||
|
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||||
|
entityTracker.setAutoTeam(true);
|
||||||
|
entityTracker.sendTeamPacket(true, false);
|
||||||
|
entityTracker.setCurrentTeam("viaversion");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -211,23 +211,6 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Server Difficulty Packet
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x41, 0x0D, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
if (Via.getConfig().isAutoTeam()) {
|
|
||||||
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
|
||||||
entityTracker.setAutoTeam(true);
|
|
||||||
entityTracker.sendTeamPacket(true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Block Change Packet
|
// Block Change Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x23, 0x0B, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x23, 0x0B, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
@ -240,6 +223,7 @@ public class WorldPackets {
|
|||||||
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x08); // Block Break Animation Packet
|
protocol.registerOutgoing(State.PLAY, 0x25, 0x08); // Block Break Animation Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x0A); // Block Action Packet
|
protocol.registerOutgoing(State.PLAY, 0x24, 0x0A); // Block Action Packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x41, 0x0D); // Server Difficulty Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x10); // Multi Block Change Packet
|
protocol.registerOutgoing(State.PLAY, 0x22, 0x10); // Multi Block Change Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x27, 0x1C); // Explosion Packet
|
protocol.registerOutgoing(State.PLAY, 0x27, 0x1C); // Explosion Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x2A, 0x22); // Particle Packet
|
protocol.registerOutgoing(State.PLAY, 0x2A, 0x22); // Particle Packet
|
||||||
|
@ -53,6 +53,8 @@ public class EntityTracker extends StoredObject {
|
|||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
@Setter
|
@Setter
|
||||||
private int mainHand;
|
private int mainHand;
|
||||||
|
@Setter
|
||||||
|
private String currentTeam;
|
||||||
|
|
||||||
public EntityTracker(UserConnection user) {
|
public EntityTracker(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren