/Client/src/net/minecraft/src/ChatClickData.java

http://phantom-labs-mc.googlecode.com/ · Java · 79 lines · 65 code · 14 blank · 0 comment · 5 complexity · 9da2ea6e257197fa6f63f800157ad5d4 MD5 · raw file

  1. package net.minecraft.src;
  2. import java.net.URI;
  3. import java.net.URISyntaxException;
  4. import java.util.logging.Level;
  5. import java.util.logging.Logger;
  6. import java.util.regex.Matcher;
  7. import java.util.regex.Pattern;
  8. public class ChatClickData
  9. {
  10. public static final Pattern field_50097_a = Pattern.compile("^(?:(https?)://)?([\\w-_\\.]{2,}\\.[a-z]{2,3})(/\\S+)?$");
  11. private final FontRenderer field_50095_b;
  12. private final ChatLine field_50096_c;
  13. private final int field_50093_d;
  14. private final int field_50094_e;
  15. private final String field_50091_f;
  16. private final String field_50092_g = func_50090_c();
  17. public ChatClickData(FontRenderer par1FontRenderer, ChatLine par2ChatLine, int par3, int par4)
  18. {
  19. field_50095_b = par1FontRenderer;
  20. field_50096_c = par2ChatLine;
  21. field_50093_d = par3;
  22. field_50094_e = par4;
  23. field_50091_f = par1FontRenderer.func_50107_a(par2ChatLine.message, par3);
  24. }
  25. public String func_50088_a()
  26. {
  27. return field_50092_g;
  28. }
  29. public URI func_50089_b()
  30. {
  31. URI uri = null;
  32. String s = func_50088_a();
  33. if (s == null)
  34. {
  35. return null;
  36. }
  37. Matcher matcher = field_50097_a.matcher(s);
  38. if (matcher.matches())
  39. {
  40. try
  41. {
  42. uri = new URI(matcher.group(0));
  43. }
  44. catch (URISyntaxException urisyntaxexception)
  45. {
  46. Logger.getLogger("Minecraft").log(Level.SEVERE, "Couldn't create URI from chat", urisyntaxexception);
  47. }
  48. }
  49. return uri;
  50. }
  51. private String func_50090_c()
  52. {
  53. int i = field_50091_f.lastIndexOf(" ", field_50091_f.length()) + 1;
  54. if (i < 0)
  55. {
  56. i = 0;
  57. }
  58. int j = field_50096_c.message.indexOf(" ", i);
  59. if (j < 0)
  60. {
  61. j = field_50096_c.message.length();
  62. }
  63. return field_50096_c.message.substring(i, j);
  64. }
  65. }