Question Help With My Plugins Config!

Discussion in 'Bukkit Help' started by OMGTurtlesFTW, Jun 22, 2015.

Thread Status:
Not open for further replies.
  1. So I have made a plugin and I wanted to know how to make the config work (like with the plugin), I want to change the text on this line here (where it says "Add IP Here!") - player.sendMessage(ChatColor.RED + "Add Your IP Here!"); I would also like it to be able to change the config so you can add your OWN server IP address where it says "Add IP Here!".

    P.S. I'm Sorry If I'm Not 100% Clear I'm New To The Bukkit Forums!

    -Thank You For Reading :D
     
  2. Offline

    oceantheskatr

    First I'd suggest learning how to store strings/get strings from the config.

    Also I'd suggest parsing for colour codes. Your code should be something like this:

    Code:
    String text = config.get("ipString"); // Gets string from config.
    text = ChatColor.translateAlternateColorCodes('&', text); // Converts color codes like &6 and &l.
    p.sendMessage(text); // Send message to player.
    In your config it'd look something like this:

    ipString: '&6You are playing on &cserver.themineshack.net&6! Enjoy!'

    Also I'd suggest posting here instead for coding help: http://bukkit.org/forums/plugin-development.5/
     
  3. Offline

    stefvanschie

    You could do this in one line of code:
    Code:
    p.sendMessage(config.getString("ipString").replace("&", "§"));
    @oceantheskatr
    Line one has to be
    Code:
    String text = config.getString("ipString"); // Gets  string from config.
     
    Last edited: Jun 22, 2015
  4. Offline

    oceantheskatr

    @OMGTurtlesFTW What stef said :)

    Just one correction, line one should be ("ipString") not ("ipString) @stefvanschie just missed that
     
  5. Offline

    stefvanschie

  6. ok thanks guys i will try this :D and also do you know where i can find a list of commands for the minecraft code such as block ID's and how to spawn entity's?

    -Thank You :)


    so where would i put this in my code? i will give you the code if you need it! @oceantheskatr

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jun 23, 2015
  7. Offline

    stefvanschie

    You put this code in the part where you want to send the player a message
     
  8. ohhh thanks @stefvanschie :)
    so i delete that line that says "if (cmd.getname().equalsIgnoreCase("GetIP")){"?
     
  9. Offline

    stefvanschie

    No, try this:
    Code:
    if (cmd.getName().equalsIgnoreCase("getip")
    {
      String text = config.get("ipString");
      text = ChatColor.translateAlternateColorCodes('&', text);
      p.sendMessage(text);
    }
     
  10. thanks :D
     
  11. Offline

    stefvanschie

  12. Offline

    oceantheskatr

Thread Status:
Not open for further replies.

Share This Page