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); }
@Override public String getOwnerName() { return SecurityHelper.getOwnerName(getContainerStack()); }
@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); }
@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; }
public GuiDynamoBase(Container container, TileEntity tile, EntityPlayer player, ResourceLocation texture) { super(container, texture); baseTile = (TileDynamoBase) tile; name = baseTile.getName(); playerName = SecurityHelper.getID(player); }
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"); }
@Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { SecurityHelper.addOwnerInformation(stack, tooltip); if (StringHelper.displayShiftForDetail && !StringHelper.isShiftKeyDown()) { tooltip.add(StringHelper.shiftForDetails()); } if (!StringHelper.isShiftKeyDown()) { return; } SecurityHelper.addAccessInformation(stack, tooltip); tooltip.add(StringHelper.getInfoText("info.thermalexpansion.storage.strongbox")); // if (isCreative(stack)) { // // } else { // // } ItemHelper.addInventoryInformation(stack, tooltip); }
public boolean canPlayerAccess(EntityPlayer player) { if (!(this instanceof ISecurable)) { return true; } ISecurable.AccessMode access = ((ISecurable) this).getAccess(); String name = player.getName(); if (access.isPublic() || (CoreProps.enableOpSecureAccess && CoreUtils.isOp(name))) { return true; } GameProfile profile = ((ISecurable) this).getOwner(); UUID ownerID = profile.getId(); if (SecurityHelper.isDefaultUUID(ownerID)) { return true; } UUID otherID = SecurityHelper.getID(player); if (ownerID.equals(otherID)) { return true; } return access.isFriendsOnly() && RegistrySocial.playerHasAccess(name, profile); }
@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); }
public static FontRendererCore loadProfile(ItemStack item) { GameProfile profile = SecurityHelper.getOwner(item); if (profile == SecurityHelper.UNKNOWN_GAME_PROFILE) { profile = null; } return setProfile(profile); }
@Override public AccessMode getAccess() { return SecurityHelper.getAccess(getContainerStack()); }
public boolean isSecured() { return !SecurityHelper.isDefaultUUID(owner.getId()); }
@Override public void run() { owner = SecurityHelper.getProfile(owner.getId(), owner.getName()); } }.start();
public static UUID getID(EntityPlayer player) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server != null && server.isServerRunning()) { return player.getGameProfile().getId(); } return getClientId(player); }
@Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { if (StringHelper.displayShiftForDetail && !StringHelper.isShiftKeyDown()) { tooltip.add(StringHelper.shiftForDetails()); } if (!StringHelper.isShiftKeyDown()) { return; } SecurityHelper.addAccessInformation(stack, tooltip); if (isVoid(stack)) { tooltip.add(StringHelper.getInfoText("info.thermalexpansion.satchel.a.v")); tooltip.add(StringHelper.getNoticeText("info.thermalexpansion.satchel.a.2")); tooltip.add(StringHelper.localizeFormat("info.thermalexpansion.satchel.b." + getMode(stack), StringHelper.getKeyName(KeyBindingItemMultiMode.INSTANCE.getKey()))); return; } if (isCreative(stack)) { tooltip.add(StringHelper.getInfoText("info.thermalexpansion.satchel.a.c")); tooltip.add(StringHelper.localize("info.thermalexpansion.satchel.a.1")); ItemHelper.addInventoryInformation(stack, tooltip); return; } tooltip.add(StringHelper.getInfoText("info.thermalexpansion.satchel.a.0")); tooltip.add(StringHelper.localize("info.thermalexpansion.satchel.a.1")); tooltip.add(StringHelper.getNoticeText("info.thermalexpansion.satchel.a.2")); tooltip.add(StringHelper.localizeFormat("info.thermalexpansion.satchel.b." + getMode(stack), StringHelper.getKeyName(KeyBindingItemMultiMode.INSTANCE.getKey()))); ItemHelper.addInventoryInformation(stack, tooltip); }
@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; }
public GuiPoweredBase(Container container, TileEntity tile, EntityPlayer player, ResourceLocation texture) { super(container, texture); baseTile = (TilePowered) tile; name = baseTile.getName(); playerName = SecurityHelper.getID(player); }
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"); } }
@Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { SecurityHelper.addOwnerInformation(stack, tooltip); if (StringHelper.displayShiftForDetail && !StringHelper.isShiftKeyDown()) { tooltip.add(StringHelper.shiftForDetails()); } if (!StringHelper.isShiftKeyDown()) { return; } SecurityHelper.addAccessInformation(stack, tooltip); String name = Type.values()[ItemHelper.getItemDamage(stack)].getName(); tooltip.add(StringHelper.getInfoText("info.thermalexpansion.device." + name)); RedstoneControlHelper.addRSControlInformation(stack, tooltip); }