Skip to content

Commit 48f0f4e

Browse files
committed
Migrate to Java 24 and Gradle 8.14.1.
Enhance JavaDocs.
1 parent 2603b08 commit 48f0f4e

22 files changed

+963
-514
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/setup-java@v4
3030
with:
3131
distribution: temurin
32-
java-version: 23
32+
java-version: 24
3333

3434
- name: Setup Gradle
3535
uses: gradle/actions/setup-gradle@v4

.github/workflows/gradle-dependency-submission.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/setup-java@v4
1818
with:
1919
distribution: temurin
20-
java-version: 23
20+
java-version: 24
2121
- name: Generate and submit dependency graph
2222
uses: gradle/actions/dependency-submission@v4
2323
with:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: actions/setup-java@v4
3939
with:
4040
distribution: temurin
41-
java-version: 23
41+
java-version: 24
4242

4343
- name: Gradle Setup
4444
uses: gradle/actions/setup-gradle@v4
@@ -125,7 +125,7 @@ jobs:
125125
uses: actions/setup-java@v4
126126
with:
127127
distribution: temurin
128-
java-version: 23
128+
java-version: 24
129129

130130
- name: Setup Gradle
131131
uses: gradle/actions/setup-gradle@v4

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ allprojects {
1919
project.getLogger().lifecycle("Set project '{}' version to '{}'.", project.name, project.version)
2020
}
2121

22+
java {
23+
toolchain {
24+
languageVersion = JavaLanguageVersion.of(24)
25+
}
26+
}
27+
2228
nexusPublishing {
2329
useStaging.set(isTaggedRevision(project.version))
2430
repositories {

gradle/wrapper/gradle-wrapper.jar

59 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
118118

119119

120120
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
213213
set -- \
214214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215215
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217217
"$@"
218218

219219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

litiengine/src/main/java/de/gurkenlabs/litiengine/abilities/targeting/CustomTargetingStrategy.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,44 @@
22

33
import de.gurkenlabs.litiengine.Game;
44
import de.gurkenlabs.litiengine.entities.ICombatEntity;
5-
6-
import java.awt.*;
5+
import java.awt.Shape;
76
import java.util.Collection;
87
import java.util.List;
98
import java.util.function.BiPredicate;
109

10+
/**
11+
* A custom targeting strategy that allows defining a specific condition for selecting targets.
12+
*
13+
* <p>This strategy uses a {@link BiPredicate} to determine whether a combat entity
14+
* should be targeted based on the executor and the potential target. It supports multi-targeting and sorting by distance.
15+
*/
1116
public class CustomTargetingStrategy extends TargetingStrategy {
1217

1318
private final BiPredicate<ICombatEntity, ICombatEntity> targetingCondition;
1419

20+
/**
21+
* Creates a new {@code CustomTargetingStrategy} with the specified targeting condition.
22+
*
23+
* @param customPredicate The condition to determine valid targets. It takes the executor and a potential target as arguments and returns
24+
* {@code true} if the target is valid.
25+
* @param multiTarget Whether the strategy supports targeting multiple entities.
26+
* @param sortByDistance Whether the targets should be sorted by their distance to the executor.
27+
*/
1528
public CustomTargetingStrategy(BiPredicate<ICombatEntity, ICombatEntity> customPredicate, boolean multiTarget, boolean sortByDistance) {
1629
super(multiTarget, sortByDistance);
1730
this.targetingCondition = customPredicate;
1831
}
1932

33+
/**
34+
* Finds the targets within the specified impact area based on the targeting condition.
35+
*
36+
* <p>If the targeting condition or the game environment is not available, this method
37+
* returns an empty collection.
38+
*
39+
* @param impactArea The area in which to search for targets.
40+
* @param executor The combat entity executing the ability.
41+
* @return A collection of combat entities that match the targeting condition.
42+
*/
2043
@Override
2144
public Collection<ICombatEntity> findTargetsInternal(Shape impactArea, ICombatEntity executor) {
2245
if (targetingCondition == null || Game.world() == null || Game.world().environment() == null) {

litiengine/src/main/java/de/gurkenlabs/litiengine/environment/CustomMapObjectLoader.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,65 @@
99
import java.util.logging.Level;
1010
import java.util.logging.Logger;
1111

12+
/**
13+
* The {@code CustomMapObjectLoader} class extends the {@link MapObjectLoader} class to provide custom functionality for loading map objects into
14+
* entities.
15+
*
16+
* <p>This class uses a functional interface {@code ConstructorInvocation} to dynamically
17+
* invoke constructors of entity classes based on the provided {@link IMapObject} and {@link Environment}. It supports various constructor signatures
18+
* and prioritizes them based on their parameter types.
19+
*
20+
* <p>It also overrides the {@code load} method to handle the creation and initialization
21+
* of entities from map objects.
22+
*/
1223
public final class CustomMapObjectLoader extends MapObjectLoader {
1324
private static final Logger log = Logger.getLogger(CustomMapObjectLoader.class.getName());
1425
private final ConstructorInvocation invoke;
1526

27+
/**
28+
* A functional interface for invoking constructors of entity classes.
29+
*
30+
* <p>This interface defines a single method {@code invoke}, which dynamically
31+
* creates an instance of an {@link IEntity} using the provided {@link Environment} and {@link IMapObject}.
32+
*/
1633
@FunctionalInterface
1734
interface ConstructorInvocation {
1835
IEntity invoke(Environment environment, IMapObject mapObject) throws InvocationTargetException, IllegalAccessException, InstantiationException;
1936
}
2037

38+
/**
39+
* Constructs a new {@code CustomMapObjectLoader} instance with the specified map object type and constructor invocation logic.
40+
*
41+
* <p>This constructor initializes the loader with a specific map object type and a functional
42+
* interface for dynamically invoking constructors of entity classes.
43+
*
44+
* @param mapObjectType the type of the map object to be handled by this loader
45+
* @param invocation the {@link ConstructorInvocation} functional interface used to create entities
46+
*/
2147
CustomMapObjectLoader(String mapObjectType, ConstructorInvocation invocation) {
2248
super(mapObjectType);
2349
this.invoke = invocation;
2450
}
2551

52+
/**
53+
* Finds the most suitable constructor for the specified entity type.
54+
*
55+
* <p>This method iterates through all constructors of the given entity class and determines
56+
* the best match based on the parameter types. It prioritizes constructors in the following order:
57+
* <ol>
58+
* <li>Constructor with parameters {@link Environment} and {@link IMapObject}</li>
59+
* <li>Constructor with parameters {@link IMapObject} and {@link Environment}</li>
60+
* <li>Constructor with a single {@link IMapObject} parameter</li>
61+
* <li>Constructor with a single {@link Environment} parameter</li>
62+
* <li>Default (no-argument) constructor</li>
63+
* </ol>
64+
*
65+
* <p>If multiple constructors match, the one with the highest priority is selected.
66+
*
67+
* @param entityType the class of the entity for which a constructor is to be found
68+
* @return a {@link ConstructorInvocation} functional interface for invoking the selected constructor, or {@code null} if no suitable constructor is
69+
* uctor is found
70+
*/
2671
static ConstructorInvocation findConstructor(Class<? extends IEntity> entityType) {
2772
ConstructorInvocation inv = null;
2873

@@ -65,7 +110,7 @@ public Collection<IEntity> load(Environment environment, IMapObject mapObject) {
65110
IEntity entity;
66111
try {
67112
entity = invoke.invoke(environment, mapObject);
68-
} catch (ReflectiveOperationException e) {
113+
} catch (ReflectiveOperationException _) {
69114
log.log(Level.SEVERE, "map object {} failed to load", mapObject.getId());
70115
return entities;
71116
}

0 commit comments

Comments
 (0)