Source:
public void changeShip(Hero hero, String newShipID, SolGame game, Console console) { SolShip originalShip = hero.getShip(); Optional<SolShip> newShip; boolean isARealShip = false; for (ResourceUrn urn : Assets.getAssetHelper().list(Json.class)) { if ((urn.getModuleName() + ":" + urn.getResourceName()).equals(newShipID)) { isARealShip = true; break; } } if (!isARealShip) { if (console != null) { console.warn("Invalid or Unknown ship ID."); } return; } HullConfig newHullConfig = game.getHullConfigManager().getConfig(newShipID); AtomicInteger objectCount = new AtomicInteger(0); game.getObjectManager().doToAllCloserThan(newHullConfig.getSize(), originalShip.getPosition(), (SolObject obj) -> objectCount.addAndGet(1) ); if (objectCount.get() > 1) { if (console != null) { console.warn("Not enough space available to spawn this ship!"); } return; } if (newHullConfig.getEngineConfig() == null) { if (console != null) { console.warn("Cannot spawn a ship which has no engine configuration!"); } return; } newShip = Optional.of(game.getShipBuilder().build(game, originalShip.getPosition(), originalShip.getVelocity(), originalShip.getAngle(), originalShip.getRotationSpeed(), originalShip.getPilot(), originalShip.getItemContainer(), newHullConfig, newHullConfig.getMaxLife(), originalShip.getHull().getGun(false), originalShip.getHull().getGun(true), null, newHullConfig.getEngineConfig().exampleEngine.copy(), new ShipRepairer(), originalShip.getMoney(), null, originalShip.getShield(), originalShip.getArmor())); game.getObjectManager().removeObjDelayed(hero.getShip()); game.getObjectManager().addObjDelayed(newShip.get()); hero.setSolShip(newShip.get(), game); }

Target:
public void changeShip(Hero hero, String newShipID, SolGame game, Console console) { SolShip originalShip = hero.getShip(); Optional<SolShip> newShip; boolean isARealShip = false; for (ResourceUrn urn : Assets.getAssetHelper().list(Json.class)) { if ((urn.getModuleName() + ":" + urn.getResourceName()).equals(newShipID)) { try { Validator.getValidatedJSON(newShipID, "engine:schemaHullConfig"); } catch (RuntimeException e) { break; } isARealShip = true; break; } } if (!isARealShip) { if (console != null) { console.warn("Could not find ship " + newShipID); } return; } HullConfig newHullConfig = game.getHullConfigManager().getConfig(newShipID); AtomicInteger objectCount = new AtomicInteger(0); game.getObjectManager().doToAllCloserThan(newHullConfig.getSize(), originalShip.getPosition(), (SolObject obj) -> objectCount.addAndGet(1) ); if (objectCount.get() > 1) { if (console != null) { console.warn("Not enough space available to spawn this ship!"); } return; } if (newHullConfig.getEngineConfig() == null) { if (console != null) { console.warn("Cannot spawn a ship which has no engine configuration!"); } return; } newShip = Optional.of(game.getShipBuilder().build(game, originalShip.getPosition(), originalShip.getVelocity(), originalShip.getAngle(), originalShip.getRotationSpeed(), originalShip.getPilot(), originalShip.getItemContainer(), newHullConfig, newHullConfig.getMaxLife(), originalShip.getHull().getGun(false), originalShip.getHull().getGun(true), null, newHullConfig.getEngineConfig().exampleEngine.copy(), new ShipRepairer(), originalShip.getMoney(), null, originalShip.getShield(), originalShip.getArmor())); game.getObjectManager().removeObjDelayed(hero.getShip()); game.getObjectManager().addObjDelayed(newShip.get()); hero.setSolShip(newShip.get(), game); }