Merge branch 'refs/heads/dev' into preview

This commit is contained in:
Nassim Jahnke 2024-04-19 10:11:05 +02:00
commit 1bb85b11e9
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 11 additions and 11 deletions

View File

@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.SerializerVersion;
import java.util.logging.Level;
public class TranslateRewriter {
@ -45,13 +46,7 @@ public class TranslateRewriter {
return;
}
String textValue;
JsonElement value = hoverEvent.get("value");
if (value.isJsonObject()) {
textValue = value.getAsJsonObject().get("text").getAsString();
} else {
textValue = value.getAsJsonPrimitive().getAsString();
}
String textValue = SerializerVersion.V1_9.toComponent(hoverEvent.get("value")).asUnformattedString();
if (AchievementTranslationMapping.get(textValue) == null) {
JsonObject invalidText = new JsonObject();
@ -79,7 +74,7 @@ public class TranslateRewriter {
typePart.addProperty("translate", "stats.tooltip.type.achievement");
JsonObject description = new JsonObject();
typePart.addProperty("italic", true);
description.addProperty("translate", value + ".desc");
description.addProperty("translate", textValue + ".desc");
baseArray.add(newLine);
baseArray.add(description);
} else if (textValue.startsWith("stat")) {
@ -91,7 +86,9 @@ public class TranslateRewriter {
hoverEvent.addProperty("action", "show_text");
hoverEvent.add("value", baseArray);
} catch (Exception e) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error rewriting show_achievement: " + hoverEvent, e);
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error rewriting show_achievement: " + hoverEvent, e);
}
JsonObject invalidText = new JsonObject();
invalidText.addProperty("text", "Invalid statistic/achievement!");
invalidText.addProperty("color", "red");

View File

@ -203,8 +203,10 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
NumberTag leastTag = attribute.getNumberTag("UUIDLeast");
NumberTag mostTag = attribute.getNumberTag("UUIDMost");
if (leastTag != null && mostTag != null) {
int[] uuidIntArray = UUIDUtil.toIntArray(leastTag.asLong(), mostTag.asLong());
int[] uuidIntArray = UUIDUtil.toIntArray(mostTag.asLong(), leastTag.asLong());
attribute.put("UUID", new IntArrayTag(uuidIntArray));
attribute.remove("UUIDLeast");
attribute.remove("UUIDMost");
}
}
}
@ -223,6 +225,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
UUID uuid = UUIDUtil.fromIntArray(uuidTag.getValue());
attribute.putLong("UUIDLeast", uuid.getLeastSignificantBits());
attribute.putLong("UUIDMost", uuid.getMostSignificantBits());
attribute.remove("UUID");
}
}
}