diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
commit | f51616bda220887fdd45c4bc951ff59e3398213a (patch) | |
tree | 35fdbb15b4c7ea0282773a388eff517a1d09d941 /src/main/java/kubatech/api/utils/ModUtils.java | |
parent | 11216d666cbc30fc1e1dfc84e1e0c2f4252b1fc2 (diff) | |
download | GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.gz GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.bz2 GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/kubatech/api/utils/ModUtils.java')
-rw-r--r-- | src/main/java/kubatech/api/utils/ModUtils.java | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/src/main/java/kubatech/api/utils/ModUtils.java b/src/main/java/kubatech/api/utils/ModUtils.java index 6870a8801d..a09b3b68ee 100644 --- a/src/main/java/kubatech/api/utils/ModUtils.java +++ b/src/main/java/kubatech/api/utils/ModUtils.java @@ -1,35 +1,30 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.*; + import javax.xml.bind.DatatypeConverter; + import net.minecraft.launchwrapper.Launch; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; + public class ModUtils { - public static final boolean isDeobfuscatedEnvironment = - (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + + public static final boolean isDeobfuscatedEnvironment = (boolean) Launch.blackboard + .get("fml.deobfuscatedEnvironment"); public static boolean isClientSided = false; private static final HashMap<String, String> classNamesToModIDs = new HashMap<>(); private static final Map.Entry<String, String> emptyEntry = new AbstractMap.SimpleEntry<>("", ""); @@ -39,15 +34,11 @@ public class ModUtils { classNamesToModIDs.put("net.minecraft", "Minecraft"); Loader.instance().getActiveModList().forEach(m -> { Object Mod = m.getMod(); - if (Mod != null) - classNamesToModIDs.put(Mod.getClass().getPackage().getName(), m.getName()); + if (Mod != null) classNamesToModIDs.put(Mod.getClass().getPackage().getName(), m.getName()); }); } - return classNamesToModIDs.entrySet().stream() - .filter(e -> classname.startsWith(e.getKey())) - .findAny() - .orElse(emptyEntry) - .getValue(); + return classNamesToModIDs.entrySet().stream().filter(e -> classname.startsWith(e.getKey())).findAny() + .orElse(emptyEntry).getValue(); } private static String modListVersion = null; @@ -55,10 +46,9 @@ public class ModUtils { public static String getModListVersion() { if (modListVersion != null) return modListVersion; @SuppressWarnings("unchecked") - ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) - ((ArrayList<ModContainer>) Loader.instance().getActiveModList()).clone(); - String sortedList = modlist.stream() - .filter(m -> m.getMod() != null) + ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) ((ArrayList<ModContainer>) Loader.instance() + .getActiveModList()).clone(); + String sortedList = modlist.stream().filter(m -> m.getMod() != null) .sorted(Comparator.comparing(ModContainer::getModId)) .collect( StringBuilder::new, @@ -81,19 +71,16 @@ public class ModUtils { public static String getModListVersionIgnoringModVersions() { if (modListVersionIgnoringModVersions != null) return modListVersionIgnoringModVersions; @SuppressWarnings("unchecked") - ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) - ((ArrayList<ModContainer>) Loader.instance().getActiveModList()).clone(); - String sortedList = modlist.stream() - .filter(m -> m.getMod() != null) + ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) ((ArrayList<ModContainer>) Loader.instance() + .getActiveModList()).clone(); + String sortedList = modlist.stream().filter(m -> m.getMod() != null) .sorted(Comparator.comparing(ModContainer::getModId)) - .collect(StringBuilder::new, (a, b) -> a.append(b.getModId()), (a, b) -> a.append(", ") - .append(b)) + .collect(StringBuilder::new, (a, b) -> a.append(b.getModId()), (a, b) -> a.append(", ").append(b)) .toString(); try { MessageDigest md = MessageDigest.getInstance("MD5"); - modListVersionIgnoringModVersions = DatatypeConverter.printHexBinary( - md.digest(sortedList.getBytes(StandardCharsets.UTF_8))) - .toUpperCase(); + modListVersionIgnoringModVersions = DatatypeConverter + .printHexBinary(md.digest(sortedList.getBytes(StandardCharsets.UTF_8))).toUpperCase(); return modListVersionIgnoringModVersions; } catch (Exception e) { modListVersionIgnoringModVersions = sortedList; |