From 444feb414e5ecef42e1b50508b324dd61728351a Mon Sep 17 00:00:00 2001 From: makamys Date: Sun, 12 Feb 2023 02:06:14 +0100 Subject: [PATCH] Fix checkstyle violations --- .../platform/MixinPlatformAgentFMLLegacy.java | 8 +++- .../spongepowered/asm/mixin/ForgeUtils.java | 44 +++++++++++++++---- .../asm/obfuscation/FMLLegacyDevRemapper.java | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/launchwrapper/java/org/spongepowered/asm/launch/platform/MixinPlatformAgentFMLLegacy.java b/src/launchwrapper/java/org/spongepowered/asm/launch/platform/MixinPlatformAgentFMLLegacy.java index 8347e7cc..f5dd1eba 100644 --- a/src/launchwrapper/java/org/spongepowered/asm/launch/platform/MixinPlatformAgentFMLLegacy.java +++ b/src/launchwrapper/java/org/spongepowered/asm/launch/platform/MixinPlatformAgentFMLLegacy.java @@ -208,6 +208,7 @@ public class MixinPlatformAgentFMLLegacy extends MixinPlatformAgentAbstract impl *

Reparseable coremods are excluded from being crawled for regular mods * during class path mod discovery, so we must not add mods on the * boot class path to this list.

+ * *

The reason we use the boot class path is because coremods in * the mods directory have been injected into the class path at this point, * and we do want to mark those as reparseable, so they don't get @@ -434,8 +435,11 @@ public class MixinPlatformAgentFMLLegacy extends MixinPlatformAgentAbstract impl } /** - *

Called after Mixin configs have been loaded. Do Forge-specific initialization.

- *

Note: The mod bootstrapping Mixin must contain an FML plugin for this to get called.

+ *

Called after Mixin configs have been loaded. Do Forge-specific + * initialization.

+ * + *

Note: The mod bootstrapping Mixin must contain an FML plugin for this + * to get called.

*/ @Override public void initPrimaryContainer() { diff --git a/src/launchwrapper/java/org/spongepowered/asm/mixin/ForgeUtils.java b/src/launchwrapper/java/org/spongepowered/asm/mixin/ForgeUtils.java index b15575f5..d1213e4b 100644 --- a/src/launchwrapper/java/org/spongepowered/asm/mixin/ForgeUtils.java +++ b/src/launchwrapper/java/org/spongepowered/asm/mixin/ForgeUtils.java @@ -1,3 +1,27 @@ +/* + * This file is part of Mixin, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.spongepowered.asm.mixin; // Reference: https://github.com/FabricMC/fabric-loader/blob/2a378f1c563b6ec96ae6620a278ecd23fa09da0f/src/main/java/net/fabricmc/loader/impl/launch/FabricMixinBootstrap.java @@ -13,22 +37,24 @@ import java.io.InputStreamReader; import java.net.URL; import java.util.*; -public class ForgeUtils { +public final class ForgeUtils { private static final Logger logger = LogManager.getLogger(); public static final String KEY_MOD_ID = "fabric-modId"; + private ForgeUtils() {} + public static void init() { Map jarNameToModid = createJarNameToModidMap(); - for(Config config : Mixins.getConfigs()) { + for (Config config : Mixins.getConfigs()) { URL resource = Launch.classLoader.getResource(config.getName()); - if(resource != null) { + if (resource != null) { String jarName = getJarNameFromResourceUrl(resource); - if(jarName != null) { + if (jarName != null) { String modid = jarNameToModid.get(jarName); - if(modid != null) { + if (modid != null) { config.getConfig().decorate(KEY_MOD_ID, modid); } } @@ -51,7 +77,7 @@ public class ForgeUtils { } } } - } catch(Exception e) { + } catch (Exception e) { logger.warn("Failed to construct jar name -> modid map, mod names will not be shown in errors."); } return map; @@ -65,17 +91,17 @@ public class ForgeUtils { } else { return Arrays.asList(new Gson().fromJson(new InputStreamReader(url.openStream()), ModMetadata.class)); } - } catch(Exception e) { + } catch (Exception e) { logger.warn("Failed to parse mcmod.info at " + url + ": " + e); } return Arrays.asList(); } private static String getJarNameFromResourceUrl(URL url) { - if(url.getPath().contains("!/")) { + if (url.getPath().contains("!/")) { String filePath = url.getPath().split("!/")[0]; String[] parts = filePath.split("/"); - if(parts.length != 0) { + if (parts.length != 0) { return parts[parts.length - 1]; } } diff --git a/src/launchwrapper/java/org/spongepowered/asm/obfuscation/FMLLegacyDevRemapper.java b/src/launchwrapper/java/org/spongepowered/asm/obfuscation/FMLLegacyDevRemapper.java index e254b72b..f7281667 100644 --- a/src/launchwrapper/java/org/spongepowered/asm/obfuscation/FMLLegacyDevRemapper.java +++ b/src/launchwrapper/java/org/spongepowered/asm/obfuscation/FMLLegacyDevRemapper.java @@ -133,7 +133,7 @@ public class FMLLegacyDevRemapper implements IRemapper { @Override public String mapDesc(String desc) { String remapped = descCache.get(desc); - if(remapped == null) { + if (remapped == null) { remapped = desc; for (Entry entry : this.mappings.entrySet()) { remapped = remapped.replace(entry.getKey(), entry.getValue());