Skip to content

Commit

Permalink
Merge pull request #106 from pupnewfster/sublocks
Browse files Browse the repository at this point in the history
Should complete and close #86
  • Loading branch information
Lanse505 committed May 24, 2018
2 parents c8c1615 + 00bfeed commit 8c46795
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package codersafterdark.reskillable.api.data;

import codersafterdark.reskillable.base.LevelLockHandler;

public interface ParentLockKey extends LockKey {
/**
* Retrieves any sub requirements this key may have.
* This usually can be implemented by calling {@link LevelLockHandler#getLocks(Class, Object[])}
* @return A RequirementHolder of the sub requirements.
*/
RequirementHolder getSubRequirements();
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ public static <T> RequirementHolder getLocks(Class<? extends T> classType, T...
} else if (locks.containsKey(lock)) {
requirements.add(locks.get(lock));
}
if (lock instanceof ParentLockKey) {
RequirementHolder subLocks = ((ParentLockKey) lock).getSubRequirements();
if (subLocks != null && !subLocks.equals(EMPTY_LOCK)) {
requirements.add(subLocks);
}
}
}
}

Expand Down Expand Up @@ -305,9 +311,8 @@ public static void onArmorEquip(LivingEquipmentChangeEvent event) {
if (slot.getSlotType().equals(EntityEquipmentSlot.Type.ARMOR)) {
ItemStack stack = player.inventory.armorInventory.get(slot.getIndex());
if (!canPlayerUseItem(player, stack)) {
ItemStack copy = stack.copy();
if (!player.inventory.addItemStackToInventory(copy)) {
player.dropItem(copy, false);
if (!player.inventory.addItemStackToInventory(stack)) {
player.dropItem(stack, false);
}
player.inventory.armorInventory.set(slot.getIndex(), ItemStack.EMPTY);
tellPlayer(player, stack, MessageLockedItem.MSG_ARMOR_EQUIP_LOCKED);
Expand Down

0 comments on commit 8c46795

Please sign in to comment.