Skip to content

Commit

Permalink
Run InventoryView interactions through inventory-access
Browse files Browse the repository at this point in the history
InventoryView was changed from class to interface, which use different bytecode instructions for invoking methods. This ABI-breaking change is intended to be resolved by Spigot's "Commodore", but these bytecode modifications are not applied in all cases, such as when using InvUI in a Paper plugin. Moving all interactions with InventoryView to inventory-access fixes this.
  • Loading branch information
NichtStudioCode committed Jul 6, 2024
1 parent 66fe68b commit d64b4eb
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -83,4 +85,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_19_R2.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_19_R3.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_20_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_20_R2.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_20_R3.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_20_R4.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -83,4 +85,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_21_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -83,4 +85,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -60,4 +62,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.craftbukkit.v1_16_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -61,4 +63,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.craftbukkit.v1_16_R2.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -61,4 +63,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -61,4 +63,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
entityPlayer.updateInventory(container);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.inventoryaccess.abstraction.util.InventoryUtils;
Expand Down Expand Up @@ -70,4 +72,9 @@ public void updateOpenInventoryTitle(@NotNull Player player, @NotNull ComponentW
serverPlayer.initMenu(menu);
}

@Override
public @Nullable ItemStack getItemStackFromView(@NotNull InventoryView view, int slot) {
return view.getItem(slot);
}

}
Loading

0 comments on commit d64b4eb

Please sign in to comment.