3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Bungee auto-team, bump BungeeCord version, workaround for block connections

Dieser Commit ist enthalten in:
creeper123123321 2019-02-24 15:02:09 -03:00
Ursprung 96366aae42
Commit f46a2bb618
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
5 geänderte Dateien mit 67 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -11,6 +11,11 @@
<artifactId>viaversion-bungee</artifactId> <artifactId>viaversion-bungee</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build> <build>
<resources> <resources>
<resource> <resource>
@ -29,7 +34,7 @@
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId> <artifactId>bungeecord-api</artifactId>
<version>1.10-SNAPSHOT</version> <version>1.13-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

Datei anzeigen

@ -5,6 +5,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.score.Team;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority; import net.md_5.bungee.event.EventPriority;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
@ -89,6 +90,7 @@ public class BungeeServerHandler implements Listener {
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception { public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
if (user == null) return; if (user == null) return;
// Auto-team handling
// Handle server/version change // Handle server/version change
if (user.has(BungeeStorage.class)) { if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class); BungeeStorage storage = user.get(BungeeStorage.class);
@ -96,7 +98,14 @@ public class BungeeServerHandler implements Listener {
if (e.getServer() != null) { if (e.getServer() != null) {
if (!e.getServer().getInfo().getName().equals(storage.getCurrentServer())) { if (!e.getServer().getInfo().getName().equals(storage.getCurrentServer())) {
// Clear auto-team
EntityTracker oldEntityTracker = user.get(EntityTracker.class); EntityTracker oldEntityTracker = user.get(EntityTracker.class);
if (oldEntityTracker != null) {
if (oldEntityTracker.isAutoTeam() && oldEntityTracker.isTeamExists()) {
oldEntityTracker.sendTeamPacket(false, true);
}
}
String serverName = e.getServer().getInfo().getName(); String serverName = e.getServer().getInfo().getName();
storage.setCurrentServer(serverName); storage.setCurrentServer(serverName);
@ -177,9 +186,28 @@ public class BungeeServerHandler implements Listener {
} }
EntityTracker newTracker = user.get(EntityTracker.class); EntityTracker newTracker = user.get(EntityTracker.class);
if (newTracker != null && oldEntityTracker != null) { if (newTracker != null) {
newTracker.setAutoTeam(oldEntityTracker.isAutoTeam()); if (Via.getConfig().isAutoTeam()) {
newTracker.setCurrentTeam(oldEntityTracker.getCurrentTeam()); String currentTeam = null;
for (Team team : player.getScoreboard().getTeams()) {
if (team.getPlayers().contains(info.getUsername())) {
currentTeam = team.getName();
}
}
// Reinitialize auto-team
newTracker.setAutoTeam(true);
if (currentTeam == null) {
// Send auto-team as it was cleared above
newTracker.sendTeamPacket(true, true);
newTracker.setCurrentTeam("viaversion");
} else {
// Auto-team will be sent when bungee send remove packet
newTracker.setAutoTeam(Via.getConfig().isAutoTeam());
newTracker.setCurrentTeam(currentTeam);
}
}
} }
Object wrapper = channelWrapper.get(player); Object wrapper = channelWrapper.get(player);

Datei anzeigen

@ -42,7 +42,7 @@ public class ConnectionData {
blockUpdatePacket.write(Type.POSITION, pos); blockUpdatePacket.write(Type.POSITION, pos);
blockUpdatePacket.write(Type.VAR_INT, newBlockState); blockUpdatePacket.write(Type.VAR_INT, newBlockState);
try { try {
blockUpdatePacket.send(Protocol1_13To1_12_2.class, true, false); blockUpdatePacket.send(Protocol1_13To1_12_2.class, true, true);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

Datei anzeigen

@ -173,19 +173,23 @@ public class WorldPackets {
Position position = wrapper.get(Type.POSITION, 0); Position position = wrapper.get(Type.POSITION, 0);
int newId = toNewId(wrapper.get(Type.VAR_INT, 0)); int newId = toNewId(wrapper.get(Type.VAR_INT, 0));
UserConnection userConnection = wrapper.user();
if (Via.getConfig().isServersideBlockConnections()) { if (Via.getConfig().isServersideBlockConnections()) {
UserConnection userConnection = wrapper.user();
ConnectionData.updateBlockStorage(userConnection, position, newId); ConnectionData.updateBlockStorage(userConnection, position, newId);
if (ConnectionData.connects(newId)) { if (ConnectionData.connects(newId)) {
newId = ConnectionData.connect(userConnection, position, newId); newId = ConnectionData.connect(userConnection, position, newId);
} }
}
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
// Workaround for packet order issue
wrapper.send(Protocol1_13To1_12_2.class, true, true);
wrapper.cancel();
if (Via.getConfig().isServersideBlockConnections()) {
ConnectionData.update(userConnection, position); ConnectionData.update(userConnection, position);
} }
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
} }
}); });
} }
@ -204,8 +208,9 @@ public class WorldPackets {
int chunkX = wrapper.get(Type.INT, 0); int chunkX = wrapper.get(Type.INT, 0);
int chunkZ = wrapper.get(Type.INT, 1); int chunkZ = wrapper.get(Type.INT, 1);
UserConnection userConnection = wrapper.user(); UserConnection userConnection = wrapper.user();
BlockChangeRecord[] records = wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0);
// Convert ids // Convert ids
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { for (BlockChangeRecord record : records) {
int newBlock = toNewId(record.getBlockId()); int newBlock = toNewId(record.getBlockId());
Position position = new Position( Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), (long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
@ -218,23 +223,33 @@ public class WorldPackets {
record.setBlockId(checkStorage(wrapper.user(), position, newBlock)); record.setBlockId(checkStorage(wrapper.user(), position, newBlock));
} }
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { if (Via.getConfig().isServersideBlockConnections()) {
int blockState = record.getBlockId(); for (BlockChangeRecord record : records) {
int blockState = record.getBlockId();
Position position = new Position( Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16), (long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(), (long) record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16)); (long) (record.getHorizontal() & 15) + (chunkZ * 16));
if (Via.getConfig().isServersideBlockConnections()) {
if (ConnectionData.connects(blockState)) { if (ConnectionData.connects(blockState)) {
blockState = ConnectionData.connect(userConnection, position, blockState); blockState = ConnectionData.connect(userConnection, position, blockState);
record.setBlockId(blockState); record.setBlockId(blockState);
} }
}
// Workaround for packet order issue
wrapper.send(Protocol1_13To1_12_2.class, true, true);
wrapper.cancel();
for (BlockChangeRecord record : records) {
Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
ConnectionData.update(userConnection, position); ConnectionData.update(userConnection, position);
} }
} }
} }
}); });
} }

Datei anzeigen

@ -137,6 +137,7 @@ public class PlayerPackets {
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
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true); wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel(); wrapper.cancel();
entityTracker.sendTeamPacket(true, true); entityTracker.sendTeamPacket(true, true);
@ -157,6 +158,7 @@ public class PlayerPackets {
if (entityTracker.isAutoTeam() if (entityTracker.isAutoTeam()
&& teamName.equals(entityTracker.getCurrentTeam())) { && teamName.equals(entityTracker.getCurrentTeam())) {
// team was removed // team was removed
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true); wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel(); wrapper.cancel();
entityTracker.sendTeamPacket(true, true); entityTracker.sendTeamPacket(true, true);
@ -215,6 +217,7 @@ public class PlayerPackets {
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
if (Via.getConfig().isAutoTeam()) { if (Via.getConfig().isAutoTeam()) {
entityTracker.setAutoTeam(true); entityTracker.setAutoTeam(true);
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true); wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel(); wrapper.cancel();
entityTracker.sendTeamPacket(true, true); entityTracker.sendTeamPacket(true, true);