IllegalPlayerAction.java 3.5 KB

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