WesJD / AnvilGUI

Capture user input in Minecraft through an anvil GUI in under 20 lines of code
MIT License
466 stars 111 forks source link

Unsupported class file major version 65 #328

Closed philskillz-coder closed 2 months ago

philskillz-coder commented 2 months ago

Im running maven with Java21

This is the pom.xml


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.skillz</groupId> <!-- Change the group id, artifact id and version to your own values -->
    <artifactId>betteritems</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <!-- Adding this so maven does not complain about it missing -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- If your plugin is targeting Minecraft 1.18 leave Java version as is (17). Minecraft 1.17 -> Java version 16 and Minecraft <= 1.16. Java version 1.8-->
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <pluginRepositories>
        <pluginRepository> <!-- Need to add this, so we can use maven shade plugin version 3.3.0-SNAPSHOT -->
            <id>maven-snapshots</id>
            <url>https://repository.apache.org/content/repositories/snapshots/</url>
        </pluginRepository>
    </pluginRepositories>

    <repositories>
        <repository>
            <id>spigot</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>codemc</id> <!-- AnvilGUI is published in the CodeMC repository-->
            <url>https://repo.codemc.io/repository/maven-public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope> <!-- If the dependency is already present on the server (like the Spigot API itself or another library plugin). Use scope provided, it prevents shading -->
        </dependency>
        <dependency>
            <groupId>net.wesjd</groupId>
            <artifactId>anvilgui</artifactId>
            <version>1.9.4-SNAPSHOT</version>
            <scope>compile</scope> <!-- Every dependency with the scope compile will be shaded -->
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>clean verfiy</defaultGoal>
        <resources> <!-- This configuration says that only in the plugin.yml placeholders should be replaced. You can use this replace ${project.version} with the version defined at the top of the POM -->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>plugin.yml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>plugin.yml</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.3.0</version> <!-- We need to use this special version because only it supports Java 16 and higher at the moment -->
                <executions> <!-- This makes sure that the shade plugin is actually run -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <minimizeJar>false</minimizeJar> <!-- DO NOT minimize the final jar, because that breaks AnvilGUI -->
                            <createDependencyReducedPom>false</createDependencyReducedPom> <!-- This disables the creating of the annoying POM file that gets created every time -->
                            <filters>
                                <filter> <!-- This filter prevents the copying of every META-INF folder of every shaded dependency into the final jar -->
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <relocations> <!-- And very importantly, relocate the package of every dependency. It prevents multiple plugins defining the same class twice -->
                                <relocation>
                                    <pattern>net.wesjd.anvilgui</pattern> <!-- The original package of AnvilGUI -->
                                    <shadedPattern>de.skillz.betteritems.anvilgui</shadedPattern> <!-- Target package in the final jar. Change these values to your own package-->
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>```

when building with maven i get the titled error `Unsupported class file major version 65`
mastercake10 commented 2 months ago

What is your output of mvn --version? Please verify that you are running maven with at least java 21.

philskillz-coder commented 2 months ago

What is your output of mvn --version? Please verify that you are running maven with at least java 21.

When running mvn --version this is the output

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: C:\Program Files\JetBrains\IntelliJ IDEA 2023.2\plugins\maven\lib\maven3
Java version: 21.0.3, vendor: Amazon.com Inc., runtime: C:\Users\Philskillz\.jdks\corretto-21.0.3
Default locale: de_DE, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additionally this is the output when running mvn package:

[INFO] 
[INFO] -----------------------< de.skillz:betteritems >------------------------
[INFO] Building betteritems 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ betteritems ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 0 resource from src\main\resources to target\classes
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ betteritems ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ betteritems ---
[INFO] Copying 0 resource from src\test\resources to target\test-classes
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ betteritems ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- surefire:3.2.2:test (default-test) @ betteritems ---
[INFO] 
[INFO] --- jar:3.3.0:jar (default-jar) @ betteritems ---
[INFO] 
[INFO] --- shade:3.3.0:shade (default) @ betteritems ---
[INFO] Including net.wesjd:anvilgui:jar:1.5.3-SNAPSHOT in the shaded jar.
Unsupported class file major version 65 

plugin.yml

name: BetterItems
version: '${project.version}'
main: de.skillz.betteritems.Main
api-version: 1.18
authors: [ Philskillz ]
description: Better Items - Custom recipes and Item signatures
philskillz-coder commented 2 months ago

Update:

I suspect the bug not being related to anvilgui. I started a new project and changed a few lines and version numbers and it works now. Thanks for engaging so fast

mastercake10 commented 2 months ago

you welcome :) you can close the issue