Advertisement
MrKirill1232

npc.java

Sep 19th, 2021 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. Index: java/org/l2jmobius/gameserver/model/actor/Npc.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. diff --git a/java/org/l2jmobius/gameserver/model/actor/Npc.java b/java/org/l2jmobius/gameserver/model/actor/Npc.java
  7. --- a/java/org/l2jmobius/gameserver/model/actor/Npc.java
  8. +++ b/java/org/l2jmobius/gameserver/model/actor/Npc.java (date 1632068486809)
  9. @@ -689,7 +689,7 @@
  10. {
  11. pom = npcId + "-" + value;
  12. }
  13. -
  14. +
  15. final String temp = "data/html/default/" + pom + ".htm";
  16. if (!Config.LAZY_CACHE)
  17. {
  18. @@ -703,25 +703,31 @@
  19. {
  20. return temp;
  21. }
  22. -
  23. +
  24. // If the file is not found, the standard message "I have nothing to say to you" is returned
  25. return "data/html/npcdefault.htm";
  26. }
  27. -
  28. +
  29. public void showChatWindow(PlayerInstance player)
  30. {
  31. showChatWindow(player, 0);
  32. }
  33. -
  34. +
  35. /**
  36. * Returns true if html exists
  37. * @param player
  38. * @param type
  39. * @return boolean
  40. */
  41. - private boolean showPkDenyChatWindow(PlayerInstance player, String type)
  42. + private boolean showPkDenyChatWindow(int value, PlayerInstance player, String type)
  43. {
  44. - String html = HtmCache.getInstance().getHtm(player, "data/html/" + type + "/" + getId() + "-pk.htm");
  45. + String pom = "";
  46. + if (value == 0) {
  47. + pom = "";
  48. + } else {
  49. + pom = "-" + value;
  50. + }
  51. + String html = HtmCache.getInstance().getHtm(player, "data/html/" + type + "/" + getId() + "-pk" + pom + ".htm");
  52. if (html != null)
  53. {
  54. html = html.replace("%objectId%", String.valueOf(getObjectId()));
  55. @@ -731,7 +737,7 @@
  56. }
  57. return false;
  58. }
  59. -
  60. +
  61. /**
  62. * Open a chat window on client with the text of the NpcInstance.<br>
  63. * <br>
  64. @@ -746,51 +752,19 @@
  65. */
  66. public void showChatWindow(PlayerInstance player, int value)
  67. {
  68. + final int npcId = getTemplate().getId();
  69. if (!_isTalkable)
  70. {
  71. player.sendPacket(ActionFailed.STATIC_PACKET);
  72. return;
  73. }
  74. -
  75. - if (player.getReputation() < 0)
  76. - {
  77. - if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (this instanceof MerchantInstance))
  78. - {
  79. - if (showPkDenyChatWindow(player, "merchant"))
  80. - {
  81. - return;
  82. - }
  83. - }
  84. - else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_GK && (this instanceof TeleporterInstance))
  85. - {
  86. - if (showPkDenyChatWindow(player, "teleporter"))
  87. - {
  88. - return;
  89. - }
  90. - }
  91. - else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && (this instanceof WarehouseInstance))
  92. - {
  93. - if (showPkDenyChatWindow(player, "warehouse"))
  94. - {
  95. - return;
  96. - }
  97. - }
  98. - else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (this instanceof FishermanInstance))
  99. - {
  100. - if (showPkDenyChatWindow(player, "fisherman"))
  101. - {
  102. - return;
  103. - }
  104. - }
  105. - }
  106. -
  107. +
  108. if (getTemplate().isType("Auctioneer") && (value == 0))
  109. {
  110. return;
  111. }
  112. -
  113. - final int npcId = getTemplate().getId();
  114. - String filename;
  115. +
  116. + String filename = "";
  117. switch (npcId)
  118. {
  119. case 31688:
  120. @@ -839,19 +813,51 @@
  121. {
  122. return;
  123. }
  124. - // Get the text of the selected HTML file in function of the npcId and of the page number
  125. - filename = (getHtmlPath(npcId, value, player));
  126. + else if (player.getReputation() < 0 && ((this instanceof MerchantInstance) ||
  127. + (this instanceof TeleporterInstance) ||
  128. + (this instanceof WarehouseInstance) ||
  129. + (this instanceof FishermanInstance)))
  130. + {
  131. + try {
  132. + if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (this instanceof MerchantInstance)) {
  133. + if (showPkDenyChatWindow(value, player, "merchant")) {
  134. + return;
  135. + }
  136. + } else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_GK && (this instanceof TeleporterInstance)) {
  137. + if (showPkDenyChatWindow(value, player, "teleporter")) {
  138. + return;
  139. + }
  140. + } else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && (this instanceof WarehouseInstance)) {
  141. + if (showPkDenyChatWindow(value, player, "warehouse")) {
  142. + return;
  143. + }
  144. + } else if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (this instanceof FishermanInstance)) {
  145. + if (showPkDenyChatWindow(value, player, "fisherman")) {
  146. + return;
  147. + }
  148. + }
  149. + } catch (Exception e) {
  150. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage (0);
  151. + npcHtmlMessage.setHtml("<html><body>My Text is missing:<br>" + getHtmlPath(npcId, value, player) + "</body></html>");
  152. + player.sendPacket(npcHtmlMessage);
  153. + }
  154. + }
  155. + else
  156. + {
  157. + // Get the text of the selected HTML file in function of the npcId and of the page number
  158. + filename = (getHtmlPath(npcId, value, player));
  159. + }
  160. break;
  161. }
  162. }
  163. -
  164. +
  165. // Send a Server->Client NpcHtmlMessage containing the text of the NpcInstance to the PlayerInstance
  166. final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  167. html.setFile(player, filename);
  168. html.replace("%npcname%", getName());
  169. html.replace("%objectId%", String.valueOf(getObjectId()));
  170. player.sendPacket(html);
  171. -
  172. +
  173. // Send a Server->Client ActionFailed to the PlayerInstance in order to avoid that the client wait another packet
  174. player.sendPacket(ActionFailed.STATIC_PACKET);
  175. }
  176.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement