Add mean averaging to FUtil

This commit is contained in:
Allink 2022-05-25 18:41:35 +01:00
parent 1726050d65
commit 72bab1e2ed
No known key found for this signature in database
GPG Key ID: 7F1F1B98F0FAAD13

View File

@ -5,12 +5,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,10 +14,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.json.simple.JSONArray;
import java.io.*; import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.text.ParseException; import java.text.ParseException;
@ -800,6 +793,42 @@ public class FUtil
return getServer().getOnlinePlayers().size() - i; 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<T> extends ArrayList<T> public static class PaginationList<T> extends ArrayList<T>
{ {