ClassInfo.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2004-2015 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 ClassId _parentClassId;
  30. /**
  31. * Constructor for ClassInfo.
  32. * @param classId the class ID
  33. * @param className the in game class name
  34. * @param parentClassId the parent class for the given {@code classId}
  35. */
  36. public ClassInfo(ClassId classId, String className, ClassId parentClassId)
  37. {
  38. _classId = classId;
  39. _className = className;
  40. _parentClassId = parentClassId;
  41. }
  42. /**
  43. * @return the class ID
  44. */
  45. public ClassId getClassId()
  46. {
  47. return _classId;
  48. }
  49. /**
  50. * @return the hardcoded in-game class name
  51. */
  52. public String getClassName()
  53. {
  54. return _className;
  55. }
  56. /**
  57. * @return the class client ID
  58. */
  59. private int getClassClientId()
  60. {
  61. int classClientId = _classId.getId();
  62. if ((classClientId >= 0) && (classClientId <= 57))
  63. {
  64. classClientId += 247;
  65. }
  66. else if ((classClientId >= 88) && (classClientId <= 118))
  67. {
  68. classClientId += 1071;
  69. }
  70. else if ((classClientId >= 123) && (classClientId <= 136))
  71. {
  72. classClientId += 1438;
  73. }
  74. return classClientId;
  75. }
  76. /**
  77. * @return the class client ID formatted to be displayed on a HTML.
  78. */
  79. public String getClientCode()
  80. {
  81. return "&$" + getClassClientId() + ";";
  82. }
  83. /**
  84. * @return the escaped class client ID formatted to be displayed on a HTML
  85. */
  86. public String getEscapedClientCode()
  87. {
  88. return Matcher.quoteReplacement(getClientCode());
  89. }
  90. /**
  91. * @return the parent class ID
  92. */
  93. public ClassId getParentClassId()
  94. {
  95. return _parentClassId;
  96. }
  97. }