Skip to content

Commit

Permalink
Remove INameMappingService (#121)
Browse files Browse the repository at this point in the history
NeoForge now uses Mojang mappings at runtime, making the name mapping service redundant.
  • Loading branch information
Su5eD authored Dec 1, 2023
1 parent cb9fccb commit 868a4d5
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 203 deletions.
6 changes: 0 additions & 6 deletions src/main/java/cpw/mods/modlauncher/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;

import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -57,11 +56,6 @@ public Optional<IModuleLayerManager> findModuleLayerManager() {
return launcher.findLayerManager();
}

@Override
public Optional<BiFunction<INameMappingService.Domain, String, String>> findNameMapping(final String targetMapping) {
return launcher.findNameMapping(targetMapping);
}

@Override
public <T> T computePropertyIfAbsent(final TypesafeMap.Key<T> key, final Function<? super TypesafeMap.Key<T>, ? extends T> valueFunction) {
return environment.computeIfAbsent(key, valueFunction);
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/cpw/mods/modlauncher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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);
}

Expand All @@ -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()
Expand Down Expand Up @@ -121,10 +117,6 @@ Optional<ILaunchHandlerService> findLaunchHandler(final String name) {
return launchService.findLaunchHandler(name);
}

Optional<BiFunction<INameMappingService.Domain, String, String>> findNameMapping(final String targetMapping) {
return nameMappingServiceHandler.findNameTranslator(targetMapping);
}

public Optional<IModuleLayerManager> findLayerManager() {
return Optional.ofNullable(this.moduleLayerHandler);
}
Expand Down

This file was deleted.

59 changes: 0 additions & 59 deletions src/main/java/cpw/mods/modlauncher/NameMappingServiceHandler.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ class TransformationServicesHandler {
this.layerHandler = layerHandler;
}

List<ITransformationService.Resource> initializeTransformationServices(ArgumentHandler argumentHandler, Environment environment, final NameMappingServiceHandler nameMappingServiceHandler) {
List<ITransformationService.Resource> 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);
}

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/cpw/mods/modlauncher/api/IEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ public interface IEnvironment {

Optional<IModuleLayerManager> 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<BiFunction<INameMappingService.Domain, String, String>> findNameMapping(String targetMapping);

final class Keys {
/**
* Version passed in through arguments
Expand All @@ -92,10 +85,6 @@ final class Keys {
* The name of the identified launch target (passed as an argument)
*/
public static final Supplier<TypesafeMap.Key<String>> LAUNCHTARGET = buildKey("launchtarget", String.class);
/**
* The naming scheme in use. Populated at startup. See: {@link INameMappingService}
*/
public static final Supplier<TypesafeMap.Key<String>> NAMING = buildKey("naming", String.class);
/**
* The audit trail for transformers applied to a class. See {@link ITransformerAuditTrail}
*/
Expand Down
63 changes: 0 additions & 63 deletions src/main/java/cpw/mods/modlauncher/api/INameMappingService.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 868a4d5

Please sign in to comment.