Very simple Plugin please help!

Discussion in 'Plugin Help/Development/Requests' started by georgepan, Jul 27, 2015.

Thread Status:
Not open for further replies.
  1. Ok so i have VERY LITTLE knowledge of Java and I'm still learning, but I wanted a very simple plugin for my server. I wanted so I could press /website and it would be a message showing me a link. I managed to do that through YouTube tutorials but I also needed a config file. Here is the part something is wrong.

    Please do not say I should learn Java well enough I am aware of that i just need this plugin for my server soon.

    Here is my source : http://pastebin.com/TgDKFy96

    The plugin loads properly and the error comes up only when i press /website.
    Ingame it says an internal error occured.

    This is the console file: http://pastebin.com/D5eEC0Yc

    I hope you can help me it's just that I need this plugin now or else i would wait until i had enough java knowledge...
     
  2. Moved to Bukkit Alternates.
     
  3. Offline

    BizarrePlatinum

    @georgepan
    • No enable/disable message necessary, Bukkit does that for you.
    • Test if sender is instance of player before casting (not too important since it's a command, for future reference)
    • Problem is arising from the config. If a pastebin of the config could be supplied, that would be great.
     
  4. I guess the format of my config file is not correct... I noticed that when i start my server it generates a file with an empty config file inside.

    I wanted to have mutliple lines with 1 string so yeah that is probably what I did wrong or something with the format.

    Config.yml: http://pastebin.com/zNY1My4K
     
  5. Offline

    BizarrePlatinum

    @georgepan is Config.yml spelt like that? If so, you need to change it to lower case. Also something I forgot to mention, using #copyDefaults(); can be replaced with just using saveDefaultConfig(); onEnable (will not overwrite an existing config file).
     
  6. Offline

    LeGhost

    BTW, I think line 33 on your code has an error...
    I think the full error is because you have multiple lines of text in your config.yml file.
    Try to set it to one line, and see if that works.
    Like this:
    Code:
    Website: &6Hi, this is a test!
     
  7. Uhm @BizarrePlatinum it is config.yml so that's not the issue

    @LeGhost I tried having only one line of text in my config file - I modified config.yml on eclipse .jar file was exported i placed my plugin into plugins folder and when i started my server it generated a file with an EMPTY(?!) config file inside.
     
  8. Offline

    BizarrePlatinum

    Not at all, multiple lines work just fine.

    @georgepan Try using saveDefaultConfig(); instead of #copyDefaults(); and I believe another problem would be that since there is more than one line, it needs to be a list of strings. Then you can just iterate through the list and send the line corresponding to the current iteration.
     
  9. Offline

    BizarrePlatinum

  10. Offline

    BizarrePlatinum

    @georgepan Get website as a list and iterate through the list's contents.
     
  11. Offline

    BizarrePlatinum

    @georgepan The config is fine, in the code instead of #getString() do #getStringList() and then just iterate through the list with a for loop.
     
  12. This does the same as before. It displays the message normally but there is that white /website underneath it...

    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
           
            if (cmd.getName().equalsIgnoreCase("website")) {
    
                for(String website : getConfig().getStringList("Website")) {
                   
                    String send = ChatColor.translateAlternateColorCodes('&', website);
                    sender.sendMessage(send);
                }
     
  13. Offline

    BizarrePlatinum

    @georgepan make it return true after the loop (problem is that since you're not telling it to stop there, it is continuing further to the lower return false, which tells bukkit to send the command's usage).
     
  14. It finally worked!(lel i suck)

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page