3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00

Merge remote-tracking branch 'origin/master' into dev

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-10-03 20:15:19 +02:00
Commit 1bc4fc211d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
7 geänderte Dateien mit 37 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -264,13 +264,15 @@ final class TagStringReader {
Tag result = null; Tag result = null;
try { try {
switch (Character.toLowerCase(current)) { // try to read and return as a number switch (Character.toLowerCase(current)) { // try to read and return as a number
// case Tokens.TYPE_INTEGER: // handled below, ints are ~special~
case Tokens.TYPE_BYTE: case Tokens.TYPE_BYTE:
result = new ByteTag(Byte.parseByte(builder.toString())); result = new ByteTag(Byte.parseByte(builder.toString()));
break; break;
case Tokens.TYPE_SHORT: case Tokens.TYPE_SHORT:
result = new ShortTag(Short.parseShort(builder.toString())); result = new ShortTag(Short.parseShort(builder.toString()));
break; break;
case Tokens.TYPE_INT:
result = new IntTag(Integer.parseInt(builder.toString()));
break;
case Tokens.TYPE_LONG: case Tokens.TYPE_LONG:
result = new LongTag(Long.parseLong(builder.toString())); result = new LongTag(Long.parseLong(builder.toString()));
break; break;

Datei anzeigen

@ -93,7 +93,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
if (plugin.getConf().isItemCache()) { if (plugin.getConf().isItemCache()) {
handItemCache = new HandItemCache(); handItemCache = new HandItemCache();
tasks.add(handItemCache.runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :) tasks.add(handItemCache.runTaskTimerAsynchronously(plugin, 1L, 1L)); // Updates player's items :)
} }
} }

Datei anzeigen

@ -137,15 +137,17 @@ public class MappingData extends MappingDataBase {
return null; // Not valid return null; // Not valid
} }
int separatorIndex = newId.indexOf(':'); int separatorIndex = newId.indexOf(':');
// Vanilla parses ``:`` and ```` as ``minecraft:`` (also ensure there's enough space) // Vanilla parses an empty and a missing namespace as the minecraft namespace
if ((separatorIndex == -1 || separatorIndex == 0) && newId.length() <= 10) { if (separatorIndex == -1) {
newId = "minecraft:" + newId; newId = "minecraft:" + newId;
} else if (separatorIndex == 0) {
newId = "minecraft" + newId;
} }
return newId; return newId;
} }
public static boolean isValid1_13Channel(String channelId) { public static boolean isValid1_13Channel(String channelId) {
return channelId.matches("([0-9a-z_.-]+):([0-9a-z_/.-]+)"); return channelId.matches("([0-9a-z_.-]+:)?[0-9a-z_/.-]+");
} }
private void loadTags(Map<String, Integer[]> output, JsonObject newTags) { private void loadTags(Map<String, Integer[]> output, JsonObject newTags) {

Datei anzeigen

@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.Position;
@ -31,6 +32,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import java.util.Collections;
public class PlayerPackets { public class PlayerPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
@ -58,19 +61,24 @@ public class PlayerPackets {
Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
protocol.getItemRewriter().handleItemToServer(item); protocol.getItemRewriter().handleItemToServer(item);
if (item == null) return;
CompoundTag tag = item.tag();
if (tag == null) return;
Tag pages = tag.get("pages");
// Fix for https://github.com/ViaVersion/ViaVersion/issues/2660
if (pages == null) {
tag.put("pages", new ListTag(Collections.singletonList(new StringTag())));
}
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit // Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
if (Via.getConfig().isTruncate1_14Books()) { if (Via.getConfig().isTruncate1_14Books() && pages instanceof ListTag) {
if (item == null) return;
CompoundTag tag = item.tag();
if (tag == null) return;
Tag pages = tag.get("pages");
if (!(pages instanceof ListTag)) return;
ListTag listTag = (ListTag) pages; ListTag listTag = (ListTag) pages;
if (listTag.size() <= 50) return; if (listTag.size() > 50) {
listTag.setValue(listTag.getValue().subList(0, 50)); listTag.setValue(listTag.getValue().subList(0, 50));
}
} }
} }
}); });

Datei anzeigen

@ -41,16 +41,13 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRew
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class EntityTracker1_9 extends EntityTrackerBase { public class EntityTracker1_9 extends EntityTrackerBase {
public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}";
public static final String DRAGON_TRANSLATABLE = "{\"translate\":\"entity.EnderDragon.name\"}";
private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>(); private final Map<Integer, UUID> uuidMap = new ConcurrentHashMap<>();
private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>(); private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>();
private final Map<Integer, Integer> vehicleMap = new ConcurrentHashMap<>(); private final Map<Integer, Integer> vehicleMap = new ConcurrentHashMap<>();
@ -254,7 +251,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
if (metadata.id() == 2) { if (metadata.id() == 2) {
BossBar bar = bossBarMap.get(entityId); BossBar bar = bossBarMap.get(entityId);
String title = (String) metadata.getValue(); String title = (String) metadata.getValue();
title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither") : title; title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE) : title;
if (bar == null) { if (bar == null) {
bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, BossColor.PINK, BossStyle.SOLID); bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, BossColor.PINK, BossStyle.SOLID);
bossBarMap.put(entityId, bar); bossBarMap.put(entityId, bar);
@ -272,7 +269,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f; float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
float health = Math.max(0.0f, Math.min(((float) metadata.getValue()) / maxHealth, 1.0f)); float health = Math.max(0.0f, Math.min(((float) metadata.getValue()) / maxHealth, 1.0f));
if (bar == null) { if (bar == null) {
String title = type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither"; String title = type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE;
bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, health, BossColor.PINK, BossStyle.SOLID); bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, health, BossColor.PINK, BossStyle.SOLID);
bossBarMap.put(entityId, bar); bossBarMap.put(entityId, bar);
bar.addConnection(user()); bar.addConnection(user());

Datei anzeigen

@ -35,6 +35,7 @@ public class NBTTagTest {
readString("{id:[I;1,2, 3, 4,5]}"); // >=1.11 readString("{id:[I;1,2, 3, 4,5]}"); // >=1.11
readString("{id:1b,b:true}"); readString("{id:1b,b:true}");
readString("{id:[L;1l,2L,3L]}"); // >=1.11 readString("{id:[L;1l,2L,3L]}"); // >=1.11
readString("{id:[I;1i,2I,3I]}");
readString("{id:'minecraft:stone'}"); // >=1.13 readString("{id:'minecraft:stone'}"); // >=1.13
readString("{id:1,id:2}"); readString("{id:1,id:2}");
readString("{id:-20b,test:3.19f}"); readString("{id:-20b,test:3.19f}");
@ -47,7 +48,6 @@ public class NBTTagTest {
//TODO fix legacy < 1.12 //TODO fix legacy < 1.12
// readString("{id:minecraft:stone}"); // readString("{id:minecraft:stone}");
// readString("{id:[I;1i,2I,3I]}");
// readString("{id:[1,2, 3, 4,5]}"); // readString("{id:[1,2, 3, 4,5]}");
} }
} }

Datei anzeigen

@ -2,8 +2,8 @@ metadata.format.version = "1.1"
[versions] [versions]
adventure = "4.8.0" adventure = "4.9.1"
gson = "2.8.7" gson = "2.8.8"
fastutil = "8.3.1" fastutil = "8.3.1"
openNBT = "2.0-SNAPSHOT" openNBT = "2.0-SNAPSHOT"
javassist = "3.28.0-GA" javassist = "3.28.0-GA"
@ -14,7 +14,7 @@ guava = "17.0"
snakeYaml = "1.18" snakeYaml = "1.18"
junit = "5.7.2" junit = "5.7.2"
checkerQual = "3.14.0" checkerQual = "3.18.0"
# Platforms # Platforms
paper = "1.16.5-R0.1-SNAPSHOT" paper = "1.16.5-R0.1-SNAPSHOT"