Class: PalworldRcon::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/palworld_rcon/client.rb

Overview

Client

Instance Method Summary collapse

Constructor Details

#initialize(host:, port:, password:) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/palworld_rcon/client.rb', line 9

def initialize(host:, port:, password:)
  @rcon_client = Rcon::Client.new(host: host, port: port, password: password)
  @rcon_client.authenticate!(ignore_first_packet: false)
end

Instance Method Details

#ban_player(player_id) ⇒ Object



24
25
26
27
# File 'lib/palworld_rcon/client.rb', line 24

def ban_player(player_id)
  cmd = "BanPlayer #{player_id}"
  execute_command(cmd)
end

#broadcast(message) ⇒ Object



14
15
16
17
# File 'lib/palworld_rcon/client.rb', line 14

def broadcast(message)
  cmd = "Broadcast #{process_message(message)}"
  execute_command(cmd)
end

#do_exitObject



45
46
47
# File 'lib/palworld_rcon/client.rb', line 45

def do_exit
  execute_command("DoExit")
end

#kick_player(player_id) ⇒ Object



19
20
21
22
# File 'lib/palworld_rcon/client.rb', line 19

def kick_player(player_id)
  cmd = "KickPlayer #{player_id}"
  execute_command(cmd)
end

#saveObject



37
38
39
# File 'lib/palworld_rcon/client.rb', line 37

def save
  execute_command("Save")
end

#server_infoObject



41
42
43
# File 'lib/palworld_rcon/client.rb', line 41

def server_info
  execute_command("Info")
end

#show_playersObject



29
30
31
# File 'lib/palworld_rcon/client.rb', line 29

def show_players
  execute_command("ShowPlayers")
end

#shutdown(count_down, message) ⇒ Object



33
34
35
# File 'lib/palworld_rcon/client.rb', line 33

def shutdown(count_down, message)
  execute_command("Shutdown #{count_down} #{process_message(message)}")
end