mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Rename Events to Messages.
This commit is contained in:
-105
@@ -1,105 +0,0 @@
|
||||
<events>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.PlayerDesignEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.PlayerDesignVerificationHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.PlayerDesignEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.WalkEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.WalkEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ChatEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ChatVerificationHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.ChatEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ButtonEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.DialogueButtonHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.BankButtonEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.DialogueContinueEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.DialogueContinueEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.CommandEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.CommandEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.SwitchItemEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.SwitchItemEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ItemOptionEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.EquipEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ItemActionEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.RemoveEventHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.BankEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ItemOnObjectEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemOnObjectVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ClosedInterfaceEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ClosedInterfaceEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.EnteredAmountEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.EnteredAmountEventHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ItemOnItemEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemOnItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.MagicOnItemEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.NpcActionEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.NpcActionVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ObjectActionEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ObjectActionVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
</events>
|
||||
@@ -0,0 +1,105 @@
|
||||
<messages>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.PlayerDesignMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.PlayerDesignVerificationHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.PlayerDesignMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.WalkMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.WalkMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ChatMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ChatVerificationHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.ChatMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ButtonMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.DialogueButtonHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.BankButtonMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.DialogueContinueMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.DialogueContinueMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.CommandMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.CommandMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.SwitchItemMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.SwitchItemMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ItemOptionMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.EquipItemHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ItemActionMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.RemoveEquippedItemHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.BankMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ItemOnObjectMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemOnObjectVerificationHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ClosedInterfaceMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ClosedInterfaceMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.EnteredAmountMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.EnteredAmountMessageHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ItemOnItemMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemVerificationHandler</handler>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemOnItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.MagicOnItemMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.NpcActionMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.NpcActionVerificationHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
<message>
|
||||
<type>org.apollo.game.message.impl.ObjectActionMessage</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.message.handler.impl.ObjectActionVerificationHandler</handler>
|
||||
</chain>
|
||||
</message>
|
||||
</messages>
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.DisplayCrossbonesEvent'
|
||||
java_import 'org.apollo.game.message.impl.DisplayCrossbonesMessage'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
AREA_ACTIONS = {}
|
||||
@@ -56,12 +56,12 @@ end
|
||||
area_action :wilderness do
|
||||
|
||||
on_entry do |player|
|
||||
player.send(DisplayCrossbonesEvent.new(true))
|
||||
player.send(DisplayCrossbonesMessage.new(true))
|
||||
player.in_wilderness = true
|
||||
end
|
||||
|
||||
on_exit do |player|
|
||||
player.send(DisplayCrossbonesEvent.new(false))
|
||||
player.send(DisplayCrossbonesMessage.new(false))
|
||||
player.in_wilderness = false
|
||||
end
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@ class BankAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the object action event
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
if event.id == BANK_BOOTH_ID
|
||||
player.start_action(BankAction.new(player, event.position))
|
||||
# Intercepts the object action message
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
if message.id == BANK_BOOTH_ID
|
||||
player.start_action(BankAction.new(player, message.position))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_npc_action do |ctx, player, event|
|
||||
npc = $world.npc_repository.get(event.index)
|
||||
on :message, :second_npc_action do |ctx, player, message|
|
||||
npc = $world.npc_repository.get(message.index)
|
||||
if BANKER_NPCS.include?(npc.id)
|
||||
player.start_action(BankAction.new(player, npc.position))
|
||||
ctx.break_handler_chain
|
||||
|
||||
+28
-28
@@ -15,7 +15,7 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.command.CommandListener'
|
||||
java_import 'org.apollo.game.event.handler.EventHandler'
|
||||
java_import 'org.apollo.game.message.handler.MessageHandler'
|
||||
java_import 'org.apollo.game.login.LoginListener'
|
||||
java_import 'org.apollo.game.login.LogoutListener'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
@@ -77,18 +77,18 @@ class ProcLogoutListener
|
||||
end
|
||||
end
|
||||
|
||||
# An EventHandler which executes a Proc object with three arguments: the chain
|
||||
# context, the player and the event.
|
||||
class ProcEventHandler < EventHandler
|
||||
# An MessageHandler which executes a Proc object with three arguments: the chain
|
||||
# context, the player and the message.
|
||||
class ProcMessageHandler < MessageHandler
|
||||
def initialize(block, option)
|
||||
super() # required (with brackets!), see http://jira.codehaus.org/browse/JRUBY-679
|
||||
@block = block
|
||||
@option = option
|
||||
end
|
||||
|
||||
def handle(ctx, player, event)
|
||||
if (@option == 0 || @option == event.option)
|
||||
@block.call(ctx, player, event)
|
||||
def handle(ctx, player, message)
|
||||
if (@option == 0 || @option == message.option)
|
||||
@block.call(ctx, player, message)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -127,11 +127,11 @@ def schedule(*args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
# Defines some sort of action to take upon an event. The following types of
|
||||
# event are currently valid:
|
||||
# Defines some sort of action to take upon an message. The following types of
|
||||
# message are currently valid:
|
||||
#
|
||||
# * :command
|
||||
# * :event
|
||||
# * :message
|
||||
# * :button
|
||||
# * :login
|
||||
# * :logout
|
||||
@@ -140,19 +140,19 @@ end
|
||||
# minimum rights level to use it). The minimum rights level defaults to
|
||||
# STANDARD. The block should have two arguments: player and command.
|
||||
#
|
||||
# An event takes no arguments. The block should have three arguments: the chain
|
||||
# context, the player and the event object.
|
||||
# An message takes no arguments. The block should have three arguments: the chain
|
||||
# context, the player and the message object.
|
||||
#
|
||||
# A button takes one argument (the id). The block should have one argument: the
|
||||
# player who clicked the button.
|
||||
def on(type, *args, &block)
|
||||
case type
|
||||
when :command then on_command(args, block)
|
||||
when :event then on_event(args, block)
|
||||
when :message then on_message(args, block)
|
||||
when :button then on_button(args, block)
|
||||
when :login then on_login(block)
|
||||
when :logout then on_logout(block)
|
||||
else raise 'Unknown event type.'
|
||||
else raise 'Unknown message type.'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,39 +162,39 @@ def on_button(args, proc)
|
||||
|
||||
id = args[0].to_i
|
||||
|
||||
on :event, :button do |ctx, player, event|
|
||||
proc.call(player) if event.widget_id == id
|
||||
on :message, :button do |ctx, player, message|
|
||||
proc.call(player) if message.widget_id == id
|
||||
end
|
||||
end
|
||||
|
||||
# Defines an action to be taken upon an event.
|
||||
# The event can either be a symbol with the lower-case underscored class name, or the class itself.
|
||||
def on_event(args, proc)
|
||||
raise 'Event must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
# Defines an action to be taken upon an message.
|
||||
# The message can either be a symbol with the lower-case underscored class name, or the class itself.
|
||||
def on_message(args, proc)
|
||||
raise 'Message must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
numbers = [ 'first', 'second', 'third', 'fourth', 'fifth' ]
|
||||
event = args[0]; option = 0
|
||||
message = args[0]; option = 0
|
||||
|
||||
numbers.each_index do |index|
|
||||
number = numbers[index]
|
||||
|
||||
if event.to_s.start_with?(number)
|
||||
if message.to_s.start_with?(number)
|
||||
option = index + 1
|
||||
event = event[number.length + 1, event.length].to_sym
|
||||
message = message[number.length + 1, message.length].to_sym
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if event.is_a?(Symbol)
|
||||
class_name = event.to_s.camelize.concat('Event')
|
||||
event = Java::JavaClass.for_name("org.apollo.game.event.impl.#{class_name}")
|
||||
if message.is_a?(Symbol)
|
||||
class_name = message.to_s.camelize.concat('Message')
|
||||
message = Java::JavaClass.for_name("org.apollo.game.message.impl.#{class_name}")
|
||||
end
|
||||
|
||||
$ctx.add_last_event_handler(event, ProcEventHandler.new(proc, option))
|
||||
$ctx.add_last_message_handler(message, ProcMessageHandler.new(proc, option))
|
||||
end
|
||||
|
||||
# Defines an action to be taken upon a command.
|
||||
def on_command(args, proc)
|
||||
raise 'Command event must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
raise 'Command message must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
|
||||
rights = args.length == 2 ? args[1] : RIGHTS_STANDARD
|
||||
$ctx.add_command_listener(args[0].to_s, ProcCommandListener.new(rights, proc))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
java_import 'org.apollo.game.event.impl.SendFriendEvent'
|
||||
java_import 'org.apollo.game.message.impl.SendFriendMessage'
|
||||
|
||||
on :event, :privacy_option do |ctx, player, event|
|
||||
player.chat_privacy = event.chat_privacy
|
||||
player.friend_privacy = event.friend_privacy
|
||||
player.trade_privacy = event.trade_privacy
|
||||
on :message, :privacy_option do |ctx, player, message|
|
||||
player.chat_privacy = message.chat_privacy
|
||||
player.friend_privacy = message.friend_privacy
|
||||
player.trade_privacy = message.trade_privacy
|
||||
|
||||
update_friends(player, event.friend_privacy == PrivacyState::OFF ? 0 : player.world_id)
|
||||
update_friends(player, message.friend_privacy == PrivacyState::OFF ? 0 : player.world_id)
|
||||
end
|
||||
@@ -1,48 +1,48 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.FriendServerStatusEvent'
|
||||
java_import 'org.apollo.game.event.impl.SendFriendEvent'
|
||||
java_import 'org.apollo.game.message.impl.FriendServerStatusMessage'
|
||||
java_import 'org.apollo.game.message.impl.SendFriendMessage'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.setting.ServerStatus'
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
|
||||
# Processes an add friend event, updating the logged-in status of the player (and the person they added) if necessary.
|
||||
on :event, :add_friend do |ctx, player, event|
|
||||
friend_username = event.username
|
||||
# Processes an add friend message, updating the logged-in status of the player (and the person they added) if necessary.
|
||||
on :message, :add_friend do |ctx, player, message|
|
||||
friend_username = message.username
|
||||
player_username = player.username
|
||||
|
||||
player.add_friend(friend_username)
|
||||
friend = $world.get_player(friend_username)
|
||||
|
||||
if friend == nil # the friend the player added is offline
|
||||
player.send(SendFriendEvent.new(friend_username, 0))
|
||||
player.send(SendFriendMessage.new(friend_username, 0))
|
||||
elsif friend.friends_with(player_username) # new friend already has the player added
|
||||
friend.send(SendFriendEvent.new(player_username, player.world_id)) unless player.friend_privacy == PrivacyState::OFF # player's private chat state is not off, so notify the friend
|
||||
friend.send(SendFriendMessage.new(player_username, player.world_id)) unless player.friend_privacy == PrivacyState::OFF # player's private chat state is not off, so notify the friend
|
||||
|
||||
player.send(SendFriendEvent.new(friend_username, friend.world_id)) unless friend.friend_privacy == PrivacyState::OFF # new friend's private chat state is not off, so notify the player
|
||||
player.send(SendFriendMessage.new(friend_username, friend.world_id)) unless friend.friend_privacy == PrivacyState::OFF # new friend's private chat state is not off, so notify the player
|
||||
elsif friend.friend_privacy == PrivacyState::ON # new friend doesn't have the player added but their private chat state is on
|
||||
player.send(SendFriendEvent.new(friend_username, friend.world_id)) # so we can let the player know what world they're on
|
||||
player.send(SendFriendMessage.new(friend_username, friend.world_id)) # so we can let the player know what world they're on
|
||||
end
|
||||
end
|
||||
|
||||
# Processes a remove friend event, updating the logged-in status of the player if necessary.
|
||||
on :event, :remove_friend do |ctx, player, event|
|
||||
friend_username = event.username
|
||||
# Processes a remove friend message, updating the logged-in status of the player if necessary.
|
||||
on :message, :remove_friend do |ctx, player, message|
|
||||
friend_username = message.username
|
||||
player_username = player.username
|
||||
|
||||
player.remove_friend(friend_username)
|
||||
if ($world.is_player_online(friend_username))
|
||||
friend = $world.get_player(friend_username)
|
||||
friend.send(SendFriendEvent.new(player_username, 0)) if (friend.friends_with(player_username) && player.friend_privacy != PrivacyState::ON)
|
||||
friend.send(SendFriendMessage.new(player_username, 0)) if (friend.friends_with(player_username) && player.friend_privacy != PrivacyState::ON)
|
||||
end
|
||||
end
|
||||
|
||||
# Update the friend server status and send the friend/ignore lists of the player logging in.
|
||||
on :login do |player|
|
||||
player.send(FriendServerStatusEvent.new(ServerStatus::CONNECTING))
|
||||
player.send(IgnoreListEvent.new(player.ignored_usernames)) if player.ignored_usernames.size > 0
|
||||
player.send(FriendServerStatusMessage.new(ServerStatus::CONNECTING))
|
||||
player.send(IgnoreListMessage.new(player.ignored_usernames)) if player.ignored_usernames.size > 0
|
||||
|
||||
username = player.username
|
||||
world = $world
|
||||
@@ -52,10 +52,10 @@ on :login do |player|
|
||||
friend = world.get_player(friend_username)
|
||||
friend_world_id = (friend == nil || !viewable?(friend, username)) ? 0 : friend.world_id
|
||||
|
||||
player.send(SendFriendEvent.new(friend_username, friend_world_id))
|
||||
player.send(SendFriendMessage.new(friend_username, friend_world_id))
|
||||
end
|
||||
|
||||
player.send(FriendServerStatusEvent.new(ServerStatus::ONLINE))
|
||||
player.send(FriendServerStatusMessage.new(ServerStatus::ONLINE))
|
||||
update_friends(player, player.world_id)
|
||||
end
|
||||
|
||||
@@ -78,7 +78,7 @@ def update_friends(player, world=0)
|
||||
next if (!other.friends_with(username) || other == player)
|
||||
|
||||
world = viewable?(player, other.username) ? world : 0
|
||||
other.send(SendFriendEvent.new(username, world))
|
||||
other.send(SendFriendMessage.new(username, world))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
on :event, :add_ignore do |ctx, player, event|
|
||||
username = event.username
|
||||
on :message, :add_ignore do |ctx, player, message|
|
||||
username = message.username
|
||||
player.add_ignore(username)
|
||||
end
|
||||
|
||||
on :event, :remove_ignore do |ctx, player, event|
|
||||
username = event.username
|
||||
on :message, :remove_ignore do |ctx, player, message|
|
||||
username = message.username
|
||||
player.remove_ignore(username)
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||
java_import 'org.apollo.game.message.impl.ForwardPrivateChatMessage'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
|
||||
on :event, :private_message do |ctx, player, event|
|
||||
friend = $world.get_player(event.username)
|
||||
friend.send(ForwardPrivateMessageEvent.new(player.username, player.privilege_level, event.compressed_message)) if interaction_permitted(player, friend)
|
||||
on :message, :private_message do |ctx, player, message|
|
||||
friend = $world.get_player(message.username)
|
||||
friend.send(ForwardPrivateChatMessage.new(player.username, player.privilege_level, message.compressed_message)) if interaction_permitted(player, friend)
|
||||
end
|
||||
|
||||
# Checks if the sender is permitted to interact with the friend they have added:
|
||||
|
||||
@@ -22,6 +22,5 @@ on :command, :graphic, RIGHTS_MOD do |player, command|
|
||||
return
|
||||
end
|
||||
|
||||
player.send(DisplayCrossbonesEvent.new(true ))
|
||||
player.play_graphic(Graphic.new(args[0].to_i))
|
||||
end
|
||||
@@ -1,8 +1,5 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
|
||||
on :command, :filter do |player, command|
|
||||
player.send_message('Your message filter is now ' + (player.toggle_message_filter ? 'enabled.' : 'disabled.'))
|
||||
end
|
||||
@@ -53,11 +53,11 @@ class ConsumeAction < Action
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the first item option event and consumes the consumable, if necessary.
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
consumable = CONSUMABLES[event.id]
|
||||
# Intercepts the first item option message and consumes the consumable, if necessary.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
consumable = CONSUMABLES[message.id]
|
||||
unless consumable == nil
|
||||
player.start_action(ConsumeAction.new(player, event.slot, consumable))
|
||||
player.start_action(ConsumeAction.new(player, message.slot, consumable))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
# Intercepts the first npc action event.
|
||||
on :event, :npc_action do |ctx, player, event|
|
||||
if (event.option == 1)
|
||||
# TODO check if player is not in pvp area
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def dialogue(name, &block)
|
||||
|
||||
end
|
||||
|
||||
dialogue :banker_introduction do
|
||||
#
|
||||
end
|
||||
@@ -45,8 +45,8 @@ class DummyAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
if (event.id == DUMMY_ID)
|
||||
player.start_action(DummyAction.new(player, event.position))
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
if (message.id == DUMMY_ID)
|
||||
player.start_action(DummyAction.new(player, message.position))
|
||||
end
|
||||
end
|
||||
@@ -11,9 +11,9 @@ ANIMATIONS = {
|
||||
666 => Animation::GLASS_WALL, 168 => Animation::YES, 13383 => Animation::GOBLIN_BOW
|
||||
}
|
||||
|
||||
# Intercept the ButtonEvent
|
||||
on :event, :button do |ctx, player, event|
|
||||
anim = ANIMATIONS[event.widget_id]
|
||||
# Intercept the button message.
|
||||
on :message, :button do |ctx, player, message|
|
||||
anim = ANIMATIONS[message.widget_id]
|
||||
unless anim == nil
|
||||
player.play_animation(anim)
|
||||
ctx.break_handler_chain
|
||||
|
||||
@@ -65,7 +65,7 @@ class HerbIdentificationAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a herb to the InventoryItemEvent interception.
|
||||
# Appends a herb to the InventoryItemMessage interception.
|
||||
def append_herb(item_id, unidentified, level, experience)
|
||||
herb = Herb.new(item_id, unidentified, level, experience)
|
||||
append_herblore_item(herb, unidentified)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.SetWidgetItemModelEvent'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetItemModelMessage'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
HERBLORE_DIALOGUE = 4429
|
||||
@@ -25,15 +25,15 @@ module HerbloreMethod
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOnItemEvent handler for all Herblore-related functions.
|
||||
on :event, :item_on_item do |ctx, player, event|
|
||||
primary = event.id
|
||||
secondary = event.target_id
|
||||
# The ItemOnItemMessage handler for all Herblore-related functions.
|
||||
on :message, :item_on_item do |ctx, player, message|
|
||||
primary = message.id
|
||||
secondary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
|
||||
if hash == nil
|
||||
secondary = event.id
|
||||
primary = event.target_id
|
||||
secondary = message.id
|
||||
primary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
end
|
||||
|
||||
@@ -46,19 +46,19 @@ on :event, :item_on_item do |ctx, player, event|
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOptionEvent handler for all Herblore-related functions.
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
id = event.id
|
||||
# The ItemOptionMessage handler for all Herblore-related functions.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
id = message.id
|
||||
method = HERBLORE_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
method.invoke(player, id, event.slot)
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
method = DRINK_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
method.invoke(player, id, event.slot)
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -83,7 +83,7 @@ def check_slot(player, slot, id, amount = 1)
|
||||
end
|
||||
|
||||
# Utility method for checking if a player's Herblore (maximum) level is at a required height. Also informs the player if this is not the case with use of the action
|
||||
# variable, like so: "You need a Herblore level of at least #{required.to_s} to #{action}."
|
||||
# variable, like so: "You need a Herblore level of at least #{required.to_s} to #{action}."
|
||||
def check_skill(player, required, action)
|
||||
if required > player.skill_set.skill(HERBLORE_SKILL_ID).current_level
|
||||
player.send_message("You need a Herblore level of at least #{required} to #{action}.")
|
||||
@@ -94,6 +94,6 @@ end
|
||||
|
||||
# Opens a 'make' dialogue for the specified player, displaying the specified item. Optionally, a listener can be used for the dialogue.
|
||||
def open_dialogue(player, item, listener = nil)
|
||||
player.send(SetWidgetItemModelEvent.new(1746, item, 170))
|
||||
player.send(SetWidgetItemModelMessage.new(1746, item, 170))
|
||||
player.interface_set.open_dialogue(listener, HERBLORE_DIALOGUE)
|
||||
end
|
||||
@@ -223,11 +223,11 @@ class GrindingAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a grinded ingredient to the ItemOnItemEvent handler interception.
|
||||
# Appends a ground ingredient to the ItemOnItemMessage handler interception.
|
||||
def append_ground(id, raw)
|
||||
grinded = GroundIngredient.new(id, raw)
|
||||
append_herblore_item(grinded, PESTLE_MORTAR, raw)
|
||||
return grinded
|
||||
ground = GroundIngredient.new(id, raw)
|
||||
append_herblore_item(ground, PESTLE_MORTAR, raw)
|
||||
return ground
|
||||
end
|
||||
|
||||
# Normal ingredients
|
||||
|
||||
@@ -310,14 +310,14 @@ class FinishedMixingAction < MixingAction
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a finished potion to the ItemOnItemEvent handling interception.
|
||||
# Appends a finished potion to the ItemOnItemMessage handling interception.
|
||||
def append_finished_potion(item, unfinished, ingredient, level, experience)
|
||||
potion = FinishedPotion.new(item, [ unfinished, ingredient ], level, experience)
|
||||
append_herblore_item(potion, unfinished.item_id, ingredient.item_id)
|
||||
return potion
|
||||
end
|
||||
|
||||
# Appends an unfinished potion to the ItemOnItemEvent handling interception.
|
||||
# Appends an unfinished potion to the ItemOnItemMessage handling interception.
|
||||
def append_unfinished_potion(item, herb, level)
|
||||
potion = UnfinishedPotion.new(item, herb, level)
|
||||
append_herblore_item(potion, herb.item_id, WATER_VIAL_ID)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.action.Action'
|
||||
java_import 'org.apollo.game.event.impl.DisplayTabInterfaceEvent'
|
||||
java_import 'org.apollo.game.message.impl.DisplayTabInterfaceMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceEvent.new(6)
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceMessage.new(6)
|
||||
|
||||
class Spell
|
||||
attr_reader :level, :elements, :experience
|
||||
@@ -119,31 +119,31 @@ class ItemSpellAction < SpellAction
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the magic on item event.
|
||||
on :event, :magic_on_item do |ctx, player, event|
|
||||
spell = event.spell_id
|
||||
# Intercepts the magic on item message.
|
||||
on :message, :magic_on_item do |ctx, player, message|
|
||||
spell = message.spell_id
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
if alch != nil
|
||||
slot = event.slot
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(AlchemyAction.new(player, alch, slot, item))
|
||||
ctx.break_handler_chain
|
||||
return
|
||||
end
|
||||
|
||||
ench = ENCHANT_SPELLS[event.id]
|
||||
ench = ENCHANT_SPELLS[message.id]
|
||||
if ench != nil and ench.button == spell
|
||||
slot = event.slot
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id]))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the button event
|
||||
on :event, :button do |ctx, player, event|
|
||||
button = event.widget_id
|
||||
# Intercepts the button message
|
||||
on :message, :button do |ctx, player, message|
|
||||
button = message.widget_id
|
||||
|
||||
tele = TELEPORT_SPELLS[button]
|
||||
if tele != nil
|
||||
|
||||
@@ -141,18 +141,18 @@ class ProspectingAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :first_object_action do |ctx, mob, event|
|
||||
ore = ORES[event.id]
|
||||
on :message, :first_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
mob.start_action(MiningAction.new(mob, event.position, ore))
|
||||
mob.start_action(MiningAction.new(mob, message.position, ore))
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_object_action do |ctx, mob, event|
|
||||
ore = ORES[event.id]
|
||||
on :message, :second_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
mob.start_action(ProspectingAction.new(mob, event.position, ore))
|
||||
elsif EXPIRED_ORES[event.id] != nil
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, event.position))
|
||||
mob.start_action(ProspectingAction.new(mob, message.position, ore))
|
||||
elsif EXPIRED_ORES[message.id] != nil
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, message.position))
|
||||
end
|
||||
end
|
||||
@@ -42,11 +42,11 @@ class BuryBoneAction < Action
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the first item option event,
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
bone = BONES[event.id]
|
||||
# Intercepts the first item option message,
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
bone = BONES[message.id]
|
||||
unless bone == nil
|
||||
player.start_action(BuryBoneAction.new(player, event.slot, bone))
|
||||
player.start_action(BuryBoneAction.new(player, message.slot, bone))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,19 +23,19 @@ class Altar
|
||||
end
|
||||
|
||||
|
||||
# Intercepts the item on object event.
|
||||
on :event, :item_on_object do |ctx, player, event|
|
||||
talisman = TALISMANS[event.id]; altar = ENTRANCE_ALTARS[event.object_id]
|
||||
# Intercepts the item on object message.
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
talisman = TALISMANS[message.id]; altar = ENTRANCE_ALTARS[message.object_id]
|
||||
if (talisman != nil && altar != nil)
|
||||
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the first object action event.
|
||||
on :event, :object_action do |ctx, player, event|
|
||||
if (event.option == 1)
|
||||
object_id = event.id
|
||||
# Intercepts the first object action message.
|
||||
on :message, :object_action do |ctx, player, message|
|
||||
if (message.option == 1)
|
||||
object_id = message.id
|
||||
if (altar = PORTALS[object_id]) != nil # Get the altar associated with this exit portal.
|
||||
player.start_action(TeleportAction.new(player, altar.entrance_position, 1, altar.exit_position))
|
||||
ctx.break_handler_chain
|
||||
|
||||
@@ -29,9 +29,9 @@ def append_talisman(hash)
|
||||
TALISMANS[id] = Talisman.new(altar_position)
|
||||
end
|
||||
|
||||
# Intercepts the item option event.
|
||||
on :event, :fourth_item_option do |ctx, player, event|
|
||||
talisman = TALISMANS[event.id]
|
||||
# Intercepts the item option message.
|
||||
on :message, :fourth_item_option do |ctx, player, message|
|
||||
talisman = TALISMANS[message.id]
|
||||
if (talisman != nil)
|
||||
player.send_message(talisman.get_message(player.position))
|
||||
ctx.break_handler_chain
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ConfigEvent'
|
||||
java_import 'org.apollo.game.message.impl.ConfigMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
|
||||
@@ -26,13 +26,13 @@ class Tiara
|
||||
end
|
||||
|
||||
def send_config(player)
|
||||
player.send(ConfigEvent.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def send_empty_config(player)
|
||||
player.send(ConfigEvent.new(CHANGE_ALTAR_OBJECT_CONFIG, 0))
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 0))
|
||||
end
|
||||
|
||||
# Appends a tiara to the list.
|
||||
@@ -43,7 +43,7 @@ def append_tiara(hash)
|
||||
TIARAS_BY_TALISMAN[talisman] = TIARAS_BY_ID[tiara_id] = TIARAS_BY_ALTAR[altar] = Tiara.new(tiara_id, altar, talisman, bitshift, experience)
|
||||
end
|
||||
|
||||
#Set the config upon login
|
||||
# Set the config upon login
|
||||
on :login do |player|
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
if hat != nil
|
||||
@@ -56,45 +56,45 @@ on :login do |player|
|
||||
send_empty_config(player)
|
||||
end
|
||||
|
||||
#Accesses the altar with 1 click when wielding the correct tiara.
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
object_id = event.id
|
||||
# Access the altar with 1 click when wielding the correct tiara.
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
object_id = message.id
|
||||
tiara = TIARAS_BY_ALTAR[object_id]
|
||||
if (tiara != nil)
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
if (hat != nil && hat.id == tiara.tiara_id)
|
||||
altar = ENTRANCE_ALTARS[tiara.altar]
|
||||
if (altar != nil)
|
||||
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
end
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Equip tiara
|
||||
on :event, :second_item_option do |ctx, player, event|
|
||||
tiara = TIARAS_BY_ID[event.id]
|
||||
# Equip tiara
|
||||
on :message, :second_item_option do |ctx, player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
if (tiara != nil)
|
||||
tiara.send_config(player)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
#Unequip tiara
|
||||
on :event, :first_item_action do |ctx, player, event|
|
||||
tiara = TIARAS_BY_ID[event.id]
|
||||
# Unequip tiara
|
||||
on :message, :first_item_action do |ctx, player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
if (tiara != nil)
|
||||
send_empty_config(player)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
#Create tiara
|
||||
on :event, :item_on_object do |ctx, player, event|
|
||||
tiara= TIARAS_BY_TALISMAN[event.id]; altar = CRAFTING_ALTARS[event.object_id]
|
||||
#C reate tiara
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
tiara= TIARAS_BY_TALISMAN[message.id]; altar = CRAFTING_ALTARS[message.object_id]
|
||||
if (tiara != nil && altar != nil)
|
||||
player.start_action(CreateTiaraAction.new(player, event.position, tiara, altar))
|
||||
player.start_action(CreateTiaraAction.new(player, message.position, tiara, altar))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,9 +8,9 @@ package org.apollo.game;
|
||||
public final class GameConstants {
|
||||
|
||||
/**
|
||||
* The maximum events per pulse per session.
|
||||
* The maximum amount of messages to process per pulse (per session).
|
||||
*/
|
||||
public static final int EVENTS_PER_PULSE = 10;
|
||||
public static final int MESSAGES_PER_PULSE = 10;
|
||||
|
||||
/**
|
||||
* The delay between consecutive pulses, in milliseconds.
|
||||
|
||||
@@ -10,12 +10,12 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apollo.Service;
|
||||
import org.apollo.game.event.handler.chain.EventHandlerChainGroup;
|
||||
import org.apollo.game.message.handler.MessageHandlerChainGroup;
|
||||
import org.apollo.game.model.World;
|
||||
import org.apollo.game.model.World.RegistrationStatus;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.sync.ClientSynchronizer;
|
||||
import org.apollo.io.EventHandlerChainParser;
|
||||
import org.apollo.io.MessageHandlerChainParser;
|
||||
import org.apollo.login.LoginService;
|
||||
import org.apollo.net.session.GameSession;
|
||||
import org.apollo.util.NamedThreadFactory;
|
||||
@@ -37,9 +37,9 @@ public final class GameService extends Service {
|
||||
private static final int UNREGISTERS_PER_CYCLE = 50;
|
||||
|
||||
/**
|
||||
* The {@link EventHandlerChainGroup}.
|
||||
* The {@link MessageHandlerChainGroup}.
|
||||
*/
|
||||
private EventHandlerChainGroup chainGroup;
|
||||
private MessageHandlerChainGroup chainGroup;
|
||||
|
||||
/**
|
||||
* A queue of players to remove.
|
||||
@@ -78,11 +78,11 @@ public final class GameService extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event handler chains.
|
||||
* Gets the message handler chains.
|
||||
*
|
||||
* @return The event handler chains.
|
||||
* @return The message handler chains.
|
||||
*/
|
||||
public EventHandlerChainGroup getEventHandlerChains() {
|
||||
public MessageHandlerChainGroup getMessageHandlerChains() {
|
||||
return chainGroup;
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ public final class GameService extends Service {
|
||||
* @throws IOException If there is an error with the file (e.g. does not exist, cannot be read, does not contain
|
||||
* valid nodes).
|
||||
* @throws SAXException If there is an error parsing the file.
|
||||
* @throws ClassNotFoundException If an event handler could not be found.
|
||||
* @throws InstantiationException If an event handler could not be instantiated.
|
||||
* @throws IllegalAccessException If an event handler could not be accessed.
|
||||
* @throws ClassNotFoundException If a message handler could not be found.
|
||||
* @throws InstantiationException If a message handler could not be instantiated.
|
||||
* @throws IllegalAccessException If a message handler could not be accessed.
|
||||
*/
|
||||
private void init() throws IOException, SAXException, ClassNotFoundException, InstantiationException,
|
||||
IllegalAccessException {
|
||||
try (InputStream is = new FileInputStream("data/events.xml")) {
|
||||
EventHandlerChainParser chainGroupParser = new EventHandlerChainParser(is);
|
||||
try (InputStream is = new FileInputStream("data/messages.xml")) {
|
||||
MessageHandlerChainParser chainGroupParser = new MessageHandlerChainParser(is);
|
||||
chainGroup = chainGroupParser.parse();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public final class GameService extends Service {
|
||||
for (Player p : world.getPlayerRepository()) {
|
||||
GameSession session = p.getSession();
|
||||
if (session != null) {
|
||||
session.handlePendingEvents(chainGroup);
|
||||
session.handlePendingMessages(chainGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.apollo.game.model.entity.Player;
|
||||
public final class CommandDispatcher {
|
||||
|
||||
/**
|
||||
* A map of event listeners.
|
||||
* A map of command strings to command listeners.
|
||||
*/
|
||||
private final Map<String, CommandListener> listeners = new HashMap<String, CommandListener>();
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package org.apollo.game.event;
|
||||
|
||||
/**
|
||||
* Represents an event that can occur in the game world.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public abstract class Event {
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.apollo.game.event.handler;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A class which handles events.
|
||||
*
|
||||
* @author Graham
|
||||
* @param <E> The type of event this class handles.
|
||||
*/
|
||||
public abstract class EventHandler<E extends Event> {
|
||||
|
||||
/**
|
||||
* Handles an event.
|
||||
*
|
||||
* @param ctx The context.
|
||||
* @param player The player.
|
||||
* @param event The event.
|
||||
*/
|
||||
public abstract void handle(EventHandlerContext ctx, Player player, E event);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.apollo.game.event.handler;
|
||||
|
||||
import org.apollo.game.event.handler.chain.EventHandlerChain;
|
||||
|
||||
/**
|
||||
* Provides operations specific to an {@link EventHandler} in an {@link EventHandlerChain}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public abstract class EventHandlerContext {
|
||||
|
||||
/**
|
||||
* Breaks the handler chain.
|
||||
*/
|
||||
public abstract void breakHandlerChain();
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package org.apollo.game.event.handler.chain;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A chain of event handlers.
|
||||
*
|
||||
* @author Graham
|
||||
* @param <E> The type of event the handlers in this chain handle.
|
||||
*/
|
||||
public final class EventHandlerChain<E extends Event> {
|
||||
|
||||
/**
|
||||
* The handlers.
|
||||
*/
|
||||
private EventHandler<E>[] handlers;
|
||||
|
||||
/**
|
||||
* Creates the event handler chain.
|
||||
*
|
||||
* @param handlers The handlers.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public EventHandlerChain(EventHandler<E>... handlers) {
|
||||
this.handlers = handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically adds an event handler to the end of the chain.
|
||||
*
|
||||
* @param handler The handler.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addLast(EventHandler<E> handler) {
|
||||
EventHandler<E>[] old = handlers;
|
||||
handlers = new EventHandler[old.length + 1];
|
||||
System.arraycopy(old, 0, handlers, 0, old.length);
|
||||
handlers[old.length] = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event, passing it down the chain until the chain is broken or the event reaches the end of the chain.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param event The event.
|
||||
*/
|
||||
public void handle(Player player, E event) {
|
||||
final boolean[] running = new boolean[1];
|
||||
running[0] = true;
|
||||
|
||||
EventHandlerContext ctx = new EventHandlerContext() {
|
||||
|
||||
@Override
|
||||
public void breakHandlerChain() {
|
||||
running[0] = false;
|
||||
}
|
||||
};
|
||||
|
||||
for (EventHandler<E> handler : handlers) {
|
||||
handler.handle(ctx, player, event);
|
||||
if (!running[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package org.apollo.game.event.handler.chain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* A group of {@link EventHandlerChain}s classified by the {@link Event} type.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class EventHandlerChainGroup {
|
||||
|
||||
/**
|
||||
* The map of event classes to event handler chains.
|
||||
*/
|
||||
private final Map<Class<? extends Event>, EventHandlerChain<?>> chains;
|
||||
|
||||
/**
|
||||
* Creates the event handler chain group.
|
||||
*
|
||||
* @param chains The chains map.
|
||||
*/
|
||||
public EventHandlerChainGroup(Map<Class<? extends Event>, EventHandlerChain<?>> chains) {
|
||||
this.chains = chains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link EventHandlerChain} from this group.
|
||||
*
|
||||
* @param <E> The type of event.
|
||||
* @param clazz The event class.
|
||||
* @return The {@link EventHandlerChain} if one was found, {@code null} otherwise.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E extends Event> EventHandlerChain<E> getChain(Class<E> clazz) {
|
||||
return (EventHandlerChain<E>) chains.get(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an {@link EventHandlerChain} associated with the specified {@link Class} to this group.
|
||||
*
|
||||
* @param clazz The event class.
|
||||
* @param chain The event handler chain.
|
||||
*/
|
||||
public <E extends Event> void register(Class<E> clazz, EventHandlerChain<E> chain) {
|
||||
chains.put(clazz, chain);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains classes related to the chaining of event handlers.
|
||||
*/
|
||||
package org.apollo.game.event.handler.chain;
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ButtonEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that responds to {@link ButtonEvent}s for withdrawing items as notes.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class BankButtonEventHandler extends EventHandler<ButtonEvent> {
|
||||
|
||||
/**
|
||||
* The withdraw as item button id.
|
||||
*/
|
||||
private static final int WITHDRAW_AS_ITEM = 5387;
|
||||
|
||||
/**
|
||||
* The withdraw as note button id.
|
||||
*/
|
||||
private static final int WITHDRAW_AS_NOTE = 5386;
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ButtonEvent event) {
|
||||
if (event.getWidgetId() == WITHDRAW_AS_ITEM) {
|
||||
player.setWithdrawingNotes(false);
|
||||
} else if (event.getWidgetId() == WITHDRAW_AS_NOTE) {
|
||||
player.setWithdrawingNotes(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ItemActionEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.bank.BankConstants;
|
||||
import org.apollo.game.model.inter.bank.BankDepositEnterAmountListener;
|
||||
import org.apollo.game.model.inter.bank.BankUtils;
|
||||
import org.apollo.game.model.inter.bank.BankWithdrawEnterAmountListener;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that handles withdrawing and depositing items from/to a player's bank.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class BankEventHandler extends EventHandler<ItemActionEvent> {
|
||||
|
||||
/**
|
||||
* Converts an option to an amount.
|
||||
*
|
||||
* @param option The option.
|
||||
* @return The amount.
|
||||
* @throws IllegalArgumentException If the option is invalid.
|
||||
*/
|
||||
private static final int optionToAmount(int option) {
|
||||
switch (option) {
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 5;
|
||||
case 3:
|
||||
return 10;
|
||||
case 4:
|
||||
return Integer.MAX_VALUE;
|
||||
case 5:
|
||||
return -1;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid option supplied.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a deposit action.
|
||||
*
|
||||
* @param ctx The event handler context.
|
||||
* @param player The player.
|
||||
* @param event The event.
|
||||
*/
|
||||
private void deposit(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
int amount = optionToAmount(event.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankDepositEnterAmountListener(player, event.getSlot(), event.getId()));
|
||||
} else if (!BankUtils.deposit(player, event.getSlot(), event.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
if (player.getInterfaceSet().contains(BankConstants.BANK_WINDOW_ID)) {
|
||||
if (event.getInterfaceId() == BankConstants.SIDEBAR_INVENTORY_ID) {
|
||||
deposit(ctx, player, event);
|
||||
} else if (event.getInterfaceId() == BankConstants.BANK_INVENTORY_ID) {
|
||||
withdraw(ctx, player, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a withdraw action.
|
||||
*
|
||||
* @param ctx The event handler context.
|
||||
* @param player The player.
|
||||
* @param event The event.
|
||||
*/
|
||||
private void withdraw(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
int amount = optionToAmount(event.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankWithdrawEnterAmountListener(player, event.getSlot(), event.getId()));
|
||||
} else if (!BankUtils.withdraw(player, event.getSlot(), event.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ChatEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.sync.block.SynchronizationBlock;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that broadcasts public chat messages.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ChatEventHandler extends EventHandler<ChatEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ChatEvent event) {
|
||||
player.getBlockSet().add(SynchronizationBlock.createChatBlock(player, event));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ChatEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that verifies {@link ChatEvent}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ChatVerificationHandler extends EventHandler<ChatEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ChatEvent event) {
|
||||
int color = event.getTextColor();
|
||||
int effects = event.getTextEffects();
|
||||
if (color < 0 || color > 11 || effects < 0 || effects > 5) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ClosedInterfaceEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} for the {@link ClosedInterfaceEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ClosedInterfaceEventHandler extends EventHandler<ClosedInterfaceEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ClosedInterfaceEvent event) {
|
||||
player.getInterfaceSet().interfaceClosed();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.command.Command;
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.CommandEvent;
|
||||
import org.apollo.game.model.World;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that dispatches {@link CommandEvent}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class CommandEventHandler extends EventHandler<CommandEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, CommandEvent event) {
|
||||
String[] components = event.getCommand().split(" ");
|
||||
String name = components[0];
|
||||
|
||||
String[] arguments = new String[components.length - 1];
|
||||
System.arraycopy(components, 1, arguments, 0, arguments.length);
|
||||
|
||||
Command command = new Command(name, arguments);
|
||||
World.getWorld().getCommandDispatcher().dispatch(player, command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ButtonEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.InterfaceType;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} which intercepts button clicks on dialogues, and forwards the event to the current listener.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class DialogueButtonHandler extends EventHandler<ButtonEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ButtonEvent event) {
|
||||
if (player.getInterfaceSet().contains(InterfaceType.DIALOGUE)) {
|
||||
boolean breakChain = player.getInterfaceSet().buttonClicked(event.getWidgetId());
|
||||
|
||||
if (breakChain) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.DialogueContinueEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.InterfaceType;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} for the {@link DialogueContinueEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class DialogueContinueEventHandler extends EventHandler<DialogueContinueEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, DialogueContinueEvent event) {
|
||||
if (player.getInterfaceSet().contains(InterfaceType.DIALOGUE)) {
|
||||
player.getInterfaceSet().continueRequested();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.EnteredAmountEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} for the {@link EnteredAmountEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class EnteredAmountEventHandler extends EventHandler<EnteredAmountEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, EnteredAmountEvent event) {
|
||||
player.getInterfaceSet().enteredAmount(event.getAmount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.ItemOnObjectEvent;
|
||||
import org.apollo.game.model.Item;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.bank.BankConstants;
|
||||
import org.apollo.game.model.inv.Inventory;
|
||||
import org.apollo.game.model.inv.SynchronizationInventoryListener;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that verifies {@link ItemObObjectEvent}s.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ItemOnObjectVerificationHandler extends EventHandler<ItemOnObjectEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ItemOnObjectEvent event) {
|
||||
if (event.getInterfaceId() != SynchronizationInventoryListener.INVENTORY_ID
|
||||
&& event.getInterfaceId() != BankConstants.SIDEBAR_INVENTORY_ID) {
|
||||
ctx.breakHandlerChain();
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory inventory = player.getInventory();
|
||||
|
||||
int slot = event.getSlot();
|
||||
if (slot < 0 || slot >= inventory.capacity()) {
|
||||
ctx.breakHandlerChain();
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = inventory.get(slot);
|
||||
if (item == null || item.getId() != event.getId()) {
|
||||
ctx.breakHandlerChain();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.CloseInterfaceEvent;
|
||||
import org.apollo.game.event.impl.PlayerDesignEvent;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* An {@link EventHandler} that handles {@link PlayerDesignEvent}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class PlayerDesignEventHandler extends EventHandler<PlayerDesignEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
|
||||
player.setAppearance(event.getAppearance());
|
||||
player.setNew(true);
|
||||
player.send(new CloseInterfaceEvent());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.apollo.game.event.handler.impl;
|
||||
|
||||
import org.apollo.game.event.handler.EventHandler;
|
||||
import org.apollo.game.event.handler.EventHandlerContext;
|
||||
import org.apollo.game.event.impl.WalkEvent;
|
||||
import org.apollo.game.model.Position;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.entity.WalkingQueue;
|
||||
|
||||
/**
|
||||
* A{@link EventHandler} that handles {@link WalkEvent}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class WalkEventHandler extends EventHandler<WalkEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, WalkEvent event) {
|
||||
WalkingQueue queue = player.getWalkingQueue();
|
||||
|
||||
Position[] steps = event.getSteps();
|
||||
for (int i = 0; i < steps.length; i++) {
|
||||
Position step = steps[i];
|
||||
if (i == 0) {
|
||||
if (!queue.addFirstStep(step)) {
|
||||
return; // ignore packet
|
||||
}
|
||||
} else {
|
||||
queue.addStep(step);
|
||||
}
|
||||
}
|
||||
|
||||
queue.setRunningQueue(event.isRunning() || player.isRunning());
|
||||
|
||||
if (queue.size() > 0) {
|
||||
player.stopAction();
|
||||
}
|
||||
player.getInterfaceSet().close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains event handler implementations.
|
||||
*/
|
||||
package org.apollo.game.event.handler.impl;
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains classes which define abstract event handlers.
|
||||
*/
|
||||
package org.apollo.game.event.handler;
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client that closes the open interface.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class CloseInterfaceEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client when the current interface is closed.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ClosedInterfaceEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to change the currently displayed tab interface.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class DisplayTabInterfaceEvent extends Event {
|
||||
|
||||
/**
|
||||
* The tab index.
|
||||
*/
|
||||
private final int tab;
|
||||
|
||||
/**
|
||||
* Creates a new display tab interface event.
|
||||
*
|
||||
* @param tab The index of the tab to display.
|
||||
*/
|
||||
public DisplayTabInterfaceEvent(int tab) {
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the tab to display.
|
||||
*
|
||||
* @return The tab index.
|
||||
*/
|
||||
public int getTab() {
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to open up the enter amount interface.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class EnterAmountEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client when the player has entered an amount.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class EnteredAmountEvent extends Event {
|
||||
|
||||
/**
|
||||
* The amount.
|
||||
*/
|
||||
private final int amount;
|
||||
|
||||
/**
|
||||
* Creates the entered amount event.
|
||||
*
|
||||
* @param amount The amount.
|
||||
*/
|
||||
public EnteredAmountEvent(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount.
|
||||
*
|
||||
* @return The amount.
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fifth {@link ItemActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class FifthItemActionEvent extends ItemActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the fifth item action event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
*/
|
||||
public FifthItemActionEvent(int interfaceId, int id, int slot) {
|
||||
super(5, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fifth {@link ItemOptionEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class FifthItemOptionEvent extends ItemOptionEvent {
|
||||
|
||||
/**
|
||||
* Creates the fifth item option event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public FifthItemOptionEvent(int interfaceId, int id, int slot) {
|
||||
super(5, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fifth {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FifthPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a fifth player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FifthPlayerActionEvent(int playerIndex) {
|
||||
super(5, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link ItemActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class FirstItemActionEvent extends ItemActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the first item action event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
*/
|
||||
public FirstItemActionEvent(int interfaceId, int id, int slot) {
|
||||
super(1, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link ItemOptionEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class FirstItemOptionEvent extends ItemOptionEvent {
|
||||
|
||||
/**
|
||||
* Creates the first item option event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public FirstItemOptionEvent(int interfaceId, int id, int slot) {
|
||||
super(1, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FirstNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new first npc action event.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public FirstNpcActionEvent(int index) {
|
||||
super(1, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.model.Position;
|
||||
|
||||
/**
|
||||
* The first {@link ObjectActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class FirstObjectActionEvent extends ObjectActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the first object action event.
|
||||
*
|
||||
* @param id The id.
|
||||
* @param position The position.
|
||||
*/
|
||||
public FirstObjectActionEvent(int id, Position position) {
|
||||
super(1, id, position);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FirstPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a first player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FirstPlayerActionEvent(int playerIndex) {
|
||||
super(1, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fourth {@link ItemActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class FourthItemActionEvent extends ItemActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the fourth item action event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
*/
|
||||
public FourthItemActionEvent(int interfaceId, int id, int slot) {
|
||||
super(4, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fourth {@link ItemOptionEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class FourthItemOptionEvent extends ItemOptionEvent {
|
||||
|
||||
/**
|
||||
* Creates the fourth item option event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public FourthItemOptionEvent(int interfaceId, int id, int slot) {
|
||||
super(4, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The fourth {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class FourthPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a fourth player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public FourthPlayerActionEvent(int playerIndex) {
|
||||
super(4, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client that represents some sort of action on an item. Note that the actual event sent
|
||||
* by the client is one of the five item action events, but this is the event that should be intercepted (and the option
|
||||
* verified).
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public abstract class ItemActionEvent extends InventoryItemEvent {
|
||||
|
||||
/**
|
||||
* Creates the item action event.
|
||||
*
|
||||
* @param option The option number.
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public ItemActionEvent(int option, int interfaceId, int id, int slot) {
|
||||
super(option, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* An {@link InventoryItemEvent} sent by the client when an item's option is clicked (e.g. equip, eat, drink, etc). Note
|
||||
* that the actual event sent by the client is one of the five item option events, but this is the event that should be
|
||||
* intercepted (and the option verified).
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public abstract class ItemOptionEvent extends InventoryItemEvent {
|
||||
|
||||
/**
|
||||
* Creates the item option event.
|
||||
*
|
||||
* @param option The option number.
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public ItemOptionEvent(int option, int interfaceId, int id, int slot) {
|
||||
super(option, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} periodically sent by the client to keep a connection alive.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class KeepAliveEvent extends Event {
|
||||
|
||||
/**
|
||||
* The time this event was created.
|
||||
*/
|
||||
private final long createdAt;
|
||||
|
||||
/**
|
||||
* Creates the keep alive event.
|
||||
*/
|
||||
public KeepAliveEvent() {
|
||||
createdAt = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time when this event was created.
|
||||
*
|
||||
* @return The time when this event was created.
|
||||
*/
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client that cleanly logs it out.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class LogoutEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to reset the animations of every mob.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class MobAnimationResetEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client representing the clicking of an npc menu action. Note that the actual event sent
|
||||
* by the client is one of the three npc action events, but this is the event that should be intercepted (and the option
|
||||
* verified).
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public abstract class NpcActionEvent extends Event {
|
||||
|
||||
/**
|
||||
* The option number.
|
||||
*/
|
||||
private final int option;
|
||||
|
||||
/**
|
||||
* The index of the clicked npc.
|
||||
*/
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* Creates an npc action event.
|
||||
*
|
||||
* @param option The option number.
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public NpcActionEvent(int option, int index) {
|
||||
this.option = option;
|
||||
this.index = index - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the menu action number (i.e. the action event 'option') clicked.
|
||||
*
|
||||
* @return The option number.
|
||||
*/
|
||||
public int getOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the npc clicked.
|
||||
*
|
||||
* @return The npc index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client that opens a dialogue interface (an interface that appears in the chat box).
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class OpenDialogueInterfaceEvent extends Event {
|
||||
|
||||
/**
|
||||
* The interface id.
|
||||
*/
|
||||
private final int interfaceId;
|
||||
|
||||
/**
|
||||
* Creates a new event with the specified interface id.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
*/
|
||||
public OpenDialogueInterfaceEvent(int interfaceId) {
|
||||
this.interfaceId = interfaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interface id.
|
||||
*
|
||||
* @return The interface id.
|
||||
*/
|
||||
public int getInterfaceId() {
|
||||
return interfaceId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client that opens an interface.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class OpenInterfaceEvent extends Event {
|
||||
|
||||
/**
|
||||
* The interface id.
|
||||
*/
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* Creates the event with the specified interface id.
|
||||
*
|
||||
* @param id The interface id.
|
||||
*/
|
||||
public OpenInterfaceEvent(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interface id.
|
||||
*
|
||||
* @return The interface id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link ItemActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class SecondItemActionEvent extends ItemActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the second item action event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
*/
|
||||
public SecondItemActionEvent(int interfaceId, int id, int slot) {
|
||||
super(2, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link ItemOptionEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class SecondItemOptionEvent extends ItemOptionEvent {
|
||||
|
||||
/**
|
||||
* Creates the second item option event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public SecondItemOptionEvent(int interfaceId, int id, int slot) {
|
||||
super(2, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SecondNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new second npc action event.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public SecondNpcActionEvent(int index) {
|
||||
super(2, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.model.Position;
|
||||
|
||||
/**
|
||||
* The second {@link ObjectActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class SecondObjectActionEvent extends ObjectActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the second object action event.
|
||||
*
|
||||
* @param id The id.
|
||||
* @param position The position.
|
||||
*/
|
||||
public SecondObjectActionEvent(int id, Position position) {
|
||||
super(2, id, position);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SecondPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a second player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public SecondPlayerActionEvent(int playerIndex) {
|
||||
super(2, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to display a server message.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ServerMessageEvent extends Event {
|
||||
|
||||
/**
|
||||
* The message.
|
||||
*/
|
||||
private final String message;
|
||||
|
||||
/**
|
||||
* Creates a server message event.
|
||||
*
|
||||
* @param message The message.
|
||||
*/
|
||||
public ServerMessageEvent(String message) {
|
||||
this(message, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a server message event.
|
||||
*
|
||||
* @param message The message.
|
||||
* @param filterable If the message can be filtered.
|
||||
*/
|
||||
public ServerMessageEvent(String message, boolean filterable) {
|
||||
this.message = message + (filterable ? ":filterable:" : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to set a widget's displayed player model.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class SetWidgetPlayerModelEvent extends Event {
|
||||
|
||||
/**
|
||||
* The interface's id.
|
||||
*/
|
||||
private final int interfaceId;
|
||||
|
||||
/**
|
||||
* Creates a new set interface player model event.
|
||||
*
|
||||
* @param interfaceId The interface's id.
|
||||
*/
|
||||
public SetWidgetPlayerModelEvent(int interfaceId) {
|
||||
this.interfaceId = interfaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interface's id.
|
||||
*
|
||||
* @return The id.
|
||||
*/
|
||||
public int getInterfaceId() {
|
||||
return interfaceId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* A {@link Event} sent by the client after a short period of time containing random data.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class SpamPacketEvent extends Event {
|
||||
|
||||
/**
|
||||
* Data sent by the spam packet.
|
||||
*/
|
||||
private final byte[] data;
|
||||
|
||||
/**
|
||||
* Creates a new spam packet event.
|
||||
*
|
||||
* @param data The data sent.
|
||||
*/
|
||||
public SpamPacketEvent(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data sent.
|
||||
*
|
||||
* @return The data.
|
||||
*/
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link ItemActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ThirdItemActionEvent extends ItemActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the third item action event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
*/
|
||||
public ThirdItemActionEvent(int interfaceId, int id, int slot) {
|
||||
super(3, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link ItemOptionEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class ThirdItemOptionEvent extends ItemOptionEvent {
|
||||
|
||||
/**
|
||||
* Creates the third item option event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The id.
|
||||
* @param slot The slot.
|
||||
*/
|
||||
public ThirdItemOptionEvent(int interfaceId, int id, int slot) {
|
||||
super(3, interfaceId, id, slot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ThirdNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new third npc action event.
|
||||
*
|
||||
* @param index The index of the npc.
|
||||
*/
|
||||
public ThirdNpcActionEvent(int index) {
|
||||
super(3, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.model.Position;
|
||||
|
||||
/**
|
||||
* The third {@link ObjectActionEvent}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ThirdObjectActionEvent extends ObjectActionEvent {
|
||||
|
||||
/**
|
||||
* Creates the third object action event.
|
||||
*
|
||||
* @param id The id.
|
||||
* @param position The position.
|
||||
*/
|
||||
public ThirdObjectActionEvent(int id, Position position) {
|
||||
super(3, id, position);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link PlayerActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ThirdPlayerActionEvent extends PlayerActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a third player action event.
|
||||
*
|
||||
* @param playerIndex The index of the clicked player.
|
||||
*/
|
||||
public ThirdPlayerActionEvent(int playerIndex) {
|
||||
super(3, playerIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent to the client to update the remaining run energy value.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class UpdateRunEnergyEvent extends Event {
|
||||
|
||||
/**
|
||||
* The run energy.
|
||||
*/
|
||||
private final int energy;
|
||||
|
||||
/**
|
||||
* Creates a new update run energy event.
|
||||
*
|
||||
* @param energy The energy.
|
||||
*/
|
||||
public UpdateRunEnergyEvent(int energy) {
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of run energy.
|
||||
*
|
||||
* @return The energy.
|
||||
*/
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains event implementations.
|
||||
*/
|
||||
package org.apollo.game.event.impl;
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains classes related to the event management in the game.
|
||||
*/
|
||||
package org.apollo.game.event;
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.apollo.game.message;
|
||||
|
||||
/**
|
||||
* A message sent by the client that can be intercepted.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public abstract class Message {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.game.message.handler;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* Handles messages received from the client.
|
||||
*
|
||||
* @author Graham
|
||||
* @param <M> The type of message handled by this class.
|
||||
*/
|
||||
public abstract class MessageHandler<M extends Message> {
|
||||
|
||||
/**
|
||||
* Handles a message.
|
||||
*
|
||||
* @param ctx The context.
|
||||
* @param player The player.
|
||||
* @param message The message.
|
||||
*/
|
||||
public abstract void handle(MessageHandlerContext ctx, Player player, M message);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.apollo.game.message.handler;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A chain of message handlers.
|
||||
*
|
||||
* @author Graham
|
||||
* @param <M> The type of message handled by this chain.
|
||||
*/
|
||||
public final class MessageHandlerChain<M extends Message> {
|
||||
|
||||
/**
|
||||
* The handlers.
|
||||
*/
|
||||
private MessageHandler<M>[] handlers;
|
||||
|
||||
/**
|
||||
* Creates the message handler chain.
|
||||
*
|
||||
* @param handlers The handlers.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public MessageHandlerChain(MessageHandler<M>... handlers) {
|
||||
this.handlers = handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically adds a message handler to the end of the chain.
|
||||
*
|
||||
* @param handler The handler.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addLast(MessageHandler<M> handler) {
|
||||
MessageHandler<M>[] old = handlers;
|
||||
handlers = new MessageHandler[old.length + 1];
|
||||
System.arraycopy(old, 0, handlers, 0, old.length);
|
||||
handlers[old.length] = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the message, passing it down the chain until the chain is broken or the message reaches the end of the
|
||||
* chain.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param message The message.
|
||||
*/
|
||||
public void handle(Player player, M message) {
|
||||
final boolean[] running = new boolean[1];
|
||||
running[0] = true;
|
||||
|
||||
MessageHandlerContext ctx = new MessageHandlerContext() {
|
||||
|
||||
@Override
|
||||
public void breakHandlerChain() {
|
||||
running[0] = false;
|
||||
}
|
||||
};
|
||||
|
||||
for (MessageHandler<M> handler : handlers) {
|
||||
handler.handle(ctx, player, message);
|
||||
if (!running[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.apollo.game.message.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
|
||||
/**
|
||||
* A group of {@link MessageHandlerChain}s classified by the {@link Message} type.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class MessageHandlerChainGroup {
|
||||
|
||||
/**
|
||||
* The map of message classes to message handler chains.
|
||||
*/
|
||||
private final Map<Class<? extends Message>, MessageHandlerChain<?>> chains;
|
||||
|
||||
/**
|
||||
* Creates the message handler chain group.
|
||||
*
|
||||
* @param chains The chains map.
|
||||
*/
|
||||
public MessageHandlerChainGroup(Map<Class<? extends Message>, MessageHandlerChain<?>> chains) {
|
||||
this.chains = chains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link MessageHandlerChain} from this group.
|
||||
*
|
||||
* @param <M> The type of message.
|
||||
* @param clazz The message class.
|
||||
* @return The {@link MessageHandlerChain} if one was found, {@code null} otherwise.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <M extends Message> MessageHandlerChain<M> getChain(Class<M> clazz) {
|
||||
return (MessageHandlerChain<M>) chains.get(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link MessageHandlerChain} associated with the specified {@link Class} to this group.
|
||||
*
|
||||
* @param clazz The message class.
|
||||
* @param chain The message handler chain.
|
||||
*/
|
||||
public <M extends Message> void register(Class<M> clazz, MessageHandlerChain<M> chain) {
|
||||
chains.put(clazz, chain);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.apollo.game.message.handler;
|
||||
|
||||
|
||||
/**
|
||||
* Provides operations specific to a {@link MessageHandler} in an {@link MessageHandlerChain}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public abstract class MessageHandlerContext {
|
||||
|
||||
/**
|
||||
* Breaks the handler chain.
|
||||
*/
|
||||
public abstract void breakHandlerChain();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ButtonMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} that responds to {@link ButtonMessage}s for withdrawing items as notes.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class BankButtonMessageHandler extends MessageHandler<ButtonMessage> {
|
||||
|
||||
/**
|
||||
* The withdraw as item button id.
|
||||
*/
|
||||
private static final int WITHDRAW_AS_ITEM = 5387;
|
||||
|
||||
/**
|
||||
* The withdraw as note button id.
|
||||
*/
|
||||
private static final int WITHDRAW_AS_NOTE = 5386;
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ButtonMessage message) {
|
||||
if (message.getWidgetId() == WITHDRAW_AS_ITEM) {
|
||||
player.setWithdrawingNotes(false);
|
||||
} else if (message.getWidgetId() == WITHDRAW_AS_NOTE) {
|
||||
player.setWithdrawingNotes(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ItemActionMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.bank.BankConstants;
|
||||
import org.apollo.game.model.inter.bank.BankDepositEnterAmountListener;
|
||||
import org.apollo.game.model.inter.bank.BankUtils;
|
||||
import org.apollo.game.model.inter.bank.BankWithdrawEnterAmountListener;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} that handles withdrawing and depositing items from/to a player's bank.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class BankMessageHandler extends MessageHandler<ItemActionMessage> {
|
||||
|
||||
/**
|
||||
* Converts an option to an amount.
|
||||
*
|
||||
* @param option The option.
|
||||
* @return The amount.
|
||||
* @throws IllegalArgumentException If the option is invalid.
|
||||
*/
|
||||
private static final int optionToAmount(int option) {
|
||||
switch (option) {
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 5;
|
||||
case 3:
|
||||
return 10;
|
||||
case 4:
|
||||
return Integer.MAX_VALUE;
|
||||
case 5:
|
||||
return -1;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid option supplied.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a deposit action.
|
||||
*
|
||||
* @param ctx The message handler context.
|
||||
* @param player The player.
|
||||
* @param message The message.
|
||||
*/
|
||||
private void deposit(MessageHandlerContext ctx, Player player, ItemActionMessage message) {
|
||||
int amount = optionToAmount(message.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankDepositEnterAmountListener(player, message.getSlot(), message.getId()));
|
||||
} else if (!BankUtils.deposit(player, message.getSlot(), message.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ItemActionMessage message) {
|
||||
if (player.getInterfaceSet().contains(BankConstants.BANK_WINDOW_ID)) {
|
||||
if (message.getInterfaceId() == BankConstants.SIDEBAR_INVENTORY_ID) {
|
||||
deposit(ctx, player, message);
|
||||
} else if (message.getInterfaceId() == BankConstants.BANK_INVENTORY_ID) {
|
||||
withdraw(ctx, player, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a withdraw action.
|
||||
*
|
||||
* @param ctx The message handler context.
|
||||
* @param player The player.
|
||||
* @param message The message.
|
||||
*/
|
||||
private void withdraw(MessageHandlerContext ctx, Player player, ItemActionMessage message) {
|
||||
int amount = optionToAmount(message.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankWithdrawEnterAmountListener(player, message.getSlot(), message.getId()));
|
||||
} else if (!BankUtils.withdraw(player, message.getSlot(), message.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ChatMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.sync.block.SynchronizationBlock;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} that broadcasts public chat messages.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ChatMessageHandler extends MessageHandler<ChatMessage> {
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ChatMessage message) {
|
||||
player.getBlockSet().add(SynchronizationBlock.createChatBlock(player, message));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ChatMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} that verifies {@link ChatMessage}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ChatVerificationHandler extends MessageHandler<ChatMessage> {
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ChatMessage message) {
|
||||
int color = message.getTextColor();
|
||||
int effects = message.getTextEffects();
|
||||
if (color < 0 || color > 11 || effects < 0 || effects > 5) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ClosedInterfaceMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} for the {@link ClosedInterfaceMessage}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class ClosedInterfaceMessageHandler extends MessageHandler<ClosedInterfaceMessage> {
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ClosedInterfaceMessage message) {
|
||||
player.getInterfaceSet().interfaceClosed();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.command.Command;
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.CommandMessage;
|
||||
import org.apollo.game.model.World;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} that dispatches {@link CommandMessage}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public final class CommandMessageHandler extends MessageHandler<CommandMessage> {
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, CommandMessage message) {
|
||||
String[] components = message.getCommand().split(" ");
|
||||
String name = components[0];
|
||||
|
||||
String[] arguments = new String[components.length - 1];
|
||||
System.arraycopy(components, 1, arguments, 0, arguments.length);
|
||||
|
||||
Command command = new Command(name, arguments);
|
||||
World.getWorld().getCommandDispatcher().dispatch(player, command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.apollo.game.message.handler.impl;
|
||||
|
||||
import org.apollo.game.message.handler.MessageHandler;
|
||||
import org.apollo.game.message.handler.MessageHandlerContext;
|
||||
import org.apollo.game.message.impl.ButtonMessage;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.game.model.inter.InterfaceType;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandler} which intercepts button clicks on dialogues, and forwards the message to the current
|
||||
* listener.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class DialogueButtonHandler extends MessageHandler<ButtonMessage> {
|
||||
|
||||
@Override
|
||||
public void handle(MessageHandlerContext ctx, Player player, ButtonMessage message) {
|
||||
if (player.getInterfaceSet().contains(InterfaceType.DIALOGUE)) {
|
||||
boolean breakChain = player.getInterfaceSet().buttonClicked(message.getWidgetId());
|
||||
|
||||
if (breakChain) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user