|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 FalsePattern |
| 3 | + * All Rights Reserved |
| 4 | + * |
| 5 | + * The above copyright notice, this permission notice and the word "SNEED" |
| 6 | + * shall be included in all copies or substantial portions of the Software. |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Lesser General Public License as published by |
| 10 | + * the Free Software Foundation, either version 3 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Lesser General Public License |
| 19 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +package com.falsepattern.lib.internal.asm; |
| 23 | + |
| 24 | +import com.falsepattern.lib.asm.IClassNodeTransformer; |
| 25 | +import lombok.val; |
| 26 | +import org.objectweb.asm.tree.ClassNode; |
| 27 | +import org.objectweb.asm.tree.MethodNode; |
| 28 | + |
| 29 | +public class NonUpdateTransformer implements IClassNodeTransformer { |
| 30 | + @Override |
| 31 | + public String getName() { |
| 32 | + return "NonUpdateTransformer"; |
| 33 | + } |
| 34 | + |
| 35 | + @Override |
| 36 | + public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) { |
| 37 | + return "moe.mickey.forge.nonupdate.NonUpdate".equals(transformedName); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public void transform(ClassNode cn, String transformedName, boolean obfuscated) { |
| 42 | + MethodNode toRemove = null; |
| 43 | + for (val method: cn.methods) { |
| 44 | + if (method.name.equals("init")) { |
| 45 | + toRemove = method; |
| 46 | + break; |
| 47 | + } |
| 48 | + } |
| 49 | + cn.methods.remove(toRemove); |
| 50 | + } |
| 51 | +} |
0 commit comments