3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 23:30:15 +01:00

Merge pull request #1206 from ViaVersion/master

merge master into dev
Dieser Commit ist enthalten in:
Myles 2019-03-03 13:29:00 +00:00 committet von GitHub
Commit b9a2279966
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
8 geänderte Dateien mit 86 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
# ViaVersion 1.6.0 - Spigot, Sponge, BungeeCord
[![Build Status](https://travis-ci.org/MylesIsCool/ViaVersion.svg?branch=master)](https://travis-ci.org/MylesIsCool/ViaVersion)
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
IRC: [#viaversion](http://irc.spi.gt/iris/?channels=viaversion) on irc.spi.gt for Support.

Datei anzeigen

@ -11,6 +11,11 @@
<artifactId>viaversion-bungee</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
@ -29,7 +34,7 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.10-SNAPSHOT</version>
<version>1.13-SNAPSHOT</version>
<scope>provided</scope>
</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.ServerConnectedEvent;
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.EventPriority;
import net.md_5.bungee.protocol.packet.PluginMessage;
@ -22,6 +23,7 @@ import us.myles.ViaVersion.bungee.storage.BungeeStorage;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -88,6 +90,7 @@ public class BungeeServerHandler implements Listener {
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
if (user == null) return;
// Auto-team handling
// Handle server/version change
if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class);
@ -95,6 +98,14 @@ public class BungeeServerHandler implements Listener {
if (e.getServer() != null) {
if (!e.getServer().getInfo().getName().equals(storage.getCurrentServer())) {
// Clear auto-team
EntityTracker oldEntityTracker = user.get(EntityTracker.class);
if (oldEntityTracker != null) {
if (oldEntityTracker.isAutoTeam() && oldEntityTracker.isTeamExists()) {
oldEntityTracker.sendTeamPacket(false, true);
}
}
String serverName = e.getServer().getInfo().getName();
storage.setCurrentServer(serverName);
@ -174,6 +185,31 @@ public class BungeeServerHandler implements Listener {
protocol.init(user);
}
EntityTracker newTracker = user.get(EntityTracker.class);
if (newTracker != null) {
if (Via.getConfig().isAutoTeam()) {
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);
setVersion.invoke(wrapper, protocolId);

Datei anzeigen

@ -30,8 +30,7 @@ public class ChunkSection {
public ChunkSection() {
this.blocks = new int[SIZE];
this.blockLight = new NibbleArray(SIZE);
palette.add(0);
inversePalette.put(0, 0);
addPaletteEntry(0);
}
/**

Datei anzeigen

@ -15,7 +15,7 @@ public class ChunkSectionType1_8 extends Type<ChunkSection> {
@Override
public ChunkSection read(ByteBuf buffer) throws Exception {
ChunkSection chunkSection = new ChunkSection();
chunkSection.clearPalette();
// Don't clear palette because 0 index needs to be air in 1.9 version
ByteBuf littleEndianView = buffer.order(ByteOrder.LITTLE_ENDIAN);

Datei anzeigen

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

Datei anzeigen

@ -173,19 +173,23 @@ public class WorldPackets {
Position position = wrapper.get(Type.POSITION, 0);
int newId = toNewId(wrapper.get(Type.VAR_INT, 0));
UserConnection userConnection = wrapper.user();
if (Via.getConfig().isServersideBlockConnections()) {
UserConnection userConnection = wrapper.user();
ConnectionData.updateBlockStorage(userConnection, position, newId);
if (ConnectionData.connects(newId)) {
newId = ConnectionData.connect(userConnection, position, newId);
}
}
wrapper.set(Type.VAR_INT, 0, checkStorage(wrapper.user(), position, newId));
if (Via.getConfig().isServersideBlockConnections()) {
// Workaround for packet order issue
wrapper.send(Protocol1_13To1_12_2.class, true, true);
wrapper.cancel();
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 chunkZ = wrapper.get(Type.INT, 1);
UserConnection userConnection = wrapper.user();
BlockChangeRecord[] records = wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0);
// Convert ids
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
for (BlockChangeRecord record : records) {
int newBlock = toNewId(record.getBlockId());
Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
@ -218,23 +223,33 @@ public class WorldPackets {
record.setBlockId(checkStorage(wrapper.user(), position, newBlock));
}
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
int blockState = record.getBlockId();
if (Via.getConfig().isServersideBlockConnections()) {
for (BlockChangeRecord record : records) {
int blockState = record.getBlockId();
Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
Position position = new Position(
(long) (record.getHorizontal() >> 4 & 15) + (chunkX * 16),
(long) record.getY(),
(long) (record.getHorizontal() & 15) + (chunkZ * 16));
if (Via.getConfig().isServersideBlockConnections()) {
if (ConnectionData.connects(blockState)) {
blockState = ConnectionData.connect(userConnection, position, 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);
}
}
}
});
}
@ -308,7 +323,7 @@ public class WorldPackets {
}
boolean willSaveConnection = false;
if (ConnectionData.needStoreBlocks() && Via.getConfig().isServersideBlockConnections()) {
if (Via.getConfig().isServersideBlockConnections() && ConnectionData.needStoreBlocks()) {
for (int p = 0; p < section.getPaletteSize(); p++) {
int newId = section.getPaletteEntry(p);
if (ConnectionData.isWelcome(newId)) {

Datei anzeigen

@ -129,7 +129,7 @@ public class PlayerPackets {
}
if (mode == 0 || mode == 3 || mode == 4) {
String[] players = wrapper.read(Type.STRING_ARRAY); // Players
String[] players = wrapper.passthrough(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);
@ -137,7 +137,10 @@ public class PlayerPackets {
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
if (mode == 4) {
// since removing add to auto team
entityTracker.sendTeamPacket(true, false);
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel();
entityTracker.sendTeamPacket(true, true);
entityTracker.setCurrentTeam("viaversion");
} else {
// since adding remove from auto team
@ -146,7 +149,6 @@ public class PlayerPackets {
}
}
}
wrapper.write(Type.STRING_ARRAY, players);
}
if (mode == 1) { // Remove team
@ -155,7 +157,10 @@ public class PlayerPackets {
if (entityTracker.isAutoTeam()
&& teamName.equals(entityTracker.getCurrentTeam())) {
// team was removed
entityTracker.sendTeamPacket(true, false);
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel();
entityTracker.sendTeamPacket(true, true);
entityTracker.setCurrentTeam("viaversion");
}
}
@ -211,7 +216,10 @@ public class PlayerPackets {
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
if (Via.getConfig().isAutoTeam()) {
entityTracker.setAutoTeam(true);
entityTracker.sendTeamPacket(true, false);
// Workaround for packet order issue
wrapper.send(Protocol1_9TO1_8.class, true, true);
wrapper.cancel();
entityTracker.sendTeamPacket(true, true);
entityTracker.setCurrentTeam("viaversion");
} else {
entityTracker.setAutoTeam(false);