Help creating my plugin

Discussion in 'Plugin Development' started by DanTDM2727, Sep 13, 2015.

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

    DanTDM2727

    @timtower i cant find Maven Install in Run As
     
    Last edited: Sep 14, 2015
  2. Offline

    timtower Moderator Moderator

    @DanTDM2727 Tried to export as jar? What method are you actually using for your jar? Maven or build path?
     
  3. Offline

    DanTDM2727

  4. Offline

    timtower Moderator Moderator

  5. Offline

    DanTDM2727

  6. Offline

    timtower Moderator Moderator

    @DanTDM2727 Define "Doesn't work"
    There are many explanations of that. All with different solutions.
     
  7. Offline

    DanTDM2727

    any good solutions and on the Java Project it has a cross @timtower
     
  8. Offline

    timtower Moderator Moderator

    @DanTDM2727 That are compile errors.
    Should be able to fix that yourself with basic java knowledge.
     
  9. Offline

    DanTDM2727

    i am terrible with java
     
  10. Offline

    timtower Moderator Moderator

    @DanTDM2727 Please fix that first. It will make everything a lot easier.
     
    teej107 likes this.
  11. Offline

    DanTDM2727

  12. Offline

    timtower Moderator Moderator

    @DanTDM2727 Trial and error. And problem solving skills.
    That is how I learned it, together with the regular google search to find out how a function works.
     
  13. Offline

    bwfcwalshy Retired Staff

    It's actually in Spigot :p

    But if you do import this it wouldn't work on any Bukkit server only Spigot servers.
     
  14. Offline

    Mee8a

  15. Offline

    DanTDM2727

  16. Offline

    timtower Moderator Moderator

    I at least won't.
    In my opinion you don't have enough java knowledge yet, and you try to make plugins that are more complicated then you currently can.
    Start with a simple hello world plugin.

    Spoon feeding is discouraged on these forums, just that you know
     
  17. Offline

    DanTDM2727

    i did this


    package me.YouTubeDanTDM.MyFirstPlugin;

    import org.bukkit.ChatColor;
    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(ChatColor.BLUE + "This Plugin Was Enabed");
    }




    @Override
    public void onDisable() {

    }

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("Wb") && sender instance of Player) {

    Player player = (Player) sender;

    player.sendMessage("Weclome Back, " + player.getName() + "!");
    }

    return false;
    }
     
  18. Offline

    Zombie_Striker

    @DanTDM2727
    1. package me.YouTubeDanTDM.MyFirstPlugin; Is a bad package name (does not follow conventions)
    2. Useless onEnable() Remove the whole OnEnable
    3. Useless onDisable. Remove onDisable
    4. Did you register your command?
    [edit] Show config. That is most likely your problem.
     
  19. Offline

    DanTDM2727

    how do i register the commands

    package me.YouTubeDanTDM.MyFirstPlugin;

    import org.bukkit.ChatColor;
    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 {


    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("Wb") && sender instance of Player) {

    Player player = (Player) sender;

    player.sendMessage("Weclome Back, " + player.getName() + "!");
    }

    return false;
    }​

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

    Zombie_Striker

    @DanTDM2727
    This shows you should really NOT be making plugins. Registering commands is probably the first or second thing any tutorial will show you how to do.

    Click the link in my signature, or HERE.
     
  21. Offline

    FisheyLP

    A few tipps about onCommand:
    • The CommandSender doesn't have to be casted to the player. It can be the console too if you just need simple things like sending a message. If the command however requires the location of the CommandSender, it is more useful to check if the sender is a Player.
    • If you return false, the command usage will be sent to the sender. Return true instead. (return false = command failed, return true = command succeeded)
    • How to register your commands: http://wiki.bukkit.org/Plugin_YAML
     
  22. Offline

    DanTDM2727

    is that it @Zombie_Striker


    package me.YouTubeDanTDM.MyFirstPlugin;

    import org.bukkit.ChatColor;
    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 {


    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("Wb") && sender instance of Player) {

    Player player = (Player) sender;

    player.sendMessage("Weclome Back, " + player.getName() + "!");
    }

    return true;
    }


    So i have registerd the command but is it correct
     
    Last edited: Sep 14, 2015
  23. Offline

    Zombie_Striker

    @DanTDM2727\
    Nope

    Now no matter what the command is, the command is the right command!

    Did you register your command IN the plugin.yml
     
  24. Offline

    DanTDM2727

  25. Offline

    Zombie_Striker

    @DanTDM2727
    So what is the problem with your plugin now? Is everything fixed.

    [edit]Just noticed you put "Instance Of" instead of "Instanceof" (you added a space when you shouldn't have) This will throw some errors meaning your plugin would not be loaded.

    If you're using any type of IDE, it should be underlined/highlighted showing this is wrong. If you're not using an IDE (if you're using notepad or something else instead), then I would suggest getting an IDE since it helps show you any errors/mistakes you might have made.

    BTW, CommandSender (what sender is) has the .sendMessage method in it. You don't get the player IF that is the only thing your command does.
     
  26. Offline

    DanTDM2727

  27. Offline

    bwfcwalshy Retired Staff

    @DanTDM2727 May I ask why your package is YouTubeDanTDM as I unserstand DanTDM is a youtuber and you are not him. What's the story there? Also follow naming conventions.
     
  28. Offline

    meguy26

    This thread was fun to read.


    @DanTDM2727
    I highly doubt you will be able to export whatever code you have, at least without errors. You seem pretty dead-set on doing the plugin now, but honestly, go learn java BEFORE attempting a project like this or using external APIs...
     
    timtower, Zombie_Striker and Garnetty like this.
  29. Offline

    Garnetty

    I'll be blunt, but you should probably learn at least a basic level of java, because if you don't know to not name your class "classname", it's going to be difficult for you to learn an API. Trust me, I tried learning bukkit before java and it was a huge mistake, but I bought a book on it and I have basic knowledge and can't wait to learn more.

    If you're interested in learning the language and not just bukkit, I'd recommend buying a book on Java or finding some online tutorial. (P.S even if you're not interested in learning java you kind of have to if you want to program a plugin)
     
  30. Offline

    DanTDM2727

    What book

    @bwfcwalshy but YouTubeDanTDM Is my Minecraft username
     
    Last edited by a moderator: Sep 16, 2015
Thread Status:
Not open for further replies.

Share This Page