diff --git a/src/main/java/cpw/mods/modlauncher/Environment.java b/src/main/java/cpw/mods/modlauncher/Environment.java index 4859cb0..1c09e34 100644 --- a/src/main/java/cpw/mods/modlauncher/Environment.java +++ b/src/main/java/cpw/mods/modlauncher/Environment.java @@ -22,7 +22,6 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import java.util.*; -import java.util.function.BiFunction; import java.util.function.Function; /** @@ -57,11 +56,6 @@ public Optional findModuleLayerManager() { return launcher.findLayerManager(); } - @Override - public Optional> findNameMapping(final String targetMapping) { - return launcher.findNameMapping(targetMapping); - } - @Override public T computePropertyIfAbsent(final TypesafeMap.Key key, final Function, ? extends T> valueFunction) { return environment.computeIfAbsent(key, valueFunction); diff --git a/src/main/java/cpw/mods/modlauncher/Launcher.java b/src/main/java/cpw/mods/modlauncher/Launcher.java index 464cde3..c7d7a8e 100644 --- a/src/main/java/cpw/mods/modlauncher/Launcher.java +++ b/src/main/java/cpw/mods/modlauncher/Launcher.java @@ -23,9 +23,7 @@ import org.apache.logging.log4j.LogManager; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; -import java.nio.file.Path; import java.util.*; -import java.util.function.BiFunction; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -40,7 +38,6 @@ public class Launcher { private final TransformationServicesHandler transformationServicesHandler; private final Environment environment; private final TransformStore transformStore; - private final NameMappingServiceHandler nameMappingServiceHandler; private final ArgumentHandler argumentHandler; private final LaunchServiceHandler launchService; private final LaunchPluginHandler launchPlugins; @@ -61,7 +58,6 @@ private Launcher() { this.transformStore = new TransformStore(); this.transformationServicesHandler = new TransformationServicesHandler(this.transformStore, this.moduleLayerHandler); this.argumentHandler = new ArgumentHandler(); - this.nameMappingServiceHandler = new NameMappingServiceHandler(this.moduleLayerHandler); this.launchPlugins = new LaunchPluginHandler(this.moduleLayerHandler); } @@ -86,7 +82,7 @@ public final TypesafeMap blackboard() { private void run(String... args) { final ArgumentHandler.DiscoveryData discoveryData = this.argumentHandler.setArgs(args); this.transformationServicesHandler.discoverServices(discoveryData); - final var scanResults = this.transformationServicesHandler.initializeTransformationServices(this.argumentHandler, this.environment, this.nameMappingServiceHandler) + final var scanResults = this.transformationServicesHandler.initializeTransformationServices(this.argumentHandler, this.environment) .stream().collect(Collectors.groupingBy(ITransformationService.Resource::target)); scanResults.getOrDefault(IModuleLayerManager.Layer.PLUGIN, List.of()) .stream() @@ -121,10 +117,6 @@ Optional findLaunchHandler(final String name) { return launchService.findLaunchHandler(name); } - Optional> findNameMapping(final String targetMapping) { - return nameMappingServiceHandler.findNameTranslator(targetMapping); - } - public Optional findLayerManager() { return Optional.ofNullable(this.moduleLayerHandler); } diff --git a/src/main/java/cpw/mods/modlauncher/NameMappingServiceDecorator.java b/src/main/java/cpw/mods/modlauncher/NameMappingServiceDecorator.java deleted file mode 100644 index 7cbfadb..0000000 --- a/src/main/java/cpw/mods/modlauncher/NameMappingServiceDecorator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ModLauncher - for launching Java programs with in-flight transformation ability. - * - * Copyright (C) 2017-2019 cpw - * - * This program 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, version 3 of the License. - * - * This program 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 program. If not, see . - */ - -package cpw.mods.modlauncher; - -import cpw.mods.modlauncher.api.*; - -import java.util.Objects; -import java.util.function.BiFunction; - -/** - * Decorator for Naming Services - */ -class NameMappingServiceDecorator { - private final INameMappingService service; - - public NameMappingServiceDecorator(INameMappingService service) { - this.service = service; - } - - public boolean validTarget(final String origin) { - return Objects.equals(this.service.understanding().getValue(), origin); - } - public String understands() { - return this.service.understanding().getKey(); - } - - public BiFunction function() { - return this.service.namingFunction(); - } - - public String toString() { - return this.service.mappingName() + ":" + this.service.mappingVersion(); - } -} diff --git a/src/main/java/cpw/mods/modlauncher/NameMappingServiceHandler.java b/src/main/java/cpw/mods/modlauncher/NameMappingServiceHandler.java deleted file mode 100644 index c593445..0000000 --- a/src/main/java/cpw/mods/modlauncher/NameMappingServiceHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ModLauncher - for launching Java programs with in-flight transformation ability. - * - * Copyright (C) 2017-2019 cpw - * - * This program 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, version 3 of the License. - * - * This program 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 program. If not, see . - */ - -package cpw.mods.modlauncher; - -import cpw.mods.modlauncher.api.*; -import cpw.mods.modlauncher.util.ServiceLoaderUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.*; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static cpw.mods.modlauncher.LogMarkers.*; - -/** - * Allow names to be transformed between naming domains. - */ -class NameMappingServiceHandler { - private static final Logger LOGGER = LogManager.getLogger(); - private final Map namingTable; - private Map nameBindings; - - public NameMappingServiceHandler(final ModuleLayerHandler layerHandler) { - namingTable = ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(layerHandler.getLayer(IModuleLayerManager.Layer.BOOT).orElseThrow(), INameMappingService.class), sce -> LOGGER.fatal("Encountered serious error loading naming service, expect problems", sce)) - .collect(Collectors.toMap(INameMappingService::mappingName, NameMappingServiceDecorator::new)); - LOGGER.debug(MODLAUNCHER,"Found naming services : [{}]", () -> String.join(",", namingTable.keySet())); - } - - - public Optional> findNameTranslator(final String targetNaming) { - return Optional.ofNullable(nameBindings.get(targetNaming)).map(NameMappingServiceDecorator::function); - } - - public void bindNamingServices(final String currentNaming) { - LOGGER.debug(MODLAUNCHER, "Current naming domain is '{}'", currentNaming); - nameBindings = namingTable.values().stream(). - filter(nameMappingServiceDecorator -> nameMappingServiceDecorator.validTarget(currentNaming)). - collect(Collectors.toMap(NameMappingServiceDecorator::understands, Function.identity())); - LOGGER.debug(MODLAUNCHER, "Identified name mapping providers {}", nameBindings); - } -} diff --git a/src/main/java/cpw/mods/modlauncher/TransformationServicesHandler.java b/src/main/java/cpw/mods/modlauncher/TransformationServicesHandler.java index 15694e4..d55f401 100644 --- a/src/main/java/cpw/mods/modlauncher/TransformationServicesHandler.java +++ b/src/main/java/cpw/mods/modlauncher/TransformationServicesHandler.java @@ -44,14 +44,11 @@ class TransformationServicesHandler { this.layerHandler = layerHandler; } - List initializeTransformationServices(ArgumentHandler argumentHandler, Environment environment, final NameMappingServiceHandler nameMappingServiceHandler) { + List initializeTransformationServices(ArgumentHandler argumentHandler, Environment environment) { loadTransformationServices(environment); validateTransformationServices(); processArguments(argumentHandler, environment); initialiseTransformationServices(environment); - // force the naming to "mojang" if nothing has been populated during transformer setup - environment.computePropertyIfAbsent(IEnvironment.Keys.NAMING.get(), a-> "mojang"); - nameMappingServiceHandler.bindNamingServices(environment.getProperty(Environment.Keys.NAMING.get()).orElse("mojang")); return runScanningTransformationServices(environment); } diff --git a/src/main/java/cpw/mods/modlauncher/api/IEnvironment.java b/src/main/java/cpw/mods/modlauncher/api/IEnvironment.java index bbdfe39..3db0216 100644 --- a/src/main/java/cpw/mods/modlauncher/api/IEnvironment.java +++ b/src/main/java/cpw/mods/modlauncher/api/IEnvironment.java @@ -64,13 +64,6 @@ public interface IEnvironment { Optional findModuleLayerManager(); - /** - * Find the naming translation for the targetMapping. - * @param targetMapping the name of the mapping to lookup - * @return a function mapping names from the current naming domain to the requested one, if available - */ - Optional> findNameMapping(String targetMapping); - final class Keys { /** * Version passed in through arguments @@ -92,10 +85,6 @@ final class Keys { * The name of the identified launch target (passed as an argument) */ public static final Supplier> LAUNCHTARGET = buildKey("launchtarget", String.class); - /** - * The naming scheme in use. Populated at startup. See: {@link INameMappingService} - */ - public static final Supplier> NAMING = buildKey("naming", String.class); /** * The audit trail for transformers applied to a class. See {@link ITransformerAuditTrail} */ diff --git a/src/main/java/cpw/mods/modlauncher/api/INameMappingService.java b/src/main/java/cpw/mods/modlauncher/api/INameMappingService.java deleted file mode 100644 index cea70b8..0000000 --- a/src/main/java/cpw/mods/modlauncher/api/INameMappingService.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ModLauncher - for launching Java programs with in-flight transformation ability. - * - * Copyright (C) 2017-2019 cpw - * - * This program 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, version 3 of the License. - * - * This program 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 program. If not, see . - */ - -package cpw.mods.modlauncher.api; - -import java.util.*; -import java.util.function.*; - -/** - * Expose known naming domains into the system, to allow for modules to lookup alternative namings. - * - * mojang, srg and mcp will be available in certain environments. - */ -public interface INameMappingService { - /** - * The name of this namemapping. - * - * E.G. srgtomcp - * - * @return a unique name for this mapping - */ - String mappingName(); - - /** - * A version number for this namemapping. - * - * @return a version number for this mapping - */ - String mappingVersion(); - - /** - * The source and target you support. If your target is not the active naming, you will be ignored. - * - * @return A key (source naming) value (target naming) pair representing your source to target translation. - */ - Map.Entry understanding(); - - /** - * A function mapping a name to another name, for the given domain. - * - * The input string will be the name in the source naming, you should return the name in the target naming. - * - * @return A function mapping names - */ - BiFunction namingFunction(); - - enum Domain { CLASS, METHOD, FIELD } -} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 488e21b..d87957b 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -12,7 +12,6 @@ exports cpw.mods.modlauncher.util; exports cpw.mods.modlauncher; uses cpw.mods.modlauncher.api.ILaunchHandlerService; - uses cpw.mods.modlauncher.api.INameMappingService; uses cpw.mods.modlauncher.api.ITransformationService; uses cpw.mods.modlauncher.serviceapi.ILaunchPluginService; uses cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;