my plugin fail, please help!

Discussion in 'Plugin Development' started by jeeperscreeper77, Aug 31, 2014.

Thread Status:
Not open for further replies.
  1. so I was making a plugin to make it so when a player does "/spawn" it takes them to "/warp spawn" it was my first attempt at making a plugin, please help! what did i do wrong?

    http://pastebin.com/B1d7qqT5

    1. what is the error with my plugin? pls help!
    2. package me.Jeepeerscreeper77.Test1;
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9. public class Main extends JavaPlugin{
    10. public void onEnable() {
    11. getLogger().info("Plugin Enabled");
    12. }
    13. public void onDisable() {
    14. getLogger().info("Plugin Disabled");
    15. }
    16. public boolean onCommand(CommandSender sender, Command cmd, String iabel, String[] args) {
    17. if(sender instanceof Player) {
    18. Player player = (Player) sender;
    19. if(cmd.getName().equalsIgnoreCase("spawn")){
    20. String hub = "warp spawn " + player.getName();
    21. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), hub);
    22. player.sendMessage(ChatColor.GOLD + "Welcome to spawn!");
    23. }
    24. }
    25. plugin.yml
    26. name: Test1
    27. author: Jeeperscreeper77
    28. version: 1
    29. description: my first plugin
    30. main: me.Jeeperscreeper77.Test1.Main
    31. commands:
    32. spawn:
    33. description: takes you back to spawn
    34. here is the error in the server,
    35. 15:14:10 ERROR]: Could not load 'plugins/Test1.jar' in folder 'plugins'
    36. org.bukkit.plugin.InvalidPluginException: Cannot find main class `.java'
    37. at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:42) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    38. at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    39. at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    40. at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    41. at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:357) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    42. at org.bukkit.craftbukkit.v1_7_R3.CraftServer.<init>(CraftServer.java:319) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    43. at net.minecraft.server.v1_7_R3.PlayerList.<init>(PlayerList.java:68) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    44. at net.minecraft.server.v1_7_R3.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    45. at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    46. at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    47. at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    48. Caused by: java.lang.ClassNotFoundException: /java
    49. at java.lang.Class.forName0(Native Method) ~[?:1.7.0_65]
    50. at java.lang.Class.forName(Class.java:270) ~[?:1.7.0_65]
    51. at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    52. ... 10 more
     
  2. @jeeeperscreeper77 Your plugin.yml may be spaced incorrectly. Make sure every key is all the way to the left, no spaces, unless it's a subkey. Every subkey is spaced two spaces more than its parent key. Let me know how this works out!
     
  3. Offline

    glasseater

    jeeperscreeper77 1. you were missing some "}"
    2. I added a return statement.
    Code:java
    1.  
    2. public void onEnable() {
    3. getLogger().info("Plugin Enabled");
    4.  
    5. }
    6.  
    7. public void onDisable() {
    8. getLogger().info("Plugin Disabled");
    9. }
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String iabel, String[] args) {
    13. if(sender instanceof Player) {
    14. Player player = (Player) sender;
    15. if(cmd.getName().equalsIgnoreCase("spawn")){
    16. String hub = "warp spawn " + player.getName();
    17. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), hub);
    18. player.sendMessage(ChatColor.GOLD + "Welcome to spawn!");
    19.  
    20. }
    21. }
    22. return false;
    23. }
    24. }
    25.  
    26.  
    27.  
    28.  


    This is what the plugin.yml should look like.
    Code:
    name: Spawn2Hub
    main: me.glasseater.spawnhub.Main
    version: 1.1
    commands:
        spawn:
            description: Go to spawn!
     
  4. Caused by: java.lang.ClassNotFoundException: me.Jeeperscreeper77.Test1.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[?:1.7.0_55]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[?:1.7.0_55]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_55]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[?:1.7.0_55]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_55]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_55]
    at java.lang.Class.forName0(Native Method) ~[?:1.7.0_55]
    at java.lang.Class.forName(Class.java:270) ~[?:1.7.0_55]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit-1.7.9.jar:git-Bukkit-1.7.2-R0.3-30-ge027d69-b3058jnks]
    ... 10 more

    now what did i do wrong?
     
  5. Offline

    RenditionsRule

    jeeperscreeper77 I think I see the problem. From what I see, the package you created was called me.Jeepeerscreeper77.Test1 rather than me.Jeeperscreeper77.Test1

    Right click your package, hover over "Refractor" and rename the package to match the one stated in plugin.yml
     
  6. Offline

    Jaaakee224

    Another person that doesn't know Java and trying to make plugins..

    jeeperscreeper77
    Heres a tip: Learn Java first.
     
  7. Thank you for your suggestion, I will take it into consideration. :)
     
Thread Status:
Not open for further replies.

Share This Page