Skip to content

Commit

Permalink
fix: old versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cerus committed Apr 26, 2024
1 parent 9a9d4b4 commit 1df4556
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-16R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-17R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-18R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-18R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-19R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-19R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bukkit-19R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>bukkit-19R3</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bukkit-20R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>bukkit-20R1</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bukkit-20R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>bukkit-20R2</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bukkit-20R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>bukkit-20R3</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bukkit-20R4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>bukkit-20R4</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>dev.cerus.visualcrafting</groupId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.security.CodeSource;
import java.util.logging.Level;
Expand All @@ -50,17 +51,17 @@ public void onEnable() {

// Initialize version adapter
final VersionAdapter versionAdapter = switch (version) {
case "1.16.5" -> new VersionAdapter16R3();
case "1.17", "1.17.1" -> new VersionAdapter17R1();
case "1.18.1" -> new VersionAdapter18R1();
case "1.18.2" -> new VersionAdapter18R2();
case "1.19", "1.19.1", "1.19.2" -> new VersionAdapter19R1();
case "1.19.3" -> new VersionAdapter19R2();
case "1.19.4" -> new VersionAdapter19R3();
case "1.20", "1.20.1" -> new VersionAdapter20R1();
case "1.20.2" -> new VersionAdapter20R2();
case "1.20.3", "1.20.4" -> new VersionAdapter20R3();
case "1.20.5" -> new VersionAdapter20R4();
case "1.16.5" -> createVersionAdapter("16R3");
case "1.17", "1.17.1" -> createVersionAdapter("17R1");
case "1.18.1" -> createVersionAdapter("18R1");
case "1.18.2" -> createVersionAdapter("18R2");
case "1.19", "1.19.1", "1.19.2" -> createVersionAdapter("19R1");
case "1.19.3" -> createVersionAdapter("19R2");
case "1.19.4" -> createVersionAdapter("19R3");
case "1.20", "1.20.1" -> createVersionAdapter("20R1");
case "1.20.2" -> createVersionAdapter("20R2");
case "1.20.3", "1.20.4" -> createVersionAdapter("20R3");
case "1.20.5" -> createVersionAdapter("20R4");
default -> null;
};
if (versionAdapter == null) {
Expand Down Expand Up @@ -185,6 +186,18 @@ private String normalize(final String s) {
return Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase();
}

// Required to prevent the JVM from complaining about java versions
private VersionAdapter createVersionAdapter(String versionSlug) {
try {
String classPath = "dev.cerus.visualcrafting.v%s.VersionAdapter%s".formatted(versionSlug.toLowerCase(), versionSlug.toUpperCase());
Class<?> cls = Class.forName(classPath);
return (VersionAdapter) cls.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
getLogger().log(Level.SEVERE, "Could not create version adapter", e);
return null;
}
}

private String getDownloadSource() {
StringBuilder sourceBuilder = new StringBuilder();
try (InputStream in = VisualCraftingPlugin.class.getClassLoader().getResourceAsStream("metadata")) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>dev.cerus.visualcrafting</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.3.0</version>
<version>1.3.1</version>
<modules>
<module>plugin</module>
<module>api</module>
Expand Down

0 comments on commit 1df4556

Please sign in to comment.