Remove the World singleton.

This commit is contained in:
Major-
2015-03-28 13:46:50 +00:00
parent 7cf31a2888
commit 3bd3ddd226
68 changed files with 620 additions and 323 deletions
+2 -12
View File
@@ -81,7 +81,7 @@ class ProcMessageHandler < MessageHandler
# Creates the ProcMessageListener.
def initialize(block, option)
super()
super($world)
@block = block
@option = option
end
@@ -200,15 +200,5 @@ def on_command(args, proc)
raise 'Command message must have one or two arguments.' unless (1..2).include?(args.length)
rights = args.length == 2 ? args[1] : RIGHTS_STANDARD
PluginContext::add_command_listener(args[0].to_s, ProcCommandListener.new(rights, proc))
end
# Defines an action to be taken upon login.
def on_login(proc)
PluginContext::add_login_listener(ProcLoginListener.new(proc))
end
# Defines an action to be taken upon logout.
def on_logout(proc)
PluginContext::add_logout_listener(ProcLogoutListener.new(proc))
$world.command_dispatcher.register(args[0].to_s, ProcCommandListener.new(rights, proc))
end
+3 -1
View File
@@ -4,7 +4,9 @@ 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}.")
position = player.position
player.send_message("You are at: #{position}.")
player.send_message("Local coordinates: (#{position.get_local_x}, #{position.get_local_y}).")
end
# Teleports the player to the specified position.
+1 -1
View File
@@ -47,7 +47,7 @@ def get_npc(hash)
z = hash.delete(:z)
position = Position.new(hash.delete(:x), hash.delete(:y), z == nil ? 0 : z)
return Npc.new(id, position)
return Npc.new($world, id, position)
end
# Applies a decoded hash (one aquired using parse_hash) to the specified npc.
@@ -18,8 +18,8 @@ CHARACTER_DESIGN = 3559
# Sends the appropriate data to the client when the player logs in to the game.
on :login do |event, player|
if player.in_tutorial_island
TutorialInstructions::show_instruction(player)
INITIAL_TABS.each_with_index { |tab, index| player.send(SwitchTabInterfaceMessage.new(index, tab)) }
# TutorialInstructions::show_instruction(player)
# INITIAL_TABS.each_with_index { |tab, index| player.send(SwitchTabInterfaceMessage.new(index, tab)) }
if (player.tutorial_island_progress == :not_started)
show_hint_icon(player)