From 72bab1e2ede3353725d001efc8c74005aff323e1 Mon Sep 17 00:00:00 2001 From: Allink Date: Wed, 25 May 2022 18:41:35 +0100 Subject: [PATCH] Add mean averaging to FUtil --- .../totalfreedommod/util/FUtil.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index c7b533ab..45364d10 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -5,12 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.WordUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; +import org.bukkit.*; import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -19,10 +14,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import org.json.simple.JSONArray; import java.io.*; -import java.lang.reflect.Field; import java.net.HttpURLConnection; import java.net.URL; import java.text.ParseException; @@ -800,6 +793,42 @@ public class FUtil return getServer().getOnlinePlayers().size() - i; } + public static double getMeanAverageDouble(double[] doubles) + { + double total = 0; + + for (double aDouble : doubles) + { + total += aDouble; + } + + return total / doubles.length; + } + + public static int getMeanAverageInt(int[] ints) + { + int total = 0; + + for (int anInt : ints) + { + total += anInt; + } + + return total / ints.length; + } + + public static long getMeanAverageLong(long[] longs) + { + long total = 0; + + for (long aLong : longs) + { + total += aLong; + } + + return total / longs.length; + } + public static class PaginationList extends ArrayList {