module Nova::Starbound::DefaultBehavior::StarRunnable
Handles running stars.
Public Class Methods
included(reciever)
click to toggle source
When this is included by {DefaultBehavior}, define the packets nessicary for star running.
@return [void]
# File lib/nova/starbound/default_behavior/star_runnable.rb, line 55 def self.included(reciever) reciever.handle :packet => :star_run end
Public Instance Methods
run_star(target, data)
click to toggle source
Runs the star with the given information.
@param target [String] the target to originate the star to
run from.
@param data [Hash] the data to pass to the event. @return [Boolean] if it was successful.
# File lib/nova/starbound/default_behavior/star_runnable.rb, line 14 def run_star(target, data) return false unless authenticated? star = Star.from_target target return false unless star inst = star.new Remote::Local inst.options = data["options"] out = inst.run(target.split('.').last, data["arguments"]) if out.is_a? NoEventError return false else return true end end
Private Instance Methods
handle_packet_star_run(packet, protocol)
click to toggle source
Handles an incoming packet request for handling stars.
@param packet [Protocol::Packet] the packet to handle. @param protocol [Protocol] the protocol. @return [void]
# File lib/nova/starbound/default_behavior/star_runnable.rb, line 37 def handle_packet_star_run(packet, protocol) raw = MultiJson.load packet.body if raw["target"] && run_star(raw["target"], raw) else protocol.respond_to packet, :standard_error, "Unable to run #{raw["target"]}" end rescue MultiJson::LoadError => e protocol.respond_to packet, :standard_error, e.message end