mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Add an ::objectinfo command.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
require 'java'
|
require 'java'
|
||||||
|
|
||||||
|
java_import 'org.apollo.game.model.Entity'
|
||||||
java_import 'org.apollo.game.model.Player'
|
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.ItemDefinition'
|
||||||
java_import 'org.apollo.game.model.def.NpcDefinition'
|
java_import 'org.apollo.game.model.def.NpcDefinition'
|
||||||
java_import 'org.apollo.game.model.def.ObjectDefinition'
|
java_import 'org.apollo.game.model.def.ObjectDefinition'
|
||||||
@@ -13,6 +15,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
|||||||
end
|
end
|
||||||
|
|
||||||
type = args.shift.downcase
|
type = args.shift.downcase
|
||||||
|
limit = args.first.to_i != 0 ? args.shift.to_i : 5
|
||||||
name = args.join(' ').downcase
|
name = args.join(' ').downcase
|
||||||
|
|
||||||
if ['npc', 'object', 'item'].index(type) == nil
|
if ['npc', 'object', 'item'].index(type) == nil
|
||||||
@@ -20,7 +23,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
|||||||
next
|
next
|
||||||
end
|
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}."
|
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}."
|
||||||
player.send_message(message)
|
player.send_message(message)
|
||||||
@@ -57,3 +60,16 @@ on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
|||||||
player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.")
|
player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.")
|
||||||
player.send_message("Its description is \"#{definition.description}\".")
|
player.send_message("Its description is \"#{definition.description}\".")
|
||||||
end
|
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
|
||||||
Reference in New Issue
Block a user