Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 6c855b4

Browse files
committed
InfernalMobs patch, close #2
1 parent 9837135 commit 6c855b4

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--- EventListener.java 2016-09-23 17:51:38.465887570 -0500
2+
+++ EventListenerDump.java 2016-09-23 17:40:57.633407594 -0500
3+
@@ -1,8 +1,11 @@
4+
-package asm.io.hotmail.com.jacob_vejvoda.infernal_mobs;
5+
import java.util.*;
6+
import org.objectweb.asm.*;
7+
public class EventListenerDump implements Opcodes {
8+
9+
+public static void main(String[] args) throws Exception{
10+
+ System.out.write(dump());
11+
+}
12+
+
13+
public static byte[] dump () throws Exception {
14+
15+
ClassWriter cw = new ClassWriter(0);
16+
@@ -1255,15 +1258,10 @@
17+
mv.visitInsn(ICONST_1);
18+
mv.visitJumpInsn(IF_ICMPNE, l28);
19+
mv.visitVarInsn(ALOAD, 1);
20+
-mv.visitMethodInsn(INVOKEVIRTUAL, "org/bukkit/event/entity/EntityDeathEvent", "getEntity", "()Lorg/bukkit/entity/LivingEntity;", false);
21+
-mv.visitMethodInsn(INVOKEINTERFACE, "org/bukkit/entity/LivingEntity", "getWorld", "()Lorg/bukkit/World;", true);
22+
-mv.visitVarInsn(ALOAD, 6);
23+
+mv.visitMethodInsn(INVOKEVIRTUAL, "org/bukkit/event/entity/EntityDeathEvent", "getDrops", "()Ljava/util/List;", false);
24+
mv.visitVarInsn(ALOAD, 8);
25+
-mv.visitMethodInsn(INVOKEINTERFACE, "org/bukkit/World", "dropItemNaturally", "(Lorg/bukkit/Location;Lorg/bukkit/inventory/ItemStack;)Lorg/bukkit/entity/Item;", true);
26+
-mv.visitVarInsn(ASTORE, 12);
27+
-mv.visitFieldInsn(GETSTATIC, "io/hotmail/com/jacob_vejvoda/infernal_mobs/EventListener", "plugin", "Lio/hotmail/com/jacob_vejvoda/infernal_mobs/infernal_mobs;");
28+
-mv.visitVarInsn(ALOAD, 12);
29+
-mv.visitMethodInsn(INVOKEVIRTUAL, "io/hotmail/com/jacob_vejvoda/infernal_mobs/infernal_mobs", "keepAlive", "(Lorg/bukkit/entity/Item;)V", false);
30+
+mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
31+
+mv.visitInsn(POP);
32+
mv.visitLabel(l28);
33+
mv.visitFrame(Opcodes.F_FULL, 12, new Object[] {"io/hotmail/com/jacob_vejvoda/infernal_mobs/EventListener", "org/bukkit/event/entity/EntityDeathEvent", "java/util/UUID", Opcodes.INTEGER, "java/util/ArrayList", Opcodes.INTEGER, "org/bukkit/Location", "org/bukkit/entity/Player", "org/bukkit/inventory/ItemStack", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER}, 0, new Object[] {});
34+
mv.visitFieldInsn(GETSTATIC, "io/hotmail/com/jacob_vejvoda/infernal_mobs/EventListener", "plugin", "Lio/hotmail/com/jacob_vejvoda/infernal_mobs/infernal_mobs;");

patch-InfernalMob/readme.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
This patch is used to integrate [InfernalMobs](https://www.spigotmc.org/resources/infernal-mobs.2156/) with the loot protect feature in NyaaUtils.
2+
See [discussion](https://github.com/NyaaCat/nyaautils/issues/2)
3+
4+
Prepare:
5+
6+
- Download `asm.jar` and `asm-util.jar` from [http://asm.ow2.org/](http://asm.ow2.org/)
7+
- Download `InfernalMobs.jar`
8+
- Have `patch` installed
9+
- Have `java` and `javac` installed
10+
11+
Steps:
12+
13+
1. Generate the bytecode:
14+
15+
java -classpath "InfernalMobs.jar:asm-util.jar:asm.jar" org.objectweb.asm.util.ASMifier io.hotmail.com.jacob_vejvoda.infernal_mobs.EventListener > EventListenerDump.java
16+
17+
2. Apply the patch
18+
19+
patch EventListenerDump.java < EventListenerDump.patch
20+
21+
3. Compile & generate the class file
22+
23+
javac -cp asm.jar EventListenerDump.java
24+
java -cp asm.jar:. EventListenerDump > EventListener.class
25+
26+
4. Copy the patched class back into `InfernalMobs.jar`

0 commit comments

Comments
 (0)