use of gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException in project Nexus by ProjectEdenGG.
the class Crate method takeKey.
public void takeKey() {
try {
boolean took = false;
ItemStack key = getCrateType().getKey();
for (ItemStack item : player.getInventory().getContents()) {
if (isNullOrAir(item))
continue;
if (ItemUtils.isFuzzyMatch(key, item)) {
item.setAmount(item.getAmount() - 1);
took = true;
break;
}
}
if (!took)
throw new CrateOpeningException("no key present");
} catch (Exception ex) {
throw new CrateOpeningException("You must have a key in your inventory");
}
}
Aggregations