IllegalPlayerAction.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2004-2013 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.util;
  20. import java.util.logging.Level;
  21. import java.util.logging.LogRecord;
  22. import java.util.logging.Logger;
  23. import com.l2jserver.Config;
  24. import com.l2jserver.gameserver.datatables.AdminTable;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. /**
  27. * This class ...
  28. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  29. */
  30. public final class IllegalPlayerAction implements Runnable
  31. {
  32. private static Logger _logAudit = Logger.getLogger("audit");
  33. private final String _message;
  34. private final int _punishment;
  35. private final L2PcInstance _actor;
  36. public static final int PUNISH_BROADCAST = 1;
  37. public static final int PUNISH_KICK = 2;
  38. public static final int PUNISH_KICKBAN = 3;
  39. public static final int PUNISH_JAIL = 4;
  40. public IllegalPlayerAction(L2PcInstance actor, String message, int punishment)
  41. {
  42. _message = message;
  43. _punishment = punishment;
  44. _actor = actor;
  45. switch (punishment)
  46. {
  47. case PUNISH_KICK:
  48. _actor.sendMessage("You will be kicked for illegal action, GM informed.");
  49. break;
  50. case PUNISH_KICKBAN:
  51. if (!_actor.isGM())
  52. {
  53. _actor.setAccessLevel(-1);
  54. _actor.setAccountAccesslevel(-1);
  55. }
  56. _actor.sendMessage("You are banned for illegal action, GM informed.");
  57. break;
  58. case PUNISH_JAIL:
  59. _actor.sendMessage("Illegal action performed!");
  60. _actor.sendMessage("You will be teleported to GM Consultation Service area and jailed.");
  61. break;
  62. }
  63. }
  64. @Override
  65. public void run()
  66. {
  67. LogRecord record = new LogRecord(Level.INFO, "AUDIT:" + _message);
  68. record.setLoggerName("audit");
  69. record.setParameters(new Object[]
  70. {
  71. _actor,
  72. _punishment
  73. });
  74. _logAudit.log(record);
  75. AdminTable.getInstance().broadcastMessageToGMs(_message);
  76. if (!_actor.isGM())
  77. {
  78. switch (_punishment)
  79. {
  80. case PUNISH_BROADCAST:
  81. return;
  82. case PUNISH_KICK:
  83. _actor.logout(false);
  84. break;
  85. case PUNISH_KICKBAN:
  86. _actor.logout();
  87. break;
  88. case PUNISH_JAIL:
  89. _actor.setPunishLevel(L2PcInstance.PunishLevel.JAIL, Config.DEFAULT_PUNISH_PARAM);
  90. break;
  91. }
  92. }
  93. }
  94. }