public percentage methods for fill and trim task

Provides public methods to get the percentage for the fill and trim
task. These can be used by 3rd party plugins to get the calculated
percentage or get the values of the processed/total amount of chunks.

Possible usages I have in mind:
- Boss bar showing a progress of the fill task
- Action bar showing the status
- ...
This commit is contained in:
Maxim Van de Wynckel 2016-01-15 12:38:17 +01:00
parent 571daa669f
commit 895bec7061
2 changed files with 56 additions and 2 deletions

View File

@ -385,7 +385,7 @@ public class WorldFillTask implements Runnable
private void reportProgress()
{
lastReport = Config.Now();
double perc = ((double)(reportTotal + reportNum) / (double)reportTarget) * 100;
double perc = getPercentageCompleted();
if (perc > 100) perc = 100;
sendMessage(reportNum + " more chunks processed (" + (reportTotal + reportNum) + " total, ~" + Config.coord.format(perc) + "%" + ")");
reportTotal += reportNum;
@ -469,4 +469,31 @@ public class WorldFillTask implements Runnable
{
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()
{
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" + ")");
}
@ -402,4 +402,31 @@ public class WorldTrimTask implements Runnable
if (notifyPlayer != null)
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;
}
}