Skip to content

Commit

Permalink
Fixed logic with index out of bound clicking
Browse files Browse the repository at this point in the history
Fixed logic with index out of bound clicking, should now be handled by
the trident listener instead. If the item is out of bounds then we
should just pass an itemwrapper with a null itemstack and then the
trident listener handles the code correctly.
  • Loading branch information
virustotalop committed Jan 27, 2019
1 parent 900022a commit fd9e277
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.clubobsidian.dynamicgui.listener.bukkit;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -39,21 +38,18 @@ public class InventoryClickListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
if(e.getInventory() == null)
Inventory inventory = e.getInventory();
if(inventory == null)
return;

int slot = e.getSlot();
if(e.getSlot() < 0 || e.getSlot() > e.getInventory().getSize() && e.getClick() != ClickType.CREATIVE)
{
return;
}

int slot = e.getSlot();
int rawSlot = e.getRawSlot();
InventoryView view = InventoryView.TOP;
if(e.getRawSlot() >= e.getInventory().getSize())
if(rawSlot >= e.getInventory().getSize())
{
view = InventoryView.BOTTOM;
}

if(e.getWhoClicked() instanceof Player)
{
Click clickType = null;
Expand All @@ -63,9 +59,14 @@ public void onInventoryClick(InventoryClickEvent e)
}

Player player = (Player) e.getWhoClicked();
InventoryWrapper<?> inventoryWrapper = new BukkitInventoryWrapper<Inventory>(e.getInventory());
InventoryWrapper<?> inventoryWrapper = new BukkitInventoryWrapper<Inventory>(inventory);
PlayerWrapper<?> playerWrapper = new BukkitPlayerWrapper<Player>(player);
ItemStack itemStack = e.getInventory().getItem(slot);
ItemStack itemStack = null;
if(slot > 0 && slot < inventory.getSize())
{
itemStack = e.getInventory().getItem(slot);
}

ItemStackWrapper<?> itemStackWrapper = null;
if(itemStack == null)
{
Expand Down

0 comments on commit fd9e277

Please sign in to comment.