Skip to content

Commit

Permalink
added a lock when clicking on an item in the inventory, thereby preve…
Browse files Browse the repository at this point in the history
…nting unauthorized players from moving items in the inventory
  • Loading branch information
DenisIndenbom committed Dec 22, 2021
1 parent 6328a8a commit e2aaa97
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.entity.EntityType;

import org.bukkit.event.inventory.InventoryClickEvent;

import org.bukkit.scheduler.BukkitRunnable;

import com.denisindenbom.cyberauth.CyberAuth;
Expand Down Expand Up @@ -128,6 +130,15 @@ public void onPlayerItemDamage(@NotNull PlayerItemDamageEvent event)
if (!userIsAuth(event.getPlayer())) event.setCancelled(true);
}

@EventHandler
void onPlayerUseInventory(@NotNull InventoryClickEvent event)
{
if (!(event.getWhoClicked() instanceof Player)) return;

// check that player is authorized
if (!userIsAuth((Player) event.getWhoClicked())) event.setCancelled(true);
}

@EventHandler
public void onPlayerPickupItem(@NotNull EntityPickupItemEvent event)
{
Expand Down

0 comments on commit e2aaa97

Please sign in to comment.