%player%, %server%, and so forth

Discussion in 'Spigot Plugin Development' started by Creatos137, Apr 30, 2017.

  1. Hey,

    I don't really understand how these work and if you can create your own. If anyone can explain this to me or link a tutorial that would be amazing!

    Thank you for your time.
    - Creatos
     
  2. Code (Text):
    #The player in this context
    Player player;

    #The message in which the variable %player% is defined
    String message = "Hello %player%";

    #message.replace(String, String) replaces all occurences of the first argument with the second.
    message = message.replace("%player%", player.getName());

    player.sendMessage(message);
     
  3. For premium resources, when a player downloads a plugin, hardcoded strings like "%%__USER__%%" are replaced with the values they're supposed to be replaced with. These don't work with non-premium plugins or plugins which were not downloaded on spigot