Skip to content

Commit

Permalink
Move NonFunctionAlteringWrapper to api package
Browse files Browse the repository at this point in the history
And give it a simpler name and purpose
  • Loading branch information
makamys committed Oct 22, 2023
1 parent 7fa7ae5 commit 0939963
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/main/java/makamys/coretweaks/api/IWrapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package makamys.coretweaks.api;

/** An object that wraps another object, and is the same type as it. */
public interface IWrapper<T> {
public T getOriginal();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.ArrayList;
import java.util.List;

import makamys.coretweaks.optimization.NonFunctionAlteringWrapper;
import makamys.coretweaks.api.IWrapper;
import net.minecraft.launchwrapper.IClassTransformer;

/** <p>A proxy for an {@link IClassTransformer} that intercepts the {@link IClassTransformer#transform(String, String, byte[])} method and redirects it to a series of wrappers who may modify the method call as they wish.</p> */
public class TransformerProxy implements IClassTransformer, NonFunctionAlteringWrapper<IClassTransformer> {
public class TransformerProxy implements IClassTransformer, IWrapper<IClassTransformer> {
protected IClassTransformer original;

private List<ITransformerWrapper> wrappers = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import com.google.common.collect.Lists;

import makamys.coretweaks.optimization.NonFunctionAlteringWrapper;
import makamys.coretweaks.api.IWrapper;
import makamys.coretweaks.util.PluralUtil;
import makamys.coretweaks.util.WrappedAddListenableList;
import makamys.coretweaks.util.WrappedAddListenableList.AdditionEvent;
Expand Down Expand Up @@ -64,8 +64,8 @@ public void hookClassLoader(boolean installListener) {

private IClassTransformer createCachedProxy(IClassTransformer transformer, boolean onlyFirst) {
IClassTransformer realTransformer = transformer;
while(realTransformer instanceof NonFunctionAlteringWrapper<?>) {
realTransformer = ((NonFunctionAlteringWrapper<IClassTransformer>)realTransformer).getOriginal();
while(realTransformer instanceof IWrapper<?>) {
realTransformer = ((IWrapper<IClassTransformer>)realTransformer).getOriginal();
}
List<ITransformerWrapper> wrappers = new ArrayList<>();
for(ITransformerWrapperProvider l : (onlyFirst ? Collections.singletonList(listeners.get(0)) : listeners)) {
Expand Down

0 comments on commit 0939963

Please sign in to comment.