|
@ -4,43 +4,51 @@ |
|
|
|
|
|
|
|
|
package com.entryrise.coupons.listeners; |
|
|
package com.entryrise.coupons.listeners; |
|
|
|
|
|
|
|
|
import org.bukkit.event.inventory.InventoryDragEvent; |
|
|
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent; |
|
|
|
|
|
import org.bukkit.event.EventPriority; |
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player; |
|
|
import org.bukkit.event.EventHandler; |
|
|
import org.bukkit.event.EventHandler; |
|
|
|
|
|
import org.bukkit.event.EventPriority; |
|
|
|
|
|
import org.bukkit.event.Listener; |
|
|
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent; |
|
|
|
|
|
import org.bukkit.event.inventory.InventoryDragEvent; |
|
|
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent; |
|
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent; |
|
|
import org.bukkit.inventory.ItemStack; |
|
|
import org.bukkit.inventory.ItemStack; |
|
|
import org.bukkit.entity.Player; |
|
|
|
|
|
|
|
|
|
|
|
import com.entryrise.coupons.Data; |
|
|
import com.entryrise.coupons.Data; |
|
|
import org.bukkit.event.block.Action; |
|
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent; |
|
|
|
|
|
import org.bukkit.event.Listener; |
|
|
|
|
|
|
|
|
|
|
|
public class CouponListener implements Listener |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
public class CouponListener implements Listener { |
|
|
@EventHandler(priority = EventPriority.HIGHEST) |
|
|
@EventHandler(priority = EventPriority.HIGHEST) |
|
|
public void onCouponInteract(final PlayerInteractEvent e) { |
|
|
|
|
|
|
|
|
public void onCouponInteract(PlayerInteractEvent e) { |
|
|
final Player p = e.getPlayer(); |
|
|
final Player p = e.getPlayer(); |
|
|
final ItemStack itm = e.getItem(); |
|
|
final ItemStack itm = e.getItem(); |
|
|
if (e.getAction() != Action.RIGHT_CLICK_AIR) { |
|
|
|
|
|
|
|
|
if (e.getAction().toString().contains("RIGHT_CLICK")) { |
|
|
|
|
|
e.setCancelled(true); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
Data.couponAction(p, itm, true); |
|
|
Data.couponAction(p, itm, true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
|
|
public void onGUIClick(final InventoryClickEvent e) { |
|
|
|
|
|
final Player p = (Player)e.getWhoClicked(); |
|
|
|
|
|
|
|
|
public void onGUIClick(InventoryClickEvent e) { |
|
|
|
|
|
final Player p = (Player) e.getWhoClicked(); |
|
|
final ItemStack itm = e.getCurrentItem(); |
|
|
final ItemStack itm = e.getCurrentItem(); |
|
|
Data.couponAction(p, itm, false); |
|
|
Data.couponAction(p, itm, false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
|
|
public void onGUIDrag(final InventoryDragEvent e) { |
|
|
|
|
|
final Player p = (Player)e.getWhoClicked(); |
|
|
|
|
|
|
|
|
public void onGUIDrag(InventoryDragEvent e) { |
|
|
|
|
|
final Player p = (Player) e.getWhoClicked(); |
|
|
final ItemStack itm = e.getOldCursor(); |
|
|
final ItemStack itm = e.getOldCursor(); |
|
|
if (Data.couponAction(p, itm, false)) { |
|
|
if (Data.couponAction(p, itm, false)) { |
|
|
e.setCancelled(true); |
|
|
e.setCancelled(true); |
|
|
e.setCursor((ItemStack)null); |
|
|
|
|
|
|
|
|
e.setCursor((ItemStack) null); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
|
|
|
|
|
public void onGUIDrag(PlayerDropItemEvent e) { |
|
|
|
|
|
if (Data.couponAction(e.getPlayer(), e.getItemDrop().getItemStack(), false)) { |
|
|
|
|
|
e.getItemDrop().remove(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|