Added option to close panel on click outside of it

This is related to commit #8d596c5f1d24ea2e319e5172b2c954a8caa46f67
This commit is contained in:
Florian CUNY 2018-06-11 12:19:14 +02:00
parent 9202cacb12
commit 63dd2d95b2
2 changed files with 15 additions and 4 deletions

View File

@ -412,6 +412,9 @@ public class Settings implements DataObject, WorldSettings {
@ConfigEntry(path = "island.require-confirmation.leave-wait")
private long leaveWait = 10L;
@ConfigEntry(path = "panel.close-on-click-outside")
private boolean closePanelOnClickOutside = true;
private String uniqueId = "config";
// Getters and setters
@ -1482,4 +1485,12 @@ public class Settings implements DataObject, WorldSettings {
this.worldFlags = worldFlags;
}
public boolean getClosePanelOnClickOutside() {
return closePanelOnClickOutside;
}
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
this.closePanelOnClickOutside = closePanelOnClickOutside;
}
}

View File

@ -13,6 +13,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.panels.Panel;
import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.user.User;
@ -23,13 +24,12 @@ public class PanelListenerManager implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event) {
// Close inventory if clicked outside
if (event.getSlotType().equals(SlotType.OUTSIDE)) {
// Close inventory if clicked outside and if setting is true
if (BSkyBlock.getInstance().getSettings().getClosePanelOnClickOutside() && event.getSlotType().equals(SlotType.OUTSIDE)) {
event.getWhoClicked().closeInventory();
return;
}
User user = User.getInstance(event.getWhoClicked()); // The player that
// clicked the item
User user = User.getInstance(event.getWhoClicked()); // The player that clicked the item
Inventory inventory = event.getInventory(); // The inventory that was
// Open the inventory panel that this player has open (they can only ever have one)
if (openPanels.containsKey(user.getUniqueId())) {