Skip to content

Commit b4cb9cf

Browse files
committed
Upgrade to Java 25, PaperMC, and JSpecify, fix bugs
1 parent 7728064 commit b4cb9cf

17 files changed

Lines changed: 268 additions & 324 deletions

lombok.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config.stopBubbling = true
2+
lombok.accessors.fluent = true

pom.xml

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,42 @@
66

77
<groupId>com.cosimo</groupId>
88
<artifactId>plugin-utilities</artifactId>
9-
<version>1.0.0-beta.3</version>
9+
<version>1.0.0-beta.4</version>
1010
<name>PluginUtilities</name>
1111
<url>https://github.com/CosimoTiger/plugin-utilities</url>
1212
<description>A library with many utilities that help with developing Spigot plugins.</description>
1313

1414
<packaging>jar</packaging>
1515

16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
19+
<junit.version>6.0.3</junit.version>
20+
<lombok.version>1.18.44</lombok.version>
21+
<java.version>25</java.version>
22+
<argLine/>
23+
</properties>
24+
1625
<build>
1726
<finalName>${project.artifactId}-${project.version}</finalName>
1827
<plugins>
1928
<plugin>
2029
<artifactId>maven-compiler-plugin</artifactId>
21-
<version>3.14.0</version>
30+
<version>3.15.0</version>
2231
<configuration>
23-
<release>21</release>
32+
<release>${java.version}</release>
2433
<annotationProcessorPaths>
2534
<path>
2635
<groupId>org.projectlombok</groupId>
2736
<artifactId>lombok</artifactId>
28-
<version>1.18.36</version>
37+
<version>${lombok.version}</version>
2938
</path>
3039
</annotationProcessorPaths>
3140
</configuration>
3241
</plugin>
3342
<plugin>
3443
<artifactId>maven-source-plugin</artifactId>
35-
<version>3.3.1</version>
44+
<version>3.4.0</version>
3645
<executions>
3746
<execution>
3847
<id>attach-sources</id>
@@ -44,9 +53,9 @@
4453
</plugin>
4554
<plugin>
4655
<artifactId>maven-javadoc-plugin</artifactId>
47-
<version>3.11.3</version>
56+
<version>3.12.0</version>
4857
<configuration>
49-
<doclint>all,-missing</doclint>
58+
<doclint>none</doclint>
5059
</configuration>
5160
<executions>
5261
<execution>
@@ -57,59 +66,62 @@
5766
</execution>
5867
</executions>
5968
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-dependency-plugin</artifactId>
72+
<executions>
73+
<execution>
74+
<goals>
75+
<goal>properties</goal>
76+
</goals>
77+
</execution>
78+
</executions>
79+
</plugin>
6080
<plugin>
6181
<artifactId>maven-surefire-plugin</artifactId>
62-
<version>3.5.3</version>
82+
<version>3.5.5</version>
83+
<configuration>
84+
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
85+
</configuration>
6386
</plugin>
6487
</plugins>
6588
</build>
6689

67-
<properties>
68-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
69-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
70-
</properties>
71-
7290
<repositories>
7391
<repository>
74-
<id>spigot-repo</id>
75-
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
92+
<id>papermc</id>
93+
<url>https://repo.papermc.io/repository/maven-public/</url>
7694
</repository>
7795
</repositories>
7896

7997
<dependencies>
8098
<dependency>
81-
<groupId>org.spigotmc</groupId>
82-
<artifactId>spigot-api</artifactId>
83-
<version>1.21.8-R0.1-SNAPSHOT</version>
84-
<scope>provided</scope>
85-
</dependency>
86-
<dependency>
87-
<groupId>org.jetbrains</groupId>
88-
<artifactId>annotations</artifactId>
89-
<version>26.0.2</version>
99+
<groupId>io.papermc.paper</groupId>
100+
<artifactId>paper-api</artifactId>
101+
<version>[26.1.2.build,)</version>
90102
<scope>provided</scope>
91103
</dependency>
92104
<dependency>
93105
<groupId>org.projectlombok</groupId>
94106
<artifactId>lombok</artifactId>
95-
<version>1.18.38</version>
107+
<version>${lombok.version}</version>
96108
</dependency>
97109
<dependency>
98110
<groupId>org.junit.jupiter</groupId>
99111
<artifactId>junit-jupiter-engine</artifactId>
100-
<version>5.13.4</version>
112+
<version>${junit.version}</version>
101113
<scope>test</scope>
102114
</dependency>
103115
<dependency>
104116
<groupId>org.junit.jupiter</groupId>
105117
<artifactId>junit-jupiter-params</artifactId>
106-
<version>5.13.4</version>
118+
<version>${junit.version}</version>
107119
<scope>test</scope>
108120
</dependency>
109121
<dependency>
110122
<groupId>org.mockito</groupId>
111123
<artifactId>mockito-core</artifactId>
112-
<version>5.19.0</version>
124+
<version>5.23.0</version>
113125
<scope>test</scope>
114126
</dependency>
115127
</dependencies>

src/main/java/com/cosimo/utilities/file/PluginFile.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.cosimo.utilities.file;
22

33
import lombok.Getter;
4-
import lombok.NonNull;
54
import org.bukkit.plugin.Plugin;
6-
import org.jetbrains.annotations.Nullable;
5+
import org.jspecify.annotations.NullMarked;
6+
import org.jspecify.annotations.Nullable;
77

88
import java.io.File;
99
import java.io.IOException;
@@ -19,27 +19,29 @@
1919
* @param <T> Memory representation type that's a result of loading this file
2020
*/
2121
@Getter
22+
@NullMarked
23+
@SuppressWarnings({"UnusedReturnValue", "unused"})
2224
public abstract class PluginFile<T> extends File {
2325

2426
/**
2527
* Plugin that this file belongs to, used for {@link Plugin#getResource(String)}
2628
*/
27-
private final @NonNull Plugin plugin;
29+
private final Plugin plugin;
2830
/**
2931
* Relative file path of the source file in the resources directory to copy into destination path
3032
*/
31-
private final @NonNull String resourcePath;
33+
private final String resourcePath;
3234

3335
/**
3436
* Creates a new instance from a given relative directory path inside the JAR resources folder of the file to copy
3537
* to the given relative destination path inside the {@link Plugin#getDataFolder()}.
3638
*
3739
* @param plugin Plugin that this file belongs to, used for {@link Plugin#getResource(String)}
38-
* @param resourcePath Relative file path of the source file in the resources directory to copy into destination
39-
* path
40+
* @param resourcePath Relative file path of the source file in the resources directory to copy into a
41+
* destination path
4042
* @param destinationPath Relative file path for the destination file in the {@link Plugin#getDataFolder()}
4143
*/
42-
public PluginFile(@NonNull Plugin plugin, @NonNull String resourcePath, @NonNull String destinationPath) {
44+
public PluginFile(Plugin plugin, String resourcePath, String destinationPath) {
4345
super(plugin.getDataFolder(), destinationPath);
4446
this.resourcePath = resourcePath;
4547
this.plugin = plugin;
@@ -55,10 +57,10 @@ public PluginFile(@NonNull Plugin plugin, @NonNull String resourcePath, @NonNull
5557
* file names, unlike this constructor.</p>
5658
*
5759
* @param plugin Plugin that this file belongs to, used for {@link Plugin#getResource(String)}
58-
* @param resourcePath Relative file path of the source file in the resources directory to copy into destination
60+
* @param resourcePath Relative file path of the source file in the resources directory to copy into a destination
5961
* path
6062
*/
61-
public PluginFile(@NonNull Plugin plugin, @NonNull String resourcePath) {
63+
public PluginFile(Plugin plugin, String resourcePath) {
6264
this(plugin, resourcePath, resourcePath);
6365
}
6466

@@ -68,15 +70,16 @@ public PluginFile(@NonNull Plugin plugin, @NonNull String resourcePath) {
6870
*
6971
* @return Whether this file already existed
7072
*/
73+
@SuppressWarnings("ResultOfMethodCallIgnored")
7174
public boolean createFile() {
7275
final var existed = this.exists();
7376

7477
if (!existed) {
7578
Optional.ofNullable(this.getParentFile()).ifPresent(File::mkdirs);
7679

77-
try (final var inputStream = this.plugin.getResource(this.getResourcePath())) {
80+
try (final var inputStream = this.plugin.getResource(this.resourcePath())) {
7881
Objects.requireNonNull(inputStream, () -> "Plugin %s's resource %s doesn't exist".formatted(
79-
this.getPlugin().getDescription().getFullName(), this.getName()));
82+
this.plugin().getPluginMeta().getDisplayName(), this.getName()));
8083
Files.copy(inputStream, this.toPath());
8184
} catch (IOException e) {
8285
throw new RuntimeException(e);
@@ -101,8 +104,7 @@ public boolean createFile() {
101104
* @param newMemory Not null object
102105
* @return This instance, useful for chaining
103106
*/
104-
@NonNull
105-
public abstract PluginFile<T> setMemory(@NonNull T newMemory);
107+
public abstract PluginFile<T> setMemory(T newMemory);
106108

107109
/**
108110
* Reads the data from the file, parses it if needed and loads it for {@link #getMemory()}.

src/main/java/com/cosimo/utilities/file/YamlFile.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.cosimo.utilities.file;
22

3-
import lombok.NonNull;
43
import org.bukkit.configuration.file.FileConfiguration;
54
import org.bukkit.configuration.file.YamlConfiguration;
65
import org.bukkit.plugin.Plugin;
6+
import org.jspecify.annotations.NullMarked;
7+
import org.jspecify.annotations.Nullable;
78

8-
import javax.annotation.Nonnull;
99
import java.io.FileInputStream;
1010
import java.io.IOException;
1111
import java.io.InputStreamReader;
@@ -16,18 +16,19 @@
1616
* {@link FileConfiguration} variable. This isn't done by default because calling superclass constructors and waiting on
1717
* them can be a problem when defining default class variables.
1818
*/
19+
@NullMarked
1920
public class YamlFile extends PluginFile<FileConfiguration> {
2021

2122
/**
2223
* Data loaded from a YAML file
2324
*/
24-
protected FileConfiguration fileConfig;
25+
protected @Nullable FileConfiguration fileConfig;
2526

26-
public YamlFile(@NonNull Plugin plugin, @NonNull String resourcePath, @NonNull String destinationFile) {
27+
public YamlFile(Plugin plugin, String resourcePath, String destinationFile) {
2728
super(plugin, resourcePath, destinationFile);
2829
}
2930

30-
public YamlFile(@NonNull Plugin plugin, @NonNull String resourcePath) {
31+
public YamlFile(Plugin plugin, String resourcePath) {
3132
super(plugin, resourcePath);
3233
}
3334

@@ -74,9 +75,8 @@ public FileConfiguration getMemory() {
7475
return this.fileConfig;
7576
}
7677

77-
@Nonnull
7878
@Override
79-
public PluginFile<FileConfiguration> setMemory(@NonNull FileConfiguration newMemory) {
79+
public PluginFile<FileConfiguration> setMemory(FileConfiguration newMemory) {
8080
this.fileConfig = newMemory;
8181
return this;
8282
}

0 commit comments

Comments
 (0)