0

I have the following code below.

I am creating a plugin for Minecraft using the Spigot/Bukkit API and the java programming language.

I have created this using the maven tool on eclipse.

I enter mvn clean package into the terminal on my mac to compile the '.jar' file.

I then drag this '.jar' file into my 'plugins' folder on my server.

However, I keep getting the issue: java.io.FileNotFoundException: Jar does not contain plugin.yml

I am not sure why the jar file does not contain the plugin.yml.

I would be so grateful for a helping hand!

pom.xml file:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.10.1</version>       
              <configuration>
                  <release>17</release>
              </configuration>   
        </plugin>
      </plugins>
    </pluginManagement>
</build>
   <repositories>
       <repository>
          <id>papermc-repo</id>
          <url>https://papermc.io/repo/repository/maven-public/</url>
       </repository>
   </repositories>
    <dependencies>
       <dependency>
          <groupId>io.papermc.paper</groupId>
          <artifactId>paper-api</artifactId>
          <version>1.19.2-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
       </dependency>
   </dependencies>
</project>

plugin.yml file:

name:newestplugin
main:newestfile.here.newestplugin.Main 
version:0.0.1-SNAPSHOT
api-version: 1.19 

The top few lines of my '.java' file:

package newestfile.here.newestplugin;

import java.util.UUID;
import java.nio.charset.StandardCharsets;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.io.File;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import java.nio.file.Files; 

public class Main extends JavaPlugin implements Listener
{
    boolean stopRepeater;

Organisation of nesting of packages:

enter image description here

Caledonian26
  • 727
  • 1
  • 10
  • 27
  • Could you show how you nested the files in your project? EG a file tree showing the `pom.xml` at the root, the java source code at `src/main//.java` and the `plugin.yml` at `resources/main/plugin.yml` – Ferrybig Dec 08 '22 at 15:08
  • Have added above - is that what you mean? Showing which package is in which folder :) – Caledonian26 Dec 08 '22 at 15:26

2 Answers2

0

You should precise in the pom.xml file, in the <build> section:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <includes>
            <include>plugin.yml</include>
        </includes>
        <filtering>true</filtering>
    </resource>
</resources>

If you have another file to add (for example config.yml), just copy the line <include>plugin.yml</include>.

Elikill58
  • 4,050
  • 24
  • 23
  • 45
  • it now says; /Users/macbook/eclipse-workspace/newestplugin/target/classes/META-INF/MANIFEST.MF (No such file or directory) on my pom.xml file. Why might this be? – Caledonian26 Dec 08 '22 at 15:56
  • It's another problem that can be fixed with [this](https://stackoverflow.com/a/22722750/10952503) answer for example – Elikill58 Dec 08 '22 at 17:19
  • Thanks so much for your support! I have finally managed to get it working after days of persevering :) – Caledonian26 Dec 09 '22 at 10:25
0

My code finally worked with the following:

plugin.yml:

name: newestplugin
main: newestfile.here.newestplugin.Main 
version: 0.0.1-SNAPSHOT
api-version: 1.19 

pom.xml:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
   <resources>
     <resource>
        <directory>src/main/resources</directory>
        <includes>
            <include>plugin.yml</include>
        </includes>
        <filtering>true</filtering>
     </resource>
   </resources>   
    <pluginManagement>
      <plugins>
        <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.10.1</version>       
              <configuration>
                  <release>17</release>
              </configuration>   
        </plugin>
      </plugins>
    </pluginManagement>
</build>
   <repositories>
       <repository>
          <id>papermc-repo</id>
          <url>https://papermc.io/repo/repository/maven-public/</url>
       </repository>
   </repositories>
    <dependencies>
       <dependency>
          <groupId>io.papermc.paper</groupId>
          <artifactId>paper-api</artifactId>
          <version>1.19.2-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
       </dependency>
   </dependencies>
</project>
Caledonian26
  • 727
  • 1
  • 10
  • 27