@Override public Entity createEntity(World world, Entity location, ItemStack stack) { if (SecurityHelper.isSecure(stack)) { location.invulnerable = true; location.isImmuneToFire = true; ((EntityItem) location).lifespan = Integer.MAX_VALUE; } return null; }
@Override public Entity createEntity(World world, Entity location, ItemStack stack) { if (SecurityHelper.isSecure(stack)) { location.invulnerable = true; location.isImmuneToFire = true; ((EntityItem) location).lifespan = Integer.MAX_VALUE; } return null; }
@Override public boolean hasCustomEntity(ItemStack stack) { return SecurityHelper.isSecure(stack); }
@Override public boolean hasCustomEntity(ItemStack stack) { return SecurityHelper.isSecure(stack); }
public static FontRenderer loadFontRendererStack(ItemStack stack) { if (SecurityHelper.isSecure(stack)) { return RenderPlayerFace.loadProfile(stack); } return ProxyClient.fontRenderer; }
public static boolean setAccess(ItemStack stack, AccessMode access) { if (!isSecure(stack)) { return false; } stack.getTagCompound().setByte("Access", (byte) access.ordinal()); return true; }
public static boolean setOwner(ItemStack stack, GameProfile name) { if (!isSecure(stack)) { return false; } stack.setTagInfo("OwnerUUID", new NBTTagString(name.getId().toString())); stack.setTagInfo("Owner", new NBTTagString(name.getName())); return true; }
@Override @Nonnull public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) { ItemStack inputStack = ItemStack.EMPTY; ItemStack outputStack = output.copy(); for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { if (stack.getItem() instanceof INBTCopyIngredient) { inputStack = stack; } } } if (inputStack.isEmpty() || SecurityHelper.isSecure(inputStack)) { return ItemStack.EMPTY; } outputStack = ItemHelper.copyTag(outputStack, inputStack); return SecurityHelper.setSecure(outputStack); }
/** * Adds Security information to ItemStacks. */ public static void addOwnerInformation(ItemStack stack, List<String> list) { if (SecurityHelper.isSecure(stack)) { boolean hasUUID = stack.getTagCompound().hasKey("OwnerUUID"); if (!stack.getTagCompound().hasKey("Owner") && !hasUUID) { list.add(StringHelper.localize("info.cofh.owner") + ": " + StringHelper.localize("info.cofh.none")); } else { if (hasUUID && stack.getTagCompound().hasKey("Owner")) { list.add(StringHelper.localize("info.cofh.owner") + ": " + stack.getTagCompound().getString("Owner") + " \u0378"); } else { list.add(StringHelper.localize("info.cofh.owner") + ": " + StringHelper.localize("info.cofh.anotherplayer")); } } } }
public static ItemStack setSecure(ItemStack stack) { if (isSecure(stack)) { return stack; } if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setBoolean("Secure", true); stack.getTagCompound().setByte("Access", (byte) 0); return stack; }
public static void addAccessInformation(ItemStack stack, List<String> list) { if (SecurityHelper.isSecure(stack)) { String accessString = ""; switch (ISecurable.AccessMode.values()[stack.getTagCompound().getByte("Access")]) { case PUBLIC: accessString = StringHelper.localize("info.cofh.accessPublic"); break; case FRIENDS: accessString = StringHelper.localize("info.cofh.accessRestricted"); break; case TEAM: accessString = StringHelper.localize("info.cofh.accessTeam"); break; case PRIVATE: accessString = StringHelper.localize("info.cofh.accessPrivate"); break; } list.add(StringHelper.localize("info.cofh.access") + ": " + accessString); } }
public GuiSatchelFilter(InventoryPlayer inventory, ContainerSatchelFilter container) { super(container); secure = SecurityHelper.isSecure(container.getFilterStack()); playerName = SecurityHelper.getID(inventory.player); filterIndex = ItemSatchel.getLevel(container.getFilterStack()); texture = CoreProps.TEXTURE_FILTER[filterIndex]; texturePath = texture.toString(); name = container.getInventoryName(); allowUserInput = false; xSize = 176; generateInfo("tab.thermalexpansion.storage.satchel_filter"); }
public static boolean canPlayerAccess(ItemStack stack, EntityPlayer player) { if (!SecurityHelper.isSecure(stack)) { return true; } String name = player.getName(); AccessMode access = SecurityHelper.getAccess(stack); if (access.isPublic() || (CoreProps.enableOpSecureAccess && CoreUtils.isOp(name))) { return true; } GameProfile profile = SecurityHelper.getOwner(stack); UUID ownerID = profile.getId(); if (SecurityHelper.isDefaultUUID(ownerID)) { return true; } UUID otherID = SecurityHelper.getID(player); return ownerID.equals(otherID) || access.isFriendsOnly() && RegistrySocial.playerHasAccess(name, profile); }
public static ItemStack removeSecure(ItemStack stack) { if (!isSecure(stack)) { return stack; } stack.getTagCompound().removeTag("Secure"); stack.getTagCompound().removeTag("Access"); stack.getTagCompound().removeTag("OwnerUUID"); stack.getTagCompound().removeTag("Owner"); if (stack.getTagCompound().hasNoTags()) { stack.setTagCompound(null); } return stack; }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (CoreUtils.isFakePlayer(player) || hand != EnumHand.MAIN_HAND) { return new ActionResult<>(EnumActionResult.FAIL, stack); } if (needsTag(stack)) { setDefaultInventoryTag(stack); } if (ServerHelper.isServerWorld(world)) { if (SecurityHelper.isSecure(stack) && SecurityHelper.isDefaultUUID(SecurityHelper.getOwner(stack).getId())) { SecurityHelper.setOwner(stack, player.getGameProfile()); ChatHelper.sendIndexedChatMessageToPlayer(player, new TextComponentTranslation("chat.cofh.secure.item.success")); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } if (canPlayerAccess(stack, player)) { if (player.isSneaking() && ItemHelper.getItemDamage(stack) != CREATIVE) { player.openGui(ThermalExpansion.instance, GuiHandler.SATCHEL_FILTER_ID, world, 0, 0, 0); } else { player.openGui(ThermalExpansion.instance, GuiHandler.SATCHEL_ID, world, 0, 0, 0); } } else if (SecurityHelper.isSecure(stack)) { ChatHelper.sendIndexedChatMessageToPlayer(player, new TextComponentTranslation("chat.cofh.secure.warning", SecurityHelper.getOwnerName(stack))); return new ActionResult<>(EnumActionResult.FAIL, stack); } } return new ActionResult<>(EnumActionResult.SUCCESS, stack); }
public GuiSatchel(InventoryPlayer inventory, ContainerSatchel container) { super(container); isCreative = ItemSatchel.isCreative(container.getContainerStack()); isVoid = ItemSatchel.isVoid(container.getContainerStack()); secure = SecurityHelper.isSecure(container.getContainerStack()); playerName = SecurityHelper.getID(inventory.player); storageIndex = ItemSatchel.getStorageIndex(container.getContainerStack()); texture = CoreProps.TEXTURE_STORAGE[storageIndex]; name = container.getInventoryName(); allowUserInput = false; xSize = 14 + 18 * MathHelper.clamp(storageIndex, 9, 14); ySize = 112 + 18 * MathHelper.clamp(storageIndex, 2, 9); if (isCreative) { generateInfo("tab.thermalexpansion.storage.satchel_c"); } else if (isVoid) { generateInfo("tab.thermalexpansion.storage.satchel_v"); } else { generateInfo("tab.thermalexpansion.storage.satchel"); } if (container.getContainerStack().isItemEnchantable() && !ItemSatchel.hasHoldingEnchant(container.getContainerStack())) { myInfo += "\n\n" + StringHelper.localize("tab.thermalexpansion.storage.enchant"); } }
if (SecurityHelper.isSecure(stack)) { GameProfile stackOwner = SecurityHelper.getOwner(stack);