Don't display achievement broadcasts to 1.12+ #757

This commit is contained in:
Myles 2017-10-11 21:12:02 +01:00
parent 11be597d11
commit fd01b9a6d2
2 changed files with 24 additions and 1 deletions

View File

@ -104,6 +104,10 @@ public class Protocol1_12To1_11_1 extends Protocol {
if (!Via.getConfig().is1_12NBTArrayFix()) return; if (!Via.getConfig().is1_12NBTArrayFix()) return;
try { try {
JsonElement obj = new JsonParser().parse(wrapper.get(Type.STRING, 0)); JsonElement obj = new JsonParser().parse(wrapper.get(Type.STRING, 0));
if (!TranslateRewriter.toClient(obj, wrapper.user())) {
wrapper.cancel();
return;
}
ChatItemRewriter.toClient(obj, wrapper.user()); ChatItemRewriter.toClient(obj, wrapper.user());
wrapper.set(Type.STRING, 0, obj.toString()); wrapper.set(Type.STRING, 0, obj.toString());
} catch (Exception e) { } catch (Exception e) {

View File

@ -0,0 +1,19 @@
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.data.UserConnection;
public class TranslateRewriter {
public static boolean toClient(JsonElement element, UserConnection user) {
if (element instanceof JsonObject) {
JsonObject obj = (JsonObject) element;
if(obj.has("translate")) {
if(obj.get("translate").getAsString().equals("chat.type.achievement")) {
return false;
}
}
}
return true;
}
}