Solved Kit Variables?

Discussion in 'Spigot Plugin Development' started by ChickenPillow, Jul 2, 2016.

Thread Status:
Not open for further replies.
  1. So Ive made a custom kitpvp plugin with custom messages, and I want it that if you put in message in config like <kit> it will show the name of the kit like in coding u can do

    p.sendMessage("§4[§cKitPvP§4] §cYou got kit §4" + kit);
    return true;

    with the + kit

    how do u add that as a possibility to config messages?
     
  2. FormallyMyles

    Supporter

    Use .replace("<kit>", kitName);

    Simple string replacement.
     
  3. Wait but for like config.yml so players can do it for messages like u have a configurable message for when you select a kit like You got the kit <kit>

    How can I make it that if they do <kit> in config it will show as the kit they choose in chat when selecting s kit?
     
  4. Where do I put the code?
     
  5. Use the Class<? extends JavaPlugin> instance to get the getConfig().getString(String path); method
     
  6. Like is it .getConfig().getOptions() .replace("<kit>", kitName);
     
  7. FormallyMyles

    Supporter

    So when loading from the config and sending to player they would have:

    String kitName = "Archer Kit";
    player.sendMessage(getConfig().getString("kit_message").replace("<kit>", kitName));

    Config would then be like:
    kit_message: "You got the <kit>, have fun!"
     
  8. Okay but that would always make it Archer Kit right? How do I make it automatically do the kit when you do /kit (name of kit)
     
  9. FormallyMyles

    Supporter

    You would change kitName variable to the variable you have for the name of your kit.
     
    • Useful Useful x 1
  10. player.sendMessage(getConfig().getString("kit_message").replace("<kit>", kitName));

    With this code, how can I add so that you can use colors in the editing message config? (for players)
     
  11. FormallyMyles

    Supporter

    Wrap with
    ChatColor.translateAlternateColorCodes('&', string)
     
  12. where in the code above would u put it in the code?
     
  13. In the player#sendMessage();
     
  14. like > p.sendMessage(getConfig().getString((ChatColor.translateAlternateColorCodes('&'"messages.get_kit").replace("<kit>", kit));

    ?
     
  15. Why not try it yourself? We can't spoonfeed all day. Just try it and if it doesn't work come back with (errors) or the problem.
     
  16. it doesnt work, ive tried many ways, but I dnt know how!!?!!
     
  17. We can't help you if you don't say what is not working and not providing any information.
     
  18. Am I doing the right code or not?
     
  19. We don't know. You don't give us information.
     
Thread Status:
Not open for further replies.