mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 00:38:11 +00:00
Update existing plugins to use the new utils plugin.
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user