Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
sword blocking option for newer protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrygames committed Apr 29, 2018
1 parent 7762387 commit c07a423
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>de.gerrygames</groupId>
<artifactId>viarewind-all</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private static byte[] dumpCustomSwordClass() throws Exception {
mv.visitVarInsn(ALOAD, 3);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ACONST_NULL);
mv.visitLdcInsn("push1");
mv.visitLdcInsn("block");
mv.visitInsn(ACONST_NULL);
mv.visitTypeInsn(CHECKCAST, "java/lang/Throwable");
mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/logging/log4j/simple/SimpleLogger", "isEnabled", "(Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Marker;Ljava/lang/String;Ljava/lang/Throwable;)Z", false);
Expand Down Expand Up @@ -295,7 +295,7 @@ private static byte[] dumpCustomSwordClass() throws Exception {
mv.visitVarInsn(ALOAD, 5);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ACONST_NULL);
mv.visitLdcInsn("push2");
mv.visitLdcInsn("block");
mv.visitInsn(ACONST_NULL);
mv.visitTypeInsn(CHECKCAST, "java/lang/Throwable");
mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/logging/log4j/simple/SimpleLogger", "isEnabled", "(Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Marker;Ljava/lang/String;Ljava/lang/Throwable;)Z", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.provider.TitleRenderProvider;
import de.gerrygames.viarewind.utils.PacketUtil;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.The5zigMod;
import eu.the5zig.mod.event.*;
import eu.the5zig.mod.modules.Category;
import eu.the5zig.mod.plugin.Plugin;
Expand Down Expand Up @@ -46,6 +47,7 @@
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.HandItemProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
Expand All @@ -58,10 +60,10 @@ public class ClientViaVersion {
public static int spoofedVersion = CLIENT_PROTOCOL_VERSION;
public static List<ProtocolVersion> supportedVersion;
public static ProtocolVersion selected;
public static boolean shieldBlocking = true;

public static UserConnection user;
public static Object networkManager;
public static boolean blockingOnNewServers = false;

private static String title = Display.getTitle();

Expand Down Expand Up @@ -120,6 +122,8 @@ public void onTick(TickEvent e) {

@EventHandler
public void onLoad(LoadEvent e) {
blockingOnNewServers = new File(The5zigMod.getVars().getMinecraftDataDirectory(), "blockingOnNewServers").exists();

ClientViaVersion.LOGGER.info("Minecraft Version: " + The5zigAPI.getAPI().getMinecraftVersion());
ClientViaVersion.LOGGER.info("5zig Version: " + The5zigAPI.getAPI().getModVersion());
ClientViaVersion.LOGGER.info("Forge installed: " + The5zigAPI.getAPI().isForgeEnvironment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class ViaTransformerIn extends ByteToMessageDecoder {
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (in.readableBytes()==0 || ClientViaVersion.user==null) return;
int packetId = Type.VAR_INT.read(in);

//ClientViaVersion.LOGGER.info("Incoming Packet: id={}, size={}", Integer.toHexString(packetId), in.readableBytes());

State state = Utils.getConnectionState(ctx.channel());
ClientViaVersion.user.get(ProtocolInfo.class).setState(state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ public void debug(String message, Object... params) {

@Override
public boolean isEnabled(Level testLevel, Marker marker, String msg, Throwable t) {
if (msg.startsWith("push")) {
if (msg.equals("push")) {
return ClientViaVersion.spoofedVersion<=47;
}
if (msg.equals("block")) {
return ClientViaVersion.spoofedVersion<=47 || ClientViaVersion.blockingOnNewServers;
}
return super.isEnabled(testLevel, marker, msg, t);
}

Expand Down

0 comments on commit c07a423

Please sign in to comment.