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

Merge branch 'master' into dev

Dieser Commit ist enthalten in:
Myles 2019-12-15 09:02:48 +00:00
Commit 4f72edeaee
5 geänderte Dateien mit 12 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -2,13 +2,11 @@
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/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) [![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.
**Allows the connection of higher client versions to lower server versions** **Allows the connection of higher client versions to lower server versions**
Supported Versions: Supported Versions:
![Table (https://i.imgur.com/iWAtD1p.png)](https://i.imgur.com/iWAtD1p.png) ![Table (https://i.imgur.com/yDtAgF7.png)](https://i.imgur.com/yDtAgF7.png)
On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version. On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version.

Datei anzeigen

@ -1,14 +1,15 @@
package us.myles.ViaVersion.api.type.types; package us.myles.ViaVersion.api.type.types;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import java.nio.charset.StandardCharsets;
public class StringType extends Type<String> { public class StringType extends Type<String> {
// String#length() (used to limit the string in Minecraft source code) uses char[]#length // String#length() (used to limit the string in Minecraft source code) uses char[]#length
private static final int maxJavaCharUtf8Length = Character.toString(Character.MAX_VALUE) private static final int maxJavaCharUtf8Length = Character.toString(Character.MAX_VALUE)
.getBytes(Charsets.UTF_8).length; .getBytes(StandardCharsets.UTF_8).length;
public StringType() { public StringType() {
super(String.class); super(String.class);
@ -21,9 +22,9 @@ public class StringType extends Type<String> {
Preconditions.checkArgument(len <= Short.MAX_VALUE * maxJavaCharUtf8Length, Preconditions.checkArgument(len <= Short.MAX_VALUE * maxJavaCharUtf8Length,
"Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len); "Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len);
byte[] b = new byte[len]; String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
buffer.readBytes(b); buffer.skipBytes(len);
String string = new String(b, Charsets.UTF_8);
Preconditions.checkArgument(string.length() <= Short.MAX_VALUE, Preconditions.checkArgument(string.length() <= Short.MAX_VALUE,
"Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length()); "Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length());
@ -34,7 +35,7 @@ public class StringType extends Type<String> {
public void write(ByteBuf buffer, String object) throws Exception { public void write(ByteBuf buffer, String object) throws Exception {
Preconditions.checkArgument(object.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", object.length()); Preconditions.checkArgument(object.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", object.length());
byte[] b = object.getBytes(Charsets.UTF_8); byte[] b = object.getBytes(StandardCharsets.UTF_8);
Type.VAR_INT.write(buffer, b.length); Type.VAR_INT.write(buffer, b.length);
buffer.writeBytes(b); buffer.writeBytes(b);
} }

Datei anzeigen

@ -36,10 +36,7 @@ public class NBTType extends Type<CompoundTag> {
return null; return null;
} else { } else {
buffer.readerIndex(readerIndex); buffer.readerIndex(readerIndex);
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer); return (CompoundTag) NBTIO.readTag((DataInput) new ByteBufInputStream(buffer));
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream);
}
} }
} }
@ -49,11 +46,7 @@ public class NBTType extends Type<CompoundTag> {
buffer.writeByte(0); buffer.writeByte(0);
} else { } else {
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer); ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream); NBTIO.writeTag((DataOutput) bytebufStream, object);
NBTIO.writeTag((DataOutput) dataOutputStream, object);
dataOutputStream.close();
} }
} }
} }

Datei anzeigen

@ -48,7 +48,7 @@ public class MappingData {
enchantmentMappings = new EnchantmentMappingByteArray(mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments")); enchantmentMappings = new EnchantmentMappingByteArray(mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments"));
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping..."); Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping...");
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds")); soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
Via.getPlatform().getLogger().info("Loading translation mappping"); Via.getPlatform().getLogger().info("Loading translation mapping");
translateMapping = new HashMap<>(); translateMapping = new HashMap<>();
Map<String, String> translateData = GsonUtil.getGson().fromJson( Map<String, String> translateData = GsonUtil.getGson().fromJson(
new InputStreamReader( new InputStreamReader(

Datei anzeigen

@ -55,7 +55,7 @@ public class Protocol1_15To1_14_4 extends Protocol {
}); });
// Edit Book // Edit Book
registerIncoming(State.PLAY, 0x0C, 0x0D, new PacketRemapper() { registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {