-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'modern' of https://github.com/Polyfrost/OneConfigLoader …
…into modern
- Loading branch information
Showing
70 changed files
with
2,273 additions
and
1,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
common/src/main/java/org/polyfrost/oneconfig/loader/relaunch/Detection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.polyfrost.oneconfig.loader.relaunch; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.lang.reflect.Field; | ||
import java.net.URL; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public interface Detection { | ||
void checkRelaunch(String id, List<URL> urls, Field classLoaderExceptionsField, Set<String> classLoaderExceptions, Field transformerExceptionsField, Set<String> transformerExceptions, Field resourceCacheField, Map<String, byte[]> resourceCache, Field negativeResourceCacheField, Set<String> negativeResourceCache) throws Exception; | ||
boolean isRelaunch(); | ||
void setRelaunch(boolean relaunch); | ||
@Nullable List<URL> getDetectedUrls(); | ||
} |
39 changes: 39 additions & 0 deletions
39
common/src/main/java/org/polyfrost/oneconfig/loader/relaunch/DetectionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.polyfrost.oneconfig.loader.relaunch; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
|
||
public interface DetectionSupplier { | ||
|
||
/** | ||
* Will try to get an instance of {@link DetectionSupplier} using a service loader, otherwise will return a no-op instance. | ||
* | ||
* @author Deftu | ||
* @since 1.1.0-alpha.x | ||
*/ | ||
static DetectionSupplier maybeCreate() { | ||
ServiceLoader<DetectionSupplier> loader = ServiceLoader.load(DetectionSupplier.class); | ||
Iterator<DetectionSupplier> iterator = loader.iterator(); | ||
if (iterator.hasNext()) { | ||
return iterator.next(); | ||
} | ||
|
||
return DetectionSupplier.DetectionSupplierNoOp.INSTANCE; | ||
} | ||
|
||
List<Detection> createDetectionList(); | ||
|
||
class DetectionSupplierNoOp implements DetectionSupplier { | ||
|
||
public static final DetectionSupplierNoOp INSTANCE = new DetectionSupplierNoOp(); | ||
|
||
@Override | ||
public List<Detection> createDetectionList() { | ||
return new ArrayList<>(); // No-op | ||
} | ||
|
||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
common/src/main/java/org/polyfrost/oneconfig/loader/relaunch/Relaunch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.polyfrost.oneconfig.loader.relaunch; | ||
|
||
import java.net.URL; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.ServiceLoader; | ||
|
||
/** | ||
* @author Deftu | ||
* @since 1.1.0-alpha.x | ||
*/ | ||
public interface Relaunch { | ||
|
||
/** | ||
* Will try to get an instance of {@link Relaunch} using a service loader, otherwise will return a no-op instance. | ||
* | ||
* @author Deftu | ||
* @since 1.1.0-alpha.x | ||
*/ | ||
static Relaunch maybeCreate() { | ||
ServiceLoader<Relaunch> loader = ServiceLoader.load(Relaunch.class); | ||
Iterator<Relaunch> iterator = loader.iterator(); | ||
if (iterator.hasNext()) { | ||
return iterator.next(); | ||
} | ||
|
||
return RelaunchNoOp.INSTANCE; | ||
} | ||
|
||
/** | ||
* @author Deftu | ||
* @since 1.1.0-alpha.x | ||
*/ | ||
void maybeRelaunch(DetectionSupplier detectionSupplier, Map<String, List<URL>> urls); | ||
|
||
/** | ||
* @author Deftu | ||
* @since 1.1.0-alpha.x | ||
*/ | ||
class RelaunchNoOp implements Relaunch { | ||
public static final RelaunchNoOp INSTANCE = new RelaunchNoOp(); | ||
|
||
@Override | ||
public void maybeRelaunch(DetectionSupplier detectionSupplier, Map<String, List<URL>> urls) { | ||
// No-op | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
common/src/main/java/org/polyfrost/oneconfig/loader/ui/Palette.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.polyfrost.oneconfig.loader.ui; | ||
|
||
import java.awt.*; | ||
|
||
public class Palette { | ||
|
||
public static final Color GRAY_900 = new Color(13, 14, 15, 255); | ||
public static final Color GRAY_700 = new Color(34, 35, 38); | ||
public static final Color PRIMARY_500 = new Color(26, 103, 255); | ||
public static final Color PRIMARY_500_80 = new Color(26, 103, 204); | ||
public static final Color WHITE_80 = new Color(255, 255, 255, 204); | ||
public static final Color TRANSPARENT = new Color(0, 0, 0, 0); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencies { | ||
implementation(projects.common) | ||
include("org.polyfrost:polyio:0.1.0") | ||
|
||
compileOnly("net.minecraft:launchwrapper:1.12") | ||
compileOnly("com.google.guava:guava:17.0") | ||
} |
44 changes: 44 additions & 0 deletions
44
relaunch/src/main/java/org/polyfrost/oneconfig/loader/relaunch/DetectionSupplierImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.polyfrost.oneconfig.loader.relaunch; | ||
|
||
import org.polyfrost.oneconfig.loader.relaunch.detection.AsmDetection; | ||
import org.polyfrost.oneconfig.loader.relaunch.detection.ExcludedKotlinDetection; | ||
import org.polyfrost.oneconfig.loader.relaunch.detection.MixinDetection; | ||
import org.polyfrost.oneconfig.loader.relaunch.detection.PreloadLibraryDetection; | ||
import org.polyfrost.oneconfig.loader.relaunch.detection.SignedMixinDetection; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DetectionSupplierImpl implements DetectionSupplier { | ||
|
||
public List<Detection> createDetectionList() { | ||
return new ArrayList<Detection>() { | ||
{ | ||
add(new AsmDetection()); | ||
add(new ExcludedKotlinDetection()); | ||
add(new SignedMixinDetection()); | ||
addAll(createComplexPreloadLibraryDetectionList()); | ||
add(new PreloadLibraryDetection("org.spongepowered:mixin", "org", "spongepowered")); | ||
add(new MixinDetection()); | ||
} | ||
}; | ||
} | ||
|
||
private List<Detection> createComplexPreloadLibraryDetectionList() { | ||
return new ArrayList<Detection>() { | ||
{ | ||
String[][][] paths = { | ||
{{"org.jetbrains.kotlin"}, {"kotlin"}}, | ||
{{"org.jetbrains.kotlinx"}, {"kotlinx", "coroutines"}}, | ||
{{"org.polyfrost:universalcraft"}, {"org", "polyfrost", "universal"}}, | ||
{{"org.polyfrost:polyui"}, {"org", "polyfrost", "polyui"}} | ||
}; | ||
|
||
for (String[][] path : paths) { | ||
add(new PreloadLibraryDetection(path[0][0], path[1])); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
} |
Oops, something went wrong.