Interface ReflectionRemapper
Particularly useful for reflection, as it's not remapped by bytecode remapping.
The various standard ReflectionRemappers can be created
using the provided static factory methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ReflectionRemapperforMappings(InputStream mappings, String fromNamespace, String toNamespace) Creates a newReflectionRemapperfrom the given mappings.static ReflectionRemapperforMappings(Path mappings, String fromNamespace, String toNamespace) Creates a newReflectionRemapperfrom the given mappings.static ReflectionRemapperforPaperReobfMappings(InputStream mappings) Creates a newReflectionRemapperusing the provided Paper reobfuscation mappings.static ReflectionRemapperforPaperReobfMappings(Path mappings) Creates a newReflectionRemapperusing the provided Paper reobfuscation mappings.static ReflectionRemapperCreates a newReflectionRemapperusing the reobf mappings file inside reobfuscated Paper jars.static ReflectionRemappernoop()Returns a noopReflectionRemapperinstance which simply passes through the given names without remapping.remapClassName(String className) Remaps a Mojang-mapped class name to its current runtime name.default StringremapClassOrArrayName(String name) Remaps a Mojang-mapped class or array name (as given to Class.forName(String)) to its current runtime name usingremapClassName(String).remapFieldName(Class<?> holdingClass, String fieldName) Remaps a Mojang-mapped field name to its current runtime name.remapMethodName(Class<?> holdingClass, String methodName, Class<?>... paramTypes) Remaps a Mojang-mapped method name to its current runtime name.default ReflectionRemapperwithClassNamePreprocessor(UnaryOperator<String> preprocessor) Creates a new reflection remapper that processes class names using the provided operator before remapping them with this remapper.
-
Method Details
-
remapClassName
Remaps a Mojang-mapped class name to its current runtime name.- Parameters:
className- fully qualified class name- Returns:
- fully qualified runtime class name
-
remapFieldName
Remaps a Mojang-mapped field name to its current runtime name.- Parameters:
holdingClass- class declaring the fieldfieldName- field name- Returns:
- runtime field name
-
remapMethodName
Remaps a Mojang-mapped method name to its current runtime name.- Parameters:
holdingClass- class declaring the methodmethodName- method nameparamTypes- parameter types- Returns:
- runtime method name
-
remapClassOrArrayName
Remaps a Mojang-mapped class or array name (as given to Class.forName(String)) to its current runtime name usingremapClassName(String).- Parameters:
name- class or array name- Returns:
- remapped name
-
withClassNamePreprocessor
Creates a new reflection remapper that processes class names using the provided operator before remapping them with this remapper.This may be useful when class names must be mangled to avoid relocation.
- Parameters:
preprocessor- class name preprocessor- Returns:
- delegating reflection remapper
-
noop
Returns a noopReflectionRemapperinstance which simply passes through the given names without remapping.- Returns:
- noop reflection remapper
-
forMappings
static ReflectionRemapper forMappings(InputStream mappings, String fromNamespace, String toNamespace) Creates a newReflectionRemapperfrom the given mappings.Note that this does not close the provided
InputStream.- Parameters:
mappings- mappingsfromNamespace- from namespacetoNamespace- to namespace- Returns:
- reflection remapper
-
forMappings
Creates a newReflectionRemapperfrom the given mappings.- Parameters:
mappings- mappingsfromNamespace- from namespacetoNamespace- to namespace- Returns:
- reflection remapper
-
forPaperReobfMappings
Creates a newReflectionRemapperusing the provided Paper reobfuscation mappings.If the current environment is detected to be Mojang-mapped,
noop()will be returned rather than reading the mappings and creating an actual remappingReflectionRemapper.- Parameters:
mappings- reobf mappings- Returns:
- reflection remapper
-
forPaperReobfMappings
Creates a newReflectionRemapperusing the provided Paper reobfuscation mappings.If the current environment is detected to be Mojang-mapped,
noop()will be returned rather than reading the mappings and creating an actual remappingReflectionRemapper.Note that this does not close the provided InputStream.
- Parameters:
mappings- reobf mappings- Returns:
- reflection remapper
-
forReobfMappingsInPaperJar
Creates a newReflectionRemapperusing the reobf mappings file inside reobfuscated Paper jars.If the current environment is detected to be Mojang-mapped,
noop()will be returned rather than reading the mappings and creating an actual remappingReflectionRemapper.- Returns:
- reflection remapper
-