-
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.
Merge branch 'v4' into feature/command-debug
- Loading branch information
Showing
117 changed files
with
4,687 additions
and
1,428 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
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
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
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,11 @@ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
group 'com.rexcantor64.triton' | ||
|
||
dependencies { | ||
api 'org.ow2.asm:asm-commons:9.2' | ||
api 'org.ow2.asm:asm:9.2' | ||
api 'me.lucko:jar-relocator:1.7' | ||
} |
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); | ||
} | ||
} |
Oops, something went wrong.