Optimization of 'updateAuction() Method'

Tested that and perfectly working ! Results are interesting and offer a fantastic decrease of the used performance. (With the startCheck() task, 13% to 0 - 1% according to Paper's timings).

Explainations:

I had to deal with this problem for a while and haven't received a satisfactory answer on your Discord (just "You have to recode the plugin"). So I decided to analyze your code to improve it and I found a great solution! This method reads lines in the data file but doesn't necessarily have to save the file since it's in most cases unchanged. So I added a boolean that goes true when changes are made, forcing the data file being saved ;).

Enjoy
This commit is contained in:
Aurélien 2019-08-30 21:46:26 +02:00 committed by GitHub
parent 67c845a5f1
commit bb933acb40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -360,11 +360,13 @@ public class Methods {
Calendar cal = Calendar.getInstance();
Calendar expireTime = Calendar.getInstance();
Calendar fullExpireTime = Calendar.getInstance();
boolean shouldSave = false;
if(data.contains("OutOfTime/Cancelled")) {
for(String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
fullExpireTime.setTimeInMillis(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
if(cal.after(fullExpireTime)) {
data.set("OutOfTime/Cancelled." + i, null);
shouldSave = true;
}
}
}
@ -413,10 +415,11 @@ public class Methods {
data.set("OutOfTime/Cancelled." + num + ".Item", data.getItemStack("Items." + i + ".Item"));
}
data.set("Items." + i, null);
shouldSave = true;
}
}
}
Files.DATA.saveFile();
if (shouldSave) Files.DATA.saveFile();
}
public static String getPrice(String ID, Boolean Expired) {