diff options
| author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
| commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
| tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/api/objects | |
| parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
| download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip | |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/api/objects')
39 files changed, 3688 insertions, 3835 deletions
diff --git a/src/main/java/gtPlusPlus/api/objects/GregtechException.java b/src/main/java/gtPlusPlus/api/objects/GregtechException.java index 916dbc4aaf..083a15f790 100644 --- a/src/main/java/gtPlusPlus/api/objects/GregtechException.java +++ b/src/main/java/gtPlusPlus/api/objects/GregtechException.java @@ -2,27 +2,24 @@ package gtPlusPlus.api.objects; public class GregtechException extends Throwable { - private static final long serialVersionUID = 3601884582161841486L; + private static final long serialVersionUID = 3601884582161841486L; - public GregtechException(String aError) { - this(aError, true); - } - - public GregtechException(String aError, boolean aIsVerbose) { - Logger.ERROR("Throwing GT++ Exception!"); - Logger.ERROR("[EXCEPTION] "+aError); - if (aIsVerbose) { - Logger.INFO("Throwing GT++ Exception!"); - Logger.INFO("[EXCEPTION] "+aError); - printStackTrace(); - } - } - - @Override - public void printStackTrace() { - super.printStackTrace(); - } - - + public GregtechException(String aError) { + this(aError, true); + } + public GregtechException(String aError, boolean aIsVerbose) { + Logger.ERROR("Throwing GT++ Exception!"); + Logger.ERROR("[EXCEPTION] " + aError); + if (aIsVerbose) { + Logger.INFO("Throwing GT++ Exception!"); + Logger.INFO("[EXCEPTION] " + aError); + printStackTrace(); + } + } + + @Override + public void printStackTrace() { + super.printStackTrace(); + } } diff --git a/src/main/java/gtPlusPlus/api/objects/Logger.java b/src/main/java/gtPlusPlus/api/objects/Logger.java index 5824c5260d..78f8ff101b 100644 --- a/src/main/java/gtPlusPlus/api/objects/Logger.java +++ b/src/main/java/gtPlusPlus/api/objects/Logger.java @@ -9,167 +9,151 @@ import org.apache.logging.log4j.LogManager; public class Logger { - public Logger(String string) { - - } - - // Logging Functions - public static final org.apache.logging.log4j.Logger modLogger = Logger.makeLogger(); - - // Generate GT++ Logger - public static org.apache.logging.log4j.Logger makeLogger() { - final org.apache.logging.log4j.Logger gtPlusPlusLogger = LogManager.getLogger("GT++"); - return gtPlusPlusLogger; - } - - private static final boolean enabled = !AsmConfig.disableAllLogging; - - public static final org.apache.logging.log4j.Logger getLogger() { - return modLogger; - } - - // Non-Dev Comments - public static void INFO(final String s) { - if (enabled) { - modLogger.info(s); - } - } - - // Non-Dev Comments - public static void MACHINE_INFO(String s, Object... args) { - if (enabled) { - boolean localPlayer = CORE_Preloader.DEV_ENVIRONMENT; - if (CORE.ConfigSwitches.MACHINE_INFO || localPlayer) { - final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); - modLogger.info("Machine Info: " + s + " | " + name1, args); - } - } - } - - // Developer Comments - public static void WARNING(final String s) { - if (enabled) { - if (CORE_Preloader.DEBUG_MODE) { - modLogger.warn(s); - } - } - } - - // Errors - public static void ERROR(final String s) { - if (enabled) { - if (CORE_Preloader.DEBUG_MODE) { - modLogger.fatal(s); - } - } - } - - // Developer Logger - public static void SPECIFIC_WARNING(final String whatToLog, final String msg, final int line) { - if (enabled) { - // if (!CORE_Preloader.DEBUG_MODE){ - FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); - // } - } - } - - // ASM Comments - public static void LOG_ASM(final String s) { - if (enabled) { - FMLRelaunchLog.info("[Special ASM Logging] ", s); - } - } - - - - - - - - - - - /** - * Special Loggers - */ - - /** - * Special Logger for Bee related content - */ - public static void BEES(final String s) { - modLogger.info("[Bees] "+s); - } - /** - * Special Logger for Debugging Bee related content - */ - public static void DEBUG_BEES(final String s) { - if (enabled) { - if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { - modLogger.info("[Debug][Bees] "+s); - } - } - } - - - - /** - * Special Logger for Materials related content - */ - public static void MATERIALS(final String s) { - if (enabled) { - if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { - modLogger.info("[Materials] "+s); - } - } - } - /** - * Special Logger for Debugging Materials related content - */ - public static void DEBUG_MATERIALS(final String s) { - if (enabled) { - if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { - modLogger.info("[Debug][Materials] "+s); - } - } - } - - /** - * Special Logger for Reflection related content - */ - public static void REFLECTION(final String s) { - if (enabled) { - if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { - modLogger.info("[Reflection] "+s); - } - } - } - - - /** - * Special Logger for Darkworld related content - */ - public static void WORLD(final String s) { - if (enabled) { - if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { - modLogger.info("[WorldGen] "+s); - } - } - } - - public static void RECIPE(String string) { - if (enabled) { - if (/*CORE_Preloader.DEV_ENVIRONMENT || */CORE_Preloader.DEBUG_MODE) { - modLogger.info("[Recipe] "+string); - } - } - } - - public static void SPACE(final String s) { - if (enabled) { - modLogger.info("[Space] "+s); - } - } - - - + public Logger(String string) {} + + // Logging Functions + public static final org.apache.logging.log4j.Logger modLogger = Logger.makeLogger(); + + // Generate GT++ Logger + public static org.apache.logging.log4j.Logger makeLogger() { + final org.apache.logging.log4j.Logger gtPlusPlusLogger = LogManager.getLogger("GT++"); + return gtPlusPlusLogger; + } + + private static final boolean enabled = !AsmConfig.disableAllLogging; + + public static final org.apache.logging.log4j.Logger getLogger() { + return modLogger; + } + + // Non-Dev Comments + public static void INFO(final String s) { + if (enabled) { + modLogger.info(s); + } + } + + // Non-Dev Comments + public static void MACHINE_INFO(String s, Object... args) { + if (enabled) { + boolean localPlayer = CORE_Preloader.DEV_ENVIRONMENT; + if (CORE.ConfigSwitches.MACHINE_INFO || localPlayer) { + final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); + modLogger.info("Machine Info: " + s + " | " + name1, args); + } + } + } + + // Developer Comments + public static void WARNING(final String s) { + if (enabled) { + if (CORE_Preloader.DEBUG_MODE) { + modLogger.warn(s); + } + } + } + + // Errors + public static void ERROR(final String s) { + if (enabled) { + if (CORE_Preloader.DEBUG_MODE) { + modLogger.fatal(s); + } + } + } + + // Developer Logger + public static void SPECIFIC_WARNING(final String whatToLog, final String msg, final int line) { + if (enabled) { + // if (!CORE_Preloader.DEBUG_MODE){ + FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); + // } + } + } + + // ASM Comments + public static void LOG_ASM(final String s) { + if (enabled) { + FMLRelaunchLog.info("[Special ASM Logging] ", s); + } + } + + /** + * Special Loggers + */ + + /** + * Special Logger for Bee related content + */ + public static void BEES(final String s) { + modLogger.info("[Bees] " + s); + } + /** + * Special Logger for Debugging Bee related content + */ + public static void DEBUG_BEES(final String s) { + if (enabled) { + if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { + modLogger.info("[Debug][Bees] " + s); + } + } + } + + /** + * Special Logger for Materials related content + */ + public static void MATERIALS(final String s) { + if (enabled) { + if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { + modLogger.info("[Materials] " + s); + } + } + } + /** + * Special Logger for Debugging Materials related content + */ + public static void DEBUG_MATERIALS(final String s) { + if (enabled) { + if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { + modLogger.info("[Debug][Materials] " + s); + } + } + } + + /** + * Special Logger for Reflection related content + */ + public static void REFLECTION(final String s) { + if (enabled) { + if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { + modLogger.info("[Reflection] " + s); + } + } + } + + /** + * Special Logger for Darkworld related content + */ + public static void WORLD(final String s) { + if (enabled) { + if (CORE_Preloader.DEV_ENVIRONMENT || CORE_Preloader.DEBUG_MODE) { + modLogger.info("[WorldGen] " + s); + } + } + } + + public static void RECIPE(String string) { + if (enabled) { + if ( + /*CORE_Preloader.DEV_ENVIRONMENT || */ CORE_Preloader.DEBUG_MODE) { + modLogger.info("[Recipe] " + string); + } + } + } + + public static void SPACE(final String s) { + if (enabled) { + modLogger.info("[Space] " + s); + } + } } diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index e04f1af03a..f0687fae4f 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -5,341 +5,336 @@ import java.util.*; public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collection<V>, Queue<V>, List<V> { - /** - * The Internal Map - */ - protected final Map<Integer, V> mInternalMap; - protected final Map<String, Integer> mInternalNameMap; - - /** - * The Internal ID - */ - private int mInternalID = 0; - private static final long serialVersionUID = 3771412318075131790L; - - - public AutoMap() { - this(new LinkedHashMap<Integer, V>()); - } - - public Map<Integer, V> getMap(){ - return mInternalMap; - } - - public AutoMap(Map<Integer, V> defaultMapType) { - mInternalMap = defaultMapType; - mInternalNameMap = new LinkedHashMap<String, Integer>(); - } - - /** - * Generates an AutoMap from the List. - * @param aList - Data to be inserted into the AutoMap. - */ - public AutoMap(List<V> aList) { - mInternalMap = new LinkedHashMap<Integer, V>(); - mInternalNameMap = new LinkedHashMap<String, Integer>(); - if (aList != null && aList.size() > 0) { - for (V obj : aList) { - add(obj); - } - } - } - /** - * Generates an AutoMap from a Set. - * @param aList - Data to be inserted into the AutoMap. - */ - public AutoMap(Set<V> aList) { - mInternalMap = new LinkedHashMap<Integer, V>(); - mInternalNameMap = new LinkedHashMap<String, Integer>(); - if (aList != null && aList.size() > 0) { - for (V obj : aList) { - add(obj); - } - } - } - /** - * Generates an AutoMap from a Collection. - * @param aList - Data to be inserted into the AutoMap. - */ - public AutoMap(Collection<V> aList) { - mInternalMap = new LinkedHashMap<Integer, V>(); - mInternalNameMap = new LinkedHashMap<String, Integer>(); - if (aList != null && aList.size() > 0) { - for (V obj : aList) { - add(obj); - } - } - } - - /** - * Generates an AutoMap from a Array. - * @param aArray - Data to be inserted into the AutoMap. - */ - public AutoMap(V[] aArray) { - mInternalMap = new LinkedHashMap<Integer, V>(); - mInternalNameMap = new LinkedHashMap<String, Integer>(); - if (aArray != null && aArray.length > 0) { - for (V obj : aArray) { - add(obj); - } - } - } - - @Override - public Iterator<V> iterator() { - return values().iterator(); - } - - public synchronized boolean setValue(V object){ - int mOriginalID = this.mInternalID; - put(object); - if (this.mInternalMap.get(mOriginalID).equals(object) || mOriginalID > this.mInternalID){ - return true; - } - else { - return false; - } - } - - public synchronized V put(V object){ - return set(object); - } - - public synchronized boolean add(V object){ - return set(object) != null; - } - - public synchronized V set(V object){ - if (object == null) { - return null; - } - mInternalNameMap.put(""+object.hashCode(), (mInternalID+1)); - return mInternalMap.put(mInternalID++, object); - } - - public synchronized V get(int id){ - return mInternalMap.get(id); - } - - public synchronized Collection<V> values(){ - return mInternalMap.values(); - } - - public synchronized int size(){ - return mInternalMap.size(); - } - - public synchronized int hashCode(){ - return mInternalMap.hashCode(); - } - - public synchronized boolean containsKey(int key){ - return mInternalMap.containsKey(key); - } - - public synchronized boolean containsValue(V value){ - return mInternalMap.containsValue(value); - } - - public synchronized boolean isEmpty(){ - return mInternalMap.isEmpty(); - } - - public synchronized void clear(){ - this.mInternalID = 0; - this.mInternalMap.clear(); - this.mInternalNameMap.clear(); - return; - } - - @SuppressWarnings("unchecked") - public V[] toArray() { - V[] toR = (V[]) java.lang.reflect.Array.newInstance(mInternalMap.get(0).getClass(), mInternalMap.size()); - for (int i = 0; i < mInternalMap.size(); i++) { - toR[i] = mInternalMap.get(i); - } - return toR; - } - - public synchronized final int getInternalID() { - return mInternalID; - } - - public synchronized final boolean remove(Object value) { - value.getClass(); - if (this.mInternalMap.containsValue(value)) { - return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); - } - return false; - } - - @Override - public boolean contains(Object o) { - for (V g : this.mInternalMap.values()) { - if (g.equals(o)) { - return true; - } - } - return false; - } - - @SuppressWarnings("unchecked") - @Override - public <V> V[] toArray(V[] a) { - return (V[]) toArray(); - } - - @Override - public boolean containsAll(Collection<?> c) { - boolean aTrue = true; - for (Object g : c) { - if (!this.contains(g)) { - aTrue = false; - } - } - return aTrue; - } - - @Override - public boolean addAll(Collection<? extends V> c) { - boolean aTrue = true; - for (V g : c) { - if (!this.add(g)) { - aTrue = false; - } - } - return aTrue; - } - - @Override - public boolean removeAll(Collection<?> c) { - boolean aTrue = true; - for (Object g : c) { - if (!this.remove(g)) { - aTrue = false; - } - } - return aTrue; - } - - @Override - public boolean retainAll(Collection<?> c) { - AutoMap<?> aTempAllocation = new AutoMap<Object>(); - boolean aTrue = false; - aTempAllocation = this; - aTempAllocation.removeAll(c); - aTempAllocation.clear(); - aTrue = aTempAllocation.isEmpty(); - aTempAllocation.clear(); - return aTrue; - } - - @Override - public boolean offer(V e) { - return add(e); - } - - @Override - public V remove() { - V y = this.get(0); - if (remove(y)) - return y; - else - return null; - } - - @Override - public V poll() { - if (this.mInternalMap.isEmpty()) { - return null; - } - return remove(); - } - - @Override - public V element() { - if (this.mInternalMap.isEmpty()) { - return null; - } - return this.get(0); - } - - @Override - public V peek() { - return element(); - } - - @Override - public boolean addAll(int index, Collection<? extends V> c) { - for (V y : c) { - add(y); - } - return true; - } - - @Override - public V set(int index, V element) { - return mInternalMap.put(index, element); - } - - @Override - public void add(int index, V element) { - add(element); - } - - @Override - public V remove(int index) { - V h = mInternalMap.get(index); - set(index, null); - return h; - } - - @Override - public int indexOf(Object o) { - int aCount = 0; - for (V of : mInternalMap.values()) { - if (of != o) { - aCount++; - continue; - } - else { - return aCount; - } - } - return -1; - } - - @Override - public int lastIndexOf(Object o) { - //TODO - return indexOf(o); - } - - @Override - public ListIterator<V> listIterator() { - // TODO Auto-generated method stub - return null; - } - - @Override - public ListIterator<V> listIterator(int index) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List<V> subList(int fromIndex, int toIndex) { - AutoMap<V> aNewSubList = new AutoMap<V>(); - for (int slot=fromIndex; slot<=toIndex; slot++) { - V obj = mInternalMap.get(slot); - if (obj == null) { - continue; - } - else { - aNewSubList.put(obj); - } - } - return aNewSubList; - } - + /** + * The Internal Map + */ + protected final Map<Integer, V> mInternalMap; + + protected final Map<String, Integer> mInternalNameMap; + + /** + * The Internal ID + */ + private int mInternalID = 0; + + private static final long serialVersionUID = 3771412318075131790L; + + public AutoMap() { + this(new LinkedHashMap<Integer, V>()); + } + + public Map<Integer, V> getMap() { + return mInternalMap; + } + + public AutoMap(Map<Integer, V> defaultMapType) { + mInternalMap = defaultMapType; + mInternalNameMap = new LinkedHashMap<String, Integer>(); + } + + /** + * Generates an AutoMap from the List. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(List<V> aList) { + mInternalMap = new LinkedHashMap<Integer, V>(); + mInternalNameMap = new LinkedHashMap<String, Integer>(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + /** + * Generates an AutoMap from a Set. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(Set<V> aList) { + mInternalMap = new LinkedHashMap<Integer, V>(); + mInternalNameMap = new LinkedHashMap<String, Integer>(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + /** + * Generates an AutoMap from a Collection. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(Collection<V> aList) { + mInternalMap = new LinkedHashMap<Integer, V>(); + mInternalNameMap = new LinkedHashMap<String, Integer>(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + + /** + * Generates an AutoMap from a Array. + * @param aArray - Data to be inserted into the AutoMap. + */ + public AutoMap(V[] aArray) { + mInternalMap = new LinkedHashMap<Integer, V>(); + mInternalNameMap = new LinkedHashMap<String, Integer>(); + if (aArray != null && aArray.length > 0) { + for (V obj : aArray) { + add(obj); + } + } + } + |
