/** * Check whether this player can open an inventory locked with the given LockCode. */ public boolean canOpen(LockCode code) { if (code.isEmpty()) { return true; } else { ItemStack itemstack = this.getCurrentEquippedItem(); return itemstack != null && itemstack.hasDisplayName() ? itemstack.getDisplayName().equals(code.getLock()) : false; } }
@Override public boolean canOpen(LockCode code) { if (m_realPlayer == null) { return super.canOpen(code); } else { syncToRealPlayer(); return syncPublicFieldsFromRealAndReturn(m_realPlayer.canOpen(code)); } }
@Override public boolean canOpen(LockCode code) { if (m_realPlayer == null) { return super.canOpen(code); } else { return m_realPlayer.canOpen(code); } }
/** * Check whether this player can open an inventory locked with the given LockCode. */ public boolean canOpen(LockCode code) { if (code.isEmpty()) { return true; } else { ItemStack itemstack = this.getHeldItemMainhand(); return !itemstack.func_190926_b() && itemstack.hasDisplayName() ? itemstack.getDisplayName().equals(code.getLock()) : false; } }
/** * Check whether this player can open an inventory locked with the given LockCode. */ public boolean canOpen(LockCode code) { if (code.isEmpty()) { return true; } else { ItemStack itemstack = this.getHeldItemMainhand(); return itemstack != null && itemstack.hasDisplayName() ? itemstack.getDisplayName().equals(code.getLock()) : false; } }
@Listener public void onChestOpen(InteractInventoryEvent.Open event, @Root Player player) { Optional<GoldRushInstance> optInst = manager.getApplicableZone(player); if (!optInst.isPresent()) { return; } GoldRushInstance inst = optInst.get(); Inventory inventory = event.getTargetInventory(); if (!inst.isLocked() && inventory instanceof ContainerChest) { IInventory chestInv = ((ContainerChest) inventory).getLowerChestInventory(); if (chestInv instanceof ILockableContainer) { LockCode newLockCode = new LockCode(UUID.randomUUID().toString()); tileEntityClaimMap.put(newLockCode.getLock(), player); ((ILockableContainer) chestInv).setLockCode(newLockCode); BigDecimal risk = Optional.ofNullable( inst.cofferRisk.get(player.getUniqueId()) ).orElse(BigDecimal.ZERO); Collection<org.spongepowered.api.item.inventory.ItemStack> queue = CofferValueMap.inst().satisfy(risk.toBigInteger()); Iterator<org.spongepowered.api.item.inventory.ItemStack> it = queue.iterator(); for (int i = 0; i < chestInv.getSizeInventory(); ++i) { if (it.hasNext()) { chestInv.setInventorySlotContents(i, tf(it.next())); continue; } chestInv.setInventorySlotContents(i, ItemStack.EMPTY); } } } }
public void setLockCode(LockCode code) { }
public LockCode getLockCode() { return LockCode.EMPTY_CODE; }
public void setLockCode(LockCode code) { this.upperChest.setLockCode(code); this.lowerChest.setLockCode(code); }
public LockCode getLockCode() { return this.upperChest.getLockCode(); }
public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.code = LockCode.fromNBT(compound); }
public LockCode getLockCode() { return this.code; }
public void setLockCode(LockCode code) { this.code = code; }