Skip to content

Commit

Permalink
Make FabricPluginManager match VanillaPluginManager changes related t…
Browse files Browse the repository at this point in the history
…o LoadOrder#BEFORE (a8c9fb1) that caused issues with plugin guice modules
  • Loading branch information
nelind3 committed Oct 15, 2024
1 parent 4cf647c commit a5e1950
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
*/
package dk.nelind.loofah.launch.plugin;

import com.google.inject.Injector;
import dk.nelind.loofah.launch.FabricLaunch;
import org.apache.logging.log4j.Logger;
import org.spongepowered.common.applaunch.plugin.DummyPluginContainer;
import org.spongepowered.common.launch.plugin.SpongePluginContainer;
import org.spongepowered.plugin.PluginCandidate;
import org.spongepowered.plugin.builtin.StandardPluginContainer;

public class FabricDummyPluginContainer extends StandardPluginContainer implements DummyPluginContainer {
import java.util.Optional;

public class FabricDummyPluginContainer extends StandardPluginContainer implements SpongePluginContainer, DummyPluginContainer {
public static FabricDummyPluginContainer of(PluginCandidate pluginCandidate) {
return new FabricDummyPluginContainer(
pluginCandidate,
Expand All @@ -43,4 +47,9 @@ private FabricDummyPluginContainer(PluginCandidate candidate, Logger logger, Obj
super(candidate, logger);
this.initializeInstance(instance);
}

@Override
public Optional<Injector> injector() {
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,26 @@ public PluginResource resource(final PluginContainer container) {

private boolean stillValid(final PluginCandidate candidate, final Map<PluginCandidate, String> consequential) {
final Optional<PluginDependency> failedId =
candidate.metadata().dependencies().stream().filter(x -> !x.optional() && !this.plugins.containsKey(x.id())).findFirst();
candidate.metadata().dependencies().stream().filter(d -> !this.isDependencyStillValid(d)).findFirst();
if (failedId.isPresent()) {
consequential.put(candidate, failedId.get().id());
return false;
}
return true;
}

private boolean isDependencyStillValid(final PluginDependency dependency) {
if (!dependency.optional()) {
return switch (dependency.loadOrder()) {
case BEFORE -> !this.plugins.containsKey(dependency.id());
case AFTER -> this.plugins.containsKey(dependency.id());
default -> true;
};
}

return true;
}

@Override
public boolean isReady() {
return this.ready;
Expand Down

0 comments on commit a5e1950

Please sign in to comment.