mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-02 16:49:10 +00:00
Merged unique code into Timer
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package org.parabot.environment.api.utils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* Functions frequently used for displaying data on paints
|
||||
*
|
||||
* @author AlexanderBielen
|
||||
*/
|
||||
public class PaintUtil {
|
||||
|
||||
/**
|
||||
* Calculates how much given variable has gained per hour
|
||||
*
|
||||
* @param currentAmount total gained amount
|
||||
* @param start time from which to start counting in milliseconds
|
||||
* @return rate per hour
|
||||
*/
|
||||
public static long calculatePerHour(int currentAmount, long start) {
|
||||
return calculatePerHour(currentAmount, 0, start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates how much given variable has gained per hour, with variable start amount
|
||||
*
|
||||
* @param currentAmount total gained amount
|
||||
* @param startAmount start amount
|
||||
* @param start time from which to start counting in milliseconds
|
||||
* @return rate per hour
|
||||
*/
|
||||
public static long calculatePerHour(int currentAmount, int startAmount, long start) {
|
||||
return (int)(((double)(currentAmount - startAmount) * 3600000D) / (double)(System.currentTimeMillis() - start));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a time difference from given timestamp till present into readable hh:mm:ss format
|
||||
*
|
||||
* @param start start time in milliseconds
|
||||
* @return readable timestamp
|
||||
*/
|
||||
public static String formatRunTime(long start) {
|
||||
DecimalFormat df = new DecimalFormat("00");
|
||||
long currentTime = System.currentTimeMillis() - start;
|
||||
long hours = currentTime / (3600000);
|
||||
currentTime -= hours * (3600000);
|
||||
long minutes = currentTime / (60000);
|
||||
currentTime -= minutes * (60000);
|
||||
long seconds = currentTime / (1000);
|
||||
return df.format(hours) + ":" + df.format(minutes) + ":" + df.format(seconds);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,18 @@ public class Timer {
|
||||
* @return hourly gains
|
||||
*/
|
||||
public int getPerHour(final int gained) {
|
||||
return (int) ((gained) * 3600000D / (System.currentTimeMillis() - start));
|
||||
return getPerHour(gained, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates hourly gains based on given variable, with variable start amount
|
||||
*
|
||||
* @param gained total gained amount
|
||||
* @param startAmount start amount
|
||||
* @return hourly gains
|
||||
*/
|
||||
public int getPerHour(final int gained, int startAmount) {
|
||||
return (int) (((gained - startAmount) * 3600000D) / (System.currentTimeMillis() - start));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user