mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-19 14:41:44 +01:00
Made CycleClick handle right click
This commit is contained in:
parent
d7b2c70b78
commit
08e11e90fa
@ -21,7 +21,6 @@ public class CycleClick implements PanelItem.ClickHandler {
|
|||||||
private BSkyBlock plugin = BSkyBlock.getInstance();
|
private BSkyBlock plugin = BSkyBlock.getInstance();
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id - the flag id that will be adjusted by this click
|
* @param id - the flag id that will be adjusted by this click
|
||||||
*/
|
*/
|
||||||
@ -46,6 +45,13 @@ public class CycleClick implements PanelItem.ClickHandler {
|
|||||||
island.setFlag(flag, rm.getRankUpValue(currentRank));
|
island.setFlag(flag, rm.getRankUpValue(currentRank));
|
||||||
}
|
}
|
||||||
user.getWorld().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
user.getWorld().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
||||||
|
} else if (click.equals(ClickType.RIGHT)) {
|
||||||
|
if (currentRank == RanksManager.VISITOR_RANK) {
|
||||||
|
island.setFlag(flag, RanksManager.OWNER_RANK);
|
||||||
|
} else {
|
||||||
|
island.setFlag(flag, rm.getRankDownValue(currentRank));
|
||||||
|
}
|
||||||
|
user.getWorld().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
||||||
}
|
}
|
||||||
// Apply change to panel
|
// Apply change to panel
|
||||||
panel.getInventory().setItem(slot, flag.toPanelItem(plugin, user).getItem());
|
panel.getInventory().setItem(slot, flag.toPanelItem(plugin, user).getItem());
|
||||||
|
@ -208,10 +208,21 @@ public class CycleClickTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnRightClick() {
|
public void testOnRightClick() {
|
||||||
|
final int SLOT = 5;
|
||||||
CycleClick udc = new CycleClick("LOCK");
|
CycleClick udc = new CycleClick("LOCK");
|
||||||
// Right click - should do nothing
|
// Rank starts at member
|
||||||
assertTrue(udc.onClick(panel, user, ClickType.RIGHT, 0));
|
// Right click
|
||||||
Mockito.verify(island, Mockito.never()).setFlag(Mockito.eq(flag), Mockito.anyInt());
|
assertTrue(udc.onClick(panel, user, ClickType.RIGHT, SLOT));
|
||||||
|
Mockito.verify(island).setFlag(Mockito.eq(flag), Mockito.eq(RanksManager.VISITOR_RANK));
|
||||||
|
Mockito.verify(flag).toPanelItem(Mockito.any(), Mockito.any());
|
||||||
|
Mockito.verify(inv).setItem(Mockito.eq(SLOT), Mockito.any());
|
||||||
|
// Check rollover
|
||||||
|
// Clicking when Visitor should go to Owner
|
||||||
|
when(island.getFlag(Mockito.any())).thenReturn(RanksManager.VISITOR_RANK);
|
||||||
|
assertTrue(udc.onClick(panel, user, ClickType.RIGHT, SLOT));
|
||||||
|
Mockito.verify(island).setFlag(Mockito.eq(flag), Mockito.eq(RanksManager.OWNER_RANK));
|
||||||
|
Mockito.verify(flag, Mockito.times(2)).toPanelItem(Mockito.any(), Mockito.any());
|
||||||
|
Mockito.verify(inv, Mockito.times(2)).setItem(Mockito.eq(SLOT), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user