Class: LaunchCraft::Java

Inherits:
Object
  • Object
show all
Defined in:
lib/launchcraft/java.rb,
lib/launchcraft/java.rb

Constant Summary collapse

BIN =
Kernel.which('java').tap {|x|
  next x if x
  break File.join(ENV['JAVA_HOME'], 'bin', 'java') if ENV['JAVA_HOME']
  raise RuntimeError, "java bin not found."
}

Class Method Summary collapse

Class Method Details

.exec(user, sessid = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/launchcraft/java.rb', line 23

def self.exec (user, sessid=nil)
    bindir = File.join(LaunchCraft.working_dir, 'bin')
    ::Java::java.lang.System.setProperty('org.lwjgl.librarypath', File.join(bindir, 'natives'))
    ::Java::java.lang.System.setProperty('net.java.games.input.librarypath', File.join(bindir, 'natives'))
    ::Java::java.lang.System.setProperty('minecraft.appname', LaunchCraft.appname)

    %w[jinput lwjgl lwjgl_util minecraft].each {|x|
      ::Kernel.require(File.join(bindir, "#{x}.jar"))
    }

    ::Java::net.minecraft.client.Minecraft.main([user, sessid].compact.to_java(:String))
end

.launch(user, sessid = nil) ⇒ Object



80
81
82
# File 'lib/launchcraft/java.rb', line 80

def launch (user, sessid=nil)
  Kernel.system(*args(user, sessid))
end

.spawn(user, sessid = nil) ⇒ Object



84
85
86
# File 'lib/launchcraft/java.rb', line 84

def spawn (user, sessid=nil)
  Kernel.spawn(*args(user, sessid))
end