ClanPenalty.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 handlers.usercommandhandlers;
  16. import java.text.SimpleDateFormat;
  17. import com.l2jserver.gameserver.handler.IUserCommandHandler;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  20. import com.l2jserver.util.StringUtil;
  21. /**
  22. * Support for clan penalty user command.
  23. * @author Tempy
  24. */
  25. public class ClanPenalty implements IUserCommandHandler
  26. {
  27. private static final int[] COMMAND_IDS =
  28. {
  29. 100
  30. };
  31. /**
  32. *
  33. * @see com.l2jserver.gameserver.handler.IUserCommandHandler#useUserCommand(int, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
  34. */
  35. public boolean useUserCommand(int id, L2PcInstance activeChar)
  36. {
  37. if (id != COMMAND_IDS[0])
  38. return false;
  39. boolean penalty = false;
  40. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  41. final StringBuilder htmlContent = StringUtil.startAppend(500,
  42. "<html><body>" +
  43. "<center><table width=270 border=0 bgcolor=111111>" +
  44. "<tr><td width=170>Penalty</td>" +
  45. "<td width=100 align=center>Expiration Date</td></tr>" +
  46. "</table><table width=270 border=0><tr>"
  47. );
  48. if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis()) {
  49. StringUtil.append(htmlContent,
  50. "<td width=170>Unable to join a clan.</td>" +
  51. "<td width=100 align=center>",
  52. format.format(activeChar.getClanJoinExpiryTime()),
  53. "</td>"
  54. );
  55. penalty = true;
  56. }
  57. if (activeChar.getClanCreateExpiryTime() > System.currentTimeMillis()) {
  58. StringUtil.append(htmlContent,
  59. "<td width=170>Unable to create a clan.</td>" +
  60. "<td width=100 align=center>",
  61. format.format(activeChar.getClanCreateExpiryTime()),
  62. "</td>"
  63. );
  64. penalty = true;
  65. }
  66. if (activeChar.getClan() != null && activeChar.getClan().getCharPenaltyExpiryTime() > System.currentTimeMillis()) {
  67. StringUtil.append(htmlContent,
  68. "<td width=170>Unable to invite a clan member.</td>" +
  69. "<td width=100 align=center>",
  70. format.format(activeChar.getClan().getCharPenaltyExpiryTime()),
  71. "</td>"
  72. );
  73. penalty = true;
  74. }
  75. if (!penalty) {
  76. htmlContent.append(
  77. "<td width=170>No penalty is imposed.</td>" +
  78. "<td width=100 align=center> </td>");
  79. }
  80. htmlContent.append(
  81. "</tr></table><img src=\"L2UI.SquareWhite\" width=270 height=1>" +
  82. "</center></body></html>");
  83. NpcHtmlMessage penaltyHtml = new NpcHtmlMessage(0);
  84. penaltyHtml.setHtml(htmlContent.toString());
  85. activeChar.sendPacket(penaltyHtml);
  86. return true;
  87. }
  88. /**
  89. *
  90. * @see com.l2jserver.gameserver.handler.IUserCommandHandler#getUserCommandList()
  91. */
  92. public int[] getUserCommandList()
  93. {
  94. return COMMAND_IDS;
  95. }
  96. }