Need help on making a plugin!!

Discussion in 'Plugin Development' started by redraskal, Sep 29, 2013.

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

    redraskal

    Hey guys! Um... I;m in the middle of making a plugin,but.......................it isn't working!! I'm using eclipse and it's not giving me ONE SINGLE ERROR ON IT!!!!!!!!!!!!!! So can any of you guys find out why? Here's the code :

    Code:java
    1. package gmail.epicfunr.plugins;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public final class Main extends JavaPlugin {
    12. public final Logger logger = Logger.getLogger("Minecraft");
    13. public static Main plugin;
    14.  
    15. public void onEnable(){
    16. getLogger().info("SBasics has been enabled!");
    17. }
    18.  
    19. public void onDisable(){
    20. getLogger().info("SBasics has been disabled!");
    21. }
    22.  
    23. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    24. if(cmd.getName().equalsIgnoreCase("isonline")){
    25. Player target = (Bukkit.getServer().getPlayer(args[0]));
    26. if (target == null) {
    27. sender.sendMessage(args[0] + " is not online!");
    28. return false;
    29. } else {
    30. if(cmd.getName().equalsIgnoreCase("ragequit")){
    31. sender.getServer().getName();
    32. Player player = (Player) sender;
    33. this.getServer().broadcastMessage(player + " has ragequit the server!");
    34. player.kickPlayer(getName());
    35. return false;
    36. }
    37. return false;
    38. }
    39. }
    40. return false;
    41. }
    42. }


    And here's the plugin.yml :

    Code:java
    1. name: SBasics
    2. author: Redraskal
    3. version: 1.6.4
    4. description: A plugin for your basic server needs.
    5. main: gmail.epicfunr.plugins
    6. commands:
    7. ragequit:
    8. description: Ragequit's the server.
    9. isonline:
    10. description: Sees if a player is online.


    Can anyone find out why it isn't working?
     
  2. Offline

    sharp237

    I think that in your plugin.yml main: has to be your mainclass' name.
     
  3. Offline

    redraskal

    Ok... um I did that and it isn't working :(. Ill show you the new code.

    Main class :
    Code:java
    1. package org.bukkit.plugin.SBasics;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public final class SBasics extends JavaPlugin {
    12. public final Logger logger = Logger.getLogger("Minecraft");
    13. public static SBasics plugin;
    14.  
    15. public void onEnable(){
    16. getLogger().info("SBasics has been enabled!");
    17. }
    18.  
    19. public void onDisable(){
    20. getLogger().info("SBasics has been disabled!");
    21. }
    22.  
    23. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    24. if(cmd.getName().equalsIgnoreCase("isonline")){
    25. Player target = (Bukkit.getServer().getPlayer(args[0]));
    26. if (target == null) {
    27. sender.sendMessage(args[0] + " is not online!");
    28. return false;
    29. } else {
    30. if(cmd.getName().equalsIgnoreCase("ragequit")){
    31. Player player = (Player) sender;
    32. this.getServer().broadcastMessage(player + " has ragequit the server!");
    33. player.kickPlayer(getName());
    34. return false;
    35. }
    36. return false;
    37. }
    38. }
    39. return false;
    40. }
    41. }


    And here's the plugin.yml :
    Code:java
    1. name: SBasics
    2. author: redraskal
    3. version: 1.6.4
    4. description: A plugin for your basic server needs.
    5. main: org.bukkit.plugin.SBasics
    6. commands:
    7. ragequit:
    8. description: Ragequit's the server.
    9. isonline:
    10. description: Sees if a player is online.


    So do you know what's wrong?
     
  4. Offline

    CubieX

    Don't use "org.bukkit.plugin". Use your own package name.
    And you have to state the package and the plugins main class name in your "main" key.
    So if your package is: gmail.epicfunr.plugins
    and your main class is "SBasics" you would write in your plugin.yml:
    Code:
    main: gmail.epicfunr.plugins.SBasics
    And you should "return true" if the player used a valid command.
    Only return "false" if he used an invalid one.
     
    se1by and tommycake50 like this.
  5. Offline

    Fozie

    Well i see the main problem and it is in your plugin.yml file.
    At the main:
    You should do {Package} + {Main Class namn}
    and remember to allways parse your yml file

    EDIT:
    I show you the differense:
    You are useing:
    org.bukkit.plugin.SBasics
    But i should be:
    org.bukkit.plugin.SBasics.Main
    because your main class's name is Main
     
  6. Offline

    Goblom

    Your plugin.yml is wrong. in the "main" you are specifying a package instead of a class file. So, bukkit in-turn doesn't know what to load.

    I see that your class name is Main. So the main in you plugin.yml needs to be changed... (You can copy paste the code below)

    Code:
    name: SBasics
    author: Redraskal
    version: 1.6.4
    description: A plugin for your basic server needs.
    main: gmail.epicfunr.plugins.SBasics
    commands:
      ragequit:
        description: Ragequit's the server.
      isonline:
        description: Sees if a player is online.
    Im not entirely sure on this, but you might also need to register the command "isonline" & "ragequit". Not just in the plugin.yml.

    To do so do this.
    Code:java
    1. public void onEnable() {
    2. getCommand("isonline").setExecutor(this);
    3. getCommand("ragequit").setExecutor(this);
    4. }
     
  7. Offline

    redraskal

    Ok guys, tried all of your sugustions, but it isn't working for some reason.
    Here's the new code :

    Main:
    Code:java
    1. package gmail.epicfunr.plugins.SBasics;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public final class Main extends JavaPlugin {
    12. public final Logger logger = Logger.getLogger("Minecraft");
    13. public static Main plugin;
    14.  
    15. public void onEnable(){
    16. getLogger().info("SBasics has been enabled!");
    17. getCommand("isonline").setExecutor(this);
    18. getCommand("ragequit").setExecutor(this);
    19. }
    20.  
    21. public void onDisable(){
    22. getLogger().info("SBasics has been disabled!");
    23. }
    24.  
    25. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    26. if(cmd.getName().equalsIgnoreCase("isonline")){
    27. Player target = (Bukkit.getServer().getPlayer(args[0]));
    28. if (target == null) {
    29. sender.sendMessage(args[0] + " is not online!");
    30. return true;
    31. } else {
    32. if(cmd.getName().equalsIgnoreCase("ragequit")){
    33. Player player = (Player) sender;
    34. this.getServer().broadcastMessage(player + " has ragequit the server!");
    35. player.kickPlayer(getName());
    36. return true;
    37. }
    38. return true;
    39. }
    40. }
    41. return true;
    42. }
    43. }


    Plugin.yml:
    Code:
    name: SBasics
    author: redraskal
    version: 1.6.4
    description: A plugin for your basic server needs.
    main: org.bukkit.plugin.SBasics.Main
    commands:
      ragequit:
        description: Ragequit's the server.
      isonline:
        description: Sees if a player is online.
    Do you know what might have went wrong in this?
     
  8. Offline

    Janmm14

    redraskal
    The version in your plugin.yml does not has to be the version of minecraft, since the most plugins don't need an update if a new minecraft version is coming.
    Are you getting any errors?
    before you write args[0], check that args.length is greater than 0.
     
  9. Offline

    Gater12

    redraskal Your main must match your package name then your class. Your package name is gmail.epicfunr.plugins.SBasics and your class name is Main. So in for your main in the plugin.yml you put gmail.epicfunr.plugins.SBasics.Main
     
  10. Offline

    redraskal

    Gater12 Yea I did but it still wont work :( As in the code above I posted, I have already changed it to this:

    Code:
    main: org.bukkit.plugin.SBasics.Main
     
  11. Offline

    GaaTavares

    redraskal Please don't post topics with the title such as "Help please", "Help with plugin" or something. This area is dedicated to help at plugins development. Be more especific,like, error with playermoveenvet, or something like that.
     
  12. Offline

    mydeblob

    redraskal
    Change it to this
    Code:
    main: gmail.epicfunr.plugins.SBasics.Main
     
  13. Offline

    redraskal

  14. Offline

    mydeblob

    redraskal
    You have org.bukkit, I don't know all your class names so maybe that is it but try this config.yml
    Code:
    name: SBasics
    main: org.bukkit.plugin.SBasics.Main
    author: redraskal
    version: 1.6.4
    description: A plugin for your basic server needs.
    commands:
      ragequit:
        description: Ragequit's the server.
      isonline:
        description: Sees if a player is online.
     
  15. Offline

    Janmm14

    redraskal
    Never use org.bukkit.??? as a package name of your plugin, see sticky thread in thie forum.
     
  16. Offline

    redraskal

    Janmm14 mydeblob I use gmail, tried org.bukkit but it didn't work.
    Also, my only class is Main and my plugin.yml
     
  17. Offline

    JPG2000

  18. Offline

    Janmm14

  19. Offline

    SainttX

     
  20. Offline

    Janmm14

    SainttX
    Your code is also wrong.

    redraskal
    use this:
    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    3. if (cmd.getName().equalsIgnoreCase("isonline")) {
    4. if (args.length < 1)
    5. sender.sendMessage("§4You have to add a player: /" + label + " <player>");
    6. else {
    7. Player target = Bukkit.getServer().getPlayer(args[0]);
    8. if (target == null)
    9. sender.sendMessage("§c" + args[0] + " is not online!");
    10. else
    11. sender.sendMessage("§a" + args[0] + " is online!");
    12. }
    13. } else if (cmd.getName().equalsIgnoreCase("ragequit"))
    14. if (sender instanceof Player) {
    15. final Player player = (Player) sender;
    16. getServer().broadcastMessage("§e" + player + " has ragequit the server!");
    17. player.kickPlayer("§bYou ragequitted §4:(");
    18. } else
    19. sender.sendMessage("§4Only players may use this command!");
    20. return true;
    21. }
     
  21. Offline

    redraskal

    Janmm14 Used that code but it didn't work. I think it is the plugin.yml because the code is right, but the plugin.yml bust have been configed wrong. Here is the plugin.yml:

    Code:
    name: SBasics
    author: redraskal
    version: 1.6.4
    description: A plugin for your basic server needs.
    main: org.bukkit.plugin.SBasics.Main
    commands:
      ragequit:
        description: Ragequit's the server.
      isonline:
        description: Sees if a player is online.
     
  22. Offline

    __Sour



    On line # 33 Change it to "Bukkit.broadcastMessage(player.getName() + " has ragquit the server");"
     
  23. Offline

    DrTURTLE2


    Am I the only one still seeing he is using org.bukkit?
     
    Janmm14 likes this.
Thread Status:
Not open for further replies.

Share This Page