Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void breakBlock(BlockBreakEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void hopper(InventoryMoveItemEvent event) {
// Custom editions require our insertion lifecycle; vanilla discs retain hopper behavior.
if (studio.discs().custom(event.getItem()) && event.getDestination().getHolder() instanceof Jukebox) {
if (studio.discs().custom(event.getItem()) && event.getDestination().getHolder(false) instanceof Jukebox) {
event.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private ItemStack button(Material material, String title, NamedTextColor color,

@EventHandler
public void click(InventoryClickEvent event) {
if (!(event.getView().getTopInventory().getHolder() instanceof Holder holder)) return;
if (!(event.getView().getTopInventory().getHolder(false) instanceof Holder holder)) return;
// Normal inventory clicks let the player pick up and put down the physical disc.
if (event.getRawSlot() >= holder.inventory.getSize()
&& (event.getClick() == ClickType.LEFT || event.getClick() == ClickType.RIGHT)) return;
Expand Down Expand Up @@ -312,7 +312,7 @@ private void refresh() {

@EventHandler
public void drag(InventoryDragEvent event) {
if (!(event.getView().getTopInventory().getHolder() instanceof Holder holder)) return;
if (!(event.getView().getTopInventory().getHolder(false) instanceof Holder holder)) return;
if (event.getRawSlots().stream().noneMatch(slot -> slot < holder.inventory.getSize())) return;
event.setCancelled(true);
if (holder.screen == Screen.EDITOR && event.getRawSlots().equals(java.util.Set.of(50))
Expand All @@ -334,7 +334,7 @@ public void close() {

// The holder of the player's open container; MockBukkit reports no top inventory when none is open.
private static InventoryHolder open(Player player) {
return player.getOpenInventory().getTopInventory() instanceof Inventory top ? top.getHolder() : null;
return player.getOpenInventory().getTopInventory() instanceof Inventory top ? top.getHolder(false) : null;
}

private static final class Holder implements InventoryHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
void worldLifecycleAndHoppersRespectCustomRecordingPlayback() {
listener.breakBlock(new org.bukkit.event.block.BlockBreakEvent(block, player));
verify(studio).stop(block);
listener.quit(new org.bukkit.event.player.PlayerQuitEvent(player, (net.kyori.adventure.text.Component) null));

Check warning on line 290 in src/test/java/net/tfminecraft/musicalinstruments/studio/StudioListenerTest.java

View workflow job for this annotation

GitHub Actions / build

PlayerQuitEvent(org.bukkit.entity.Player,net.kyori.adventure.text.Component) in org.bukkit.event.player.PlayerQuitEvent has been deprecated and marked for removal
verify(studio).quit(player);
var world = mock(org.bukkit.World.class);
when(world.getUID()).thenReturn(java.util.UUID.randomUUID());
Expand All @@ -300,10 +300,10 @@
verify(studio, times(2)).unload(world.getUID(), 2, 3);
var source = mock(org.bukkit.inventory.Inventory.class);
var destination = mock(org.bukkit.inventory.Inventory.class);
when(destination.getHolder()).thenReturn(box);
when(destination.getHolder(false)).thenReturn(box);
var blocked = new org.bukkit.event.inventory.InventoryMoveItemEvent(source, disc, destination, true);
listener.hopper(blocked); assertTrue(blocked.isCancelled());
when(destination.getHolder()).thenReturn(null);
when(destination.getHolder(false)).thenReturn(null);
var ordinary = new org.bukkit.event.inventory.InventoryMoveItemEvent(source, disc, destination, true);
listener.hopper(ordinary); assertFalse(ordinary.isCancelled());
when(discs.custom(disc)).thenReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void setup() throws Exception {
when(scheduler.runTaskTimer(eq(plugin), any(Runnable.class), eq(10L), eq(10L))).thenReturn(refreshTask);
when(server.createInventory(any(InventoryHolder.class), anyInt(), any(Component.class))).thenAnswer(call -> {
when(inventory.getHolder()).thenReturn(call.getArgument(0));
when(inventory.getHolder(false)).thenReturn(call.getArgument(0));
when(inventory.getSize()).thenReturn(call.getArgument(1));
return inventory;
});
Expand Down