-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from 3arthqu4ke/progressbar
Added progress bar for downloads
- Loading branch information
Showing
15 changed files
with
265 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
headlessmc-api/src/main/java/me/earth/headlessmc/api/command/line/Progressbar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.earth.headlessmc.api.command.line; | ||
|
||
import lombok.Data; | ||
|
||
public interface Progressbar extends AutoCloseable { | ||
void stepBy(long n); | ||
|
||
void stepTo(long n); | ||
|
||
void step(); | ||
|
||
void maxHint(long n); | ||
|
||
boolean isDummy(); | ||
|
||
@Override | ||
void close(); | ||
|
||
static Progressbar dummy() { | ||
return new Progressbar() { | ||
@Override | ||
public void close() { | ||
|
||
} | ||
|
||
@Override | ||
public void stepBy(long n) { | ||
|
||
} | ||
|
||
@Override | ||
public void stepTo(long n) { | ||
|
||
} | ||
|
||
@Override | ||
public void step() { | ||
|
||
} | ||
|
||
@Override | ||
public void maxHint(long n) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isDummy() { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
@Data | ||
class Configuration { | ||
private final String taskName; | ||
private final long initialMax; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
dependencies { | ||
api project(':headlessmc-api') | ||
api 'org.jline:jline:3.26.3' | ||
api ('me.tongfei:progressbar:0.9.5') { | ||
exclude module: 'jline' | ||
} | ||
implementation 'net.java.dev.jna:jna:5.14.0' | ||
// TODO: maybe also package jansi for testing? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
headlessmc-jline/src/main/java/me/earth/headlessmc/jline/JlineProgressbar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.earth.headlessmc.jline; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import me.earth.headlessmc.api.command.line.Progressbar; | ||
import me.tongfei.progressbar.ProgressBar; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class JlineProgressbar implements Progressbar { | ||
private final ProgressBar progressBar; | ||
|
||
@Override | ||
public void stepBy(long n) { | ||
progressBar.stepBy(n); | ||
} | ||
|
||
@Override | ||
public void stepTo(long n) { | ||
progressBar.stepTo(n); | ||
} | ||
|
||
@Override | ||
public void step() { | ||
progressBar.step(); | ||
} | ||
|
||
@Override | ||
public void maxHint(long n) { | ||
progressBar.maxHint(n); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
progressBar.close(); | ||
} | ||
|
||
@Override | ||
public boolean isDummy() { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.