Skip to content

Commit

Permalink
add gamemode check in ItemUtils#removeItem
Browse files Browse the repository at this point in the history
  • Loading branch information
shradinx committed Nov 2, 2024
1 parent 8687a62 commit 835afa3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vindicterra.vindicterralib.entities.players;

import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand All @@ -13,7 +14,10 @@ public class ItemUtils {
*
* @return True if item was successfully removed, otherwise false
*/
public static boolean removeItem(Player player, Material material, int amount) {
public static boolean removeItem(Player player, Material material, int amount, boolean checkGamemode) {
if (checkGamemode && player.getGameMode().equals(GameMode.CREATIVE)) {
return false;
}
int index = player.getInventory().first(material);
if (index == -1) return false;
ItemStack first = player.getInventory().getItem(index);
Expand Down

0 comments on commit 835afa3

Please sign in to comment.