Get rid of singleton, and refactor LauncherFactory to be a static class
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
parent
e68dcea6bc
commit
9062d28704
@ -138,10 +138,7 @@ public final class EntryPoint {
|
||||
}
|
||||
|
||||
try {
|
||||
Launcher launcher =
|
||||
LauncherFactory
|
||||
.INSTANCE
|
||||
.createLauncher(params);
|
||||
Launcher launcher = LauncherFactory.createLauncher(params);
|
||||
|
||||
launcher.launch();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
package org.prismlauncher;
|
||||
|
||||
|
||||
import org.prismlauncher.impl.LegacyLauncher;
|
||||
import org.prismlauncher.impl.StandardLauncher;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
@ -42,13 +43,11 @@ import org.prismlauncher.utils.Parameters;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public final class LauncherFactory {
|
||||
private static final Map<String, LauncherProvider> launcherRegistry = new HashMap<>();
|
||||
|
||||
public static final LauncherFactory INSTANCE = new LauncherFactory();
|
||||
|
||||
private final Map<String, LauncherProvider> launcherRegistry = new HashMap<>();
|
||||
|
||||
private LauncherFactory() {
|
||||
static {
|
||||
launcherRegistry.put("standard", new LauncherProvider() {
|
||||
@Override
|
||||
public Launcher provide(Parameters parameters) {
|
||||
@ -62,8 +61,10 @@ public final class LauncherFactory {
|
||||
}
|
||||
});
|
||||
}
|
||||
private LauncherFactory() {
|
||||
}
|
||||
|
||||
public Launcher createLauncher(Parameters parameters) {
|
||||
public static Launcher createLauncher(Parameters parameters) {
|
||||
String name = parameters.first("launcher");
|
||||
|
||||
LauncherProvider launcherProvider = launcherRegistry.get(name);
|
||||
|
Loading…
Reference in New Issue
Block a user