mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Fix PanelListenerManager tests.
Added JavaDoc and adjusted boolean method name.
This commit is contained in:
parent
21601089f4
commit
e5cfab50f7
@ -1485,10 +1485,17 @@ public class Settings implements DataObject, WorldSettings {
|
||||
this.worldFlags = worldFlags;
|
||||
}
|
||||
|
||||
public boolean getClosePanelOnClickOutside() {
|
||||
/**
|
||||
* @return whether panels should close when clicked outside or not
|
||||
*/
|
||||
public boolean isClosePanelOnClickOutside() {
|
||||
return closePanelOnClickOutside;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set panel close on click outside
|
||||
* @param closePanelOnClickOutside
|
||||
*/
|
||||
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
|
||||
this.closePanelOnClickOutside = closePanelOnClickOutside;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class PanelListenerManager implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
// Close inventory if clicked outside and if setting is true
|
||||
if (BSkyBlock.getInstance().getSettings().getClosePanelOnClickOutside() && event.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||
if (BSkyBlock.getInstance().getSettings().isClosePanelOnClickOutside() && event.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
@ -25,19 +26,28 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.Settings;
|
||||
import us.tastybento.bskyblock.api.panels.Panel;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem.ClickHandler;
|
||||
import us.tastybento.bskyblock.api.panels.PanelListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
* Test class for PanelListenerManager.java
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BSkyBlock.class, Util.class, Bukkit.class })
|
||||
public class PanelListenerManagerTest {
|
||||
|
||||
private Player player;
|
||||
@ -52,12 +62,21 @@ public class PanelListenerManagerTest {
|
||||
private Inventory anotherInv;
|
||||
private PanelListener pl;
|
||||
private ClickHandler ch;
|
||||
private Settings settings;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
BSkyBlock plugin = mock(BSkyBlock.class);
|
||||
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
|
||||
// Settings
|
||||
settings = mock(Settings.class);
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
when(settings.isClosePanelOnClickOutside()).thenReturn(true);
|
||||
|
||||
uuid = UUID.randomUUID();
|
||||
player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user