Class: RuneRb::Game::Entity::Commands::Ban

Inherits:
RuneRb::Game::Entity::Command show all
Defined in:
app/game/entity/commands/ban.rb

Overview

Bans a profile from the network.

Since:

  • 0.9.3

Instance Method Summary collapse

Methods inherited from RuneRb::Game::Entity::Command

#initialize

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Constructor Details

This class inherits a constructor from RuneRb::Game::Entity::Command

Instance Method Details

#executeObject

Since:

  • 0.9.3


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/game/entity/commands/ban.rb', line 5

def execute
  return unless @assets[:command][0].size > 0

  begin
    # First we update the banned status for the user
    RuneRb::Database::PlayerProfile[@assets[:command][0].downcase].update(banned: true)
    @assets[:context].session.write_message(:SystemTextMessage, message: "The player, #{@assets[:command][0]}, has been banned.")
  rescue StandardError => e
    err "An error occurred retrieving profile for: #{@assets[:command][0]}!", e
    puts e.backtrace
    return
  end

  # Next, we log the player out if they're connected to the same world instance.
  target = @assets[:context].world.request(:context, name: @assets[:command][0])
  if target
    @assets[:context].world.release(target)
  else
    @assets[:context].session.write_message(:SystemTextMessage, message: "Could not locate #{@assets[:command][0]} in any existing world instances.")
  end
end