Plugins do not register

Discussion in 'Plugin Development' started by klosjaarrr, Oct 9, 2014.

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

    klosjaarrr

    Hey all... It seems I'm forgetting a simple step to make my plugins work again (Maven project), since the plugins do not load. I made a TestPlugin to test it out, and the same problem occurs. I have the following files:

    TestPlugin.java
    Code:java
    1. import java.util.logging.Logger;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8.  
    9. public class TestPlugin extends JavaPlugin {
    10.  
    11. public static TestPlugin instance;
    12. public final static Logger log = Logger.getLogger("Minecraft");
    13.  
    14. @Override
    15. public void onEnable() {
    16. TestPlugin.instance = this;
    17. getLogger().info("TestPlugin has been enabled!");
    18. }
    19.  
    20. @Override
    21. public void onDisable() {
    22. getLogger().info("TestPlugin has been disabled!");
    23. }
    24.  
    25. @Override
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27.  
    28. if (!cmd.getName().equalsIgnoreCase("test")) {
    29. return false;
    30. }
    31.  
    32. if (!(sender instanceof Player)) {
    33. sender.sendMessage("This command can only be executed by players.");
    34. return true;
    35. }
    36.  
    37. Player player = (Player) sender;
    38. player.sendMessage("It is alive :o");
    39.  
    40. return true;
    41.  
    42. }
    43.  
    44. }
    45.  


    pom.xml
    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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.kevinvoorn</groupId>
      <artifactId>PlayerTitles</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <build>
          <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                      <source>1.7</source>
                      <target>1.7</target>
                  </configuration>
              </plugin>
          </plugins>
      </build>
        <repositories>
          <repository>
              <id>bukkit-repo</id>
              <url>http://repo.bukkit.org/content/groups/public/</url>
          </repository>
      </repositories>
        <dependencies>
          <dependency>
              <groupId>org.bukkit</groupId>
              <artifactId>bukkit</artifactId>
              <version>1.7.2-R0.3</version>
              <type>jar</type>
              <scope>provided</scope>
          </dependency>
      </dependencies>
    </project>
    plugin.yml
    Code:
    name: TestTitles
    main: com.kevinvoorn.testplugin
    version: 1.0.0
    description: Allows me to test this plugin
    author: klosjaarrr
     
    commands:
        test:
            usage: /<command>
            description: Tests if the command works
         
    permissions:
        testplugin.test:
            description: Grants access to /test
    What am I doing wrong? I update the project just before compiling it as a JAR file, still nothing seems to work.
     
  2. Offline

    Klumel8

    I do not know why, but for some reason bukkit uses maven now? i think this is because you can no longer download bukkit from bukkit.org. You can however still download it from a torrent (i do not support that) but its an option. andyou could just add the craftbukkit.jar to the configuration build (like we had to do before maven). maybe that will help.
    also you could just try to make it simpler with just:
    Code:
    if (cmd.getName().equalsIgnoreCase("test")) {
    Player p = (Player) sender;
    p.sendMessage("WEll this will show you if it works...");
    }
     
  3. Offline

    fireblast709

    klosjaarrr Any errors on startup? Also:
    • Don't use the Minecraft Logger, use the Logger you get from JavaPlugin's getLogger() method.
    • Remove that static plugin instance.
    • No need for enable/disable messages, Bukkit does this for you.
    Klumel8 Make sure that you check if sender instanceof Player before casting.
     
  4. Offline

    AdamQpzm

    Klumel8 The use of Maven isn't related at all to the DMCA. Using Maven has always been an option, and Bukkit & CraftBukkit have always been built with Maven. Well, I say always, there was a time before Maven but essentially always. :)
     
  5. Offline

    klosjaarrr

    I looked in the server logs, but it doesn't show up at all: It's like its not in the plugin folder (but I am sure it is). I've tried to do the things you suggested, but it still doesn't work. It seems to be a Maven issue, as it worked before I used Maven. Any idea what else I could do?
     
  6. Offline

    fireblast709

    klosjaarrr of it's in the plugins folder and it is a .jar file, then Bukkit should attempt to load it (which means there should be anything about it in the last server log)
     
  7. Offline

    klosjaarrr

    Ok so I looked again, apparently I have my plugin.yml in the wrong folder (as it cannot be found). Any idea where I should put it? Currently I have it in my src/main/resources (Maven project).

    Code:
    [13:30:49] [Server thread/ERROR]: Could not load 'plugins/TestPlugin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[spigot_1649.jar:git-Spigot-1649]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot_1649.jar:git-Spigot-1649]
        at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.java:369) [spigot_1649.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:152) [spigot_1649.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [spigot_1649.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot_1649.jar:git-Spigot-1649]
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 6 more
    fireblast709

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  8. Offline

    fireblast709

    klosjaarrr you forgot to add plugin.yml to the jar (or you forgot to add it during the export if you use Eclipse, afaik Netbeans and IntelliJ would add it automatically)
     
  9. Offline

    Gnat008

    fireblast709
    I tell Maven in the pom file to include plugin.yml and config.yml from the resources folder, with IntelliJ.
     
  10. Offline

    fireblast709

    Gnat008 for me it happens automatically with resources located at src/main/resources/ ;3
     
  11. Offline

    klosjaarrr

    I did not forget to add it during the export, will try adding it manually to the pom.xml. It is still weird, as it seems to work for others. I'm not really in favour of changing to another IDE as I'm quite used to Eclipse :) thanks for the help anyway, will try a couple of the suggestions above and let you know if it worked or not :)
     
  12. Offline

    teej107

    You can make sure the jar has it by opening its contents. It may vary from OS but there is probably something along the lines of "Open Archive". When you export, make sure you have the plugin.yml selected and "Export generated class files and resources" checked
     
Thread Status:
Not open for further replies.

Share This Page