Class CommonHelper

java.lang.Object
com.pixelmonmod.pixelmon.api.util.helpers.CommonHelper

public class CommonHelper extends Object
Miscellaneous utility methods.
  • Field Details

    • bitFilters

      public static final int[] bitFilters
  • Constructor Details

    • CommonHelper

      public CommonHelper()
  • Method Details

    • ensureIndex

      public static void ensureIndex(List<?> a, int i)
      ensures that ArrayList a can call set(i, Object)
      Parameters:
      a -
      i -
    • set

      public static <T> T set(ArrayList<T> a, T value, int index)
    • insert

      public static <T> void insert(ArrayList<T> a, T value)
      Sets the index of the first null element in a to value, or adds value to the end of a if none of the elements are null.
      Parameters:
      a -
      value -
    • indexOfAbsoluteMax

      public static int indexOfAbsoluteMax(Object array) throws ClassCastException
      Parameters:
      array - - An Array of either Number primitives, or actual Number objects
      Returns:
      The index of the max value, or -1 if there was more than one instance of the max value in the array
      Throws:
      ClassCastException - if you fail at reading javadocs
    • wrapperArray

      public static Object[] wrapperArray(Object aprimitive)
    • addEntries

      public static <K, V> Map<K,V> addEntries(Map<K,V> map, K[] keys, V[] vals)
    • addEntries

      public static <K, V> Map<K,V> addEntries(Map<K,V> map, Object[] kvs)
      adds entries for every 2 objects in kvs.
    • getIgnoreCase

      public static <V> V getIgnoreCase(Map<String,V> map, String key)
    • textInQuotes

      public static String textInQuotes(String str)
    • decodeInteger

      public static byte[] decodeInteger(int encoded, int size)
      Decodes an integer into an array of small numbers
      Parameters:
      encoded - The integer created from the #encodeInteger method
      size - The bitwidth per smaller number. The maximum size for the smaller inclusions is equal to 2^size. Note: this method only supports sizes from 1-8 inclusive.
      Returns:
      The decoded array
    • encodeInteger

      public static int encodeInteger(byte[] toEncode, int size)
      Encodes an array of small numbers into an integer.
      Parameters:
      toEncode - The array to encode
      size - The bitwidth of each small number. The maximum value for each smaller value is equal top 2^size. Numbers larger than this will have additional bits discarded.
      Returns:
    • disableLogMessage

      public static boolean disableLogMessage(Class<?> clazz, String regex)