ClassInfo.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /**
  17. * This class will hold the information of the player classes.
  18. * @author Zoey76
  19. */
  20. public final class ClassInfo
  21. {
  22. private final ClassId _classId;
  23. private final String _className;
  24. private final String _classServName;
  25. private final ClassId _parentClassId;
  26. /**
  27. * Constructor for ClassInfo.
  28. * @param classId the class Id.
  29. * @param className the in game class name.
  30. * @param classServName the server side class name.
  31. * @param parentClassId the parent class for the given {@code classId}.
  32. */
  33. public ClassInfo(ClassId classId, String className, String classServName, ClassId parentClassId)
  34. {
  35. _classId = classId;
  36. _className = className;
  37. _classServName = classServName;
  38. _parentClassId = parentClassId;
  39. }
  40. /**
  41. * @return the class Id.
  42. */
  43. public ClassId getClassId()
  44. {
  45. return _classId;
  46. }
  47. /**
  48. * @param displayClientName if {@code true} the code to display the client side name will be returned, <b>HTMLs only</b>.
  49. * @return the in-game class name.
  50. */
  51. public String getClassName(boolean displayClientName)
  52. {
  53. return displayClientName ? getClassClientCode() : _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. private String getClassClientCode()
  79. {
  80. return "&$" + getClassClientId() + ";";
  81. }
  82. /**
  83. * @return the server side class name.
  84. */
  85. public String getClassServName()
  86. {
  87. return _classServName;
  88. }
  89. /**
  90. * @return the parent class Id.
  91. */
  92. public ClassId getParentClassId()
  93. {
  94. return _parentClassId;
  95. }
  96. }