Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Commit

Permalink
Fix cases where other plugins could cancel events but still get Armor…
Browse files Browse the repository at this point in the history
…EquipEvent called.
  • Loading branch information
Arnuh committed Dec 9, 2019
1 parent 47559c4 commit 465be5c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/com/codingforcookies/armorequip/ArmorListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
Expand All @@ -29,8 +30,9 @@ public class ArmorListener implements Listener{
public ArmorListener(List<String> blockedMaterials){
this.blockedMaterials = blockedMaterials;
}
//Event Priority is highest because other plugins might cancel the events before we check.

@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public final void inventoryClick(final InventoryClickEvent e){
boolean shift = false, numberkey = false;
if(e.isCancelled()) return;
Expand Down Expand Up @@ -102,8 +104,8 @@ public final void inventoryClick(final InventoryClickEvent e){
}
}
}

@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void playerInteractEvent(PlayerInteractEvent e){
if(e.getAction() == Action.PHYSICAL) return;
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
Expand All @@ -128,8 +130,8 @@ public void playerInteractEvent(PlayerInteractEvent e){
}
}
}

@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void inventoryDrag(InventoryDragEvent event){
// getType() seems to always be even.
// Old Cursor gives the item you are equipping
Expand Down

0 comments on commit 465be5c

Please sign in to comment.