File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
org/mangorage/mangobotcore/plugin Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 4444
4545 provides org .mangorage .mangobotcore .plugin .api .Plugin with org .mangorage .mangobotcore .MangoBotCore ;
4646 uses org .mangorage .mangobotcore .plugin .api .Plugin ;
47+ uses org .mangorage .mangobotcore .plugin .api .IPluginInfoGetter ;
4748}
Original file line number Diff line number Diff line change 1+ package org .mangorage .mangobotcore .plugin .api ;
2+
3+ import java .util .List ;
4+
5+ /**
6+ * Allows you to grab all metadata info, of all plugins
7+ * before any plugin ctor ever gets called!
8+ */
9+ public interface IPluginInfoGetter {
10+ void onGet (List <Metadata > list );
11+ }
Original file line number Diff line number Diff line change 33import com .google .gson .Gson ;
44import com .google .gson .GsonBuilder ;
55import org .mangorage .commonutils .log .LogHelper ;
6+ import org .mangorage .mangobotcore .plugin .api .IPluginInfoGetter ;
67import org .mangorage .mangobotcore .plugin .api .MangoBotPlugin ;
8+ import org .mangorage .mangobotcore .plugin .api .Metadata ;
79import org .mangorage .mangobotcore .plugin .api .Plugin ;
810import org .mangorage .mangobotcore .plugin .api .PluginContainer ;
911import org .mangorage .mangobotcore .plugin .api .PluginManager ;
@@ -78,6 +80,19 @@ public void load() {
7880 }
7981 }
8082
83+ LogHelper .info ("Giving Metadata info out..." );
84+
85+ ServiceLoader .load (IPluginInfoGetter .class )
86+ .stream ()
87+ .forEach (provider -> {
88+ final var list = manager .getLibraries ()
89+ .stream ()
90+ .map (library -> (Metadata ) library .getObject ().getMetadata ())
91+ .toList ();
92+ provider .get ().onGet (list );
93+ });
94+
95+
8196 LogHelper .info ("Loading Plugins..." );
8297
8398 for (Library <PluginContainerImpl > library : manager .getLibrariesInOrder ()) {
You can’t perform that action at this time.
0 commit comments