Plugin Help Help with stringlist

Discussion in 'Plugin Help/Development/Requests' started by Rahat, Apr 11, 2015.

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

    Rahat

    Fixed
     
    Last edited: Apr 12, 2015
  2. Offline

    pie_flavor

    @Rahat Tip: Use [syntax=java] or [code=java] instead of [syntax] or [code] so that the syntax is highlighted, making it easier to read..
    It is good that you are checking since this is your first time. I am unclear as to what the problem is, but this can be written much more simply and without a lot of things that will error.

    I have rewritten this here and my edits are as follows:
    1. Removed unnecessary logger/logging code from onEnable and onDisable. Bukkit logs these messages automatically. Seriously, try the plugin without them and check the log. If you need the logger for any reason other than enables/disables, use getLogger(). You wouldn't have gotten off the ground anyway because you define the variable logger but never populate it.
    2. Re-indented everything. The Java standard is 4 spaces, and yours is all over the place. Also deleted those weird linebreaks.
    3. You evidently have a grasp of color codes, it's much easier to use them directly than referencing ChatColor each time. Made a method c() which takes a String and changes all % codes to color codes, and changed all the messages accordingly. Generally I would use & instead of % but you can't here because you're putting the actual & code in the chat.
    4. Made a lot of things concurrent with other things (e.g. some color code lines had 2 spaces between name and code, the rest had 3)
    5. Changed return to true. If a command returns false, the sender will be also sent the usage message defined in plugin.yml. False should only be returned if the player typed the command wrong.
    That said, you have not listed what your actual problem is, or what the actual function of that second class is. Please do so.
     
  3. Offline

    Rahat

    Fixed

    So at
    Code:java
    1.  
    2. sender.sendMessage(c("%7-----------------" + this.getConfig().getStringList("server-name")+"%7-----------------"));
    3.  
    4. I want to make a config so the config will say be like :
    5. Colours
    6. Servername:
    7. The servername will be what ever someone puts
    8.  
    9. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  4. Offline

    pie_flavor

    @Rahat Right. Change getStringList() to getString() and it'll work.
     
  5. Offline

    Rahat

    @pie_flavor I got a error with ChatColor.translateAlternateColorCodes
    Code:java
    1.  
    2. String c(String s) {
    3. return ChatColor.translateAlternateColorCodes("%",s);
    4.  
    5. [URL]http://pastebin.com/H1fVncRT[/URL]
    6.  
    7. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  6. Offline

    cnc4

    @Rahat
    maybe add cast to: "%" so you will get:
    Code:
    (char) "%"
     
  7. Offline

    I Al Istannen

    @Rahat or use '%' with the ' character. " stands for String, ' for char.
     
  8. Offline

    Rahat

    Where should i add it ? because translateAlternateColorCodes still underlined
     
  9. Offline

    cnc4

    @Rahat

    Yes my mistake, do: '%'
     
  10. Offline

    I Al Istannen

    @Rahat I think it was Line 17:
    Code:
    String c(String s) {
      return ChatColor.translateAlternateColorCodes('%',s);
    }
    
     
  11. Offline

    Rahat

  12. Offline

    cnc4

    @Rahat

    Do:
    Code:
     String c(String s) {
            return ChatColor.translateAlternateColorCodes('%',s);
     
  13. Offline

    Rahat

    Ty

    @mrCookieSlime could you delete this post

    <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
     
    Last edited by a moderator: Apr 12, 2015
  14. Offline

    mrCookieSlime

    @Rahat
    Locked. We don't delete Threads.
    Also, please use the report button instead.
     
Thread Status:
Not open for further replies.

Share This Page