Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +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
Dieser Commit ist enthalten in:
Ursprung
91ca18de3e
Commit
10217f5c5f
22
README.md
22
README.md
@ -2,9 +2,21 @@
|
|||||||
|
|
||||||
Allows older Minecraft versions on a newer Minecraft server
|
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:
|
||||||
![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;
|
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.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
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.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
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;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
|||||||
if (object.has("translate"))
|
if (object.has("translate"))
|
||||||
handleTranslations(object);
|
handleTranslations(object);
|
||||||
|
|
||||||
|
ChatItemRewriter.toClient(object, wrapper.user());
|
||||||
wrapper.set(Type.STRING, 0, object.toString());
|
wrapper.set(Type.STRING, 0, object.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Only print if ViaVer debug is enabled
|
// 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);
|
prefix = ChatUtil.removeUnusedColor(prefix, 'f', true);
|
||||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||||
|
|
||||||
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
||||||
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
||||||
|
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
|
||||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||||
wrapper.write(Type.STRING, prefix);
|
wrapper.write(Type.STRING, prefix);
|
||||||
wrapper.write(Type.STRING, suffix);
|
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);
|
int data = wrapper.get(Type.INT, 0);
|
||||||
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||||
int blockState = wrapper.get(Type.INT, 0);
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
int combined = BlockItemPackets1_13.toOldId(blockState);
|
int combined = Protocol1_13_2To1_14.getNewBlockStateId(blockState);
|
||||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
|
||||||
wrapper.set(Type.INT, 0, combined);
|
wrapper.set(Type.INT, 0, combined);
|
||||||
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
||||||
wrapper.set(Type.INT, 0, data + 1);
|
wrapper.set(Type.INT, 0, data + 1);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren