Add an ::objectinfo command.

This commit is contained in:
Major-
2014-03-06 18:26:58 +00:00
parent b9db104679
commit 92f4c7daf5
+17 -1
View File
@@ -1,6 +1,8 @@
require 'java'
java_import 'org.apollo.game.model.Entity'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.def.ItemDefinition'
java_import 'org.apollo.game.model.def.NpcDefinition'
java_import 'org.apollo.game.model.def.ObjectDefinition'
@@ -13,6 +15,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
end
type = args.shift.downcase
limit = args.first.to_i != 0 ? args.shift.to_i : 5
name = args.join(' ').downcase
if ['npc', 'object', 'item'].index(type) == nil
@@ -20,7 +23,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
next
end
ids = locate_entity(type, name).join(', ')
ids = locate_entity(type, name, limit).join(', ')
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}."
player.send_message(message)
@@ -56,4 +59,17 @@ on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
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
# 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
id = args[0].to_i
definition = ObjectDefinition.lookup(id)
player.send_message("Object #{id} is called #{definition.name} and its description is \"#{definition.description}\".")
end