From 11f4a9d5e7aef43c090157688362547d834f788a Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Date: Thu, 23 Apr 2020 22:17:57 +0200 Subject: [PATCH] Made the object_added listener a little cleaner by inhereting from the parent class. --- lib/aethyr/core/commands/admin/acarea.rb | 3 +- lib/aethyr/core/commands/admin/acdoor.rb | 3 +- lib/aethyr/core/commands/admin/acexit.rb | 3 +- lib/aethyr/core/commands/admin/acomm.rb | 3 +- lib/aethyr/core/commands/admin/acomment.rb | 3 +- lib/aethyr/core/commands/admin/aconfig.rb | 3 +- lib/aethyr/core/commands/admin/acportal.rb | 3 +- lib/aethyr/core/commands/admin/acprop.rb | 3 +- lib/aethyr/core/commands/admin/acreate.rb | 3 +- lib/aethyr/core/commands/admin/acroom.rb | 3 +- lib/aethyr/core/commands/admin/adelete.rb | 3 +- lib/aethyr/core/commands/admin/adesc.rb | 3 +- lib/aethyr/core/commands/admin/aforce.rb | 3 +- lib/aethyr/core/commands/admin/ahelp.rb | 3 +- lib/aethyr/core/commands/admin/ahide.rb | 3 +- lib/aethyr/core/commands/admin/ainfo.rb | 3 +- lib/aethyr/core/commands/admin/alearn.rb | 3 +- lib/aethyr/core/commands/admin/alist.rb | 3 +- lib/aethyr/core/commands/admin/alog.rb | 3 +- lib/aethyr/core/commands/admin/aput.rb | 3 +- lib/aethyr/core/commands/admin/areact.rb | 3 +- lib/aethyr/core/commands/admin/areas.rb | 3 +- lib/aethyr/core/commands/admin/areload.rb | 3 +- lib/aethyr/core/commands/admin/asave.rb | 3 +- lib/aethyr/core/commands/admin/aset.rb | 3 +- lib/aethyr/core/commands/admin/ashow.rb | 3 +- lib/aethyr/core/commands/admin/astatus.rb | 3 +- lib/aethyr/core/commands/admin/ateach.rb | 3 +- lib/aethyr/core/commands/admin/awatch.rb | 3 +- lib/aethyr/core/commands/admin/awho.rb | 3 +- .../core/commands/admin/deleteplayer.rb | 3 +- lib/aethyr/core/commands/admin/restart.rb | 3 +- lib/aethyr/core/commands/admin/terrain.rb | 3 +- lib/aethyr/core/commands/block.rb | 3 +- lib/aethyr/core/commands/close.rb | 3 +- lib/aethyr/core/commands/command_handler.rb | 18 ++++++++---- lib/aethyr/core/commands/dodge.rb | 3 +- lib/aethyr/core/commands/drop.rb | 3 +- lib/aethyr/core/commands/emotes/agree.rb | 3 +- lib/aethyr/core/commands/emotes/back.rb | 3 +- lib/aethyr/core/commands/emotes/blush.rb | 3 +- lib/aethyr/core/commands/emotes/bow.rb | 3 +- lib/aethyr/core/commands/emotes/brb.rb | 3 +- lib/aethyr/core/commands/emotes/bye.rb | 3 +- lib/aethyr/core/commands/emotes/cheer.rb | 3 +- lib/aethyr/core/commands/emotes/cry.rb | 3 +- lib/aethyr/core/commands/emotes/curtsey.rb | 3 +- lib/aethyr/core/commands/emotes/eh.rb | 3 +- lib/aethyr/core/commands/emotes/emote.rb | 3 +- lib/aethyr/core/commands/emotes/er.rb | 3 +- lib/aethyr/core/commands/emotes/ew.rb | 3 +- lib/aethyr/core/commands/emotes/frown.rb | 3 +- lib/aethyr/core/commands/emotes/grin.rb | 3 +- lib/aethyr/core/commands/emotes/hi.rb | 3 +- lib/aethyr/core/commands/emotes/hm.rb | 3 +- lib/aethyr/core/commands/emotes/hug.rb | 3 +- lib/aethyr/core/commands/emotes/huh.rb | 3 +- lib/aethyr/core/commands/emotes/laugh.rb | 3 +- lib/aethyr/core/commands/emotes/no.rb | 3 +- lib/aethyr/core/commands/emotes/nod.rb | 3 +- lib/aethyr/core/commands/emotes/pet.rb | 3 +- lib/aethyr/core/commands/emotes/poke.rb | 3 +- lib/aethyr/core/commands/emotes/ponder.rb | 3 +- lib/aethyr/core/commands/emotes/shrug.rb | 3 +- lib/aethyr/core/commands/emotes/sigh.rb | 3 +- lib/aethyr/core/commands/emotes/skip.rb | 3 +- lib/aethyr/core/commands/emotes/smile.rb | 3 +- lib/aethyr/core/commands/emotes/snicker.rb | 3 +- lib/aethyr/core/commands/emotes/uh.rb | 3 +- lib/aethyr/core/commands/emotes/wave.rb | 3 +- lib/aethyr/core/commands/emotes/yawn.rb | 3 +- lib/aethyr/core/commands/emotes/yes.rb | 3 +- lib/aethyr/core/commands/gait.rb | 3 +- lib/aethyr/core/commands/generic.rb | 3 +- lib/aethyr/core/commands/get.rb | 3 +- lib/aethyr/core/commands/give.rb | 3 +- lib/aethyr/core/commands/inventory.rb | 3 +- lib/aethyr/core/commands/issue.rb | 3 +- lib/aethyr/core/commands/kick.rb | 3 +- lib/aethyr/core/commands/locking.rb | 3 +- lib/aethyr/core/commands/look.rb | 3 +- lib/aethyr/core/commands/map.rb | 3 +- lib/aethyr/core/commands/more.rb | 3 +- lib/aethyr/core/commands/move.rb | 3 +- lib/aethyr/core/commands/news.rb | 3 +- lib/aethyr/core/commands/open.rb | 3 +- lib/aethyr/core/commands/portal.rb | 3 +- lib/aethyr/core/commands/pose.rb | 3 +- lib/aethyr/core/commands/punch.rb | 3 +- lib/aethyr/core/commands/put.rb | 3 +- lib/aethyr/core/commands/quit.rb | 3 +- lib/aethyr/core/commands/remove.rb | 3 +- lib/aethyr/core/commands/say.rb | 3 +- lib/aethyr/core/commands/set.rb | 3 +- lib/aethyr/core/commands/sit.rb | 3 +- lib/aethyr/core/commands/skills.rb | 3 +- lib/aethyr/core/commands/slash.rb | 3 +- lib/aethyr/core/commands/stand.rb | 3 +- lib/aethyr/core/commands/tell.rb | 3 +- lib/aethyr/core/commands/unwield.rb | 3 +- lib/aethyr/core/commands/wear.rb | 3 +- lib/aethyr/core/commands/whereis.rb | 3 +- lib/aethyr/core/commands/whisper.rb | 3 +- lib/aethyr/core/commands/wield.rb | 3 +- lib/aethyr/core/registry.rb | 28 ++++--------------- 105 files changed, 121 insertions(+), 234 deletions(-) diff --git a/lib/aethyr/core/commands/admin/acarea.rb b/lib/aethyr/core/commands/admin/acarea.rb index 1c64faa..89ed1ff 100644 --- a/lib/aethyr/core/commands/admin/acarea.rb +++ b/lib/aethyr/core/commands/admin/acarea.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcareaHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acdoor.rb b/lib/aethyr/core/commands/admin/acdoor.rb index ea803f7..f42d50b 100644 --- a/lib/aethyr/core/commands/admin/acdoor.rb +++ b/lib/aethyr/core/commands/admin/acdoor.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcdoorHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acexit.rb b/lib/aethyr/core/commands/admin/acexit.rb index 196494d..f550945 100644 --- a/lib/aethyr/core/commands/admin/acexit.rb +++ b/lib/aethyr/core/commands/admin/acexit.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcexitHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acomm.rb b/lib/aethyr/core/commands/admin/acomm.rb index 4faf52d..5dec941 100644 --- a/lib/aethyr/core/commands/admin/acomm.rb +++ b/lib/aethyr/core/commands/admin/acomm.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcommHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acomment.rb b/lib/aethyr/core/commands/admin/acomment.rb index 1cd5889..7b6223a 100644 --- a/lib/aethyr/core/commands/admin/acomment.rb +++ b/lib/aethyr/core/commands/admin/acomment.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcommentHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/aconfig.rb b/lib/aethyr/core/commands/admin/aconfig.rb index f5c5f99..ee090b3 100644 --- a/lib/aethyr/core/commands/admin/aconfig.rb +++ b/lib/aethyr/core/commands/admin/aconfig.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AconfigHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acportal.rb b/lib/aethyr/core/commands/admin/acportal.rb index 6b75b5f..970179d 100644 --- a/lib/aethyr/core/commands/admin/acportal.rb +++ b/lib/aethyr/core/commands/admin/acportal.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcportalHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acprop.rb b/lib/aethyr/core/commands/admin/acprop.rb index 1f73bca..4dafccf 100644 --- a/lib/aethyr/core/commands/admin/acprop.rb +++ b/lib/aethyr/core/commands/admin/acprop.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcpropHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acreate.rb b/lib/aethyr/core/commands/admin/acreate.rb index a3748f5..e99197e 100644 --- a/lib/aethyr/core/commands/admin/acreate.rb +++ b/lib/aethyr/core/commands/admin/acreate.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcreateHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/acroom.rb b/lib/aethyr/core/commands/admin/acroom.rb index 283ebee..b329c27 100644 --- a/lib/aethyr/core/commands/admin/acroom.rb +++ b/lib/aethyr/core/commands/admin/acroom.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AcroomHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/adelete.rb b/lib/aethyr/core/commands/admin/adelete.rb index 6d0cfce..a3a914b 100644 --- a/lib/aethyr/core/commands/admin/adelete.rb +++ b/lib/aethyr/core/commands/admin/adelete.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AdeleteHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/adesc.rb b/lib/aethyr/core/commands/admin/adesc.rb index 55ed33c..3e205c2 100644 --- a/lib/aethyr/core/commands/admin/adesc.rb +++ b/lib/aethyr/core/commands/admin/adesc.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AdescHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/aforce.rb b/lib/aethyr/core/commands/admin/aforce.rb index 33be713..ee6ca47 100644 --- a/lib/aethyr/core/commands/admin/aforce.rb +++ b/lib/aethyr/core/commands/admin/aforce.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AforceHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/ahelp.rb b/lib/aethyr/core/commands/admin/ahelp.rb index fdd86b0..506c1cb 100644 --- a/lib/aethyr/core/commands/admin/ahelp.rb +++ b/lib/aethyr/core/commands/admin/ahelp.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AhelpHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/ahide.rb b/lib/aethyr/core/commands/admin/ahide.rb index c044d6b..6806659 100644 --- a/lib/aethyr/core/commands/admin/ahide.rb +++ b/lib/aethyr/core/commands/admin/ahide.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AhideHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/ainfo.rb b/lib/aethyr/core/commands/admin/ainfo.rb index 4d4289c..560c7a7 100644 --- a/lib/aethyr/core/commands/admin/ainfo.rb +++ b/lib/aethyr/core/commands/admin/ainfo.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AinfoHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/alearn.rb b/lib/aethyr/core/commands/admin/alearn.rb index ebaec22..6399d09 100644 --- a/lib/aethyr/core/commands/admin/alearn.rb +++ b/lib/aethyr/core/commands/admin/alearn.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AlearnHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/alist.rb b/lib/aethyr/core/commands/admin/alist.rb index 0b6a297..3c09fee 100644 --- a/lib/aethyr/core/commands/admin/alist.rb +++ b/lib/aethyr/core/commands/admin/alist.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AlistHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/alog.rb b/lib/aethyr/core/commands/admin/alog.rb index 2ead2ec..80dea62 100644 --- a/lib/aethyr/core/commands/admin/alog.rb +++ b/lib/aethyr/core/commands/admin/alog.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AlogHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/aput.rb b/lib/aethyr/core/commands/admin/aput.rb index 620c478..6e804b9 100644 --- a/lib/aethyr/core/commands/admin/aput.rb +++ b/lib/aethyr/core/commands/admin/aput.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AputHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/areact.rb b/lib/aethyr/core/commands/admin/areact.rb index afc1130..b76c788 100644 --- a/lib/aethyr/core/commands/admin/areact.rb +++ b/lib/aethyr/core/commands/admin/areact.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AreactHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/areas.rb b/lib/aethyr/core/commands/admin/areas.rb index ec4497d..59fe9c9 100644 --- a/lib/aethyr/core/commands/admin/areas.rb +++ b/lib/aethyr/core/commands/admin/areas.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AreasHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/areload.rb b/lib/aethyr/core/commands/admin/areload.rb index f973095..4f2ce25 100644 --- a/lib/aethyr/core/commands/admin/areload.rb +++ b/lib/aethyr/core/commands/admin/areload.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AreloadHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/asave.rb b/lib/aethyr/core/commands/admin/asave.rb index c3dd762..2aecde9 100644 --- a/lib/aethyr/core/commands/admin/asave.rb +++ b/lib/aethyr/core/commands/admin/asave.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AsaveHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/aset.rb b/lib/aethyr/core/commands/admin/aset.rb index 75c0998..cb23e15 100644 --- a/lib/aethyr/core/commands/admin/aset.rb +++ b/lib/aethyr/core/commands/admin/aset.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AsetHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/ashow.rb b/lib/aethyr/core/commands/admin/ashow.rb index d3827b4..514d930 100644 --- a/lib/aethyr/core/commands/admin/ashow.rb +++ b/lib/aethyr/core/commands/admin/ashow.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AshowHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/astatus.rb b/lib/aethyr/core/commands/admin/astatus.rb index 526739a..9533d09 100644 --- a/lib/aethyr/core/commands/admin/astatus.rb +++ b/lib/aethyr/core/commands/admin/astatus.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AstatusHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/ateach.rb b/lib/aethyr/core/commands/admin/ateach.rb index 067c570..b09c621 100644 --- a/lib/aethyr/core/commands/admin/ateach.rb +++ b/lib/aethyr/core/commands/admin/ateach.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AteachHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/awatch.rb b/lib/aethyr/core/commands/admin/awatch.rb index 988f434..6ae429b 100644 --- a/lib/aethyr/core/commands/admin/awatch.rb +++ b/lib/aethyr/core/commands/admin/awatch.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AwatchHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/awho.rb b/lib/aethyr/core/commands/admin/awho.rb index 4ce2ff7..2241a30 100644 --- a/lib/aethyr/core/commands/admin/awho.rb +++ b/lib/aethyr/core/commands/admin/awho.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AwhoHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/deleteplayer.rb b/lib/aethyr/core/commands/admin/deleteplayer.rb index ddfdb08..6a3f377 100644 --- a/lib/aethyr/core/commands/admin/deleteplayer.rb +++ b/lib/aethyr/core/commands/admin/deleteplayer.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(DeleteplayerHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/restart.rb b/lib/aethyr/core/commands/admin/restart.rb index 47c4b55..db77414 100644 --- a/lib/aethyr/core/commands/admin/restart.rb +++ b/lib/aethyr/core/commands/admin/restart.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(RestartHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/admin/terrain.rb b/lib/aethyr/core/commands/admin/terrain.rb index a13f1ab..077b1e6 100644 --- a/lib/aethyr/core/commands/admin/terrain.rb +++ b/lib/aethyr/core/commands/admin/terrain.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(TerrainHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/block.rb b/lib/aethyr/core/commands/block.rb index c8267ab..270952a 100644 --- a/lib/aethyr/core/commands/block.rb +++ b/lib/aethyr/core/commands/block.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(BlockHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/close.rb b/lib/aethyr/core/commands/close.rb index 2298ea4..39fc2d5 100644 --- a/lib/aethyr/core/commands/close.rb +++ b/lib/aethyr/core/commands/close.rb @@ -15,8 +15,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(CloseHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/command_handler.rb b/lib/aethyr/core/commands/command_handler.rb index 53a5b56..9765552 100644 --- a/lib/aethyr/core/commands/command_handler.rb +++ b/lib/aethyr/core/commands/command_handler.rb @@ -2,10 +2,10 @@ require 'aethyr/core/commands/help_handler' module Aethyr module Extend - + class InputHandler attr_reader :player - + def initialize(player, *args) super(*args) @player = player @@ -15,13 +15,21 @@ module Aethyr false end end - + class CommandHandler < InputHandler include Aethyr::Extend::HandleHelp - + def initialize(player, commands, *args) super(player, commands, *args) end + + protected + #event listener parent that listens for when a new user is added to the manager + def self.object_added(data, klass: child_class) + return unless data[:game_object].is_a? Player + data[:game_object].subscribe(klass.new(data[:game_object])) + end + end end -end \ No newline at end of file +end diff --git a/lib/aethyr/core/commands/dodge.rb b/lib/aethyr/core/commands/dodge.rb index ddb8146..5edf091 100644 --- a/lib/aethyr/core/commands/dodge.rb +++ b/lib/aethyr/core/commands/dodge.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(DodgeHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/drop.rb b/lib/aethyr/core/commands/drop.rb index 676b1a2..bf333f2 100644 --- a/lib/aethyr/core/commands/drop.rb +++ b/lib/aethyr/core/commands/drop.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(DropHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/agree.rb b/lib/aethyr/core/commands/emotes/agree.rb index 2056470..fa8e8fd 100644 --- a/lib/aethyr/core/commands/emotes/agree.rb +++ b/lib/aethyr/core/commands/emotes/agree.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(AgreeHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/back.rb b/lib/aethyr/core/commands/emotes/back.rb index d95a27d..ecd52fc 100644 --- a/lib/aethyr/core/commands/emotes/back.rb +++ b/lib/aethyr/core/commands/emotes/back.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(BackHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/blush.rb b/lib/aethyr/core/commands/emotes/blush.rb index 94e99bb..ca3a5c0 100644 --- a/lib/aethyr/core/commands/emotes/blush.rb +++ b/lib/aethyr/core/commands/emotes/blush.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(BlushHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/bow.rb b/lib/aethyr/core/commands/emotes/bow.rb index 9dd79cc..39d1232 100644 --- a/lib/aethyr/core/commands/emotes/bow.rb +++ b/lib/aethyr/core/commands/emotes/bow.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(BowHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/brb.rb b/lib/aethyr/core/commands/emotes/brb.rb index 69fb99c..d8d6dce 100644 --- a/lib/aethyr/core/commands/emotes/brb.rb +++ b/lib/aethyr/core/commands/emotes/brb.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(BrbHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/bye.rb b/lib/aethyr/core/commands/emotes/bye.rb index 92ca962..a8dcae9 100644 --- a/lib/aethyr/core/commands/emotes/bye.rb +++ b/lib/aethyr/core/commands/emotes/bye.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(ByeHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/cheer.rb b/lib/aethyr/core/commands/emotes/cheer.rb index ad1a428..8ecd1e5 100644 --- a/lib/aethyr/core/commands/emotes/cheer.rb +++ b/lib/aethyr/core/commands/emotes/cheer.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(CheerHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/cry.rb b/lib/aethyr/core/commands/emotes/cry.rb index 5996c33..15f1eef 100644 --- a/lib/aethyr/core/commands/emotes/cry.rb +++ b/lib/aethyr/core/commands/emotes/cry.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(CryHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/curtsey.rb b/lib/aethyr/core/commands/emotes/curtsey.rb index a1fe14e..2fda515 100644 --- a/lib/aethyr/core/commands/emotes/curtsey.rb +++ b/lib/aethyr/core/commands/emotes/curtsey.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(CurtseyHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/eh.rb b/lib/aethyr/core/commands/emotes/eh.rb index 18ad176..2e18249 100644 --- a/lib/aethyr/core/commands/emotes/eh.rb +++ b/lib/aethyr/core/commands/emotes/eh.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(EhHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/emote.rb b/lib/aethyr/core/commands/emotes/emote.rb index a8a8a0f..3664b1b 100644 --- a/lib/aethyr/core/commands/emotes/emote.rb +++ b/lib/aethyr/core/commands/emotes/emote.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(EmoteHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/er.rb b/lib/aethyr/core/commands/emotes/er.rb index d48087d..768d046 100644 --- a/lib/aethyr/core/commands/emotes/er.rb +++ b/lib/aethyr/core/commands/emotes/er.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(ErHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/ew.rb b/lib/aethyr/core/commands/emotes/ew.rb index 13aac91..58101b2 100644 --- a/lib/aethyr/core/commands/emotes/ew.rb +++ b/lib/aethyr/core/commands/emotes/ew.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(EwHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/frown.rb b/lib/aethyr/core/commands/emotes/frown.rb index a9391ed..76e8bc8 100644 --- a/lib/aethyr/core/commands/emotes/frown.rb +++ b/lib/aethyr/core/commands/emotes/frown.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(FrownHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/grin.rb b/lib/aethyr/core/commands/emotes/grin.rb index cea8422..989dec3 100644 --- a/lib/aethyr/core/commands/emotes/grin.rb +++ b/lib/aethyr/core/commands/emotes/grin.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(GrinHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/hi.rb b/lib/aethyr/core/commands/emotes/hi.rb index 62abdf5..f976dcd 100644 --- a/lib/aethyr/core/commands/emotes/hi.rb +++ b/lib/aethyr/core/commands/emotes/hi.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(HiHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/hm.rb b/lib/aethyr/core/commands/emotes/hm.rb index 8e24c08..93a7e6b 100644 --- a/lib/aethyr/core/commands/emotes/hm.rb +++ b/lib/aethyr/core/commands/emotes/hm.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(HmHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/hug.rb b/lib/aethyr/core/commands/emotes/hug.rb index 165ef9d..aef4908 100644 --- a/lib/aethyr/core/commands/emotes/hug.rb +++ b/lib/aethyr/core/commands/emotes/hug.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(HugHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/huh.rb b/lib/aethyr/core/commands/emotes/huh.rb index 799e278..af05a4a 100644 --- a/lib/aethyr/core/commands/emotes/huh.rb +++ b/lib/aethyr/core/commands/emotes/huh.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(HuhHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/laugh.rb b/lib/aethyr/core/commands/emotes/laugh.rb index 2f8c540..15f674c 100644 --- a/lib/aethyr/core/commands/emotes/laugh.rb +++ b/lib/aethyr/core/commands/emotes/laugh.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(LaughHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/no.rb b/lib/aethyr/core/commands/emotes/no.rb index 362f242..36acf88 100644 --- a/lib/aethyr/core/commands/emotes/no.rb +++ b/lib/aethyr/core/commands/emotes/no.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(NoHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/nod.rb b/lib/aethyr/core/commands/emotes/nod.rb index d3e81f2..231b30e 100644 --- a/lib/aethyr/core/commands/emotes/nod.rb +++ b/lib/aethyr/core/commands/emotes/nod.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(NodHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/pet.rb b/lib/aethyr/core/commands/emotes/pet.rb index 9e9fdd7..ea72c04 100644 --- a/lib/aethyr/core/commands/emotes/pet.rb +++ b/lib/aethyr/core/commands/emotes/pet.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PetHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/poke.rb b/lib/aethyr/core/commands/emotes/poke.rb index 9ee7853..06cebdc 100644 --- a/lib/aethyr/core/commands/emotes/poke.rb +++ b/lib/aethyr/core/commands/emotes/poke.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PokeHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/ponder.rb b/lib/aethyr/core/commands/emotes/ponder.rb index 73f7962..9e307c8 100644 --- a/lib/aethyr/core/commands/emotes/ponder.rb +++ b/lib/aethyr/core/commands/emotes/ponder.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PonderHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/shrug.rb b/lib/aethyr/core/commands/emotes/shrug.rb index db39ea8..f1cd033 100644 --- a/lib/aethyr/core/commands/emotes/shrug.rb +++ b/lib/aethyr/core/commands/emotes/shrug.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(ShrugHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/sigh.rb b/lib/aethyr/core/commands/emotes/sigh.rb index 8056ad8..9ae6ead 100644 --- a/lib/aethyr/core/commands/emotes/sigh.rb +++ b/lib/aethyr/core/commands/emotes/sigh.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SighHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/skip.rb b/lib/aethyr/core/commands/emotes/skip.rb index 9a906c7..5931ab7 100644 --- a/lib/aethyr/core/commands/emotes/skip.rb +++ b/lib/aethyr/core/commands/emotes/skip.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SkipHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/smile.rb b/lib/aethyr/core/commands/emotes/smile.rb index 0101a45..f432a29 100644 --- a/lib/aethyr/core/commands/emotes/smile.rb +++ b/lib/aethyr/core/commands/emotes/smile.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SmileHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/snicker.rb b/lib/aethyr/core/commands/emotes/snicker.rb index 3f5836b..182820e 100644 --- a/lib/aethyr/core/commands/emotes/snicker.rb +++ b/lib/aethyr/core/commands/emotes/snicker.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SnickerHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/uh.rb b/lib/aethyr/core/commands/emotes/uh.rb index 809d1cf..d5540e3 100644 --- a/lib/aethyr/core/commands/emotes/uh.rb +++ b/lib/aethyr/core/commands/emotes/uh.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(UhHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/wave.rb b/lib/aethyr/core/commands/emotes/wave.rb index c0d4778..6cd8b5b 100644 --- a/lib/aethyr/core/commands/emotes/wave.rb +++ b/lib/aethyr/core/commands/emotes/wave.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(WaveHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/yawn.rb b/lib/aethyr/core/commands/emotes/yawn.rb index f82b5ed..bd37ba5 100644 --- a/lib/aethyr/core/commands/emotes/yawn.rb +++ b/lib/aethyr/core/commands/emotes/yawn.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(YawnHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/emotes/yes.rb b/lib/aethyr/core/commands/emotes/yes.rb index ea8a2fa..f6fa418 100644 --- a/lib/aethyr/core/commands/emotes/yes.rb +++ b/lib/aethyr/core/commands/emotes/yes.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(YesHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/gait.rb b/lib/aethyr/core/commands/gait.rb index c8605c5..ae22aa5 100644 --- a/lib/aethyr/core/commands/gait.rb +++ b/lib/aethyr/core/commands/gait.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(GaitHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/generic.rb b/lib/aethyr/core/commands/generic.rb index 1f98062..e8c8f19 100644 --- a/lib/aethyr/core/commands/generic.rb +++ b/lib/aethyr/core/commands/generic.rb @@ -12,8 +12,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(GenericHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/get.rb b/lib/aethyr/core/commands/get.rb index dcf6b58..0c1f226 100644 --- a/lib/aethyr/core/commands/get.rb +++ b/lib/aethyr/core/commands/get.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(GetHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/give.rb b/lib/aethyr/core/commands/give.rb index e626446..7570d50 100644 --- a/lib/aethyr/core/commands/give.rb +++ b/lib/aethyr/core/commands/give.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(GiveHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/inventory.rb b/lib/aethyr/core/commands/inventory.rb index 34d9a06..e8a4044 100644 --- a/lib/aethyr/core/commands/inventory.rb +++ b/lib/aethyr/core/commands/inventory.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(InventoryHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/issue.rb b/lib/aethyr/core/commands/issue.rb index 01122e0..6e2cd88 100644 --- a/lib/aethyr/core/commands/issue.rb +++ b/lib/aethyr/core/commands/issue.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(IssueHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/kick.rb b/lib/aethyr/core/commands/kick.rb index c6c6f38..ee1ce3d 100644 --- a/lib/aethyr/core/commands/kick.rb +++ b/lib/aethyr/core/commands/kick.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(KickHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/locking.rb b/lib/aethyr/core/commands/locking.rb index db98813..16cad9d 100644 --- a/lib/aethyr/core/commands/locking.rb +++ b/lib/aethyr/core/commands/locking.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(LockingHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/look.rb b/lib/aethyr/core/commands/look.rb index 7b0615b..e32779d 100644 --- a/lib/aethyr/core/commands/look.rb +++ b/lib/aethyr/core/commands/look.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(LookHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/map.rb b/lib/aethyr/core/commands/map.rb index 60b747f..3e7790f 100644 --- a/lib/aethyr/core/commands/map.rb +++ b/lib/aethyr/core/commands/map.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(MapHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/more.rb b/lib/aethyr/core/commands/more.rb index 97ffa7e..8733b44 100644 --- a/lib/aethyr/core/commands/more.rb +++ b/lib/aethyr/core/commands/more.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(MoreHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/move.rb b/lib/aethyr/core/commands/move.rb index a835167..a1f4db6 100644 --- a/lib/aethyr/core/commands/move.rb +++ b/lib/aethyr/core/commands/move.rb @@ -15,8 +15,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(MoveHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/news.rb b/lib/aethyr/core/commands/news.rb index a5e235e..5cf35a8 100644 --- a/lib/aethyr/core/commands/news.rb +++ b/lib/aethyr/core/commands/news.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(NewsHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/open.rb b/lib/aethyr/core/commands/open.rb index 2b4fba7..4dbd64e 100644 --- a/lib/aethyr/core/commands/open.rb +++ b/lib/aethyr/core/commands/open.rb @@ -14,8 +14,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(OpenHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/portal.rb b/lib/aethyr/core/commands/portal.rb index 70ae36c..7eec926 100644 --- a/lib/aethyr/core/commands/portal.rb +++ b/lib/aethyr/core/commands/portal.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PortalHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/pose.rb b/lib/aethyr/core/commands/pose.rb index ec3a1da..2ea47e8 100644 --- a/lib/aethyr/core/commands/pose.rb +++ b/lib/aethyr/core/commands/pose.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PoseHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/punch.rb b/lib/aethyr/core/commands/punch.rb index 786aae9..ef05ab2 100644 --- a/lib/aethyr/core/commands/punch.rb +++ b/lib/aethyr/core/commands/punch.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PunchHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/put.rb b/lib/aethyr/core/commands/put.rb index b4e7af2..1a3853f 100644 --- a/lib/aethyr/core/commands/put.rb +++ b/lib/aethyr/core/commands/put.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(PutHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/quit.rb b/lib/aethyr/core/commands/quit.rb index 47dfbf4..4a85f1b 100644 --- a/lib/aethyr/core/commands/quit.rb +++ b/lib/aethyr/core/commands/quit.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(QuitHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/remove.rb b/lib/aethyr/core/commands/remove.rb index 35e998e..848f6e0 100644 --- a/lib/aethyr/core/commands/remove.rb +++ b/lib/aethyr/core/commands/remove.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(RemoveHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/say.rb b/lib/aethyr/core/commands/say.rb index 1626c75..c4ab494 100644 --- a/lib/aethyr/core/commands/say.rb +++ b/lib/aethyr/core/commands/say.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SayHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/set.rb b/lib/aethyr/core/commands/set.rb index f67089b..fead960 100644 --- a/lib/aethyr/core/commands/set.rb +++ b/lib/aethyr/core/commands/set.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SetHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/sit.rb b/lib/aethyr/core/commands/sit.rb index 365ae51..34bb68e 100644 --- a/lib/aethyr/core/commands/sit.rb +++ b/lib/aethyr/core/commands/sit.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SitHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/skills.rb b/lib/aethyr/core/commands/skills.rb index 9a711e6..f216db3 100644 --- a/lib/aethyr/core/commands/skills.rb +++ b/lib/aethyr/core/commands/skills.rb @@ -13,8 +13,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SkillsHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/slash.rb b/lib/aethyr/core/commands/slash.rb index 10ff8ac..dc94f70 100644 --- a/lib/aethyr/core/commands/slash.rb +++ b/lib/aethyr/core/commands/slash.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(SlashHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/stand.rb b/lib/aethyr/core/commands/stand.rb index 8565141..328e22d 100644 --- a/lib/aethyr/core/commands/stand.rb +++ b/lib/aethyr/core/commands/stand.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(StandHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/tell.rb b/lib/aethyr/core/commands/tell.rb index a66f538..2019903 100644 --- a/lib/aethyr/core/commands/tell.rb +++ b/lib/aethyr/core/commands/tell.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(TellHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/unwield.rb b/lib/aethyr/core/commands/unwield.rb index ed828a2..0b1841d 100644 --- a/lib/aethyr/core/commands/unwield.rb +++ b/lib/aethyr/core/commands/unwield.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(UnwieldHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/wear.rb b/lib/aethyr/core/commands/wear.rb index afca7ef..0ac3e8c 100644 --- a/lib/aethyr/core/commands/wear.rb +++ b/lib/aethyr/core/commands/wear.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(WearHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/whereis.rb b/lib/aethyr/core/commands/whereis.rb index b693209..940f11f 100644 --- a/lib/aethyr/core/commands/whereis.rb +++ b/lib/aethyr/core/commands/whereis.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(WhereisHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/whisper.rb b/lib/aethyr/core/commands/whisper.rb index 537c785..1d59c57 100644 --- a/lib/aethyr/core/commands/whisper.rb +++ b/lib/aethyr/core/commands/whisper.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(WhisperHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/commands/wield.rb b/lib/aethyr/core/commands/wield.rb index 46ec3e4..2ce23a2 100644 --- a/lib/aethyr/core/commands/wield.rb +++ b/lib/aethyr/core/commands/wield.rb @@ -11,8 +11,7 @@ module Aethyr end def self.object_added(data) - return unless data[:game_object].is_a? Player - data[:game_object].subscribe(WieldHandler.new(data[:game_object])) + super(data, klass: self) end def player_input(data) diff --git a/lib/aethyr/core/registry.rb b/lib/aethyr/core/registry.rb index b4ab627..f122025 100644 --- a/lib/aethyr/core/registry.rb +++ b/lib/aethyr/core/registry.rb @@ -1,45 +1,27 @@ module Aethyr module Extend class HandlerRegistry - @@handlers = Set.new - + @@handlers = Set.new + def self.register_handler(new_handler) raise "Bad handler!" unless new_handler unless @@handlers.include? new_handler @@handlers << new_handler end end - + def self.get_handlers return @@handlers.dup end - + def self.handle(manager) @@handlers.each do |handler| manager.subscribe(handler) end nil end - -# def self.help_handle(input, player) -# @@handlers.values.each do |handler| -# next unless handler.is_a? Aethyr::Extend::HandleHelp -# e = handler.help_handle(input, player) -# return e unless e.nil? -# end -# nil -# end -# -# def self.help_topics(player) -# topics = [] -# @@handlers.values.each do |handler| -# next unless handler.is_a? Aethyr::Extend::HandleHelp -# topics.push *(handler.commands) -# end -# topics -# end end end end -require 'aethyr/core/util/all-commands' \ No newline at end of file +require 'aethyr/core/util/all-commands' -- GitLab