mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-14 10:55:20 +01:00
Merge dev, fixed suffix length check (#165)
* fix falling block data remap (#161) * Update README.md (#162) * fix item hover event on 1.11 (#164) * Fix kick for overly long suffix
This commit is contained in:
parent
91ca18de3e
commit
10217f5c5f
22
README.md
22
README.md
@ -2,9 +2,21 @@
|
||||
|
||||
Allows older Minecraft versions on a newer Minecraft server
|
||||
|
||||
|
||||
Requires [ViaVersion](http://viaversion.com) to be installed
|
||||
**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/
|
||||
|
||||
### Supported versions:
|
||||
![supported_versions](http://i.imgur.com/gXCifhK.png)
|
||||
![supported_versions](https://camo.githubusercontent.com/75fd692876cdeadbb8a84ed3175e6f0fc23a640a/68747470733a2f2f692e696d6775722e636f6d2f695741744431702e706e67)
|
||||
|
||||
---
|
||||
|
||||
### Releases / Dev Builds:
|
||||
|
||||
***Requires [ViaVersion](http://viaversion.com) to be installed***
|
||||
|
||||
You can find official releases here:
|
||||
**Spgot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]**
|
||||
|
||||
You can find official dev builds here:
|
||||
**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ **[1.9.x - 1.14.x]**
|
||||
|
||||
**Maven:** https://repo.viaversion.com/
|
||||
|
||||
**Issue tracker:** https://github.com/ViaVersion/ViaBackwards/issues
|
||||
|
@ -0,0 +1,48 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
public class ChatItemRewriter {
|
||||
|
||||
public static void toClient(JsonElement element, UserConnection user) {
|
||||
if (element instanceof JsonObject) {
|
||||
JsonObject obj = (JsonObject) element;
|
||||
if (obj.has("hoverEvent")) {
|
||||
if (obj.get("hoverEvent") instanceof JsonObject) {
|
||||
JsonObject hoverEvent = (JsonObject) obj.get("hoverEvent");
|
||||
if (hoverEvent.has("action") && hoverEvent.has("value")) {
|
||||
String type = hoverEvent.get("action").getAsString();
|
||||
if (type.equals("show_item") || type.equals("show_entity")) {
|
||||
JsonElement value = hoverEvent.get("value");
|
||||
|
||||
if (value.isJsonArray()) {
|
||||
JsonArray newArray = new JsonArray();
|
||||
|
||||
int index = 0;
|
||||
for (JsonElement valueElement : value.getAsJsonArray()) {
|
||||
if (valueElement.isJsonPrimitive() && valueElement.getAsJsonPrimitive().isString()) {
|
||||
String newValue = index + ":" + valueElement.getAsString();
|
||||
newArray.add(new JsonPrimitive(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
hoverEvent.add("value", newArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj.has("extra")) {
|
||||
toClient(obj.get("extra"), user);
|
||||
}
|
||||
} else if (element instanceof JsonArray) {
|
||||
JsonArray array = (JsonArray) element;
|
||||
for (JsonElement value : array) {
|
||||
toClient(value, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,9 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
@ -20,9 +23,6 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -47,6 +47,7 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
if (object.has("translate"))
|
||||
handleTranslations(object);
|
||||
|
||||
ChatItemRewriter.toClient(object, wrapper.user());
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
} catch (Exception e) {
|
||||
// Only print if ViaVer debug is enabled
|
||||
|
@ -247,8 +247,10 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
prefix = ChatUtil.removeUnusedColor(prefix, 'f', true);
|
||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||
|
||||
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
||||
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
|
||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||
wrapper.write(Type.STRING, prefix);
|
||||
wrapper.write(Type.STRING, suffix);
|
||||
|
@ -95,8 +95,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||
int combined = Protocol1_13_2To1_14.getNewBlockStateId(blockState);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
||||
wrapper.set(Type.INT, 0, data + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user