Exploding Arrows Cmd Error

Discussion in 'Plugin Development' started by Developerjohn, Nov 15, 2014.

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

    Developerjohn

    Here is the error I get in cmd when I start my server:
    [02:10:59 ERROR]: Could not load 'plugins\ExplodingArrows.jar' in folder 'plugin
    s'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.DeveloperJohn.
    ExplodingArrows.ExplosiveArrows'
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:42) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:127) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:328) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:251) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.ja
    va:350) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:31
    2) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [c
    raftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.jav
    a:126) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :424) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    Caused by: java.lang.ClassNotFoundException: me.DeveloperJohn.ExplodingArrows.Explo
    siveArrows
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_25]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_
    25]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_25]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:77) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_25]
    at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_25]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    ... 10 more

    Here is my code:
    Code:java
    1. import java.util.logging.Logger;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.entity.Arrow;
    5. import org.bukkit.entity.Entity;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.entity.ProjectileHitEvent;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class ExplosiveArrows extends JavaPlugin implements Listener{
    13. public final Logger logger = Logger .getLogger("Minecraft");
    14. public static ExplosiveArrows plugin;
    15.  
    16. @Override
    17. public void onDisable(){
    18. this.logger.info("[ExplodingArrows] Plugin Disabled!");
    19. this.logger.severe("[ExplodingArrows] SEVERE! ExplodingArrows didn't start up correctly!");
    20. this.logger.warning("[ExplodingArrows] Attempting to start ExplodingArrows!");
    21.  
    22. }
    23.  
    24. @Override
    25. public void onEnable(){
    26. getServer().getPluginManager().registerEvents(this, this);
    27. this.logger.info("[ExplodingArrows] Plugin Enabled!");
    28. this.logger.warning("[ExplodingArrows] Attempting to start ExplodingArrows!");
    29.  
    30. }
    31.  
    32. @EventHandler
    33. public void onProjectileHit(ProjectileHitEvent event){
    34.  
    35. Entity entity = event.getEntity();
    36. if (event.getEntity() instanceof Player && entity instanceof Arrow){
    37.  
    38. Location loc = entity.getLocation();
    39. loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4f , false, false);
    40. }
    41. }
    42. }
    43.  
    44.  


    And lastly, my plugin.yml:
    Code:java
    1. name: ExplosiveArrows
    2. main: me.DeveloperJohn.ExplodingArrows.ExplosiveArrows
    3. version: 1.0
    4. description: This makes arrows explode!
     
  2. Offline

    Avygeil

    Developerjohn
    Also, please don't get the Minecraft logger and don't use a static reference to your plugin that you don't ever assign anyway.
     
  3. Offline

    Developerjohn

    Avygeil What? I though you're supposed to log plugins.
     
  4. Offline

    Avygeil

    Developerjohn Don't use the Minecraft logger, use the one provided by Bukkit instead. :) See Server#getLogger. But about your actual problem, you should check your project's packages.
     
  5. Offline

    Developerjohn

    Avygeil What do you mean check the packages?
     
  6. Offline

    teej107

  7. Offline

    Avygeil

    Developerjohn Your class was not found. You referenced it as
    Code:
    main: me.DeveloperJohn.ExplodingArrows.ExplosiveArrows
    Therefore, check if your package tree is right. I don't see a "package" declaration at the top of your class file either.
     
  8. Offline

    Developerjohn

    Avygeil The names:
    class name: ExplosiveArrows
    package: me.DeveloperJohn.ExplodingArrows
    project folder name: Exploding Arrows
     
  9. Offline

    Avygeil

    Developerjohn Try to see if the plugin exported correctly : open the JAR file like a zip file with an archiver, and check if the exported package matches the one you provided in plugin.yml. You might have left something unchecked (assuming you're using Eclipse).
     
  10. Offline

    Developerjohn

    Avygeil Aha! I found the problem. It was with my plugin.yml. I have something to tell you though, after I posted the error message, code, and the plugin.yml, I forgot my old Bukkit name was on it. If you didn't know, yes I've had two Bukkit accounts. The reason I made a new one was because it felt like there was too much hate towards it, so I abandoned it. Anyways, in the plugin.yml, it said:
    Code:java
    1. main: me.##########.ExplodingArrows.ExplosiveArrows

    The first # which stands for the beginning of my old Bukkit name was lower case.

    Problem Solved, and also thanks for the help!:cool:
    -from now on, I'll start using the Bukkit logger and a few other new things.

    Avygeil Wait, now the explosion doesn't want to occur.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
    Avygeil likes this.
  11. Offline

    Avygeil

    Developerjohn
    Code:java
    1. if (event.getEntity() instanceof Player && entity instanceof Arrow)

    Why do you check if it's a Player ? getEntity returns the projectile entity, not the player who shot the arrow. Just check if it's an instance of an arrow in your if.
    If you want to check who shot the arrow, cast to Projectile and use Projectile#getShooter. :)
     
  12. Offline

    Developerjohn

    Avygeil No, I want the explosion to occur only on players, not any other entity.
     
  13. Offline

    Avygeil

    Developerjohn Then this is the wrong event, as ProjectileHitEvent does not carry this information. Use EntityDamageByEntityEvent instead, where you can do all your checks (getEntity() and getDamager() instanceof Player and Arrow).
     
Thread Status:
Not open for further replies.

Share This Page