mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 08:40:08 +00:00
Housekeeping
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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
|
||||
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::animate [animation-id]')
|
||||
|
||||
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
|
||||
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::graphic [graphic-id]')
|
||||
|
||||
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'
|
||||
|
||||
# Opens the player's bank.
|
||||
on :command, :bank, RIGHTS_ADMIN do |player, _command|
|
||||
player.open_bank
|
||||
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,45 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.cache.def.ItemDefinition'
|
||||
|
||||
# Adds the specified item to the player's inventory.
|
||||
on :command, :item, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
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
|
||||
|
||||
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 inventory.
|
||||
on :command, :remove, RIGHTS_MOD do |player, command|
|
||||
args = command.arguments
|
||||
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
|
||||
|
||||
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 inventory.
|
||||
on :command, :empty, RIGHTS_MOD do |player, _command|
|
||||
player.inventory.clear
|
||||
end
|
||||
|
||||
# Gives the player 1,000 of each rune.
|
||||
on :command, :runes, RIGHTS_ADMIN do |player, _command|
|
||||
(554..566).each { |item| player.inventory.add(item, 1000) }
|
||||
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,69 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.cache.def.ItemDefinition'
|
||||
java_import 'org.apollo.cache.def.NpcDefinition'
|
||||
java_import 'org.apollo.cache.def.ObjectDefinition'
|
||||
java_import 'org.apollo.game.model.entity.Entity'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments.to_a
|
||||
message = 'Invalid syntax - ::lookup [npc/object/item] [name]'
|
||||
next unless valid_arg_length(args, (1..10), player, message)
|
||||
|
||||
type = args.shift.downcase
|
||||
limit = args.first.to_i == 0 ? 5 : args.shift.to_i
|
||||
name = args.join(' ').downcase
|
||||
|
||||
if %w(npc object item).index(type).nil?
|
||||
player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]')
|
||||
next
|
||||
end
|
||||
|
||||
ids = find_entities(type, name, limit).join(', ')
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# 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
|
||||
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::objectinfo [object id]')
|
||||
|
||||
id = args[0].to_i
|
||||
definition = ObjectDefinition.lookup(id)
|
||||
player.send_message("Object #{id} is called #{definition.name} and its description is "\
|
||||
"\"#{definition.description}\".")
|
||||
player.send_message("Its width is #{definition.width} and its length is #{definition.length}.")
|
||||
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>util</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -0,0 +1,12 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
# Adds a command to broadcast a message to every player on the server.
|
||||
on :command, :broadcast, RIGHTS_ADMIN do |player, command|
|
||||
message = command.arguments.to_a.join(' ')
|
||||
broadcast = "[Broadcast] #{player.get_username.capitalize}: #{message}"
|
||||
|
||||
$world.player_repository.each { |other| other.send_message(broadcast) }
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>message</id>
|
||||
<version>1</version>
|
||||
<name>Messaging commands</name>
|
||||
<description>Adds various message-related commands, such as enabling the server-side chat filter or broadcasting a message.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
<author>xEliqa</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>broadcast.rb</script>
|
||||
</scripts>
|
||||
<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,68 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
java_import 'org.apollo.game.model.entity.Npc'
|
||||
|
||||
# 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, 4].include?(args.length) && (id = args[0].to_i) > -1
|
||||
player.send_message('Invalid syntax - ::spawn [npc id] [optional-x] [optional-y] [optional-z]')
|
||||
return
|
||||
end
|
||||
|
||||
if blacklist.include?(id)
|
||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||
return
|
||||
end
|
||||
|
||||
if args.length == 1
|
||||
position = player.position
|
||||
else
|
||||
height = args.length == 4 ? args[3].to_i : player.position.height
|
||||
position = Position.new(args[1].to_i, args[2].to_i, height)
|
||||
end
|
||||
|
||||
$world.register(Npc.new($world, id, position))
|
||||
end
|
||||
|
||||
# Mass spawns npcs around the player.
|
||||
on :command, :mass, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2 && (id = args[0].to_i) > -1 && (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
|
||||
|
||||
min_x = center_position.x - range
|
||||
min_y = center_position.y - range
|
||||
max_x = center_position.x + range
|
||||
max_y = center_position.y + range
|
||||
z = center_position.height
|
||||
|
||||
(min_x..max_x).each do |x|
|
||||
(min_y..max_y).each do |y|
|
||||
$world.register(Npc.new($world, 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|
|
||||
$world.npc_repository.each { |npc| $world.unregister(npc) }
|
||||
player.send_message('Unregistered all npcs from the world.')
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>punishment</id>
|
||||
<version>1</version>
|
||||
<name>Punishment commands</name>
|
||||
<description>Adds various punishment commands, such as banning or muting a player.</description>
|
||||
<authors>
|
||||
<author>lare96</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>punish.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,53 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
# Adds a command to mute a player. Admins cannot be muted.
|
||||
on :command, :mute, RIGHTS_MOD do |player, command|
|
||||
name = command.arguments.to_a.join(' ')
|
||||
on_player = $world.get_player(name)
|
||||
|
||||
if validate(player, on_player)
|
||||
on_player.muted = true
|
||||
on_player.send_message('You have just been muted.')
|
||||
player.send_message("You have just muted #{on_player.get_username}.")
|
||||
end
|
||||
end
|
||||
|
||||
# Adds a command to unmute a player.
|
||||
on :command, :unmute, RIGHTS_MOD do |player, command|
|
||||
name = command.arguments.to_a.join(' ')
|
||||
on_player = $world.get_player(name)
|
||||
|
||||
if validate(player, on_player)
|
||||
on_player.muted = false
|
||||
on_player.send_message('You are no longer muted.')
|
||||
player.send_message("You have just unmuted #{on_player.get_username}.")
|
||||
end
|
||||
end
|
||||
|
||||
# Adds a command to ban a player. Admins cannot be banned.
|
||||
on :command, :ban, RIGHTS_ADMIN do |player, command|
|
||||
name = command.arguments.to_a.join(' ')
|
||||
on_player = $world.get_player(name)
|
||||
|
||||
if validate(player, on_player)
|
||||
on_player.banned = true
|
||||
on_player.logout # TODO force logout
|
||||
player.send_message("You have just banned #{on_player.get_username}.")
|
||||
end
|
||||
end
|
||||
|
||||
# Ensures the player isn't nil, and that they aren't an Administrator.
|
||||
def validate(player, on_player)
|
||||
if on_player.nil?
|
||||
player.send_message('That player does not exist.')
|
||||
return false
|
||||
elsif on_player.get_privilege_level == RIGHTS_ADMIN
|
||||
player.send_message('You cannot perform this action on Administrators.')
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
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,44 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.entity.SkillSet'
|
||||
java_import 'org.apollo.game.model.entity.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]')
|
||||
next
|
||||
end
|
||||
|
||||
experience = SkillSet.get_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'
|
||||
|
||||
# Sends the player's position.
|
||||
on :command, :pos, RIGHTS_MOD do |player, _command|
|
||||
player.send_message("You are at: #{player.position}.")
|
||||
end
|
||||
|
||||
# Teleports the player to the specified position.
|
||||
on :command, :tele, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
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
|
||||
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