ClanPenalty.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. @Override
  32. public boolean useUserCommand(int id, L2PcInstance activeChar)
  33. {
  34. if (id != COMMAND_IDS[0])
  35. return false;
  36. boolean penalty = false;
  37. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  38. final StringBuilder htmlContent = StringUtil.startAppend(500,
  39. "<html><body>" +
  40. "<center><table width=270 border=0 bgcolor=111111>" +
  41. "<tr><td width=170>Penalty</td>" +
  42. "<td width=100 align=center>Expiration Date</td></tr>" +
  43. "</table><table width=270 border=0><tr>"
  44. );
  45. if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis()) {
  46. StringUtil.append(htmlContent,
  47. "<td width=170>Unable to join a clan.</td>" +
  48. "<td width=100 align=center>",
  49. format.format(activeChar.getClanJoinExpiryTime()),
  50. "</td>"
  51. );
  52. penalty = true;
  53. }
  54. if (activeChar.getClanCreateExpiryTime() > System.currentTimeMillis()) {
  55. StringUtil.append(htmlContent,
  56. "<td width=170>Unable to create a clan.</td>" +
  57. "<td width=100 align=center>",
  58. format.format(activeChar.getClanCreateExpiryTime()),
  59. "</td>"
  60. );
  61. penalty = true;
  62. }
  63. if (activeChar.getClan() != null && activeChar.getClan().getCharPenaltyExpiryTime() > System.currentTimeMillis()) {
  64. StringUtil.append(htmlContent,
  65. "<td width=170>Unable to invite a clan member.</td>" +
  66. "<td width=100 align=center>",
  67. format.format(activeChar.getClan().getCharPenaltyExpiryTime()),
  68. "</td>"
  69. );
  70. penalty = true;
  71. }
  72. if (!penalty) {
  73. htmlContent.append(
  74. "<td width=170>No penalty is imposed.</td>" +
  75. "<td width=100 align=center> </td>");
  76. }
  77. htmlContent.append(
  78. "</tr></table><img src=\"L2UI.SquareWhite\" width=270 height=1>" +
  79. "</center></body></html>");
  80. NpcHtmlMessage penaltyHtml = new NpcHtmlMessage(0);
  81. penaltyHtml.setHtml(htmlContent.toString());
  82. activeChar.sendPacket(penaltyHtml);
  83. return true;
  84. }
  85. @Override
  86. public int[] getUserCommandList()
  87. {
  88. return COMMAND_IDS;
  89. }
  90. }