This is blackmagic (reflections) based mod (that does not call obfuscated core methods for now) to allow multiple CharacterCreationPluginImpl scripts to load it's data into memory without major side effects.
Current implementation is:
Spoiler
package data.scripts.plugins;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import data.scripts.world.RawCodeGen;
import data.usc.uscData;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
public class CharacterCreationPluginImpl implements CharacterCreationPlugin {
// externals block
@SuppressWarnings("rawtypes")
public static List _getResponses = new ArrayList();
public static int _stage = 0;
public static
HashMap<String,ResponseImpl> _ResponsePool = new HashMap<String,ResponseImpl>();
Logger fun = Logger.getLogger(this.getClass());
public static class ResponseImpl implements Response {
private String text;
public ResponseImpl(String text) {
this.text = text;
}
public String getText() {
return text;
}
}
public void eventbussurrogate1() throws Exception{
Class test = Class.forName("data.scripts.plugins.CharacterCreationPluginImpl_1");
Method inv = test.getMethod("main", null);
Method tt = test.getMethod("getResponses", null);
inv.invoke(null, null);
tt.invoke(null, null);
}
public void eventbussurrogate() throws Exception{
Class<?> test = Class.forName("data.scripts.plugins.CharacterCreationPluginImpl_0");
Method inv = test.getDeclaredMethod("main", null);
Method tt = test.getDeclaredMethod("getResponses", null);
fun.info("sur 1");
inv.invoke(null, null);
tt.invoke(null, null);
fun.info("sur 2");
}
private String[] prompts = new String[] {"1","2","3","4"};
public String getPrompt() {
if (_stage < prompts.length) {
return prompts[_stage];
}
return null;
}
public List getResponses() {
_getResponses = new ArrayList();
fun.info("TEST 1");
try {
fun.info("TEST 2");
eventbussurrogate();
fun.info("TEST 3");
} catch (Exception e) {
fun.info("TEST 4");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString();
fun.info(sw.toString()+ "FFFF");
fun.info("TEST 5");
}
try {
eventbussurrogate1();
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString();
fun.info(sw.toString()+ "FFFF");
}
fun.info("SIZE OF ARRAY OUTSIDE " + _getResponses.size());
return _getResponses;
}
public void submit(Response response, CharacterCreationData data) {
_stage++;
}
public void startingShipPicked(String variantId, CharacterCreationData data) {
}
}
Surrogates implementation is:
Spoiler
package data.scripts.plugins;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.CharacterCreationPlugin.CharacterCreationData;
import com.fs.starfarer.api.characters.CharacterCreationPlugin.Response;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import data.scripts.plugins.CharacterCreationPluginImpl.ResponseImpl;
import data.usc.uscData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
public class CharacterCreationPluginImpl_0 {
static Logger fun = Logger.getLogger("INVOKE");
@SuppressWarnings("unused")
public static void main(){
HashMap<String, ResponseImpl> _ResponsePool = CharacterCreationPluginImpl._ResponsePool;
fun.info("INSIDE 1");
_ResponsePool.put("LOL",new ResponseImpl(
"Served as a junior supply officer in an independent system's navy"));
_ResponsePool.put("LOL1",new ResponseImpl(
"Hired out as a gunner on a mercenary ship"));
_ResponsePool.put("LOL2",new ResponseImpl(
"Spent time as a co-pilot on a patrol ship in an independent system"));
fun.info("INSIDE 2");
}
public static void getResponses() {
List current = CharacterCreationPluginImpl._getResponses;
HashMap<String, ResponseImpl> _ResponsePool = CharacterCreationPluginImpl._ResponsePool;
fun.info("INSIDE 3");
fun.info("STAGE " + CharacterCreationPluginImpl._stage);
switch (CharacterCreationPluginImpl._stage){
case 0:fun.info("case 1");
current.add(_ResponsePool.get("LOL")); break;
case 1:fun.info("case 2");
current.add(_ResponsePool.get("LOL1")); break;
case 2:fun.info("case 3");
current.add(_ResponsePool.get("LOL2")); break;
}
fun.info("INSIDE 4");
fun.info("SIZE OF ARRAY " + current.size());
}
}
Current version is proof of concept, a bit later (after few cups of coffe) i will try to implement class discovery method, that will search all suitable classes and load em.
Currently it able to load as many classes as needed as long as them follow CharacterCreationPluginImpl_NUMBER format.
I will cap number of attempts at 32 for now, soo every one will have nice chance to select free number and sucsessfuly load code.
NOTE it may fail on your machine due java.io limitation, PM me i will provide patch for this or remove any java.io calls (they used to log stacktraces only)
Edit: [code=java] ~Trylo