mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Move EventContext functionality into Event, remove EventContext, add LogoutEvent support.
This commit is contained in:
@@ -19,6 +19,7 @@ java_import 'org.apollo.game.message.handler.MessageHandler'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
java_import 'org.apollo.game.model.event.EventListener'
|
||||
java_import 'org.apollo.game.model.event.PlayerEvent'
|
||||
java_import 'org.apollo.game.model.setting.PrivilegeLevel'
|
||||
java_import 'org.apollo.game.scheduling.ScheduledTask'
|
||||
java_import 'org.apollo.util.plugin.PluginContext'
|
||||
@@ -66,8 +67,10 @@ class ProcEventListener
|
||||
end
|
||||
|
||||
# Executes the block handling the Event.
|
||||
def handle(event, context)
|
||||
@block.call(event, context)
|
||||
def handle(event)
|
||||
args = [ event ]
|
||||
args << event.player if event.kind_of?(PlayerEvent)
|
||||
@block.call(*args)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -42,8 +42,7 @@ on :message, :remove_friend do |ctx, player, message|
|
||||
end
|
||||
|
||||
# Update the friend server status and send the friend/ignore lists of the player logging in.
|
||||
on :login do |event, context|
|
||||
player = event.player
|
||||
on :login do |event, player|
|
||||
player.send(FriendServerStatusMessage.new(ServerStatus::CONNECTING))
|
||||
player.send(IgnoreListMessage.new(player.ignored_usernames)) if player.ignored_usernames.size > 0
|
||||
|
||||
@@ -63,8 +62,8 @@ on :login do |event, context|
|
||||
end
|
||||
|
||||
# Notifies the player's friends that the player has logged out.
|
||||
on :logout do |event, context|
|
||||
update_friends(event.player, 0)
|
||||
on :logout do |event, player|
|
||||
update_friends(player, 0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ end
|
||||
|
||||
# Appends a tiara to the list.
|
||||
def append_tiara(hash)
|
||||
raise 'Hash must contain a tiara id, altar id, talisman id, a bitshift number, and experience.' unless hash.has_key?(:tiara_id) && hash.has_key?(:altar) && hash.has_key?(:talisman) && hash.has_key?(:bitshift) && hash.has_key?(:experience)
|
||||
raise 'Hash must contain a tiara id, altar id, talisman id, a bitshift number, and experience.' unless hash.has_keys?(:altar, :bitshift, :experience, :talisman, :tiara_id)
|
||||
tiara_id = hash[:tiara_id]; altar = hash[:altar]; talisman = hash[:talisman]; bitshift = hash[:bitshift]; experience = hash[:experience]
|
||||
|
||||
TIARAS_BY_TALISMAN[talisman] = TIARAS_BY_ID[tiara_id] = TIARAS_BY_ALTAR[altar] = Tiara.new(tiara_id, altar, talisman, bitshift, experience)
|
||||
end
|
||||
|
||||
# Sets the correct config upon login, if the player is wearing a tiara.
|
||||
on :login do |event, context|
|
||||
on :login do |event, player|
|
||||
player = event.player
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user