Advertisement
gegy1000

Untitled

Aug 1st, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package net.timeless.jurassicraft.common.lang;
  2.  
  3. import net.minecraft.util.StatCollector;
  4.  
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import java.util.Map.Entry;
  8. import java.util.regex.Pattern;
  9.  
  10. public class AdvLang
  11. {
  12. private String langPath;
  13. private Map<String, String> properties = new HashMap<>();
  14.  
  15. public AdvLang(String langPath)
  16. {
  17. this.langPath = langPath;
  18. }
  19.  
  20. public AdvLang withProperty(String propertyName, String value)
  21. {
  22. properties.put(propertyName, StatCollector.translateToLocal(value));
  23.  
  24. return this;
  25. }
  26.  
  27. public String build()
  28. {
  29. String translation = StatCollector.translateToLocal(langPath);
  30.  
  31. for (Entry<String, String> property : properties.entrySet())
  32. {
  33. translation = translation.replaceAll(Pattern.quote("{" + property.getKey() + "}"), property.getValue());
  34. }
  35.  
  36. return translation;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement