Last active
January 22, 2019 11:22
-
-
Save TheCodedOne/ed66dd1372a944c22501bedee81690b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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