Jar does not contain plugin.yml

Discussion in 'Plugin Development' started by caledonian26, Dec 8, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    caledonian26

    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:

    Code:
    <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:

    Code:
    name:newestplugin
    main:newestfile.here.newestplugin.Main
    version:0.0.1-SNAPSHOT
    api-version: 1.19 
    The top few lines of my '.java' file:

    Code:
    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;
     
  2. Offline

    timtower Administrator Administrator Moderator

    @caledonian26 Open up the generated jar, show a screenshot of what is in it.
    And why do you make threads for all small issues while we have been talking about it on the old one?
     
  3. Offline

    caledonian26

    It is not letting me open it for some reason... :(
     

    Attached Files:

  4. Offline

    timtower Administrator Administrator Moderator

    @caledonian26 You don't execute it, you open with an archive program
     
  5. Offline

    caledonian26

    This is the output when trying with Zip editor:

    screenshot:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    sorry for the second message - I couldn't add the screenshot to the first!
     

    Attached Files:

    Last edited by a moderator: Dec 8, 2022
  6. Offline

    DopeBrot

    you plugin.yml is pointing to:
    you would need to change that to main:Main
     
  7. Offline

    caledonian26

    Sadly still not working :( really can't understand why!

    I now have the error message:

    org.bukkit.plugin.InvalidDescriptionException: Plugin description file is empty or not properly structured. Is name:newestplugin main:Main version:0.0.1-SNAPSHOT api-version:1.19but should be a map.

    Is the version correct? 0.0.1-snapshot?
     
    Last edited: Dec 8, 2022
  8. Offline

    DopeBrot

    your plugin.yml should be in the jar at the top
    in you plugin.yml you need to write where the main class is.

    in the picture i created a simple plugin
    my main class is in the "root" directory
    and in the plugin.yml i wrote "Main"
    because the plugin.yml and main class are in the same directory
    if my main would be in "me/dev"
    i would write me.dev.Main

    make you create an screenshot from you ide it could help
     

    Attached Files:

  9. Offline

    timtower Administrator Administrator Moderator

    Your plugin.yml is missing spaces after the semicolon
     
  10. Offline

    caledonian26

    Thank you so much for the advice. I changed the newestfile.here.newestplugin.Main and it now does not give any errors :)

    However, I still cannot find the plugin output file?

    [Server thread/INFO]: [newestplugin] Loading newestplugin v0.0.1-SNAPSHOT

     
    Last edited: Dec 9, 2022
  11. Offline

    timtower Administrator Administrator Moderator

  12. Offline

    caledonian26

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

    I no longer get any errors on the log file :)

    ahhhh - it's finally working!! I can now see the file being generated.

    As an example:

    09-12-2022 09:55:21 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:22 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:22 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:23 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:23 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:24 CurrentLocation(x,y,z): 47 -50 41
    09-12-2022 09:55:26 CurrentLocation(x,y,z): 47 -50 43
    09-12-2022 09:55:26 CurrentLocation(x,y,z): 46 -50 46
    09-12-2022 09:55:27 CurrentLocation(x,y,z): 45 -49 45
    09-12-2022 09:55:28 CurrentLocation(x,y,z): 46 -50 42
    09-12-2022 09:55:29 CurrentLocation(x,y,z): 47 -50 37
    09-12-2022 09:55:30 CurrentLocation(x,y,z): 47 -49 33
    09-12-2022 09:55:31 CurrentLocation(x,y,z): 46 -49 30

    Thank you so so so much for all your support.

    And apologies if at times I came across as 'stupid' - just to give a bit of context, I am a first-year PhD student in Cognitive Neuroscience. This is my first time learning java and using bukkit/spigot/minecraft :)

    This is what my final plugin.yml file looks like:

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

    This is what my final pom.xml file looks like:

    Code:
    <projectxmlns="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>
     
    Last edited: Dec 9, 2022
Thread Status:
Not open for further replies.

Share This Page