mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Recursive plugin loading.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
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
|
||||
|
||||
player.play_animation(Animation.new(args[0].to_i))
|
||||
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
|
||||
|
||||
player.play_graphic(Graphic.new(args[0].to_i))
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-animate</id>
|
||||
<version>1</version>
|
||||
<name>Animate Commands</name>
|
||||
<description>Adds animation-related commands.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>animate.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,6 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
||||
|
||||
on :command, :bank, RIGHTS_ADMIN do |player, command|
|
||||
BankUtils.open_bank player
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-bank</id>
|
||||
<version>1</version>
|
||||
<name>Bank Command</name>
|
||||
<description>Adds a ::bank command.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>bank.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,9 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.settings.PrivacyState'
|
||||
|
||||
on :command, :filter do |player, command|
|
||||
player.send_message('Your message filter is now ' + (player.toggle_message_filter ? 'enabled.' : 'disabled.'))
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-filter</id>
|
||||
<version>1</version>
|
||||
<name>Filter commandr</name>
|
||||
<description>Adds a command to toggle a server-side message filter, for clients that have not been edited.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>filter.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,51 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.def.ItemDefinition'
|
||||
|
||||
# Adds the specified item to the player's own 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
|
||||
|
||||
id = args[0].to_i
|
||||
amount = args.length == 2 ? args[1].to_i : 1
|
||||
if (id < 0 || id >= ItemDefinition.count)
|
||||
player.send_message('The item id you specified is out of bounds!')
|
||||
next
|
||||
end
|
||||
|
||||
player.inventory.add(id, amount)
|
||||
end
|
||||
|
||||
# Removes the specified item from the player's own 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
|
||||
|
||||
id = args[0].to_i
|
||||
amount = args.length == 2 ? args[1].to_i : 1
|
||||
if (id < 0 || id >= ItemDefinition.count)
|
||||
player.send_message('The item id you specified is out of bounds!')
|
||||
next
|
||||
end
|
||||
|
||||
player.inventory.remove(id, amount)
|
||||
end
|
||||
|
||||
# Clears the player's own inventory.
|
||||
on :command, :empty, RIGHTS_MOD do |player, command|
|
||||
player.inventory.clear
|
||||
end
|
||||
|
||||
# Gives the player one thousand of each rune.
|
||||
on :command, :runes, RIGHTS_ADMIN do |player, command|
|
||||
(554..566).each do |i|
|
||||
player.inventory.add(i, 1000)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-item</id>
|
||||
<version>1</version>
|
||||
<name>Item Commands</name>
|
||||
<description>Adds ::item, ::remove and ::empty commands.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>item.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,75 @@
|
||||
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'
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]')
|
||||
next
|
||||
end
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-lookup</id>
|
||||
<version>1</version>
|
||||
<name>Lookup Command</name>
|
||||
<description>Adds a ::lookup command.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>lookup.rb</script>
|
||||
</scripts>
|
||||
<dependencies>
|
||||
<dependency>entity-spawning</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-npc</id>
|
||||
<version>1</version>
|
||||
<name>Npc Commands</name>
|
||||
<description>Adds npc-related commands.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>spawn.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,64 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.Npc'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
# 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.
|
||||
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]')
|
||||
return
|
||||
end
|
||||
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||
return
|
||||
end
|
||||
|
||||
position = args.length == 1 ? player.position : Position.new(args[1].to_i, args[2].to_i, player.position.height)
|
||||
|
||||
World.world.register(Npc.new(id, position))
|
||||
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)
|
||||
player.send_message('Invalid syntax - ::spawn [npc id] [range (1-5)]')
|
||||
return
|
||||
end
|
||||
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||
return
|
||||
end
|
||||
|
||||
center_position = player.position
|
||||
|
||||
minX = center_position.x - range
|
||||
minY = center_position.y - range
|
||||
maxX = center_position.x + range
|
||||
maxY = center_position.y + range
|
||||
z = center_position.height
|
||||
|
||||
for x in minX..maxX do
|
||||
for y in minY..maxY do
|
||||
World.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|
|
||||
iterator = World.world.npc_repository.iterator
|
||||
while iterator.has_next
|
||||
World.world.unregister(iterator.next)
|
||||
end
|
||||
player.send_message('Unregistered all npcs from the world.')
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-skill</id>
|
||||
<version>1</version>
|
||||
<name>Skill Commands</name>
|
||||
<description>Adds skill-related commands.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>skill.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,41 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.SkillSet'
|
||||
java_import 'org.apollo.game.model.Skill'
|
||||
|
||||
# Maximises the player's skill set.
|
||||
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
|
||||
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]")
|
||||
return
|
||||
end
|
||||
|
||||
experience = SkillSet.experience_for_level(level)
|
||||
current = level
|
||||
|
||||
if args.length == 3 && args[2].to_s == "old"
|
||||
skill = player.skill_set.skill(skill_id)
|
||||
current = skill.current_level
|
||||
end
|
||||
|
||||
player.skill_set.set_skill(skill_id, Skill.new(experience, current, level))
|
||||
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]")
|
||||
return
|
||||
end
|
||||
|
||||
player.skill_set.add_experience(skill_id, experience)
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-teleport</id>
|
||||
<version>1</version>
|
||||
<name>Teleport Commands</name>
|
||||
<description>Adds ::pos and ::tele commands.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>teleport.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,20 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
on :command, :pos, RIGHTS_MOD do |player, command|
|
||||
player.send_message("You are at: #{player.position}")
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
x = args[0].to_i
|
||||
y = args[1].to_i
|
||||
z = args.length == 3 ? args[2].to_i : player.position.height
|
||||
|
||||
player.teleport Position.new(x, y, z) if (0..4).include?(z)
|
||||
end
|
||||
Reference in New Issue
Block a user