#1414: Convert InventoryView to interface

By: Miles Holder <mwholder2005@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2024-06-16 08:47:38 +10:00
parent 6af115230a
commit d2d0972bc3
4 changed files with 238 additions and 2 deletions

View File

@@ -67,6 +67,10 @@ public class Commodore {
"org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent"
);
private static final Set<String> CLASS_TO_INTERFACE = Set.of(
"org/bukkit/inventory/InventoryView"
);
private static Map<String, RerouteMethodData> createReroutes(Class<?> clazz) {
Map<String, RerouteMethodData> reroutes = RerouteBuilder.buildFromClass(clazz);
REROUTES.add(reroutes);
@@ -288,6 +292,17 @@ public class Commodore {
return;
}
if (CLASS_TO_INTERFACE.contains(owner)) {
if (opcode == Opcodes.INVOKEVIRTUAL) {
opcode = Opcodes.INVOKEINTERFACE;
}
if (opcode == Opcodes.H_INVOKEVIRTUAL) {
opcode = Opcodes.H_INVOKEINTERFACE;
}
itf = true;
}
// SPIGOT-4496
if (owner.equals("org/bukkit/map/MapView") && name.equals("getId") && desc.equals("()S")) {
// Should be same size on stack so just call other method