Skip to content

Commit

Permalink
[Feature management] Load all features in plugin's main thread to avo…
Browse files Browse the repository at this point in the history
…id API calls from load event before a feature actually loads (#1409)
  • Loading branch information
NEZNAMY committed Jan 10, 2025
1 parent ae82871 commit 3ec772e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions shared/src/main/java/me/neznamy/tab/shared/FeatureManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,9 @@ public class FeatureManager {
public void load() {
for (TabFeature f : values) {
if (!(f instanceof Loadable)) continue;
TimedCaughtTask task = new TimedCaughtTask(TAB.getInstance().getCpu(), () -> {
long time = System.currentTimeMillis();
((Loadable) f).load();
TAB.getInstance().debug("Feature " + f.getClass().getSimpleName() + " processed load in " + (System.currentTimeMillis()-time) + "ms");
}, f.getFeatureName(), CpuUsageCategory.PLUGIN_LOAD);
if (f instanceof CustomThreaded) {
((CustomThreaded) f).getCustomThread().execute(task);
} else {
task.run();
}
long time = System.currentTimeMillis();
((Loadable) f).load();
TAB.getInstance().debug("Feature " + f.getClass().getSimpleName() + " processed load in " + (System.currentTimeMillis()-time) + "ms");
}
if (TAB.getInstance().getConfiguration().getUsers() instanceof MySQLUserConfiguration) {
MySQLUserConfiguration users = (MySQLUserConfiguration) TAB.getInstance().getConfiguration().getUsers();
Expand Down

0 comments on commit 3ec772e

Please sign in to comment.