Improve metrics additions

This commit is contained in:
Phoenix616 2020-06-21 19:09:03 +01:00
parent 4885092435
commit 4a04a623a7
2 changed files with 11 additions and 11 deletions

View File

@ -451,7 +451,7 @@ public class ChestShop extends JavaPlugin {
}
private int[] getChartArray(boolean value) {
return new int[]{value ? 1 : 0, value ? 0 : 1};
return new int[]{!value ? 1 : 0, value ? 0 : 1};
}
private static final int PROJECT_BUKKITDEV_ID = 31263;

View File

@ -16,13 +16,13 @@ public class MetricsModule implements Listener {
private static long lastReset = System.currentTimeMillis();
private static int buyTransactionsLast = 0;
private static int sellTransactionsLast = 0;
private static int buyTransactionsLast = -1;
private static int sellTransactionsLast = -1;
private static long buyTransactionsCurrent = 0;
private static long sellTransactionsCurrent = 0;
private static int boughtItemsLast = 0;
private static int soldItemsLast = 0;
private static int boughtItemsLast = -1;
private static int soldItemsLast = -1;
private static long boughtItemsCurrent = 0;
private static long soldItemsCurrent = 0;
@ -47,32 +47,32 @@ public class MetricsModule implements Listener {
public static int getBuyTransactions() {
checkReset();
return buyTransactionsLast;
return buyTransactionsLast > -1 ? buyTransactionsLast : NumberUtil.toInt(buyTransactionsCurrent);
}
public static int getSellTransactions() {
checkReset();
return sellTransactionsLast;
return sellTransactionsLast > -1 ? sellTransactionsLast : NumberUtil.toInt(sellTransactionsCurrent);
}
public static int getTotalTransactions() {
checkReset();
return buyTransactionsLast + sellTransactionsLast;
return getBuyTransactions() + getSellTransactions();
}
public static int getBoughtItemsCount() {
checkReset();
return boughtItemsLast;
return boughtItemsLast > -1 ? boughtItemsLast : NumberUtil.toInt(boughtItemsCurrent);
}
public static int getSoldItemsCount() {
checkReset();
return soldItemsLast;
return soldItemsLast > -1 ? soldItemsLast : NumberUtil.toInt(soldItemsCurrent);
}
public static int getTotalItemsCount() {
checkReset();
return boughtItemsLast + soldItemsLast;
return getBoughtItemsCount() + getSoldItemsCount();
}
private static void checkReset() {