%variable% help

Discussion in 'Plugin Development' started by johnny_boy, Jan 9, 2017.

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


    So many people use (in there configs) stuff like %motd% to replace that with whatever it is. How would I make that?
  2. Offline


    string.replace("%variable%, whatever);
    Based on this question, I suggest you learn Java first... this is String manipulation which is essentially the basics of Java (and not Bukkit.)
  3. Offline


  4. Offline


    Oh don't worry, I know java perfectly fine. I just didn't know about this particular method.
  5. Offline


    Then you don't know it "perfectly fine".
    FisheyLP and Zombie_Striker like this.
  6. Offline


    Something along the lines of...
    String variable = "54";
    String result = getConfig().getString("Path.to.string").replaceAll("%var%", variable);
  7. Offline



    I'd argue that there isn't any proof he doesn't.


    Don't spoonfeed, and don't use replaceAll, which uses regex, not a string.


    Alright, then the method is String#replace(String, String), the first one is a pattern to find and the second is the value to replace it with. You invoke the method on a String, and it returns the transmuted String. That should be all you need.

    As an aside, since it returns the value as a String, you can chain the method calls, for example:

    String var = test.replace("1", "one")
        .replace("2", "two")
        .replace("3", "three");
    johnny_boy and AlvinB like this.
  8. Offline


    I dont see how i am spoonfeeding yet A5H73Y is not? Not to point finger's but he also just posted code.
  9. Offline


    Do not take it as something against you. Both you and A5H73Y spoonfed. Which arent what we do on this forum.

    Please try to tell him how to do it, instead of giving him the exact code that does it.

    Sendt fra min ALE-L21 med Tapatalk
  10. Offline


    I gotchu :)
  11. Offline


    I feel bad i clicked on the link.

    However i learned lots of java by coming here and get help from you guys.
    ipodtouch0218 likes this.
  12. Offline


    I disagree with this.
    I posted the syntax, relevant to what he asked; If someone asked what is "Hello" in French, you'd answer "Bonjour", not a sentence which contains "Bonjour" etc.
    JanTuck likes this.
  13. Offline


    True, but there is a difference with that example. That is just asking what one simple word means and just telling the person what it means. What you are doing is giving them a full senentance, without any context to what the other words mean. If anything, you got it backwards.

    The reasons we do not like spoonfeeding on the Bukkit forums can be found in the How To Make a Plugin Dev Thread sticky. In that thread, it says:
  14. Offline


    This post was not made to be argued on, but I personally think @mythbusterma's response helped me the most. Thank you!
    mythbusterma likes this.
  15. Offline


    If your problem has been solved, mark this thread a s solved.
Thread Status:
Not open for further replies.

Share This Page