ClassInfo.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.base;
  16. import java.util.regex.Matcher;
  17. /**
  18. * This class will hold the information of the player classes.
  19. * @author Zoey76
  20. */
  21. public final class ClassInfo
  22. {
  23. private final ClassId _classId;
  24. private final String _className;
  25. private final String _classServName;
  26. private final ClassId _parentClassId;
  27. /**
  28. * Constructor for ClassInfo.
  29. * @param classId the class Id.
  30. * @param className the in game class name.
  31. * @param classServName the server side class name.
  32. * @param parentClassId the parent class for the given {@code classId}.
  33. */
  34. public ClassInfo(ClassId classId, String className, String classServName, ClassId parentClassId)
  35. {
  36. _classId = classId;
  37. _className = className;
  38. _classServName = classServName;
  39. _parentClassId = parentClassId;
  40. }
  41. /**
  42. * @return the class Id.
  43. */
  44. public ClassId getClassId()
  45. {
  46. return _classId;
  47. }
  48. /**
  49. * @return the hardcoded in-game class name.
  50. */
  51. public String getClassName()
  52. {
  53. return _className;
  54. }
  55. /**
  56. * @return the class client Id.
  57. */
  58. private int getClassClientId()
  59. {
  60. int classClientId = _classId.getId();
  61. if ((classClientId >= 0) && (classClientId <= 57))
  62. {
  63. classClientId += 247;
  64. }
  65. else if ((classClientId >= 88) && (classClientId <= 118))
  66. {
  67. classClientId += 1071;
  68. }
  69. else if ((classClientId >= 123) && (classClientId <= 136))
  70. {
  71. classClientId += 1438;
  72. }
  73. return classClientId;
  74. }
  75. /**
  76. * @return the class client Id formatted to be displayed on a HTML.
  77. */
  78. public String getClientCode()
  79. {
  80. return "&$" + getClassClientId() + ";";
  81. }
  82. /**
  83. * @return the escaped class client Id formatted to be displayed on a HTML.
  84. */
  85. public String getEscapedClientCode()
  86. {
  87. return Matcher.quoteReplacement(getClientCode());
  88. }
  89. /**
  90. * @return the server side class name.
  91. */
  92. public String getClassServName()
  93. {
  94. return _classServName;
  95. }
  96. /**
  97. * @return the parent class Id.
  98. */
  99. public ClassId getParentClassId()
  100. {
  101. return _parentClassId;
  102. }
  103. }