ClanPenalty.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack 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 DataPack 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 handlers.usercommandhandlers;
  20. import java.text.SimpleDateFormat;
  21. import com.l2jserver.gameserver.handler.IUserCommandHandler;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  24. import com.l2jserver.util.StringUtil;
  25. /**
  26. * Clan Penalty user command.
  27. * @author Tempy
  28. */
  29. public class ClanPenalty implements IUserCommandHandler
  30. {
  31. private static final int[] COMMAND_IDS =
  32. {
  33. 100
  34. };
  35. @Override
  36. public boolean useUserCommand(int id, L2PcInstance activeChar)
  37. {
  38. if (id != COMMAND_IDS[0])
  39. {
  40. return false;
  41. }
  42. boolean penalty = false;
  43. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  44. final StringBuilder htmlContent = StringUtil.startAppend(500, "<html><body><center><table width=270 border=0 bgcolor=111111><tr><td width=170>Penalty</td><td width=100 align=center>Expiration Date</td></tr></table><table width=270 border=0><tr>");
  45. if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
  46. {
  47. StringUtil.append(htmlContent, "<td width=170>Unable to join a clan.</td><td width=100 align=center>", format.format(activeChar.getClanJoinExpiryTime()), "</td>");
  48. penalty = true;
  49. }
  50. if (activeChar.getClanCreateExpiryTime() > System.currentTimeMillis())
  51. {
  52. StringUtil.append(htmlContent, "<td width=170>Unable to create a clan.</td><td width=100 align=center>", format.format(activeChar.getClanCreateExpiryTime()), "</td>");
  53. penalty = true;
  54. }
  55. if ((activeChar.getClan() != null) && (activeChar.getClan().getCharPenaltyExpiryTime() > System.currentTimeMillis()))
  56. {
  57. StringUtil.append(htmlContent, "<td width=170>Unable to invite a clan member.</td><td width=100 align=center>", format.format(activeChar.getClan().getCharPenaltyExpiryTime()), "</td>");
  58. penalty = true;
  59. }
  60. if (!penalty)
  61. {
  62. htmlContent.append("<td width=170>No penalty is imposed.</td><td width=100 align=center></td>");
  63. }
  64. htmlContent.append("</tr></table><img src=\"L2UI.SquareWhite\" width=270 height=1></center></body></html>");
  65. final NpcHtmlMessage penaltyHtml = new NpcHtmlMessage();
  66. penaltyHtml.setHtml(htmlContent.toString());
  67. activeChar.sendPacket(penaltyHtml);
  68. return true;
  69. }
  70. @Override
  71. public int[] getUserCommandList()
  72. {
  73. return COMMAND_IDS;
  74. }
  75. }