Merge pull request #55 from Maximvdw/master

public percentage methods for fill and trim task
This commit is contained in:
Brett Flannigan 2016-01-16 03:43:22 -06:00
commit 72c5deed28
2 changed files with 56 additions and 2 deletions

View File

@ -385,7 +385,7 @@ public class WorldFillTask implements Runnable
private void reportProgress() private void reportProgress()
{ {
lastReport = Config.Now(); lastReport = Config.Now();
double perc = ((double)(reportTotal + reportNum) / (double)reportTarget) * 100; double perc = getPercentageCompleted();
if (perc > 100) perc = 100; if (perc > 100) perc = 100;
sendMessage(reportNum + " more chunks processed (" + (reportTotal + reportNum) + " total, ~" + Config.coord.format(perc) + "%" + ")"); sendMessage(reportNum + " more chunks processed (" + (reportTotal + reportNum) + " total, ~" + Config.coord.format(perc) + "%" + ")");
reportTotal += reportNum; reportTotal += reportNum;
@ -469,4 +469,31 @@ public class WorldFillTask implements Runnable
{ {
return forceLoad; return forceLoad;
} }
/**
* Get the percentage completed for the fill task.
*
* @return Percentage
*/
public double getPercentageCompleted() {
return ((double) (reportTotal + reportNum) / (double) reportTarget) * 100;
}
/**
* Amount of chunks completed for the fill task.
*
* @return Number of chunks processed.
*/
public int getChunksCompleted() {
return reportTotal;
}
/**
* Total amount of chunks that need to be generated for the fill task.
*
* @return Number of chunks that need to be processed.
*/
public int getChunksTotal() {
return reportTarget;
}
} }

View File

@ -391,7 +391,7 @@ public class WorldTrimTask implements Runnable
private void reportProgress() private void reportProgress()
{ {
lastReport = Config.Now(); lastReport = Config.Now();
double perc = ((double)(reportTotal) / (double)reportTarget) * 100; double perc = getPercentageCompleted();
sendMessage(reportTrimmedRegions + " entire region(s) and " + reportTrimmedChunks + " individual chunk(s) trimmed so far (" + Config.coord.format(perc) + "% done" + ")"); sendMessage(reportTrimmedRegions + " entire region(s) and " + reportTrimmedChunks + " individual chunk(s) trimmed so far (" + Config.coord.format(perc) + "% done" + ")");
} }
@ -402,4 +402,31 @@ public class WorldTrimTask implements Runnable
if (notifyPlayer != null) if (notifyPlayer != null)
notifyPlayer.sendMessage("[Trim] " + text); notifyPlayer.sendMessage("[Trim] " + text);
} }
/**
* Get the percentage completed for the trim task.
*
* @return Percentage
*/
public double getPercentageCompleted() {
return ((double) (reportTotal) / (double) reportTarget) * 100;
}
/**
* Amount of chunks completed for the trim task.
*
* @return Number of chunks processed.
*/
public int getChunksCompleted() {
return reportTotal;
}
/**
* Total amount of chunks that need to be trimmed for the trim task.
*
* @return Number of chunks that need to be processed.
*/
public int getChunksTotal() {
return reportTarget;
}
} }