Add a progress helper
This commit is contained in:
parent
150027f1cd
commit
c6d83e67d5
2 changed files with 39 additions and 1 deletions
|
@ -12,7 +12,7 @@ plugins {
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.1.3"
|
version = "1.1.4"
|
||||||
group = "dev.zontreck"
|
group = "dev.zontreck"
|
||||||
archivesBaseName = "LibAC"
|
archivesBaseName = "LibAC"
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
|
38
src/main/java/dev/zontreck/ariaslib/util/Progress.java
Normal file
38
src/main/java/dev/zontreck/ariaslib/util/Progress.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package dev.zontreck.ariaslib.util;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class Progress
|
||||||
|
{
|
||||||
|
private int maximum;
|
||||||
|
private int current;
|
||||||
|
private AtomicInteger tickNum = new AtomicInteger(0);
|
||||||
|
private static final String TICKS="-\\|/";
|
||||||
|
|
||||||
|
public String getSpinnerTick()
|
||||||
|
{
|
||||||
|
if(tickNum.get()>=TICKS.length()) tickNum.set(0);
|
||||||
|
|
||||||
|
return "[ " + TICKS.substring(tickNum.getAndIncrement(), tickNum.get()) + " ]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Progress(int maximum)
|
||||||
|
{
|
||||||
|
current=0;
|
||||||
|
this.maximum=maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPercent(){
|
||||||
|
return (current*100/maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPercentStr()
|
||||||
|
{
|
||||||
|
return (getPercent()+"%");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPercentOf(int current, int max)
|
||||||
|
{
|
||||||
|
return (current*100/max);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue