-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ItemUtils.java to know if an item is modded and get the modded …
…item that come with that itemStack
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package xyz.prismenetwork.kelpmodloader.Item; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
import xyz.prismenetwork.kelpmodloader.Constant; | ||
|
||
public class ItemUtils { | ||
public static boolean isModed(ItemStack itemStack) { | ||
if (itemStack.hasItemMeta()) { | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
if (itemMeta.getCustomModelData() - 1 != 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static ModdedItem getModedItem(ItemStack itemStack) { | ||
if (itemStack.hasItemMeta()) { | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
assert itemMeta != null; | ||
if (itemMeta.getCustomModelData() - 1 != 0) { | ||
for (int i = 0; i < Constant.Items.size(); i++) { | ||
ModdedItem item = Constant.Items.get(i); | ||
if (itemMeta.getCustomModelData() == item.getId() - 1 && itemStack.getType() == item.ItemMaterial) { | ||
return item; | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |