Solved Why wont my Plugin Work?

Discussion in 'Plugin Help/Development/Requests' started by Eperl33, May 15, 2015.

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

    Eperl33

    I am trying to code my first plugin, and it seems that it is not working. Can someone help me out?

    Here is my code:
    Code:
    package me.Eperl33.Test;
    
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Test extends JavaPlugin{
         @Override
            public void onEnable() {
                     getLogger().info("Plugin Test has been enabled");
                 }
       
            @Override
            public void onDisable() {
                    getLogger().info("Plugin Test has been disabled");
              
            }
    
        public boolean onCommand(CommandSender sender, Command cmd, String label, String []args){
            Player player = (Player) sender;
                if(label.equalsIgnoreCase("c")){
                    if(player.hasPermission("GameMode.c")){
                        player.setGameMode(GameMode.CREATIVE);
                  
                }else{
                    player.sendMessage(ChatColor.RED + "Permission denied");
                }
              
            }
            if(label.equalsIgnoreCase("s")){
                if(player.hasPermission("GameMode.s")){
                    player.setGameMode(GameMode.SURVIVAL);
                  
                }else{
                    player.sendMessage(ChatColor.RED + "Permission denied");
                }
              
            }
            return false;
          
          
              
              
              
              
            }
        }
    


    Also, this is my plugin.yml:


    Code:
    name: Test
    main: me.Eperl33.Test.Test
    version: 1.0
    commands:
           c:
             description: gamemode c
                usage: /<command>
          s:
            description: gamemode s
            usage: /<command>
    Thanks for the help! :)
     
  2. Offline

    Garnetty

    Implement CommandExecutor and add an Override annotation on the onCommand method.
     
  3. Offline

    Konato_K

    @Garnetty JavaPlugin already implements command executor, and override annotations are not necessary (it's good practice though).

    @Eperl33 You haven't told us what the problem is, do you get any errors in the console?
     
  4. Offline

    Garnetty

    Yeah I know that it isn't mandatory to add the override, and thanks for telling me that it's actually overriding the method in JavaPlugin, learn something new every day, my apologies.
     
  5. Offline

    Eperl33

    When I put it in the server, I don't receive any errors. When typing /pl into the console, it says I have no plugins.
     
  6. Offline

    Gater12

    @Eperl33
    Any errors in the console?
     
  7. Offline

    Eperl33

    As I said, when I put it in the server, I don't receive any errors and the plugin doesn't show up. When typing /pl into the console, it says I have no plugins.
     
  8. Offline

    87pen

    I was always taught to never capitalize your package. I think it might be your plugin.yml
     
  9. Offline

    TheDiamond06

    @Eperl33 You obviously did not put your plugin in your plugins folder if there are no errors in console. There has to be something to stop it from enabling. What is up with your plugin.yml syntax. Indent TWO SPACES!
     
    Konato_K likes this.
  10. Offline

    Eperl33

    Here is my console. I am getting error messages now


    Code:
    [09:52:51 WARN]: Plugin `game_mode_changer v1.0' uses the space-character (0x20)
    in its name `game mode changer' - this is discouraged
    [09:52:51 INFO]: Set PluginClassLoader as parallel capable
    [09:52:51 ERROR]: Could not load 'plugins\gamemodechanger.jar' in folder 'plugin
    s'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.Eperl33.gam
    emodechanger'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:66) ~[spigot.jar:git-Spigot-1638]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:129) ~[spigot.jar:git-Spigot-1638]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:336) ~[spigot.jar:git-Spigot-1638]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:258) [spigot.jar:git-Spigot-1638]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.ja
    va:369) [spigot.jar:git-Spigot-1638]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:86
    4) [spigot.jar:git-Spigot-1638]
            at org.bukkit.Bukkit.reload(Bukkit.java:301) [spigot.jar:git-Spigot-1638
    ]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23) [spigot.jar:git-Spigot-1638]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    1) [spigot.jar:git-Spigot-1638]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServe
    r.java:767) [spigot.jar:git-Spigot-1638]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchServerCommand(Craf
    tServer.java:753) [spigot.jar:git-Spigot-1638]
            at net.minecraft.server.v1_7_R4.DedicatedServer.aB(DedicatedServer.java:
    326) [spigot.jar:git-Spigot-1638]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    90) [spigot.jar:git-Spigot-1638]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [spigot.jar:git-Spigot-1638]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [spigot.jar:git-Spigot-1638]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [spigot.jar:git-Spigot-1638]
    Caused by: java.lang.ClassNotFoundException: me.Eperl33.gamemodechanger
            at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_31]
            at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_31]
            at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_
    31]
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_31]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:101) ~[spigot.jar:git-Spigot-1638]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:86) ~[spigot.jar:git-Spigot-1638]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_31]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_31]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_31]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_31]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:64) ~[spigot.jar:git-Spigot-1638]
            ... 15 more
    [09:52:51 WARN]: Could not register alias lobby because it contains commands tha
    t do not exist: warp lobby
    [09:52:51 WARN]: Could not register alias apply because it contains commands tha
    t do not exist: warp apply
    [09:52:51 WARN]: Could not register alias donate because it contains commands th
    at do not exist: warp donate
    [09:52:51 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [09:52:51 INFO]: CONSOLE: Reload complete.
    >pl
    [09:53:02 INFO]: Plugins (0):
    >
     
  11. Offline

    Konato_K

    Code:
    Caused by: java.lang.ClassNotFoundException: me.Eperl33.gamemodechanger
    I see you changed the package in your plugin.yml, did you change it in your Java class aswell?
     
  12. Offline

    Eperl33

    Yes. I have changed it everywhere.
     
  13. Offline

    Konato_K

    @Eperl33 Then you have a typo in the package somewhere, or you didn't put the class file in the jar, but the server is not able to find the class you're specifying
     
  14. Offline

    Eperl33

    Thanks for the help! I found out that I forgot to add something in the plugin.yml
     
Thread Status:
Not open for further replies.

Share This Page