8000 Make DetectVersion future-proof by using API when applicable · CommandAPI/CommandAPI@8ea52a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ea52a7

Browse files
committed
Make DetectVersion future-proof by using API when applicable
1 parent f87f0fc commit 8ea52a7

File tree

2 files changed

+22
-5
lines changed
  • commandapi-platforms/commandapi-paper/commandapi-paper-nms/commandapi-paper-dv

2 files changed

+22
-5
lines changed

commandapi-platforms/commandapi-paper/commandapi-paper-nms/commandapi-paper-dv/pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<artifactId>commandapi-paper-dv</artifactId>
1313

1414
<properties>
15-
<minecraft.mappings>1.20.1-R0.1-SNAPSHOT</minecraft.mappings>
16-
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
17-
<paper.version>1.20.1-R0.1-SNAPSHOT</paper.version>
15+
<minecraft.mappings>1.20.6-R0.1-SNAPSHOT</minecraft.mappings>
16+
<spigot.version>1.20.6-R0.1-SNAPSHOT</spigot.version>
17+
<paper.version>1.20.6-R0.1-SNAPSHOT</paper.version>
1818
</properties>
1919

2020
<repositories>
@@ -26,9 +26,19 @@
2626
<id>codemc-repo</id>
2727
<url>https://repo.codemc.io/repository/nms/</url>
2828
</repository>
29+
<repository>
30+
<id>papermc</id>
31+
<url>https://repo.papermc.io/repository/maven-public/</url>
32+
</repository>
2933
</repositories>
3034

3135
<dependencies>
36+
<dependency>
37+
<groupId>io.papermc.paper</groupId>
38+
<artifactId>paper-api</artifactId>
39+
<version>${paper.version}</version>
40+
<scope>provided</scope>
41+
</dependency>
3242
<dependency>
3343
<groupId>org.spigotmc</groupId>
3444
<artifactId>spigot</artifactId>
@@ -60,7 +70,7 @@
6070
<plugin>
6171
<groupId>net.md-5</groupId>
6272
<artifactId>specialsource-maven-plugin</artifactId>
63-
<version>1.2.4</version>
73+
<version>2.0.4</version>
6474
<executions>
6575
<execution>
6676
<phase>package</phase>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
package dev.jorel.commandapi.nms;
22

3+
import io.papermc.paper.ServerBuildInfo;
34
import net.minecraft.SharedConstants;
45

56
public class DetectVersion {
67

78
private DetectVersion() {}
89

910
public static String getVersion() {
10-
return SharedConstants.getCurrentVersion().getId();
11+
try {
12+
return ServerBuildInfo.buildInfo().minecraftVersionId();
13+
} catch (Throwable t) {
14+
// We don't even care what the exception was, we just know that if it throws, we are on a version that doesn't have
15+
// the ServerBuildInfo so we can fall back to internals which are all the same on versions on and before 1.20.6
16+
return SharedConstants.getCurrentVersion().getId();
17+
}
1118
}
1219

1320
}

0 commit comments

Comments
 (0)
0