| 1 | /* |
| 2 | * Decompiled with CFR 0.151. |
| 3 | * |
| 4 | * Could not load the following classes: |
| 5 | * com.wurmonline.client.comm.SimpleServerConnectionClass |
| 6 | */ |
| 7 | package net.encode.wurmesp.feature.hook; |
| 8 | |
| 9 | import com.wurmonline.client.comm.SimpleServerConnectionClass; |
| 10 | import java.lang.reflect.Method; |
| 11 | import java.nio.ByteBuffer; |
| 12 | import java.util.logging.Level; |
| 13 | import net.encode.wurmesp.WurmEspMod; |
| 14 | |
| 15 | public class CmdShowDeedPlan |
| 16 | extends Hook { |
| 17 | public CmdShowDeedPlan() { |
| 18 | this.prepareHook("com.wurmonline.client.comm.SimpleServerConnectionClass", "reallyHandleCmdShowDeedPlan", "(Ljava/nio/ByteBuffer;)V", () -> (proxy, method, args) -> { |
| 19 | if (WurmEspMod.deedsize) { |
| 20 | ByteBuffer bb = (ByteBuffer)args[0]; |
| 21 | byte type = bb.get(); |
| 22 | switch (type) { |
| 23 | case 0: { |
| 24 | int qId = bb.getInt(); |
| 25 | SimpleServerConnectionClass simpleServerConnectionClass = (SimpleServerConnectionClass)proxy; |
| 26 | Method readStringByteLengthMethod = simpleServerConnectionClass.getClass().getDeclaredMethod("readStringByteLength", ByteBuffer.class); |
| 27 | readStringByteLengthMethod.setAccessible(true); |
| 28 | Object[] readStringByteLengthArgs = new Object[]{bb}; |
| 29 | String deedName = (String)readStringByteLengthMethod.invoke(simpleServerConnectionClass, readStringByteLengthArgs); |
| 30 | int tokenX = bb.getInt(); |
| 31 | int tokenY = bb.getInt(); |
| 32 | int startX = bb.getInt(); |
| 33 | int startY = bb.getInt(); |
| 34 | int endX = bb.getInt(); |
| 35 | int endY = bb.getInt(); |
| 36 | int perimSize = bb.getInt(); |
| 37 | WurmEspMod.tilesHighlightManager.addData(startX, startY, endX, endY); |
| 38 | WurmEspMod.tileshighlight = true; |
| 39 | } |
| 40 | } |
| 41 | } else { |
| 42 | method.invoke(proxy, args); |
| 43 | } |
| 44 | return null; |
| 45 | }); |
| 46 | WurmEspMod.logger.log(Level.INFO, "[WurmEspMod] SimpleServerConnectionClass.reallyHandleCmdShowDeedPlan hooked"); |
| 47 | } |
| 48 | } |
| 49 | |