ClassInfo.java 2.8 KB

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