-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: conditionally relocate adventure across all platforms
- Loading branch information
1 parent
725a6e5
commit b82f1bb
Showing
19 changed files
with
325 additions
and
129 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
40 changes: 40 additions & 0 deletions
40
core/loader/src/main/java/com/rexcantor64/triton/loader/utils/CommonLoader.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,40 @@ | ||
package com.rexcantor64.triton.loader.utils; | ||
|
||
import lombok.Builder; | ||
import lombok.Singular; | ||
import me.lucko.jarrelocator.Relocation; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Builder | ||
public class CommonLoader { | ||
private static final String CORE_JAR_NAME = "triton-core.jarinjar"; | ||
|
||
private final String jarInJarName; | ||
private final String bootstrapClassName; | ||
@Singular | ||
private final Set<LoaderFlag> flags; | ||
@Singular | ||
private final List<Class<?>> constructorTypes; | ||
@Singular | ||
private final List<Object> constructorValues; | ||
|
||
public LoaderBootstrap loadPlugin() { | ||
List<Relocation> relocations = new ArrayList<>(); | ||
if (flags.contains(LoaderFlag.RELOCATE_ADVENTURE)) { | ||
relocations.add(new Relocation("net/kyori/adventure", "com/rexcantor64/triton/lib/adventure")); | ||
} | ||
|
||
@SuppressWarnings("resource") | ||
JarInJarClassLoader loader = new JarInJarClassLoader(getClass().getClassLoader(), relocations, CORE_JAR_NAME, jarInJarName); | ||
|
||
Class<?>[] constructorTypes = this.constructorTypes.toArray(new Class<?>[this.constructorTypes.size() + 1]); | ||
constructorTypes[constructorTypes.length - 1] = Set.class; | ||
Object[] constructorValues = this.constructorValues.toArray(new Object[this.constructorValues.size() + 1]); | ||
constructorValues[constructorValues.length - 1] = Collections.unmodifiableSet(this.flags); | ||
return loader.instantiatePlugin(bootstrapClassName, constructorTypes, constructorValues); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
core/loader/src/main/java/com/rexcantor64/triton/loader/utils/LoaderFlag.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,5 @@ | ||
package com.rexcantor64.triton.loader.utils; | ||
|
||
public enum LoaderFlag { | ||
RELOCATE_ADVENTURE, | ||
} |
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
5 changes: 5 additions & 0 deletions
5
core/src/main/java/com/rexcantor64/triton/dependencies/Repository.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,5 @@ | ||
package com.rexcantor64.triton.dependencies; | ||
|
||
public class Repository { | ||
public final static String DIOGOTC_MIRROR = "https://repo.diogotc.com/mirror/"; | ||
} |
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
Oops, something went wrong.