@@ -8,23 +8,57 @@ namespace AutoDuty.Helpers
88{
99 using System ;
1010 using System . Collections . Generic ;
11- using static FFXIVClientStructs . FFXIV . Client . Game . GcArmyManager . Delegates ;
11+ using System . Linq ;
12+ using System . Reflection ;
13+ using Serilog ;
1214
1315 public static class ActiveHelper
1416 {
1517 internal static HashSet < IActiveHelper > activeHelpers = [ ] ;
18+
19+ public static void InvokeAllHelpers ( )
20+ {
21+ Type baseType = typeof ( ActiveHelperBase < > ) ;
22+ Assembly assembly = typeof ( ActiveHelper ) . Assembly ;
23+
24+ foreach ( Type type in assembly . GetTypes ( ) )
25+ {
26+ if ( ! type . IsClass || type . IsAbstract )
27+ continue ;
28+
29+ Type ? current = type ;
30+ while ( current != null )
31+ {
32+ if ( current . IsGenericType && current . GetGenericTypeDefinition ( ) == baseType )
33+ break ;
34+ if ( current . BaseType is { IsGenericType : true } && current . BaseType . GetGenericTypeDefinition ( ) == baseType )
35+ {
36+ Svc . Log . Warning ( type . FullName ) ;
37+ Activator . CreateInstance ( type ) ;
38+ break ;
39+ }
40+ current = current . BaseType ;
41+ }
42+ }
43+ }
1644 }
1745
1846 internal interface IActiveHelper
1947 {
20- internal void StopIfRunning ( ) ;
48+ internal void StopIfRunning ( ) ;
49+ public string [ ] ? Commands { get ; init ; }
50+ public string ? CommandDescription { get ; init ; }
51+ public void OnCommand ( string [ ] args ) ;
2152 }
2253
2354 internal abstract class ActiveHelperBase < T > : IActiveHelper where T : ActiveHelperBase < T > , new ( )
2455 {
2556 protected abstract string Name { get ; }
2657 protected abstract string DisplayName { get ; }
2758
59+ public virtual string [ ] ? Commands { get ; init ; }
60+ public virtual string ? CommandDescription { get ; init ; }
61+
2862 protected virtual string [ ] AddonsToClose { get ; } = [ ] ;
2963
3064 protected virtual int TimeOut { get ; set ; } = 300_000 ;
@@ -44,6 +78,12 @@ public static T Instance
4478 }
4579 }
4680
81+ public ActiveHelperBase ( )
82+ {
83+ instance = ( T ) this ;
84+ ActiveHelper . activeHelpers . Add ( this ) ;
85+ }
86+
4787
4888 internal static void Invoke ( )
4989 {
@@ -57,6 +97,13 @@ internal virtual void Start()
5797 this . DebugLog ( this . Name + " already running" ) ;
5898 return ;
5999 }
100+ if ( PlayerHelper . GetGrandCompanyRank ( ) <= 5 )
101+ {
102+ Svc . Log . Info ( "GC Turnin requires GC Rank 6 or Higher" ) ;
103+ return ;
104+ }
105+
106+
60107 this . InfoLog ( this . Name + " started" ) ;
61108 State = ActionState . Running ;
62109 Plugin . States |= PluginState . Other ;
@@ -85,6 +132,7 @@ public void StopIfRunning()
85132 this . Stop ( ) ;
86133 }
87134
135+
88136 internal virtual void Stop ( )
89137 {
90138 if ( State == ActionState . Running )
@@ -154,6 +202,11 @@ public unsafe bool CloseAddons()
154202 return true ;
155203 }
156204
205+ public virtual void OnCommand ( string [ ] args )
206+ {
207+ this . Start ( ) ;
208+ }
209+
157210 protected void DebugLog ( string s )
158211 {
159212 Svc . Log . Debug ( $ "{ this . Name } : { s } ") ;
0 commit comments