Pass InventoryDragEvent to GUI menu

This commit is contained in:
fullwall 2021-04-15 23:25:13 +08:00
parent 3ad450b1be
commit 3c1d48137d
2 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -62,6 +63,13 @@ public class EquipmentEditor extends Editor {
} }
} }
@EventHandler
public void onInventoryClick(InventoryDragEvent event) {
if (menu != null && event.getWhoClicked().equals(player)) {
menu.onInventoryDrag(event);
}
}
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
if (menu != null && event.getPlayer().equals(player)) { if (menu != null && event.getPlayer().equals(player)) {

View File

@ -41,7 +41,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
private boolean canAttack() { private boolean canAttack() {
BoundingBox handleBB = NMS.getBoundingBox(handle), targetBB = NMS.getBoundingBox(target); BoundingBox handleBB = NMS.getBoundingBox(handle), targetBB = NMS.getBoundingBox(target);
return attackTicks == 0 && (handleBB.maxY > targetBB.minY && handleBB.minY < targetBB.maxY) return attackTicks <= 0 && (handleBB.maxY > targetBB.minY && handleBB.minY < targetBB.maxY)
&& closeEnough(distanceSquared()) && hasLineOfSight(); && closeEnough(distanceSquared()) && hasLineOfSight();
} }