Listen for the PositionUpdateEvent so area listeners now function.

This commit is contained in:
Major-
2015-03-01 02:31:55 +00:00
parent 3982c3b5f8
commit 406329c295
2 changed files with 82 additions and 43 deletions
+12 -27
View File
@@ -3,8 +3,20 @@ require 'java'
java_import 'org.apollo.game.message.impl.DisplayCrossbonesMessage'
java_import 'org.apollo.game.model.entity.Player'
# Registers an area action.
def area_action(name, &block)
AREA_ACTIONS[name] = action = AreaAction.new
action.instance_eval(&block)
end
AREA_ACTIONS = {}
private
# An action that is called when a player enters or exits an area.
class AreaAction
@@ -38,31 +50,4 @@ class AreaAction
@on_exit.call(player) unless @on_exit.nil?
end
end
# Registers an area action.
def area_action(name, &block)
AREA_ACTIONS[name] = action = AreaAction.new
action.instance_eval(&block)
end
# Defines the pvp area action.
area_action :pvp do
on_entry { |player| player.in_pvp = true }
on_exit { |player| player.in_pvp = false }
end
# Defines the wilderness area action.
area_action :wilderness do
on_entry do |player|
player.send(DisplayCrossbonesMessage.new(true))
player.in_wilderness = true
end
on_exit do |player|
player.send(DisplayCrossbonesMessage.new(false))
player.in_wilderness = false
end
end