Module: Fishbans

Extended by:
Fishbans
Includes:
BlockEngine, PlayerSkins
Included in:
Fishbans
Defined in:
lib/fishbans.rb,
lib/block_engine.rb,
lib/player_skins.rb

Defined Under Namespace

Modules: BlockEngine, PlayerSkins

Constant Summary collapse

SERVICES =
[
  'mcbouncer',
  'minebans',
  'glizer',
  'mcblockit',
  'mcbans'
]

Instance Method Summary collapse

Methods included from PlayerSkins

#get_player_front, #get_player_head, #get_player_skin

Methods included from BlockEngine

#get_block, #get_monster

Instance Method Details

#get_all_bans(username) ⇒ Object

Gets all bans on a user.

Parameters:

  • username (String)

    The username to check.

Returns:

  • see #parse_generic_ban_result

Raises:

  • see #get



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

def get_all_bans(username)
  response = get("http://api.fishbans.com/bans/#{username}")
  parse_generic_ban_result(response)
end

#get_ban_service(username, service) ⇒ Boolean, Hash<String, String>

Gets all bans for a given service for a user.

Parameters:

  • username (String)

    The username to check.

  • service (String)

    The service to check. Can be any of the values in the SERVICES array.

Returns:

  • (Boolean)

    False if the service is not an accepted value.

  • (Hash<String, String>)

    Key: Minecraft server; value: reason

Raises:

  • see #get



35
36
37
38
39
40
41
42
43
44
# File 'lib/fishbans.rb', line 35

def get_ban_service(username, service)
  service.downcase!

  if SERVICES.include? service
    response = get("http://api.fishbans.com/bans/#{username}/#{service}")
    parse_generic_ban_result(response)[service]
  else
    false
  end
end

#get_total_bans(username) ⇒ Integer

Gets the total number of bans that the user has.

Parameters:

  • username (String)

    The username to check.

Returns:

  • (Integer)

    The number of bans the user has.

Raises:

  • see #get



50
51
52
53
# File 'lib/fishbans.rb', line 50

def get_total_bans(username)
  response = get("http://api.fishbans.com/stats/#{username}")
  response['stats']['totalbans']
end

#get_total_bans_service(username, service) ⇒ Boolean, Integer

Gets the total number of bans by service that the user has.

Parameters:

  • username (String)

    The username to check.

  • service (String)

    The service to check. Can be any of the values in the SERVICES array.

Returns:

  • (Boolean)

    False if the service is not an accepted value.

  • (Integer)

    The number of bans the user has in the given service. See SERVICES for valid services.

Raises:

  • see #get



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/fishbans.rb', line 62

def get_total_bans_service(username, service)
  service.downcase!

  if SERVICES.include?(service)
    # Note that the /service part is not necessary, but it slightly improves
    #   performance of the API.
    response = get("http://api.fishbans.com/stats/#{username}/#{service}")
    response['stats']['service'][service]
  else
    false
  end
end

#get_userid(username) ⇒ String

Gets the Minecraft UUID for the user.

Parameters:

  • username (String)

    The username to get the ID for.

Returns:

  • (String)

    The user’s UUID.

Raises:

  • see #get



79
80
81
82
# File 'lib/fishbans.rb', line 79

def get_userid(username)
  response = get("http://api.fishbans.com/uuid/#{username}")
  response['uuid']
end

#get_username_history(username) ⇒ Array<String>

Gets username history for the user.

Parameters:

  • username (String)

    The username to get history for.

Returns:

  • (Array<String>)

    Array of strings containing old usernames.

Raises:

  • see #get



88
89
90
91
# File 'lib/fishbans.rb', line 88

def get_username_history(username)
  response = get("http://api.fishbans.com/history/#{username}")
  response['data']['history']
end