Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Commit
67a0a47778
@ -132,20 +132,33 @@ public class PlayerPackets {
|
||||
String[] players = wrapper.read(Type.STRING_ARRAY); // Players
|
||||
final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||
String myName = wrapper.user().get(ProtocolInfo.class).getUsername();
|
||||
String teamName = wrapper.get(Type.STRING, 0);
|
||||
for (String player : players) {
|
||||
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
|
||||
if (mode == 4) {
|
||||
// since removing add to auto team
|
||||
entityTracker.sendTeamPacket(true, false);
|
||||
|
||||
entityTracker.setCurrentTeam("viaversion");
|
||||
} else {
|
||||
// since adding remove from auto team
|
||||
entityTracker.sendTeamPacket(false, true);
|
||||
entityTracker.setCurrentTeam(teamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
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,21 @@ public class PlayerPackets {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Scoreboard will be cleared when join game is received
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||
if (Via.getConfig().isAutoTeam()) {
|
||||
entityTracker.setAutoTeam(true);
|
||||
entityTracker.sendTeamPacket(true, false);
|
||||
entityTracker.setCurrentTeam("viaversion");
|
||||
} else {
|
||||
entityTracker.setAutoTeam(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
protocol.registerOutgoing(State.PLAY, 0x23, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
@ -240,6 +223,7 @@ public class WorldPackets {
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x08); // Block Break Animation 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, 0x27, 0x1C); // Explosion Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2A, 0x22); // Particle Packet
|
||||
|
@ -53,6 +53,8 @@ public class EntityTracker extends StoredObject {
|
||||
private GameMode gameMode;
|
||||
@Setter
|
||||
private int mainHand;
|
||||
@Setter
|
||||
private String currentTeam;
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren