From c162705cd42b16eedfcc9ec85c739a9c34796199 Mon Sep 17 00:00:00 2001 From: Major- Date: Sat, 9 Aug 2014 17:12:25 +0100 Subject: [PATCH] Update existing plugins to use the new utils plugin. --- data/plugins/areas/areas.rb | 2 +- data/plugins/cmd/animate/animate.rb | 10 ++----- data/plugins/cmd/bank/bank.rb | 4 ++- data/plugins/cmd/item/item.rb | 22 +++++--------- data/plugins/cmd/lookup/lookup.rb | 28 +++++------------ data/plugins/cmd/npc/spawn.rb | 13 ++++---- data/plugins/cmd/teleport/teleport.rb | 5 +--- data/plugins/consumables/food.rb | 2 +- data/plugins/consumables/potions.rb | 30 +++++++++---------- data/plugins/dummy/dummy.rb | 4 +-- data/plugins/entity/spawning/npc-spawn.rb | 15 +++++----- data/plugins/location/al-kharid/npcs.rb | 2 +- data/plugins/location/edgeville/npcs.rb | 2 +- data/plugins/location/lumbridge/npcs.rb | 2 +- data/plugins/location/tutorial-island/npcs.rb | 22 +++++++++----- data/plugins/util/command.rb | 14 ++++++--- 16 files changed, 79 insertions(+), 98 deletions(-) diff --git a/data/plugins/areas/areas.rb b/data/plugins/areas/areas.rb index fd260542..3dc06e8f 100644 --- a/data/plugins/areas/areas.rb +++ b/data/plugins/areas/areas.rb @@ -35,7 +35,7 @@ end # Creates a new area and registers it with the supplied coordinates. def area(hash) - raise 'Hash must contain a name, coordinates, and actions pair.' unless hash.has_key?(:name) && hash.has_key?(:coordinates) && hash.has_key?(:actions) + raise 'Hash must contain a name, coordinates, and actions pair.' unless hash.has_keys?(:name, :coordinates, :actions) name = hash[:name]; coordinates = hash[:coordinates]; actions = hash[:actions] AREAS << Area.new(name, coordinates, actions.is_a?(Symbol) ? [actions] : actions) diff --git a/data/plugins/cmd/animate/animate.rb b/data/plugins/cmd/animate/animate.rb index 890a3d89..42d63e02 100644 --- a/data/plugins/cmd/animate/animate.rb +++ b/data/plugins/cmd/animate/animate.rb @@ -6,10 +6,7 @@ java_import 'org.apollo.game.model.Graphic' # Makes the player perform the animation with the specified id. on :command, :animate, RIGHTS_MOD do |player, command| args = command.arguments - unless args.length == 1 - player.send_message('Invalid syntax - ::animate [animation-id]') - return - end + next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::animate [animation-id]') player.play_animation(Animation.new(args[0].to_i)) end @@ -17,10 +14,7 @@ end # Makes the player perform the graphic with the specified id. on :command, :graphic, RIGHTS_MOD do |player, command| args = command.arguments - unless args.length == 1 - player.send_message('Invalid syntax - ::graphic [graphic-id]') - return - end + next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::graphic [graphic-id]') player.play_graphic(Graphic.new(args[0].to_i)) end \ No newline at end of file diff --git a/data/plugins/cmd/bank/bank.rb b/data/plugins/cmd/bank/bank.rb index 073f6a98..6c28fa91 100644 --- a/data/plugins/cmd/bank/bank.rb +++ b/data/plugins/cmd/bank/bank.rb @@ -1,6 +1,8 @@ require 'java' + java_import 'org.apollo.game.model.inter.bank.BankUtils' +# Opens the player's bank. on :command, :bank, RIGHTS_ADMIN do |player, command| - BankUtils.open_bank player + BankUtils.open_bank(player) end \ No newline at end of file diff --git a/data/plugins/cmd/item/item.rb b/data/plugins/cmd/item/item.rb index 05307ad9..504ac3a5 100644 --- a/data/plugins/cmd/item/item.rb +++ b/data/plugins/cmd/item/item.rb @@ -2,13 +2,10 @@ require 'java' java_import 'org.apollo.game.model.def.ItemDefinition' -# Adds the specified item to the player's own inventory. +# Adds the specified item to the player's inventory. on :command, :item, RIGHTS_ADMIN do |player, command| args = command.arguments - unless (1..2).include? args.length - player.send_message('Invalid syntax - ::item [id] [amount]') - next - end + 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 @@ -20,13 +17,10 @@ on :command, :item, RIGHTS_ADMIN do |player, command| player.inventory.add(id, amount) end -# Removes the specified item from the player's own inventory. +# Removes the specified item from the player's inventory. on :command, :remove, RIGHTS_MOD do |player, command| args = command.arguments - unless (1..2).include? args.length - player.send_message('Invalid syntax - ::remove [id] [amount]') - next - end + next unless valid_arg_length(args, (1..2), player, 'Invalid syntax - ::remove [id] [amount]') id = args[0].to_i amount = args.length == 2 ? args[1].to_i : 1 @@ -38,14 +32,12 @@ on :command, :remove, RIGHTS_MOD do |player, command| player.inventory.remove(id, amount) end -# Clears the player's own inventory. +# Clears the player's inventory. on :command, :empty, RIGHTS_MOD do |player, command| player.inventory.clear end -# Gives the player one thousand of each rune. +# Gives the player 1,000 of each rune. on :command, :runes, RIGHTS_ADMIN do |player, command| - (554..566).each do |i| - player.inventory.add(i, 1000) - end + (554..566).each { |item| player.inventory.add(item, 1000) } end \ No newline at end of file diff --git a/data/plugins/cmd/lookup/lookup.rb b/data/plugins/cmd/lookup/lookup.rb index fa9d863f..13a07c7c 100644 --- a/data/plugins/cmd/lookup/lookup.rb +++ b/data/plugins/cmd/lookup/lookup.rb @@ -9,13 +9,10 @@ java_import 'org.apollo.game.model.entity.Player' on :command, :lookup, RIGHTS_ADMIN do |player, command| args = command.arguments.to_a - unless args.length > 1 - player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]') - next - end + next unless valid_arg_length(args, (1..10), player, 'Invalid syntax - ::lookup [npc/object/item] [name]') type = args.shift.downcase - limit = args.first.to_i != 0 ? args.shift.to_i : 5 + limit = args.first.to_i == 0 ? 5 : args.shift.to_i; name = args.join(' ').downcase if ['npc', 'object', 'item'].index(type) == nil @@ -25,22 +22,19 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command| ids = find_entities(type, name, limit).join(', ') - message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}." + message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids for \"#{name}\" are: #{ids}." player.send_message(message) end # Sends the user a message with information about the item with the specified id. on :command, :iteminfo, RIGHTS_ADMIN do |player, command| args = command.arguments - unless args.length == 1 - player.send_message('Invalid syntax - ::iteminfo [item id]') - next - end + next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::iteminfo [item id]') id = args[0].to_i 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("Its description is \"#{definition.description}\".") end @@ -48,15 +42,12 @@ end # Sends the user a message with information about the npc with the specified id. on :command, :npcinfo, RIGHTS_ADMIN do |player, command| args = command.arguments - unless args.length == 1 - player.send_message('Invalid syntax - ::npcinfo [npc id]') - next - end + next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::npcinfo [npc id]') 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" + player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.") player.send_message("Its description is \"#{definition.description}\".") end @@ -64,10 +55,7 @@ end # Sends the user a message with information about the object with the specified id. on :command, :objectinfo, RIGHTS_ADMIN do |player, command| args = command.arguments - unless args.length == 1 - player.send_message('Invalid syntax - ::objectinfo [npc id]') - next - end + next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::objectinfo [npc id]') id = args[0].to_i definition = ObjectDefinition.lookup(id) diff --git a/data/plugins/cmd/npc/spawn.rb b/data/plugins/cmd/npc/spawn.rb index e85fd7de..01424b03 100644 --- a/data/plugins/cmd/npc/spawn.rb +++ b/data/plugins/cmd/npc/spawn.rb @@ -10,12 +10,12 @@ blacklist = [] # 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 + 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]') return end - if blacklist.include? id + if blacklist.include?(id) player.send_message("Sorry, npc #{id} is blacklisted!") return end @@ -28,12 +28,12 @@ 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 and (id = args[0].to_i) > -1 and (1..5).include?(range = args[1].to_i) player.send_message('Invalid syntax - ::spawn [npc id] [range (1-5)]') return end - if blacklist.include? id + if blacklist.include?(id) player.send_message("Sorry, npc #{id} is blacklisted!") return end @@ -56,9 +56,6 @@ end # Unregisters all npcs from the world npc repository. on :command, :clearnpcs, RIGHTS_ADMIN do |player, command| - iterator = $world.npc_repository.iterator - while iterator.has_next - $world.unregister(iterator.next) - end + $world.npc_repository.each { |npc| $world.unregister(npc) } player.send_message('Unregistered all npcs from the world.') end \ No newline at end of file diff --git a/data/plugins/cmd/teleport/teleport.rb b/data/plugins/cmd/teleport/teleport.rb index f93c54bd..cc82a25d 100644 --- a/data/plugins/cmd/teleport/teleport.rb +++ b/data/plugins/cmd/teleport/teleport.rb @@ -10,10 +10,7 @@ end # Teleports the player to the specified position. on :command, :tele, RIGHTS_ADMIN do |player, command| args = command.arguments - unless (2..3).include?(args.length) - player.send_message('Invalid syntax - ::tele [x] [y] [optional-z]') - return - end + next unless valid_arg_length(args, (2..3), player, 'Invalid syntax - ::tele [x] [y] [optional-z]') x = args[0].to_i y = args[1].to_i diff --git a/data/plugins/consumables/food.rb b/data/plugins/consumables/food.rb index 53f2daca..025b0ea2 100644 --- a/data/plugins/consumables/food.rb +++ b/data/plugins/consumables/food.rb @@ -29,7 +29,7 @@ end # Appends a food item to the list of consumables. def append_food(hash) - raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_key?(:name) && hash.has_key?(:id) && hash.has_key?(:restoration)) + raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_keys?(:name, :id, :restoration)) name = hash[:name]; id = hash[:id]; restoration = hash[:restoration] append_consumable(Food.new(name, id, restoration)) diff --git a/data/plugins/consumables/potions.rb b/data/plugins/consumables/potions.rb index 5311a98e..50f6304a 100644 --- a/data/plugins/consumables/potions.rb +++ b/data/plugins/consumables/potions.rb @@ -18,7 +18,7 @@ class Potion < Consumable unless index == @doses.length player.inventory.add(@doses[index]) player.send_message("You drink some of your #{name} potion.", true) - player.send_message("You have #{@doses.length - index} dose#{"s" unless index == 3} of potion left.", true) + player.send_message("You have #{ @doses.length - index } dose#{ "s" unless index == 3 } of potion left.", true) else player.send_message('You drink the last of your potion.') player.inventory.add(EMPTY_VIAL_ID) @@ -56,12 +56,11 @@ end # Returns the parameters for the potion, as an array. Raises if any of the specified keys do not exist def get_parameters(hash, keys) - parameters = [] - keys.each do |key| - raise "Hash must contain key #{key}." unless hash.has_key?(key) - parameters << hash[key] - end + raise "Hash must contain the following keys: #{ keys.join(", ") }." unless hash.has_keys?(*keys) + parameters = [] + keys.each { |key| parameters << hash[key] } + return parameters end @@ -71,7 +70,7 @@ def append_potion(hash) unless (hash.size == 2) keys << :skills << :boost - class_name.insert(0, 'Boosting') + class_name.prepend('Boosting') end parameters = get_parameters(hash, keys) @@ -84,9 +83,9 @@ end # Some frequently-used boosts and skills # Lambda parameters are | maximum_skill_level, current_skill_level | -basic_combat_boost = lambda { |m, l| l * 1.08 + 1 } -super_combat_boost = lambda { |m, l| l * 1.12 + 2 } -non_combat_boost = lambda { |m, l| l + 3 } +basic_combat_boost = lambda { |max, level| level * 1.08 + 1 } +super_combat_boost = lambda { |max, level| level * 1.12 + 2 } +non_combat_boost = lambda { |max, level| level + 3 } all_skills = (ATTACK_SKILL_ID..RUNECRAFT_SKILL_ID).to_a combat_skills = [ ATTACK_SKILL_ID, STRENGTH_SKILL_ID, DEFENCE_SKILL_ID, MAGIC_SKILL_ID, RANGED_SKILL_ID ] @@ -98,13 +97,12 @@ append_potion :name => :attack, :doses => [ 2428, 121, 123, 125 ], :skills append_potion :name => :strength, :doses => [ 113, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => basic_combat_boost append_potion :name => :defence, :doses => [ 2432, 133, 135, 137 ], :skills => DEFENCE_SKILL_ID, :boost => basic_combat_boost -append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost -append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost +append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost +append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost +append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |max, level| level / 4 + 7 } -append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |m, l| l / 4 + 7 } - -append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |m, l| [ l * 1.3 + 10, m ].min } -append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |m, l| [ l * 1.25 + 8, m ].min } +append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |max, level| [ level * 1.3 + 10, max ].min } +append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |max, level| [ level * 1.25 + 8, max ].min } append_potion :name => :super_attack, :doses => [ 2436, 145, 147, 149 ], :skills => ATTACK_SKILL_ID, :boost => super_combat_boost append_potion :name => :super_strength, :doses => [ 2440, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => super_combat_boost diff --git a/data/plugins/dummy/dummy.rb b/data/plugins/dummy/dummy.rb index f0158b73..fb0d0fb8 100644 --- a/data/plugins/dummy/dummy.rb +++ b/data/plugins/dummy/dummy.rb @@ -46,7 +46,5 @@ class DummyAction < DistancedAction end on :message, :second_object_action do |ctx, player, message| - if (message.id == DUMMY_ID) - player.start_action(DummyAction.new(player, message.position)) - end + player.start_action(DummyAction.new(player, message.position)) if message.id == DUMMY_ID end \ No newline at end of file diff --git a/data/plugins/entity/spawning/npc-spawn.rb b/data/plugins/entity/spawning/npc-spawn.rb index c4bbd788..344eabd6 100644 --- a/data/plugins/entity/spawning/npc-spawn.rb +++ b/data/plugins/entity/spawning/npc-spawn.rb @@ -11,7 +11,7 @@ java_import 'org.apollo.game.model.entity.Npc' # Information about npc spawning # # Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following: -# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) +# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) # :x - the x coordinate where the npc will spawn. # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: @@ -25,7 +25,7 @@ java_import 'org.apollo.game.model.entity.Npc' # Spawns an npc with the properties specified in the hash. def spawn_npc(hash) - raise 'A name (or id), x coordinate, and y coordinate must be specified to spawn an npc.' unless (hash.has_key?(:name) || hash.has_key?(:id)) && hash.has_key?(:x) && hash.has_key?(:y) + raise 'A name (or id), x coordinate, and y coordinate must be specified to spawn an npc.' unless (hash.has_key?(:name) || hash.has_key?(:id)) && hash.has_keys?(:x, :y) npc = get_npc(hash) spawn(npc, hash) end @@ -41,7 +41,7 @@ end # Returns an npc with the id and position specified by the hash. def get_npc(hash) - id = hash.delete(:id) || lookup_npc(hash.delete(:name)) + id = lookup_npc(hash.delete(:name)) z = hash.delete(:z) position = Position.new(hash.delete(:x), hash.delete(:y), z == nil ? 0 : z) @@ -64,22 +64,23 @@ end # Parses the remaining key-value pairs in the hash. def decode_hash(position, hash) decoded = {} + hash.each do |key, value| case key when :face - facing_position = direction_to_position(value, position) - decoded[:face] = facing_position + decoded[:face] = direction_to_position(value, position) when :delta_bounds dx, dy, x, y, z = value[0], value[1], position.x, position.y, position.height - raise 'Delta values cannot be less than 0.' if dx < 0 || dy < 0 + raise 'Delta values cannot be less than 0.' if (dx < 0 || dy < 0) decoded[:boundary] = [ Position.new(x + dx, y, z), Position.new(x, y + dy, z), Position.new(x - dx, y, z), Position.new(x, y - dy, z) ] when :bounds then decoded[:boundary] = value when :spawn_animation then decoded[:spawn_animation] = Animation.new(value) - when :spawn_graphic then decoded[:spawn_graphic] = Graphic.new(value) + when :spawn_graphic then decoded[:spawn_graphic ] = Graphic.new(value) else raise "Unrecognised key #{key} - value #{value}." end end + return decoded end diff --git a/data/plugins/location/al-kharid/npcs.rb b/data/plugins/location/al-kharid/npcs.rb index 886e1ffa..d61324ae 100644 --- a/data/plugins/location/al-kharid/npcs.rb +++ b/data/plugins/location/al-kharid/npcs.rb @@ -1,7 +1,7 @@ # Information about npc spawning # # Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following: -# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) +# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) # :x - the x coordinate where the npc will spawn. # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: diff --git a/data/plugins/location/edgeville/npcs.rb b/data/plugins/location/edgeville/npcs.rb index eecce498..36cb4eb0 100644 --- a/data/plugins/location/edgeville/npcs.rb +++ b/data/plugins/location/edgeville/npcs.rb @@ -1,7 +1,7 @@ # Information about npc spawning # # Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following: -# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) +# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) # :x - the x coordinate where the npc will spawn. # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: diff --git a/data/plugins/location/lumbridge/npcs.rb b/data/plugins/location/lumbridge/npcs.rb index cf5c7163..12dfc1d0 100644 --- a/data/plugins/location/lumbridge/npcs.rb +++ b/data/plugins/location/lumbridge/npcs.rb @@ -1,7 +1,7 @@ # Information about npc spawning # # Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following: -# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) +# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) # :x - the x coordinate where the npc will spawn. # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: diff --git a/data/plugins/location/tutorial-island/npcs.rb b/data/plugins/location/tutorial-island/npcs.rb index ec032673..2ce4f67d 100644 --- a/data/plugins/location/tutorial-island/npcs.rb +++ b/data/plugins/location/tutorial-island/npcs.rb @@ -1,7 +1,7 @@ # Information about npc spawning # # Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following: -# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) +# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4) # :x - the x coordinate where the npc will spawn. # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: @@ -12,6 +12,8 @@ # :spawn_graphic - the graphic that will be played when the npc spawns. +# Functional npcs + # 'Above-ground' npcs spawn_npc :name => :runescape_guide, :x => 3093, :y => 3107 @@ -31,6 +33,17 @@ spawn_npc :name => :combat_instructor, :x => 3104, :y => 9506 # Non-humanoid npcs spawn_npc :name => :fishing_spot_316, :x => 3102, :y => 3093 + +spawn_npc :name => :chicken, :x => 3140, :y => 3095 +spawn_npc :name => :chicken, :x => 3140, :y => 3093 +spawn_npc :name => :chicken, :x => 3138, :y => 3092 +spawn_npc :name => :chicken, :x => 3137, :y => 3094 +spawn_npc :name => :chicken, :x => 3138, :y => 3095 + + +# 'Below-ground' npcs +# Note: They aren't actually on a different plane, they're just in a different location that pretends to be underground. + spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9514 spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9517 spawn_npc :name => :giant_rat_87, :x => 3106, :y => 9514 @@ -38,9 +51,4 @@ spawn_npc :name => :giant_rat_87, :x => 3104, :y => 9514 spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9519 spawn_npc :name => :giant_rat_87, :x => 3109, :y => 9516 spawn_npc :name => :giant_rat_87, :x => 3108, :y => 9520 -spawn_npc :name => :giant_rat_87, :x => 3102, :y => 9517 -spawn_npc :name => :chicken_41, :x => 3140, :y => 3095 -spawn_npc :name => :chicken_41, :x => 3140, :y => 3093 -spawn_npc :name => :chicken_41, :x => 3138, :y => 3092 -spawn_npc :name => :chicken_41, :x => 3137, :y => 3094 -spawn_npc :name => :chicken_41, :x => 3138, :y => 3095 \ No newline at end of file +spawn_npc :name => :giant_rat_87, :x => 3102, :y => 9517 \ No newline at end of file diff --git a/data/plugins/util/command.rb b/data/plugins/util/command.rb index 0676a372..4673b861 100644 --- a/data/plugins/util/command.rb +++ b/data/plugins/util/command.rb @@ -3,9 +3,15 @@ def valid_arg_length(args, length, player, message) valid = length.kind_of?(Range) ? length.include?(args.length) : length == args.length - if (!valid) - player.send_message(message) - return false + player.send_message(message) if !valid + return valid +end + +# Add a has_keys? method to hash +class Hash + + def has_keys?(*keys) + keys.each { |key| return false unless has_key?(key) } + return true end - return true end \ No newline at end of file