Help plz with 2 plugins I'm making!

Discussion in 'Plugin Development' started by Randomguy, Feb 3, 2015.

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

    Randomguy

    well hello, I'm making 2 plugins, called BossBarMessage and Comments. Comments, when you do /positive it sends you a positive comment, /negative is the opposite. /random sends you a random comment, and /comments gives you the comments help. Code:

    package com.Zach.Comments;



    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 Comments extends JavaPlugin {



    @Override

    public void onEnable() {

    getLogger().info("Comments Commenting!");

    getConfig().options().copyDefaults(true);

    saveConfig();

    }



    @Override

    public void onDisable() {

    getLogger().info("Comments Sucessfully Disabled!");

    saveConfig();

    }





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



    if (cmd.getName().equalsIgnoreCase("positive") && sender instanceof Player) {

    if(getConfig().getStringList("Positive").isEmpty()) {

    sender.sendMessage(ChatColor.AQUA + "Sorry, there are no positive comments! Please alert a staff member!");

    }



    }

    returnfalse;



    }

    }

    config:

    #Config.yml for Comments!
    #In Positive, add comments you want for /positive. For /negative, do the same, and for
    #random, you can add positive and negative comments!
    Positive:

    Negative:

    Random:


    plugin.yml:

    name: Comments
    main: com.Zach.Comments.Comments
    version: 1.0
    description: Do /negative or /positive to figure out what this plugin does!
    commands:
    Positive:
    description: Sends the user a positive comment!
    Negative:
    description: Sends the user a negative comment!
    Random:
    description: Sends the user a random comment, either posotive or negative!
    Comments:
    description: Commands for the plugin Comments!

    my problem for comments is i don't know how to hook up making it say one of the random comments listed in the config... I'm new to this plz help

    as for bossbarmessage, heres the code:

    package com.Zach.BossBarMessage;

    import me.confuser.barapi.BarAPI;

    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 BossBarMessage extends JavaPlugin {

    @Override
    public void onEnable() {
    getLogger().info("BossBarMessage Enabled Successfully");
    }

    @Override
    public void onDisable() {
    getLogger().info("BossBarMessage Sucessfully Disabled!");
    }


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

    if (cmd.getName().equalsIgnoreCase("bossbar help") && sender instanceof Player); {

    Player player = (Player) sender;
    player.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "BossBarMessage Help:");
    player.sendMessage(ChatColor.YELLOW + "/BossBar = displays the BossBarMessage Help");
    player.sendMessage(ChatColor.YELLOW + "/BossBar help = displays the BossBarMessage Help");
    player.sendMessage(ChatColor.YELLOW + "/BossBar disable = Disables the display of the BossBarMessage for you");
    player.sendMessage(ChatColor.YELLOW + "/BossBar enable = Enables the display of the BossBarMessage for you");
    player.sendMessage(ChatColor.YELLOW + "Note: The default is set to the bossbar is enabled for everyone");


    }else if (cmd.getName().equalsIgnoreCase("bossbar disable") && sender instanceof Player) {
    if (BarAPI.hasBar((Player) sender)); {
    BarAPI.removeBar((Player) sender); }
    sender.sendMessage(ChatColor.DARK_PURPLE + "Disabled the bossbar!");
    while (BarAPI.hasBar((Player) sender) == false);
    sender.sendMessage(ChatColor.DARK_PURPLE + "You already have the bossbar off!");


    }else if (cmd.getName().equalsIgnoreCase("bossbar enable") && sender instanceof Player) {

    if (BarAPI.hasBar((Player) sender));
    sender.sendMessage(ChatColor.DARK_PURPLE + "You already have the bar on!");
    while (BarAPI.hasBar((Player) sender) == false); {
    BarAPI.setMessage((Player) sender, Label, 75f);
    }

    }
    return false;
    }
    }

    plugin.yml:

    name: BossBarMessage
    main: com.Zach.BossBarMessage.BossBarMessage
    version: 1.0
    dependency: [BarAPI]
    commands:
    bossbar:
    description: Bossbar help
    bossbar help:
    description: Bossbar help
    bossbar disable:
    description: Disables the bossbar
    bossbar enable:
    description: Enables the bossbar

    my problem with this is 1. the bossbar doesn't come up, 2. when i do /bossbar enable the bossbar menu comes up, 3. I'm not sure how to disable and enable the bossbar... and 4. I'm not sure if what i did is right... 5. i don't know how to change the bossbar by doing a command... plz help... i know I'm asking a lot but I'm not sure what to do :( I'm stumped.

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

    EpicCraft21

    This is all kinda confusing, please use the insert code button near the save button up top when posting, so it looks like this:
    Code:
    This is what it is supposed to look like!:)
     
    teej107 likes this.
  3. Offline

    teej107

    @Randomguy
    Using the
    Code:
    Java code tag!!!!!!
    will be even more readable.
    I didn't even look at your code tbh because it's annoying to read.
     
    MordorKing78 likes this.
  4. Offline

    1Rogue

    (on a different note if you have two separate issues then that warrants two separate threads/topics).
     
  5. Offline

    Randomguy

    sorry... ill repost it...

    how do i do this? i don't get it... is it the use bb code editor?

    how do i do this?
     
    Last edited by a moderator: Feb 3, 2015
  6. Offline

    StefanXX

    Last edited by a moderator: Feb 4, 2015
    Protophite likes this.
  7. Offline

    Randomguy

    oh... i feel stupid... lol thanks :)

    Code:
    package com.Zach.Comments;
    
    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 Comments extends JavaPlugin {
        
        @Override
            public void onEnable() {
                getLogger().info("Comments Commenting!");
                getConfig().options().copyDefaults(true);
                saveConfig();
         }
           
            @Override
            public void onDisable() {
                getLogger().info("Comments Sucessfully Disabled!");
                saveConfig();
            }
               
           
            public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
               
                if (cmd.getName().equalsIgnoreCase("positive") && sender instanceof Player) {
                    if(getConfig().getStringList("Positive").isEmpty()) {
                    sender.sendMessage(ChatColor.AQUA + "Sorry, there are no positive comments! Please alert a staff member!");
                    }
                   
                }
                return false;
    
            }
    }
    plugin.yml:
    Code:
    name: Comments
    main: com.Zach.Comments.Comments
    version: 1.0
    description: Do /negative or /positive to figure out what this plugin does!
    commands:
        Positive:
            description: Sends the user a positive comment!
        Negative:
            description: Sends the user a negative comment!
        Random:
            description: Sends the user a random comment, either posotive or negative!
        Comments:
            description: Commands for the plugin Comments!
    config.yml:
    Code:
    #Config.yml for Comments!
    #In Positive, add comments you want for /positive. For /negative, do the same, and for
    #random, you can add positive and negative comments!
    Positive:
    #add positive comments here!
    Negative:
    #add negative comments here!
    Random:
    #add random comments here!
    ill start another thread for the other plugin I'm making... because there 2 different topics...

    heres a link to the other thread...

    http://bukkit.org/threads/bossbarmessage-plugin-with-barapi.339948/
     
    Last edited by a moderator: Feb 4, 2015
  8. Offline

    CraftCreeper6

    @Randomguy
    You have not even added any Strings too the list...
     
    Lightspeed likes this.
  9. Offline

    Randomguy

    again... sorry kinda new to this...

    why would i need strings? again new to this....

    and btw can i see code? I'm better when someone shows me how to do it than tells me

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Feb 3, 2015
  10. @Randomguy No one will spoonfeed you hence @CraftCreeper6's profile picture. He has stated it pretty clear, you haven't added anything to your list.
     
    CraftCreeper6 likes this.
  11. Offline

    Randomguy

    ok... but i don't understand where he means that... where do i add strings?
     
  12. Offline

    CraftCreeper6

  13. Offline

    Skionz

    Just going to point this out, but your wrong. You do not learn better when you are handed the code. You may get whatever your doing done faster, but you will not learn anything and you will be crawling back with more issues in the future.
     
  14. Offline

    Randomguy

    ok... I'm just saying when i look at it i usually understand it and remember it for next time...
     
  15. Offline

    CraftCreeper6

    @Randomguy
    That's not how the brain works. Have you ever been told to revise for a test? I am sure you have. The teacher usually gives tips. E.G: Write the things you really need to learn a few times and try remember it. You cannot just look at something and remember it unless you have a photographic memory... Only around 3 people on the planet have a photographic memory.
     
  16. Offline

    Lewishjames

    Use a hashmap and loop through the sentances or comments. Also please use the "Code" section to insert your JavaScripts and code
     
  17. Offline

    CraftCreeper6

    @Lewishjames
    HashMaps wont survive over reloads / shutdowns.
     
  18. Offline

    Lewishjames

    @CraftCreeper6 Well then he will just have to state the sentences and then loop through them.
     
  19. Offline

    CraftCreeper6

    @Lewishjames
    He wants to use configuration. (Don't get off-topic).
     
  20. Offline

    Randomguy

    what i mean is i comment what it does and look back to it if i need to

    you know what... I'm not going to argue right now... the arguing gets us knowhere

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Feb 4, 2015
  21. Offline

    Lewishjames

    Oh well you would have to read through the configuration file. If you don't know how to use configs properly its one of the most basic things to start off with. I suggest use BcBROZ of pogostick29Dev's channel.
     
  22. Offline

    CraftCreeper6

    @Lewishjames
    Neither, Bukkit wiki, YouTube videos contain many bad habits. Like; Lazy access and incorrectly named methods.


    @Randomguy
    Here.
     
  23. Offline

    Randomguy

    i use stormcorefilms, bcbroz, and voidnationmc

    thanks!

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Feb 4, 2015
  24. Offline

    xTrollxDudex

    I'm so sorry.
     
  25. Offline

    Burnett

    @Randomguy I started the same as you almost 3 years ago. I too found the BCBroz and preferred code examples. I had to be taken to a dark place with lots of statics to get those bad habits ironed out. Take it from me to stop watching bukkit tutorials on youtube. Go check out thenewboston if you need visual learning for Java. As for bukkit, well if you know Java you wont need to learn bukkit. You will only need to reference the bukkit documentation and the wiki to find what you need.
     
  26. Offline

    Randomguy

    ok, thanks for that!
     
  27. Offline

    Randomguy

    but can we get back to the question at hand, how to i connect the broadcasting the messages to the string list, and how do i make it random... is it like this?

    Code:
            public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
               
                if (cmd.getName().equalsIgnoreCase("Positive") && sender instanceof Player) {
                    if(getConfig().getStringList("Positive").isEmpty()) {
                    sender.sendMessage(ChatColor.AQUA + "Sorry, there are no positive comments! Please alert a staff member!");
                    }
                    if(getConfig().getStringList("Positive").isEmpty() == false);
                    getConfig().getStringList("Positive");
                    sender.sendMessage(ChatColor.BLUE + "" + getConfig().getStringList("Positive"));
    or would you do some random generating thing outside the sender.sendmessage?
     
  28. Offline

    Randomguy

    plz help... I'm stumped...
     
  29. Offline

    Shawckz

    Maybe learn java first....
    Also, forum formatting exists for a reason.
    im dead LOL
     
Thread Status:
Not open for further replies.

Share This Page