Skip to content

Commit

Permalink
Merge branch 'v4' into feature/command-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotcorreia committed Jul 15, 2024
2 parents a9fcf36 + 3443490 commit 97beb21
Show file tree
Hide file tree
Showing 117 changed files with 4,687 additions and 1,428 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug Report
description: Have you found a bug while using Triton? Report it here and help us improve!
labels: ["bug"]
labels: ["type:bug", "triage"]
assignees:
- diogotcorreia
body:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Feature Request
description: Do you have an idea for a new feature? This is where you should request it!
labels: ["feature"]
labels: ["type:feature", "triage"]
assignees:
- diogotcorreia
body:
Expand Down
13 changes: 3 additions & 10 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ group 'com.rexcantor64.triton'

apply from: '../gradle/publish.gradle'

sourceSets {
ap {
compileClasspath += main.compileClasspath + main.output
}
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.20-R0.1-SNAPSHOT'

compileOnly 'net.kyori:adventure-api:4.11.0'
compileOnly 'net.kyori:adventure-text-serializer-bungeecord:4.1.2'
Expand All @@ -29,11 +23,10 @@ task javadocJar(type: Jar) {
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
from sourceSets.ap.output
}

jar {
from sourceSets.ap.output
from sourceSets.main.output
manifest {
attributes 'Automatic-Module-Name': 'com.rexcantor64.triton.api'
}
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/com/rexcantor64/triton/api/Triton.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.rexcantor64.triton.api.language.LanguageManager;
import com.rexcantor64.triton.api.language.LanguageParser;
import com.rexcantor64.triton.api.language.MessageParser;
import com.rexcantor64.triton.api.language.TranslationManager;
import com.rexcantor64.triton.api.players.LanguagePlayer;
import com.rexcantor64.triton.api.players.PlayerManager;

Expand Down Expand Up @@ -53,6 +54,14 @@ default TritonConfig getConf() {
@Deprecated
LanguageParser getLanguageParser();

/**
* Get the {@link TranslationManager translation manager}.
*
* @return The {@link TranslationManager translation manager}.
* @since 4.0.0
*/
TranslationManager getTranslationManager();

/**
* Get the {@link MessageParser message parser}.
*
Expand Down
22 changes: 19 additions & 3 deletions api/src/main/java/com/rexcantor64/triton/api/TritonAPI.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.rexcantor64.triton.api;

import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;

/**
* The entry point of the API
*
* @since 1.0.0
*/
public class TritonAPI {
public final class TritonAPI {
@Internal
private static Triton instance;

/**
* Get the instance of the {@link Triton plugin}.
Expand All @@ -16,8 +19,21 @@ public class TritonAPI {
* @since 1.0.0
*/
public static @NotNull Triton getInstance() {
//noinspection ConstantConditions
return null;
if (instance == null) {
throw new UnsupportedOperationException("Triton is not running (yet?)! If you're seeing this, some plugin is trying to use the Triton API before Triton has loaded.");
}
return instance;
}

@SuppressWarnings("unused")
@Internal
private static void register(@NotNull Triton instance) {
TritonAPI.instance = instance;
}

@Internal
private TritonAPI() {
throw new UnsupportedOperationException("This class cannot be instantiated.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ public interface TritonConfig {
*/
boolean isAdvancements();

/**
* @return The value of "language-creation.death-screen.enabled" in the config.
* @since 3.10.0
*/
boolean isDeathScreen();

/**
* @return The value of "language-creation.terminal" in the config.
* @since 2.6.0
Expand Down Expand Up @@ -323,4 +329,10 @@ public interface TritonConfig {
*/
FeatureSyntax getAdvancementsSyntax();

/**
* @return The {@link com.rexcantor64.triton.api.config.FeatureSyntax FeatureSyntax} of "language-creation
* .death-screen" in the config.
*/
FeatureSyntax getDeathScreenSyntax();

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public interface LanguageManager {
String getTextFromMain(String code, Object... args);

/**
* Get the 4 sign lines for a sign in a player's language.
* Get the 8 sign lines (4 for the front, 4 for the back) for a sign in a player's language.
*
* @param player The {@link LanguagePlayer LanguagePlayer} to get the language from. Use the
* {@link com.rexcantor64.triton.api.players.PlayerManager PlayerManager} to get it.
Expand All @@ -85,7 +85,7 @@ public interface LanguageManager {
String[] getSign(LanguagePlayer player, SignLocation location);

/**
* Get the 4 sign lines for a sign in a player's language, but allows for dynamic signs.
* Get the 8 sign lines (4 for the front, 4 for the back) for a sign in a player's language, but allows for dynamic signs.
*
* @param player The {@link LanguagePlayer LanguagePlayer} to get the language from. Use the
* {@link com.rexcantor64.triton.api.players.PlayerManager PlayerManager} to get it.
Expand All @@ -100,7 +100,7 @@ public interface LanguageManager {
String[] getSign(LanguagePlayer player, SignLocation location, String[] defaultLines);

/**
* Get the 4 sign lines for a sign in a player's language, but allows for dynamic signs.
* Get the 8 sign lines (4 for the front, 4 for the back) for a sign in a player's language, but allows for dynamic signs.
* This also allows for the defaultLines to only be fetched if needed, improving performance.
*
* @param player The {@link LanguagePlayer LanguagePlayer} to get the language from. Use the
Expand All @@ -117,7 +117,7 @@ public interface LanguageManager {
String[] getSign(LanguagePlayer player, SignLocation location, Supplier<String[]> defaultLines);

/**
* Get the 4 sign lines for a sign in a player's language, but allows for dynamic signs.
* Get the 8 sign lines (4 for the front, 4 for the back) for a sign in a player's language, but allows for dynamic signs.
* This also allows for the defaultLines to only be fetched if needed, improving performance.
*
* @param language The {@link Language#getName() name of the language} to use. If invalid, this will fall back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public interface TranslationManager {
*/
@NotNull Optional<Component> getTextComponent(@NotNull Localized locale, @NotNull String key, @NotNull Component... arguments);

/**
* // TODO javadoc
*
* @since 4.0.0
*/
@NotNull Optional<String> getTextString(@NotNull Localized locale, @NotNull String key);

/**
* // TODO javadoc
*
Expand Down
47 changes: 34 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ allprojects {
mavenLocal()
mavenCentral()
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
name 'diogotcRepositorySnapshots'
url 'https://repo.diogotc.com/snapshots/'
}
maven {
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
Expand All @@ -33,15 +37,16 @@ allprojects {
url 'https://nexus.velocitypowered.com/repository/maven-public/'
}
maven {
name 'diogotcRepositorySnapshots'
url 'https://repo.diogotc.com/snapshots/'
// Mirror other people's repositories
name 'diogotcRepositoryMirror'
url 'https://repo.diogotc.com/mirror/'
}
}
}

subprojects {
dependencies {
implementation 'org.jetbrains:annotations:23.0.0'
compileOnly 'org.jetbrains:annotations:23.0.0'

compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
Expand All @@ -52,18 +57,34 @@ subprojects {
}

dependencies {
implementation project(':api')
implementation project(':core:triton-core-loader')
implementation project(':triton-bungeecord:triton-bungeecord-loader')
implementation project(':triton-spigot:triton-spigot-loader')
implementation project(':triton-velocity:triton-velocity-loader')

implementation project(path: ":core")
implementation project(path: ":triton-bungeecord")
implementation project(path: ":triton-spigot")
implementation project(path: ":triton-velocity")
compileOnly project(':core')
compileOnly project(':triton-bungeecord')
compileOnly project(':triton-spigot')
compileOnly project(':triton-velocity')
}

shadowJar {
getArchiveBaseName().set(rootProject.name)
relocate 'org.bstats', 'com.rexcantor64.triton.metrics'
//relocate 'org.slf4j', 'com.rexcantor64.shaded.slf4j'
relocate 'net.kyori.adventure.text.minimessage', 'com.rexcantor64.shaded.minimessage'
relocate 'com.tananaev.jsonpatch', 'com.rexcantor64.shaded.jsonpatch'
relocate 'com.zaxxer.hikari', 'com.rexcantor64.shaded.hikari'

from {
project(':core').tasks.shadowJar.archiveFile
}
from {
project(':triton-bungeecord').tasks.shadowJar.archiveFile
}
from {
project(':triton-spigot').tasks.shadowJar.archiveFile
}
from {
project(':triton-velocity').tasks.shadowJar.archiveFile
}

relocate 'org.objectweb.asm', 'com.rexcantor64.triton.lib.objectweb.asm'
relocate 'me.lucko.jarrelocator', 'com.rexcantor64.triton.lib.jarrelocator'
}
44 changes: 33 additions & 11 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}

group 'com.rexcantor64.triton'
Expand All @@ -9,14 +10,14 @@ test {
}

dependencies {
implementation project(path: ":api")
compileOnly project(':core:triton-core-loader')
compileOnly project(":api")

// Adventure / MiniMessage
// TODO check which of these should be compileOnly or implementation
compileOnly 'net.kyori:adventure-text-serializer-gson:4.11.0'
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.11.0'
compileOnly 'net.kyori:adventure-text-serializer-plain:4.11.0'
implementation('net.kyori:adventure-text-minimessage:4.11.0') {
compileOnly 'net.kyori:adventure-text-serializer-gson:4.15.0'
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.15.0'
compileOnly 'net.kyori:adventure-text-serializer-plain:4.15.0'
compileOnly('net.kyori:adventure-text-minimessage:4.15.0') {
exclude group: 'net.kyori', module: 'adventure-api'
exclude group: 'net.kyori', module: 'adventure-key'
exclude group: 'net.kyori', module: 'adventure-text-serialize-gson'
Expand All @@ -28,7 +29,7 @@ dependencies {
compileOnly 'com.google.guava:guava:31.1-jre'

compileOnly 'org.apache.logging.log4j:log4j-core:2.17.1'
compileOnly 'org.yaml:snakeyaml:1.32'
compileOnly 'org.yaml:snakeyaml:2.0'

implementation 'org.slf4j:slf4j-nop:1.7.36'
implementation 'com.zaxxer:HikariCP:4.0.3'
Expand All @@ -37,12 +38,33 @@ dependencies {
}
compileOnly 'com.google.code.gson:gson:2.9.0'

implementation 'net.byteflux:libby-core:1.3.0'

// Test dependencies
testImplementation project(":api")

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'

testImplementation 'net.kyori:adventure-api:4.11.0'
testImplementation 'net.kyori:adventure-text-serializer-gson:4.11.0'
testImplementation 'net.kyori:adventure-text-serializer-legacy:4.11.0'
testImplementation 'net.kyori:adventure-text-serializer-plain:4.11.0'
testImplementation 'net.kyori:adventure-api:4.15.0'
testImplementation 'net.kyori:adventure-text-serializer-gson:4.15.0'
testImplementation 'net.kyori:adventure-text-serializer-legacy:4.15.0'
testImplementation 'net.kyori:adventure-text-serializer-plain:4.15.0'
}

shadowJar {
archiveFileName = 'triton-core.jarinjar'

relocate 'org.bstats', 'com.rexcantor64.triton.metrics'
//relocate 'org.slf4j', 'com.rexcantor64.shaded.slf4j'
relocate 'com.tananaev.jsonpatch', 'com.rexcantor64.shaded.jsonpatch'
relocate 'com.zaxxer.hikari', 'com.rexcantor64.shaded.hikari'

relocate 'net.kyori.adventure.text.minimessage', 'com.rexcantor64.triton.lib.adventure.text.minimessage'
relocate 'net.kyori.adventure.text.serializer.gson', 'com.rexcantor64.triton.lib.adventure.text.serializer.gson'
relocate 'net.kyori.adventure.text.serializer.legacy', 'com.rexcantor64.triton.lib.adventure.text.serializer.legacy'
relocate 'net.kyori.adventure.text.serializer.plain', 'com.rexcantor64.triton.lib.adventure.text.serializer.plain'
relocate 'net.kyori.adventure.text.serializer.bungeecord', 'com.rexcantor64.triton.lib.adventure.text.serializer.bungeecord'

relocate 'net.byteflux.libby', 'com.rexcantor64.triton.lib.libby'
}
11 changes: 11 additions & 0 deletions core/loader/build.gradle
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'
}
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);
}
}
Loading

0 comments on commit 97beb21

Please sign in to comment.