Class: MinecraftSpigot

Inherits:
Object
  • Object
show all
Defined in:
lib/servers/minecraft_spigot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMinecraftSpigot

Returns a new instance of MinecraftSpigot.



8
9
10
11
12
# File 'lib/servers/minecraft_spigot.rb', line 8

def initialize
  @name = "minecraft"
  @app_id = nil
  @version = "1.15.1"
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



7
8
9
# File 'lib/servers/minecraft_spigot.rb', line 7

def app_id
  @app_id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/servers/minecraft_spigot.rb', line 7

def name
  @name
end

Instance Method Details

#install_server(install_path, version = @version) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/servers/minecraft_spigot.rb', line 18

def install_server(install_path, version = @version)
  FileUtils.mkdir_p(install_path)
  File.open("#{install_path}/BuildTools.jar", "wb") do |file|
    file.write(open("https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar").read())
  end
  system("cd #{install_path} && java -Xmx1024M -jar #{install_path}/BuildTools.jar --rev #{version}")
end

#launch(install_path) ⇒ Object



14
15
16
# File 'lib/servers/minecraft_spigot.rb', line 14

def launch(install_path)
  "cd #{install_path} && java -Xms1G -Xmx2G -jar spigot.jar --noconsole"
end

#post_install(install_path, version = @version) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/servers/minecraft_spigot.rb', line 26

def post_install(install_path, version = @version)
  system("rm -f #{install_path}/eula.txt")
  system("touch #{install_path}/eula.txt")
  system("echo 'eula=true' >> #{install_path}/eula.txt")

  system("mv #{install_path}/spigot-#{version}.jar #{install_path}/spigot.jar")
end