First Plugin

Discussion in 'Plugin Development' started by Archarin, Jan 15, 2013.

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

    Archarin

    I need help just continuing a plugin I'm making. I don't know what to do next. What it should do is when you type "/Enchant" it opens an enchanting table that you can use like you normally would. It is for servers that don't like the when people use "/Enchant Sharpness 10" for example. It is essentially a more fair way to enchant for donators. Could you tell me what to do next or what I
    have done wrong? Here it is.:)
     
  2. Offline

    gomeow

    Try player.openEnchanting(null, true);
     
    Thermo_Core likes this.
  3. Offline

    Archarin

    Thanks. Do you see any other problems with the code. If I get it all ready and set up the plugin.yml could I run it on my server?
     
  4. Offline

    gomeow

    Thermo_Core

    I would skip logging when the plugin in enabled and disabled, because Bukkit does that automatically.

    Here is an updated onCommand to make things a bit better:

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("enchantopen")) { //Using just "enchant" would conflict with over plugins.
    3. if(sender instanceof Player) { //Check if a player sent it
    4. Player player = (Player) sender; //Cast only after checking instanceof
    5. player.openEnchanting(null, true); //Open the enchanting table
    6. return true;
    7. }
    8. else {
    9. sender.sendMessage(ChatColor.RED+"Only players can open the enchanting table!");
    10. return true;
    11. }
    12. }
    13. return false;
    14. }
     
    Thermo_Core likes this.
  5. Offline

    chasechocolate

    Logger.getLogger("Minecraft") is kinda outdated. There is already a logger built into JavaPlugin (getLogger()). I just use this method to log messages to the console:
    Code:java
    1. public void log(String msg){
    2. getLogger().info(msg);
    3. }

    This automatically adds the [YourPlugin] prefix to the message.
     
  6. Offline

    Archarin

    I did everything and set up the plugin.yml, but it won't load on my server? The error can not load PvPEnchant comes up. Here is the final code http://pastebin.com/2cTbdAJe . Here is the plugin.yml
    Code:
    name: PvPEnchant
    main: com.coredevelopment
    version: 1.0
    commands:
    ExpTable:
          description: Opens An Enchanting Table!
          usage: /<command>
          permission: <plugin name>.ExpTable
          permission-message: You Don't Have <permission>
     
  7. Offline

    Miner_Fil

    Thermo_Core
    i think you did something wrong there, Did u mean this
    Code:
    name: PvPEnchant
    main: com.coredevelopment
    version: 1.0
    commands:
      ExpTable:
          description: Opens An Enchanting Table!
          usage: /<command>
          permission: <plugin name>.ExpTable
          permission-message: You Don't Have <permission>
     
  8. Offline

    Archarin

    Thank you for the reply, but it still doesn't work. This is the error it gives me when I load it. I probably did something really stupid wrong. Server Log: http://pastebin.com/JMhCngKh
     
  9. Offline

    Miner_Fil

    Thermo_Core
    What is your main class file called?

    The error is that the Main Class File could not be found
     
  10. Offline

    Archarin

    Probably PvPEnchant, but I might be wrong because I'm %100 sure what the Main Class File is.
     
  11. Offline

    Miner_Fil

    If your main class file is PvPEnchant then use this
    Code:
    name: PvPEnchant
    main: com.coredevelopment.PvPEnchant
    version: 1.0
    commands:
      ExpTable:
          description: Opens An Enchanting Table!
          usage: /<command>
          permission: <plugin name>.ExpTable
          permission-message: You Don't Have <permission>
     
    Thermo_Core likes this.
  12. Offline

    ZachBora

    Isn't your JavaPlugin class called AlphaEnchant ?
     
  13. Offline

    Miner_Fil

    Then he should use this for his plugin.yml
    Code:
    name: PvPEnchant
    main: com.coredevelopment.AlphaEnchant
    version: 1.0
    commands:
      ExpTable:
          description: Opens An Enchanting Table!
          usage: /<command>
          permission: <plugin name>.ExpTable
          permission-message: You Don't Have <permission>
     
    Thermo_Core likes this.
  14. Offline

    Archarin

    It was, but I changed it. It was to much of a rip off of Alpha Chest.
     
  15. Offline

    Miner_Fil

    You would use this then Thermo_Core
     
  16. Offline

    Archarin

    Miner_Fil gomeow Thank you so much for all of your help.:D So far it works and I have created my first plugin. I will now test it for a while until I am confident with the results. Thank You!
     
  17. Offline

    Miner_Fil

    You Welcome ;)

    No, You didn't Know!?!?!?!
    You only need a command executor when you create the commands in different classes

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  18. Offline

    Archarin

    Do you know how to add colors into the console?
     
  19. Offline

    Sagacious_Zed Bukkit Docs

    Please look at all the interfaces that JavaPlugin already implements.
     
  20. Offline

    Miner_Fil

    Yes, You use ChatColor.RED for example if you put it like ChatColor. you should have options of colors
     
  21. Offline

    Plaze_Demon

    Yes sorry I'm used to making commands in a different class (keeps it neater) no need for the !!???? Though :p
     
  22. Offline

    Miner_Fil

  23. Offline

    Archarin

    How do you make it say dev.bukkit.org profile: in by your avatar?
     
  24. Offline

    william9518

    thermo, for the color coding, create a method like this:
    Code:
     public String toColor(String string){
              string = ChatColor.translateAlternateColorCodes('&', string);
              return string;
        }
    and to make the color do
    "&ahi" will return a light green or if you want manual way (no changing in config, no user interface changing, etc)
    just do ChatColor.GREEN + "String"
    for the bukkit dev, go to ur profile here and connect ur profile to ur buk dev profile.
     
  25. Offline

    Miner_Fil

    I linked my forums.bukkit.org account with my dev.bukkit.org account
     
  26. Offline

    Archarin

    How?
     
  27. Offline

    Miner_Fil

Thread Status:
Not open for further replies.

Share This Page