import ShipPlugin from "server/src/classes/Plugins/Ship" ; import { DataContext } from "server/src/utils/DataContext" ; import { getPlugin } from "./utils" ; export const pluginShipsRequest = { pluginShips ( context , params , publishParams ) { if ( publishParams && params . pluginId !== publishParams . pluginId ) throw null ; const plugin = getPlugin ( context , params . pluginId ) ; return plugin . aspects . ships ; } , pluginShip ( context , params , publishParams ) { if ( publishParams && params . pluginId !== publishParams . pluginId ) throw null ; const plugin = getPlugin ( context , params . pluginId ) ; const ship = plugin . aspects . ships . find ( ship => ship . name === params . shipId ) ; if ( ! ship ) throw null ; return ship ; } , availableShips ( context ) { return context . server . plugins . reduce ( ( ships , plugin ) => { if ( ! plugin . active ) return ships ; return ships . concat ( plugin . aspects . ships ) ; } , [ ] ) . map ( ship => ( { name : ship . name , description : ship . description , vanityUrl : ship . toJSON ( ) . assets . vanity , pluginName : ship . pluginName , } ) ) ; } , } ;