Cleanup sources

This commit is contained in:
cyberpwn
2021-08-16 18:53:01 -04:00
parent af602a414a
commit a462ab98e9
73 changed files with 1235 additions and 1508 deletions

View File

@@ -26,8 +26,8 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
public class DownloadJob implements Job{
private DL.Download download;
public class DownloadJob implements Job {
private final DL.Download download;
private int tw;
private int cw;
@@ -38,13 +38,9 @@ public class DownloadJob implements Job{
download.monitor(new DownloadMonitor() {
@Override
public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse) {
if(size == -1)
{
if (size == -1) {
tw = 1;
}
else
{
} else {
tw = (int) (size / 100);
cw = (int) (downloaded / 100);
}
@@ -61,8 +57,7 @@ public class DownloadJob implements Job{
public void execute() {
try {
download.start();
while(download.isState(DL.DownloadState.DOWNLOADING))
{
while (download.isState(DL.DownloadState.DOWNLOADING)) {
download.downloadChunk();
}
} catch (IOException e) {

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.scheduling.jobs;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
@@ -26,8 +25,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.util.concurrent.CompletableFuture;
public interface Job
{
public interface Job {
String getName();
void execute();
@@ -36,35 +34,27 @@ public interface Job
int getTotalWork();
default int getWorkRemaining()
{
default int getWorkRemaining() {
return getTotalWork() - getWorkCompleted();
}
int getWorkCompleted();
default String getProgressString()
{
default String getProgressString() {
return Form.pc(getProgress(), 0);
}
default double getProgress()
{
return (double)getWorkCompleted() / (double)getTotalWork();
default double getProgress() {
return (double) getWorkCompleted() / (double) getTotalWork();
}
default void execute(VolmitSender sender)
{
default void execute(VolmitSender sender) {
PrecisionStopwatch p = PrecisionStopwatch.start();
CompletableFuture<?> f = J.afut(this::execute);
int c = J.ar(() -> {
if(sender.isPlayer())
{
if (sender.isPlayer()) {
sender.sendProgress(getProgress(), getName());
}
else
{
} else {
sender.sendMessage(getName() + ": " + getProgressString());
}
}, sender.isPlayer() ? 0 : 20);

View File

@@ -25,13 +25,11 @@ public class JobCollection implements Job {
private String status;
private final KList<Job> jobs;
public JobCollection(String name, Job... jobs)
{
public JobCollection(String name, Job... jobs) {
this(name, new KList<>(jobs));
}
public JobCollection(String name, KList<Job> jobs)
{
public JobCollection(String name, KList<Job> jobs) {
this.name = name;
status = null;
this.jobs = new KList<>(jobs);
@@ -44,8 +42,7 @@ public class JobCollection implements Job {
@Override
public void execute() {
for(Job i : jobs)
{
for (Job i : jobs) {
status = i.getName();
i.execute();
}

View File

@@ -25,21 +25,18 @@ public abstract class QueueJob<T> implements Job {
private int totalWork;
private int completed;
public QueueJob()
{
public QueueJob() {
totalWork = 0;
completed = 0;
queue = new KList<>();
}
public void queue(T t)
{
public void queue(T t) {
queue.add(t);
totalWork++;
}
public void queue(KList<T> f)
{
public void queue(KList<T> f) {
queue.addAll(f);
totalWork += f.size();
}
@@ -49,8 +46,7 @@ public abstract class QueueJob<T> implements Job {
@Override
public void execute() {
totalWork = queue.size();
while(queue.isNotEmpty())
{
while (queue.isNotEmpty()) {
execute(queue.pop());
completeWork();
}

View File

@@ -18,13 +18,12 @@
package com.volmit.iris.util.scheduling.jobs;
public class SingleJob implements Job{
public class SingleJob implements Job {
private boolean done;
private final String name;
private final Runnable runnable;
public SingleJob(String name, Runnable runnable)
{
public SingleJob(String name, Runnable runnable) {
this.name = name;
done = false;
this.runnable = runnable;