Update all plugins to conform to Rubocop.

This commit is contained in:
Major-
2015-08-27 18:17:58 +01:00
parent 424d2bda29
commit 8f3fd75b33
75 changed files with 1625 additions and 1537 deletions
+1 -1
View File
@@ -17,4 +17,4 @@ on :command, :graphic, RIGHTS_MOD do |player, command|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::graphic [graphic-id]')
player.play_graphic(Graphic.new(args[0].to_i))
end
end
+2 -2
View File
@@ -1,6 +1,6 @@
require 'java'
# Opens the player's bank.
on :command, :bank, RIGHTS_ADMIN do |player, command|
on :command, :bank, RIGHTS_ADMIN do |player, _command|
player.open_bank
end
end
+8 -6
View File
@@ -6,10 +6,11 @@ java_import 'org.apollo.cache.def.ItemDefinition'
on :command, :item, RIGHTS_ADMIN do |player, command|
args = command.arguments
next unless valid_arg_length(args, (1..2), player, 'Invalid syntax - ::item [id] [amount]')
id = args[0].to_i
amount = args.length == 2 ? args[1].to_i : 1
if (id < 0 || id >= ItemDefinition.count)
if id < 0 || id >= ItemDefinition.count
player.send_message('The item id you specified is out of bounds!')
next
end
@@ -24,7 +25,8 @@ on :command, :remove, RIGHTS_MOD do |player, command|
id = args[0].to_i
amount = args.length == 2 ? args[1].to_i : 1
if (id < 0 || id >= ItemDefinition.count)
if id < 0 || id >= ItemDefinition.count
player.send_message('The item id you specified is out of bounds!')
next
end
@@ -33,11 +35,11 @@ on :command, :remove, RIGHTS_MOD do |player, command|
end
# Clears the player's inventory.
on :command, :empty, RIGHTS_MOD do |player, command|
on :command, :empty, RIGHTS_MOD do |player, _command|
player.inventory.clear
end
# Gives the player 1,000 of each rune.
on :command, :runes, RIGHTS_ADMIN do |player, command|
on :command, :runes, RIGHTS_ADMIN do |player, _command|
(554..566).each { |item| player.inventory.add(item, 1000) }
end
end
+17 -12
View File
@@ -9,20 +9,22 @@ java_import 'org.apollo.game.model.entity.Player'
on :command, :lookup, RIGHTS_ADMIN do |player, command|
args = command.arguments.to_a
next unless valid_arg_length(args, (1..10), player, 'Invalid syntax - ::lookup [npc/object/item] [name]')
message = 'Invalid syntax - ::lookup [npc/object/item] [name]'
next unless valid_arg_length(args, (1..10), player, message)
type = args.shift.downcase
limit = args.first.to_i == 0 ? 5 : args.shift.to_i;
limit = args.first.to_i == 0 ? 5 : args.shift.to_i
name = args.join(' ').downcase
if ['npc', 'object', 'item'].index(type) == nil
player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]')
if %w(npc object item).index(type).nil?
player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]')
next
end
ids = find_entities(type, name, limit).join(', ')
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids for \"#{name}\" are: #{ids}."
message = ids.empty? ? "Could not find an #{type} called #{name}." :
"Possible ids for \"#{name}\" are: #{ids}."
player.send_message(message)
end
@@ -35,7 +37,8 @@ on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
definition = ItemDefinition.lookup(id)
members = definition.is_members_only ? 'members' : 'not members'
player.send_message("Item #{id} is called #{definition.name}, is #{members} only, and has a team of #{definition.team}.")
player.send_message("Item #{id} is called #{definition.name}, is #{members} only, and has a "\
"team of #{definition.team}.")
player.send_message("Its description is \"#{definition.description}\".")
end
@@ -46,7 +49,8 @@ on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
id = args[0].to_i
definition = NpcDefinition.lookup(id)
is_combative = definition.has_combat_level ? "has a combat level of #{definition.combat_level}" : "does not have a combat level"
is_combative = definition.has_combat_level ? "has a combat level of #{definition.combat_level}" :
'does not have a combat level'
player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.")
player.send_message("Its description is \"#{definition.description}\".")
@@ -59,6 +63,7 @@ on :command, :objectinfo, RIGHTS_ADMIN do |player, command|
id = args[0].to_i
definition = ObjectDefinition.lookup(id)
player.send_message("Object #{id} is called #{definition.name} and its description is \"#{definition.description}\".")
player.send_message("Object #{id} is called #{definition.name} and its description is "\
"\"#{definition.description}\".")
player.send_message("Its width is #{definition.width} and its length is #{definition.length}.")
end
end
+4 -3
View File
@@ -5,7 +5,8 @@ java_import 'org.apollo.game.model.entity.Player'
# Adds a command to broadcast a message to every player on the server.
on :command, :broadcast, RIGHTS_ADMIN do |player, command|
message = command.arguments.to_a.join(" ")
message = command.arguments.to_a.join(' ')
broadcast = "[Broadcast] #{player.get_username.capitalize}: #{message}"
$world.player_repository.each { |player| player.send_message(broadcast) }
end
$world.player_repository.each { |other| other.send_message(broadcast) }
end
+3 -2
View File
@@ -1,5 +1,6 @@
require 'java'
on :command, :filter do |player, command|
player.send_message('Your message filter is now ' + (player.toggle_message_filter ? 'enabled.' : 'disabled.'))
end
status = player.toggle_message_filter ? 'enabled' : 'disabled'
player.send_message('Your message filter is now ' + status + '.')
end
+20 -13
View File
@@ -7,11 +7,12 @@ java_import 'org.apollo.game.model.entity.Npc'
# An array of npcs that cannot be spawned.
blacklist = []
# Spawns a non-blacklisted npc in the specified position, or the player's position if both 'x' and 'y' are not supplied.
# Spawns a non-blacklisted npc in the specified position, or the player's position if both 'x' and
# 'y' are not supplied.
on :command, :spawn, RIGHTS_ADMIN do |player, command|
args = command.arguments
unless [1, 3].include?(args.length) and (id = args[0].to_i) > -1
player.send_message('Invalid syntax - ::spawn [npc id] [optional-x] [optional-y]')
unless [1, 3, 4].include?(args.length) && (id = args[0].to_i) > -1
player.send_message('Invalid syntax - ::spawn [npc id] [optional-x] [optional-y] [optional-z]')
return
end
@@ -20,7 +21,12 @@ on :command, :spawn, RIGHTS_ADMIN do |player, command|
return
end
position = args.length == 1 ? player.position : Position.new(args[1].to_i, args[2].to_i, player.position.height)
if args.length == 1
position = player.position
else
height = args.length == 4 ? args[3].to_i : player.position.height
position = Position.new(args[1].to_i, args[2].to_i, height)
end
$world.register(Npc.new(id, position))
end
@@ -28,7 +34,7 @@ end
# Mass spawns npcs around the player.
on :command, :mass, RIGHTS_ADMIN do |player, command|
args = command.arguments
unless args.length == 2 and (id = args[0].to_i) > -1 and (1..5).include?(range = args[1].to_i)
unless args.length == 2 && (id = args[0].to_i) > -1 && (1..5).include?(range = args[1].to_i)
player.send_message('Invalid syntax - ::spawn [npc id] [range (1-5)]')
return
end
@@ -40,22 +46,23 @@ on :command, :mass, RIGHTS_ADMIN do |player, command|
center_position = player.position
minX = center_position.x - range
minY = center_position.y - range
maxX = center_position.x + range
maxY = center_position.y + range
min_x = center_position.x - range
min_y = center_position.y - range
max_x = center_position.x + range
max_y = center_position.y + range
z = center_position.height
for x in minX..maxX do
for y in minY..maxY do
(min_x..max_x).each do |x|
(min_y..max_y).each do |y|
$world.register(Npc.new(id, Position.new(x, y, z)))
end
end
player.send_message("Mass spawning npcs with id #{id}.")
end
# Unregisters all npcs from the world npc repository.
on :command, :clearnpcs, RIGHTS_ADMIN do |player, command|
on :command, :clearnpcs, RIGHTS_ADMIN do |player, _command|
$world.npc_repository.each { |npc| $world.unregister(npc) }
player.send_message('Unregistered all npcs from the world.')
end
end
+11 -8
View File
@@ -3,8 +3,9 @@ java_import 'org.apollo.game.model.entity.SkillSet'
java_import 'org.apollo.game.model.entity.Skill'
# Maximises the player's skill set.
on :command, :max, RIGHTS_ADMIN do |player, command|
on :command, :max, RIGHTS_ADMIN do |player, _command|
skills = player.skill_set
(0...skills.size).each do |skill|
skills.add_experience(skill, SkillSet::MAXIMUM_EXP)
end
@@ -13,15 +14,16 @@ end
# Levels the specified skill to the specified level, optionally updating the current level as well.
on :command, :level, RIGHTS_ADMIN do |player, command|
args = command.arguments
unless (2..3).include?(args.length) && (0..20).include?(skill_id = args[0].to_i) && (1..99).include?(level = args[1].to_i)
player.send_message("Invalid syntax - ::level [skill-id] [level]")
unless (2..3).include?(args.length) && (0..20).include?(skill_id = args[0].to_i) &&
(1..99).include?(level = args[1].to_i)
player.send_message('Invalid syntax - ::level [skill-id] [level]')
return
end
experience = SkillSet.experience_for_level(level)
current = level
if args.length == 3 && args[2].to_s == "old"
if args.length == 3 && args[2].to_s == 'old'
skill = player.skill_set.skill(skill_id)
current = skill.current_level
end
@@ -32,10 +34,11 @@ end
# Adds the specified amount of experience to the specified skill.
on :command, :xp, RIGHTS_ADMIN do |player, command|
args = command.arguments
unless args.length == 2 && (0..20).include?(skill_id = args[0].to_i) && (experience = args[1].to_i) >= 0
player.send_message("Invalid syntax - ::xp [skill-id] [experience]")
unless args.length == 2 && (0..20).include?(skill_id = args[0].to_i) &&
(experience = args[1].to_i) >= 0
player.send_message('Invalid syntax - ::xp [skill-id] [experience]')
return
end
player.skill_set.add_experience(skill_id, experience)
end
end
+3 -5
View File
@@ -3,10 +3,8 @@ require 'java'
java_import 'org.apollo.game.model.Position'
# Sends the player's position.
on :command, :pos, RIGHTS_MOD do |player, command|
position = player.position
player.send_message("You are at: #{position}.")
player.send_message("Local coordinates: (#{position.get_local_x}, #{position.get_local_y}).")
on :command, :pos, RIGHTS_MOD do |player, _command|
player.send_message("You are at: #{player.position}.")
end
# Teleports the player to the specified position.
@@ -19,4 +17,4 @@ on :command, :tele, RIGHTS_ADMIN do |player, command|
z = args.length == 3 ? args[2].to_i : player.position.height
player.teleport(Position.new(x, y, z)) if (0..4).include?(z)
end
end