Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
189ff6d
Downward merge 3.7.1 (#31)
CrAfTsArMy Mar 28, 2026
9e9da6d
docs: Remove version tags in java doc (#32)
CrAfTsArMy Mar 28, 2026
e8d0a4d
fix: Sort addons correctly respecting thier depends (#33)
CrAfTsArMy Mar 29, 2026
0152e59
chore: Allow more chars and limit names to 128 chars (#34)
CrAfTsArMy Mar 29, 2026
d5a6807
fix: No longer clear short ttl lists (#35)
CrAfTsArMy Apr 6, 2026
7a47d68
chore: Load the artifact loader only if needed (#36)
CrAfTsArMy Apr 6, 2026
6278f76
chore: Allow more characters for addon names (#37)
CrAfTsArMy Apr 6, 2026
41c2f8d
chore: Add the print format annotation (#38)
CrAfTsArMy Apr 6, 2026
2901430
chore: Add .jfr files to gitignore
CrAfTsArMy Apr 6, 2026
a4363c3
chore: Bump version of gradle to 9.4.1
CrAfTsArMy Apr 6, 2026
308b2b5
Revert "chore: Add the print format annotation (#38)"
CrAfTsArMy Apr 6, 2026
5064af5
chore: Merge in app and file addon loading process (#39)
CrAfTsArMy Apr 6, 2026
416e813
fix: Fix ReflectionUtils#restrictToCallers (#40)
CrAfTsArMy Apr 6, 2026
b9baa23
refactor: Use addon class name if no meta annotation is present (#41)
CrAfTsArMy Apr 6, 2026
e499f8d
chore: Bump version of craftscore to 3.8.14
CrAfTsArMy Apr 12, 2026
b14d7c3
refactor: Use CompletableFuture#allOf
CrAfTsArMy Apr 12, 2026
6180057
refactor: Replace stream with for loop
CrAfTsArMy Apr 12, 2026
c250431
fix: Fix code sources for in app addons
CrAfTsArMy Apr 12, 2026
cfb4f16
refactor: STACK_WALKER is now accessible
CrAfTsArMy Apr 12, 2026
fe426f5
chore: Bump version of tika-core to 3.3.0
CrAfTsArMy Apr 12, 2026
7a3a9f1
chore: Bump version to 3.7.2
CrAfTsArMy Apr 12, 2026
3dcb8d6
chore: Better version matching (#42)
CrAfTsArMy Apr 19, 2026
21171c4
chore: Bump version to 3.7.2-2
CrAfTsArMy Apr 19, 2026
cf41c68
Downward merge 3.7.2
CrAfTsArMy Apr 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ bin/
/logs/
/sessions/

### Test Stuff ###
test/

### Mac OS ###
.DS_Store

### JFR ###
*.jfr

.env
.env.repo
.env.repo
23 changes: 19 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id "java-library"
id "application"
id "de.craftsblock.gradle.publish" version "0.0.20"
id "de.craftsblock.gradle.publish" version "0.0.21"
id("com.autonomousapps.dependency-analysis") version "3.8.0"
}

java {
Expand All @@ -17,7 +18,7 @@ application {
}

group = "de.craftsblock"
version = "3.7.1"
version = "3.7.2-2"

repositories {
mavenCentral()
Expand All @@ -29,7 +30,7 @@ dependencies {
// CraftsBlock related dependencies ---------------------------------------------------------------------------------------

// https://repo.craftsblock.de/#/releases/de/craftsblock/craftscore/bom
implementation platform("de.craftsblock.craftscore:bom:3.8.13-pre9")
implementation platform("de.craftsblock.craftscore:bom:3.8.15")

// https://repo.craftsblock.de/#/releases/de/craftsblock/craftscore/buffer
api "de.craftsblock.craftscore:buffer"
Expand All @@ -49,7 +50,7 @@ dependencies {
// Third party needed dependencies ----------------------------------------------------------------------------------------

// https://mvnrepository.com/artifact/org.apache.tika/tika-core
implementation "org.apache.tika:tika-core:3.2.3"
implementation "org.apache.tika:tika-core:3.3.0"

// https://mvnrepository.com/artifact/org.jetbrains/annotations
implementation "org.jetbrains:annotations:26.1.0"
Expand All @@ -76,6 +77,20 @@ dependencies {

// https://mvnrepository.com/artifact/org.apache.maven.resolver/maven-resolver-util
implementation "org.apache.maven.resolver:maven-resolver-util:2.0.16"

// Testing ----------------------------------------------------------------------------------------------------------------

// https://mvnrepository.com/artifact/org.junit/junit-bom
testImplementation platform('org.junit:junit-bom:6.1.0-M1')

// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api'

// https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// https://mvnrepository.com/artifact/org.assertj/assertj-core
testImplementation 'org.assertj:assertj-core:4.0.0-M1'
}

tasks.withType(JavaCompile).configureEach {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
29 changes: 20 additions & 9 deletions src/main/java/de/craftsblock/craftsnet/CraftsNet.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.security.CodeSource;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.jar.JarFile;
Expand All @@ -46,15 +45,14 @@
*
* @author CraftsBlock
* @author Philipp Maywald
* @version 3.6.1
* @since 1.0.0-SNAPSHOT
*/
public class CraftsNet {

/**
* The current version of CraftsNet.
*/
public static final String version = "3.7.1";
public static final String version = "3.7.2-2";

private static CraftsNet instance;

Expand Down Expand Up @@ -121,10 +119,10 @@ public void start(CraftsNetBuilder builder) throws IOException {
logStream.start();

if (instance != null) {
Arrays.stream(new Logger[]{logger, instance.logger}).forEach(log -> {
for (Logger log : new Logger[]{logger, instance.logger}) {
log.warning("Detected another instance of CraftsNet in the jvm!");
log.warning("This may cause some errors.");
});
}
}

instance = this;
Expand All @@ -134,8 +132,8 @@ public void start(CraftsNetBuilder builder) throws IOException {
logger.debug("JVM Version: %s; Max recognizable class file version: %s.%s",
jvmVersion.toString(), jvmVersion.feature() + 44, jvmVersion.interim());

if (!builder.shouldSkipVersionCheck() && version.matches("^\\d+(?:\\.\\d+)*$")) {
Versions.verbalCheck(this);
if (!builder.shouldSkipVersionCheck() && version.matches("^\\d+(?:[.-]\\d+)*$")) {
Versions.verbalCheckCraftsNet(this);
}

logger.debug("Preloading gson for faster processing");
Expand Down Expand Up @@ -547,7 +545,7 @@ public static CraftsNetBuilder create() {
*/
@SafeVarargs
public static AddonContainingBuilder create(Class<? extends Addon>... addons) {
return CraftsNet.create(List.of(addons));
return create(ReflectionUtils.getCallerClass(), List.of(addons));
}

/**
Expand All @@ -560,8 +558,21 @@ public static AddonContainingBuilder create(Class<? extends Addon>... addons) {
* @return A new {@link AddonContainingBuilder} instance initialized with the specified addons.
*/
public static AddonContainingBuilder create(Collection<Class<? extends Addon>> addons) {
return create(ReflectionUtils.getCallerClass(), addons);
}

/**
* Creates a new builder instance for configuring CraftsNet with the specified addons
* and caller class.
*
* @param caller The caller that called the create method.
* @param addons A {@link Collection} of {@link Addon} classes to include in the configuration.
* @return A new {@link AddonContainingBuilder} instance initialized with the specified addons.
* @since 3.8.14
*/
private static AddonContainingBuilder create(Class<?> caller, Collection<Class<? extends Addon>> addons) {
return new AddonContainingBuilder(addons)
.addCodeSource(ReflectionUtils.getCallerClass().getProtectionDomain().getCodeSource());
.addCodeSource(caller.getProtectionDomain().getCodeSource());
}

}
1 change: 0 additions & 1 deletion src/main/java/de/craftsblock/craftsnet/addon/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
*
* @author CraftsBlock
* @author Philipp Maywald
* @version 1.4.1
* @see AddonLoader
* @see AddonManager
* @since 1.0.0-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*
* @author CraftsBlock
* @author Philipp Maywald
* @version 1.3.4
* @see Addon
* @see AddonLoader
* @since 1.0.0-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
* @author Philipp Maywald
* @author CraftsBlock
* @version 1.0.2
* @see Addon
* @since 3.3.5-SNAPSHOT
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.eclipse.aether.resolution.DependencyResult;
import org.eclipse.aether.supplier.RepositorySystemSupplier;
import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
import org.eclipse.aether.util.filter.OrDependencyFilter;
import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
Expand All @@ -40,22 +39,25 @@
*
* @author CraftsBlock
* @author Philipp Maywald
* @version 2.1.2
* @see <a href="https://maven.apache.org/resolver/index.html">Eclipse Aether</a>
* @since 3.0.0-SNAPSHOT
*/
public final class ArtifactLoader {

private final RepositorySystem repository;
private final RepositorySystemSession.CloseableSession session;
private final List<RemoteRepository> repositories;
private final List<RemoteRepository> defaultRepos;
private RepositorySystem repository;
private RepositorySystemSession.CloseableSession session;
private List<RemoteRepository> repositories;
private List<RemoteRepository> defaultRepos;

/**
* Creates a new instance of the artifact loader
* Sets up the artifact loading.
*/
@SuppressWarnings("deprecation")
public ArtifactLoader() {
public void setup() {
if (repository != null) {
return;
}

RepositorySystemSupplier repositorySupplier = new RepositorySystemSupplier();
repository = repositorySupplier.get();

Expand Down Expand Up @@ -91,13 +93,21 @@ public ArtifactLoader() {
* Cleanup internal repository cache
*/
public void cleanup() {
if (repositories == null) {
return;
}

repositories.removeIf(remoteRepository -> !defaultRepos.contains(remoteRepository));
}

/**
* Cleanup and shutdown of the internal repository resolver
*/
public void stop() {
if (repository == null) {
return;
}

cleanup();
session.close();
repository.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import de.craftsblock.craftsnet.addon.Addon;
import de.craftsblock.craftsnet.addon.meta.AddonConfiguration;
import de.craftsblock.craftsnet.logging.Logger;
import de.craftsblock.craftsnet.utils.reflection.ReflectionUtils;
import org.jetbrains.annotations.ApiStatus;

import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
Expand All @@ -14,7 +16,6 @@
*
* @author CraftsBlock
* @author Philipp Maywald
* @version 1.3.0
* @see CraftsNetUrlClassLoader
* @since 3.0.3-SNAPSHOT
*/
Expand All @@ -40,8 +41,10 @@ public final class AddonClassLoader extends CraftsNetUrlClassLoader<AddonClassLo
* @param craftsNet The CraftsNet instance which instantiates this classloader
* @param configuration The configuration of the addon.
*/
AddonClassLoader(CraftsNet craftsNet, AddonConfiguration configuration) {
@ApiStatus.Internal
public AddonClassLoader(CraftsNet craftsNet, AddonConfiguration configuration) {
super(craftsNet, configuration.classpath(), ClassLoader.getSystemClassLoader());
ReflectionUtils.restrictToCallers(AddonConfiguration.class, AddonLoader.class);
this.logger = this.getCraftsNet().getLogger();

addonLoaders.add(this);
Expand Down
Loading