Skip to content

Instantly share code, notes, and snippets.

@TheCodedOne
Last active January 22, 2019 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheCodedOne/ed66dd1372a944c22501bedee81690b0 to your computer and use it in GitHub Desktop.
Save TheCodedOne/ed66dd1372a944c22501bedee81690b0 to your computer and use it in GitHub Desktop.
package com.hrznstudio.spatial.mixin;
import org.reflections.Reflections;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import java.util.HashSet;
import java.util.Set;
/**
* ASM Hack to the PackageScanner to reduce connection time.
*/
@Mixin(targets = "improbable.worker.PackageScanner")
public class MixinPackageScanner {
private static final String[] prefixes = new String[]{
"improbable",
"your_base_component_package_here"
};
/**
* @reason Reduce SpatialOS connection from 10 minutes to 3 seconds
* @author Coded
*/
@Overwrite
public static <T> Set<Class<? extends T>> getAllSubClassesOf(final Class<T> desiredClass) {
Set<Class<? extends T>> set = new HashSet<>();
for (String prefix : prefixes) {
set.addAll(new Reflections(prefix).getSubTypesOf(desiredClass));
}
return set;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment