String getEstimatedRunTimeRemaining(boolean inSeconds)
	{
		// Calculate the amount of energy lost every tick.
		// Negative weight has the same depletion effect as 0 kg. >64kg counts as 64kg.
		final int effectiveWeight = Math.min(Math.max(client.getWeight(), 0), 64);

		// 100% energy is 10000 energy units
		int energyUnitsLost = effectiveWeight * 67 / 64 + 67;

		if (client.getVarbitValue(Varbits.RUN_SLOWED_DEPLETION_ACTIVE) != 0)
		{
			energyUnitsLost *= 0.3; // Stamina effect reduces energy depletion to 30%
		}
		else if (isRingOfEnduranceEquipped()) // Ring of Endurance passive effect does not stack with stamina potion
		{
			Integer charges = getRingOfEnduranceCharges();
			if (charges == null)
			{
				return "?";
			}

			if (charges >= RING_OF_ENDURANCE_PASSIVE_EFFECT)
			{
				energyUnitsLost *= 0.85; // Ring of Endurance passive effect reduces energy depletion to 85%
			}
		}

		// Math.ceil is correct here - only need 1 energy unit to run
		final double ticksLeft = Math.ceil(client.getEnergy() / (double) energyUnitsLost);
		final double secondsLeft = ticksLeft * Constants.GAME_TICK_LENGTH / 1000.0;

		// Return the text
		if (inSeconds)
		{
			return (int) Math.floor(secondsLeft) + "s";
		}
		else
		{
			final int minutes = (int) Math.floor(secondsLeft / 60.0);
			final int seconds = (int) Math.floor(secondsLeft - (minutes * 60.0));
			return minutes + ":" + StringUtils.leftPad(Integer.toString(seconds), 2, "0");
		}
	}
@Test
	public void testEstimatedRuntimeRemaining()
	{
		ItemContainer equipment = mock(ItemContainer.class);
		when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipment);
		when(equipment.count(RING_OF_ENDURANCE)).thenReturn(1);
		when(client.getVarbitValue(Varbits.RUN_SLOWED_DEPLETION_ACTIVE)).thenReturn(1);
		when(client.getEnergy()).thenReturn(10000);
		assertEquals("300s", runEnergyPlugin.getEstimatedRunTimeRemaining(true));

		when(client.getVarbitValue(Varbits.RUN_SLOWED_DEPLETION_ACTIVE)).thenReturn(0);
		when(configManager.getRSProfileConfiguration(RunEnergyConfig.GROUP_NAME, "ringOfEnduranceCharges", Integer.class)).thenReturn(512);
		assertEquals("1:47", runEnergyPlugin.getEstimatedRunTimeRemaining(false));
	}