L2GameClient.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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 com.l2jserver.gameserver.network;
  16. import java.net.InetAddress;
  17. import java.nio.ByteBuffer;
  18. import java.sql.Connection;
  19. import java.sql.PreparedStatement;
  20. import java.sql.ResultSet;
  21. import java.util.List;
  22. import java.util.concurrent.RejectedExecutionException;
  23. import java.util.concurrent.ScheduledFuture;
  24. import java.util.concurrent.locks.ReentrantLock;
  25. import java.util.logging.Level;
  26. import java.util.logging.LogRecord;
  27. import java.util.logging.Logger;
  28. import javolution.util.FastList;
  29. import org.mmocore.network.MMOClient;
  30. import org.mmocore.network.MMOConnection;
  31. import com.l2jserver.Config;
  32. import com.l2jserver.L2DatabaseFactory;
  33. import com.l2jserver.gameserver.LoginServerThread;
  34. import com.l2jserver.gameserver.ThreadPoolManager;
  35. import com.l2jserver.gameserver.LoginServerThread.SessionKey;
  36. import com.l2jserver.gameserver.datatables.CharNameTable;
  37. import com.l2jserver.gameserver.datatables.ClanTable;
  38. import com.l2jserver.gameserver.model.CharSelectInfoPackage;
  39. import com.l2jserver.gameserver.model.L2Clan;
  40. import com.l2jserver.gameserver.model.L2World;
  41. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  42. import com.l2jserver.gameserver.model.entity.L2Event;
  43. import com.l2jserver.gameserver.model.entity.TvTEvent;
  44. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  45. import com.l2jserver.gameserver.network.serverpackets.ServerClose;
  46. import com.l2jserver.gameserver.util.Util;
  47. import com.l2jserver.util.EventData;
  48. /**
  49. * Represents a client connected on Game Server
  50. * @author KenM
  51. */
  52. public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
  53. {
  54. protected static final Logger _log = Logger.getLogger(L2GameClient.class.getName());
  55. protected static final Logger _logAccounting = Logger.getLogger("accounting");
  56. /**
  57. * CONNECTED - client has just connected
  58. * AUTHED - client has authed but doesnt has character attached to it yet
  59. * IN_GAME - client has selected a char and is in game
  60. * @author KenM
  61. */
  62. public static enum GameClientState { CONNECTED, AUTHED, IN_GAME }
  63. public GameClientState state;
  64. // Info
  65. private String _accountName;
  66. private SessionKey _sessionId;
  67. private L2PcInstance _activeChar;
  68. private ReentrantLock _activeCharLock = new ReentrantLock();
  69. private boolean _isAuthedGG;
  70. private long _connectionStartTime;
  71. private List<Integer> _charSlotMapping = new FastList<Integer>();
  72. // Task
  73. protected final ScheduledFuture<?> _autoSaveInDB;
  74. protected ScheduledFuture<?> _cleanupTask = null;
  75. // Crypt
  76. private GameCrypt _crypt;
  77. // Flood protection
  78. public byte packetsSentInSec = 0;
  79. public int packetsSentStartTick = 0;
  80. public byte underflowReadsInMin = 0;
  81. public int underflowReadStartTick = 0;
  82. private boolean _isDetached = false;
  83. private boolean _protocol;
  84. public L2GameClient(MMOConnection<L2GameClient> con)
  85. {
  86. super(con);
  87. state = GameClientState.CONNECTED;
  88. _connectionStartTime = System.currentTimeMillis();
  89. _crypt = new GameCrypt();
  90. if (Config.CHAR_STORE_INTERVAL > 0)
  91. {
  92. _autoSaveInDB = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(
  93. new AutoSaveTask(), 300000L, (Config.CHAR_STORE_INTERVAL*60000L)
  94. );
  95. }
  96. else
  97. {
  98. _autoSaveInDB = null;
  99. }
  100. }
  101. public byte[] enableCrypt()
  102. {
  103. byte[] key = BlowFishKeygen.getRandomKey();
  104. _crypt.setKey(key);
  105. return key;
  106. }
  107. public GameClientState getState()
  108. {
  109. return state;
  110. }
  111. public void setState(GameClientState pState)
  112. {
  113. state = pState;
  114. }
  115. public long getConnectionStartTime()
  116. {
  117. return _connectionStartTime;
  118. }
  119. @Override
  120. public boolean decrypt(ByteBuffer buf, int size)
  121. {
  122. _crypt.decrypt(buf.array(), buf.position(), size);
  123. return true;
  124. }
  125. @Override
  126. public boolean encrypt(final ByteBuffer buf, final int size)
  127. {
  128. _crypt.encrypt(buf.array(), buf.position(), size);
  129. buf.position(buf.position() + size);
  130. return true;
  131. }
  132. public L2PcInstance getActiveChar()
  133. {
  134. return _activeChar;
  135. }
  136. public void setActiveChar(L2PcInstance pActiveChar)
  137. {
  138. _activeChar = pActiveChar;
  139. if (_activeChar != null)
  140. {
  141. L2World.getInstance().storeObject(getActiveChar());
  142. }
  143. }
  144. public ReentrantLock getActiveCharLock()
  145. {
  146. return _activeCharLock;
  147. }
  148. public void setGameGuardOk(boolean val)
  149. {
  150. _isAuthedGG = val;
  151. }
  152. public boolean isAuthedGG()
  153. {
  154. return _isAuthedGG;
  155. }
  156. public void setAccountName(String pAccountName)
  157. {
  158. _accountName = pAccountName;
  159. }
  160. public String getAccountName()
  161. {
  162. return _accountName;
  163. }
  164. public void setSessionId(SessionKey sk)
  165. {
  166. _sessionId = sk;
  167. }
  168. public SessionKey getSessionId()
  169. {
  170. return _sessionId;
  171. }
  172. public void sendPacket(L2GameServerPacket gsp)
  173. {
  174. if (_isDetached) return;
  175. // Packets from invisible chars sends only to GMs
  176. if (gsp.isInvisible() && getActiveChar() != null && !getActiveChar().isGM())
  177. return;
  178. getConnection().sendPacket(gsp);
  179. gsp.runImpl();
  180. }
  181. public boolean isDetached()
  182. {
  183. return _isDetached;
  184. }
  185. public void setDetached(boolean b)
  186. {
  187. _isDetached = b;
  188. }
  189. /**
  190. * Method to handle character deletion
  191. *
  192. * @return a byte:
  193. * <li>-1: Error: No char was found for such charslot, caught exception, etc...
  194. * <li> 0: character is not member of any clan, proceed with deletion
  195. * <li> 1: character is member of a clan, but not clan leader
  196. * <li> 2: character is clan leader
  197. */
  198. public byte markToDeleteChar(int charslot)
  199. {
  200. int objid = getObjectIdForSlot(charslot);
  201. if (objid < 0)
  202. return -1;
  203. Connection con = null;
  204. try
  205. {
  206. con = L2DatabaseFactory.getInstance().getConnection();
  207. PreparedStatement statement = con.prepareStatement("SELECT clanId FROM characters WHERE charId=?");
  208. statement.setInt(1, objid);
  209. ResultSet rs = statement.executeQuery();
  210. rs.next();
  211. int clanId = rs.getInt(1);
  212. byte answer = 0;
  213. if (clanId != 0)
  214. {
  215. L2Clan clan = ClanTable.getInstance().getClan(clanId);
  216. if (clan == null)
  217. answer = 0; // jeezes!
  218. else if (clan.getLeaderId() == objid)
  219. answer = 2;
  220. else
  221. answer = 1;
  222. }
  223. rs.close();
  224. statement.close();
  225. // Setting delete time
  226. if (answer == 0)
  227. {
  228. if (Config.DELETE_DAYS == 0)
  229. deleteCharByObjId(objid);
  230. else
  231. {
  232. statement = con.prepareStatement("UPDATE characters SET deletetime=? WHERE charId=?");
  233. statement.setLong(1, System.currentTimeMillis() + Config.DELETE_DAYS*86400000L); // 24*60*60*1000 = 86400000
  234. statement.setInt(2, objid);
  235. statement.execute();
  236. statement.close();
  237. }
  238. LogRecord record = new LogRecord(Level.WARNING, "Delete");
  239. record.setParameters(new Object[]{objid, L2GameClient.this});
  240. _logAccounting.log(record);
  241. }
  242. return answer;
  243. }
  244. catch (Exception e)
  245. {
  246. _log.log(Level.SEVERE, "Error updating delete time of character.", e);
  247. return -1;
  248. }
  249. finally
  250. {
  251. try { con.close(); } catch (Exception e) {}
  252. }
  253. }
  254. /**
  255. * Save the L2PcInstance to the database.
  256. */
  257. public static void saveCharToDisk(L2PcInstance cha, boolean storeItems)
  258. {
  259. try
  260. {
  261. cha.store();
  262. if (Config.UPDATE_ITEMS_ON_CHAR_STORE && storeItems)
  263. {
  264. cha.getInventory().updateDatabase();
  265. cha.getWarehouse().updateDatabase();
  266. }
  267. }
  268. catch (Exception e)
  269. {
  270. _log.log(Level.SEVERE, "Error saving character..", e);
  271. }
  272. }
  273. public void markRestoredChar(int charslot) throws Exception
  274. {
  275. //have to make sure active character must be nulled
  276. /*if (getActiveChar() != null)
  277. {
  278. saveCharToDisk (getActiveChar());
  279. if (Config.DEBUG) _log.fine("active Char saved");
  280. this.setActiveChar(null);
  281. }*/
  282. int objid = getObjectIdForSlot(charslot);
  283. if (objid < 0)
  284. return;
  285. Connection con = null;
  286. try
  287. {
  288. con = L2DatabaseFactory.getInstance().getConnection();
  289. PreparedStatement statement = con.prepareStatement("UPDATE characters SET deletetime=0 WHERE charId=?");
  290. statement.setInt(1, objid);
  291. statement.execute();
  292. statement.close();
  293. }
  294. catch (Exception e)
  295. {
  296. _log.log(Level.SEVERE, "Error restoring character.", e);
  297. }
  298. finally
  299. {
  300. try { con.close(); } catch (Exception e) {}
  301. }
  302. LogRecord record = new LogRecord(Level.WARNING, "Restore");
  303. record.setParameters(new Object[]{objid, L2GameClient.this});
  304. _logAccounting.log(record);
  305. }
  306. public static void deleteCharByObjId(int objid)
  307. {
  308. if (objid < 0)
  309. return;
  310. CharNameTable.getInstance().removeName(objid);
  311. Connection con = null;
  312. try
  313. {
  314. con = L2DatabaseFactory.getInstance().getConnection();
  315. PreparedStatement statement ;
  316. statement = con.prepareStatement("DELETE FROM character_friends WHERE charId=? OR friendId=?");
  317. statement.setInt(1, objid);
  318. statement.setInt(2, objid);
  319. statement.execute();
  320. statement.close();
  321. statement = con.prepareStatement("DELETE FROM character_hennas WHERE charId=?");
  322. statement.setInt(1, objid);
  323. statement.execute();
  324. statement.close();
  325. statement = con.prepareStatement("DELETE FROM character_macroses WHERE charId=?");
  326. statement.setInt(1, objid);
  327. statement.execute();
  328. statement.close();
  329. statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=?");
  330. statement.setInt(1, objid);
  331. statement.execute();
  332. statement.close();
  333. statement = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId=?");
  334. statement.setInt(1, objid);
  335. statement.executeUpdate();
  336. statement.close();
  337. statement = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=?");
  338. statement.setInt(1, objid);
  339. statement.execute();
  340. statement.close();
  341. statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
  342. statement.setInt(1, objid);
  343. statement.execute();
  344. statement.close();
  345. statement = con.prepareStatement("DELETE FROM character_skills WHERE charId=?");
  346. statement.setInt(1, objid);
  347. statement.execute();
  348. statement.close();
  349. statement = con.prepareStatement("DELETE FROM character_skills_save WHERE charId=?");
  350. statement.setInt(1, objid);
  351. statement.execute();
  352. statement.close();
  353. statement = con.prepareStatement("DELETE FROM character_subclasses WHERE charId=?");
  354. statement.setInt(1, objid);
  355. statement.execute();
  356. statement.close();
  357. statement = con.prepareStatement("DELETE FROM heroes WHERE charId=?");
  358. statement.setInt(1, objid);
  359. statement.execute();
  360. statement.close();
  361. statement = con.prepareStatement("DELETE FROM olympiad_nobles WHERE charId=?");
  362. statement.setInt(1, objid);
  363. statement.execute();
  364. statement.close();
  365. statement = con.prepareStatement("DELETE FROM seven_signs WHERE charId=?");
  366. statement.setInt(1, objid);
  367. statement.execute();
  368. statement.close();
  369. statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id IN (SELECT object_id FROM items WHERE items.owner_id=?)");
  370. statement.setInt(1, objid);
  371. statement.execute();
  372. statement.close();
  373. statement = con.prepareStatement("DELETE FROM item_attributes WHERE itemId IN (SELECT object_id FROM items WHERE items.owner_id=?)");
  374. statement.setInt(1, objid);
  375. statement.execute();
  376. statement.close();
  377. statement = con.prepareStatement("DELETE FROM items WHERE owner_id=?");
  378. statement.setInt(1, objid);
  379. statement.execute();
  380. statement.close();
  381. statement = con.prepareStatement("DELETE FROM merchant_lease WHERE player_id=?");
  382. statement.setInt(1, objid);
  383. statement.execute();
  384. statement.close();
  385. statement = con.prepareStatement("DELETE FROM character_raid_points WHERE charId=?");
  386. statement.setInt(1, objid);
  387. statement.execute();
  388. statement.close();
  389. statement = con.prepareStatement("DELETE FROM character_recommends WHERE charId=? OR target_id=?");
  390. statement.setInt(1, objid);
  391. statement.setInt(2, objid);
  392. statement.execute();
  393. statement.close();
  394. statement = con.prepareStatement("DELETE FROM character_instance_time WHERE charId=?");
  395. statement.setInt(1, objid);
  396. statement.execute();
  397. statement.close();
  398. statement = con.prepareStatement("DELETE FROM characters WHERE charId=?");
  399. statement.setInt(1, objid);
  400. statement.execute();
  401. statement.close();
  402. }
  403. catch (Exception e)
  404. {
  405. _log.log(Level.SEVERE, "Error deleting character.", e);
  406. }
  407. finally
  408. {
  409. try { con.close(); } catch (Exception e) {}
  410. }
  411. }
  412. public L2PcInstance loadCharFromDisk(int charslot)
  413. {
  414. L2PcInstance character = L2PcInstance.load(getObjectIdForSlot(charslot));
  415. if (character != null)
  416. {
  417. // preinit some values for each login
  418. character.setRunning(); // running is default
  419. character.standUp(); // standing is default
  420. character.refreshOverloaded();
  421. character.refreshExpertisePenalty();
  422. character.setOnlineStatus(true);
  423. }
  424. else
  425. {
  426. _log.severe("could not restore in slot: "+ charslot);
  427. }
  428. //setCharacter(character);
  429. return character;
  430. }
  431. /**
  432. * @param chars
  433. */
  434. public void setCharSelection(CharSelectInfoPackage[] chars)
  435. {
  436. _charSlotMapping.clear();
  437. for (int i = 0; i < chars.length; i++)
  438. {
  439. int objectId = chars[i].getObjectId();
  440. _charSlotMapping.add(Integer.valueOf(objectId));
  441. }
  442. }
  443. public void close(L2GameServerPacket gsp)
  444. {
  445. getConnection().close(gsp);
  446. }
  447. /**
  448. * @param charslot
  449. * @return
  450. */
  451. private int getObjectIdForSlot(int charslot)
  452. {
  453. if (charslot < 0 || charslot >= _charSlotMapping.size())
  454. {
  455. _log.warning(toString()+" tried to delete Character in slot "+charslot+" but no characters exits at that slot.");
  456. return -1;
  457. }
  458. Integer objectId = _charSlotMapping.get(charslot);
  459. return objectId.intValue();
  460. }
  461. @Override
  462. protected void onForcedDisconnection()
  463. {
  464. LogRecord record = new LogRecord(Level.WARNING, "Disconnected abnormally");
  465. record.setParameters(new Object[]{L2GameClient.this});
  466. _logAccounting.log(record);
  467. }
  468. @Override
  469. protected void onDisconnection()
  470. {
  471. // no long running tasks here, do it async
  472. try
  473. {
  474. ThreadPoolManager.getInstance().executeTask(new DisconnectTask());
  475. }
  476. catch (RejectedExecutionException e)
  477. {
  478. // server is closing
  479. }
  480. }
  481. public void closeNow()
  482. {
  483. super.getConnection().close(ServerClose.STATIC_PACKET);
  484. cleanMe(true);
  485. }
  486. /**
  487. * Produces the best possible string representation of this client.
  488. */
  489. @Override
  490. public String toString()
  491. {
  492. try
  493. {
  494. InetAddress address = getConnection().getInetAddress();
  495. switch (getState())
  496. {
  497. case CONNECTED:
  498. return "[IP: "+(address == null ? "disconnected" : address.getHostAddress())+"]";
  499. case AUTHED:
  500. return "[Account: "+getAccountName()+" - IP: "+(address == null ? "disconnected" : address.getHostAddress())+"]";
  501. case IN_GAME:
  502. return "[Character: "+(getActiveChar() == null ? "disconnected" : getActiveChar().getName())+" - Account: "+getAccountName()+" - IP: "+(address == null ? "disconnected" : address.getHostAddress())+"]";
  503. default:
  504. throw new IllegalStateException("Missing state on switch");
  505. }
  506. }
  507. catch (NullPointerException e)
  508. {
  509. return "[Character read failed due to disconnect]";
  510. }
  511. }
  512. class DisconnectTask implements Runnable
  513. {
  514. /**
  515. * @see java.lang.Runnable#run()
  516. */
  517. public void run()
  518. {
  519. boolean fast = true;
  520. try
  521. {
  522. final L2PcInstance player = L2GameClient.this.getActiveChar();
  523. if (player != null && !isDetached())
  524. {
  525. setDetached(true);
  526. if (!player.isInOlympiadMode()
  527. && !player.isFestivalParticipant()
  528. && !TvTEvent.isPlayerParticipant(player.getObjectId()) && !player.isInJail())
  529. {
  530. if ((player.isInStoreMode() && Config.OFFLINE_TRADE_ENABLE)
  531. || (player.isInCraftMode() && Config.OFFLINE_CRAFT_ENABLE))
  532. {
  533. player.leaveParty();
  534. if (Config.OFFLINE_SET_NAME_COLOR)
  535. {
  536. player.getAppearance().setNameColor(Config.OFFLINE_NAME_COLOR);
  537. player.broadcastUserInfo();
  538. }
  539. LogRecord record = new LogRecord(Level.INFO, "Entering offline mode");
  540. record.setParameters(new Object[]{L2GameClient.this});
  541. _logAccounting.log(record);
  542. return;
  543. }
  544. }
  545. if (player.isInCombat() || player.isLocked())
  546. {
  547. fast = false;
  548. }
  549. }
  550. cleanMe(fast);
  551. }
  552. catch (Exception e1)
  553. {
  554. _log.log(Level.WARNING, "Error while disconnecting client.", e1);
  555. }
  556. }
  557. }
  558. public void cleanMe(boolean fast)
  559. {
  560. try
  561. {
  562. synchronized(this)
  563. {
  564. if (_cleanupTask == null)
  565. {
  566. _cleanupTask = ThreadPoolManager.getInstance().scheduleGeneral(new CleanupTask(), fast ? 5 : 15000L);
  567. }
  568. }
  569. }
  570. catch (Exception e1)
  571. {
  572. _log.log(Level.WARNING, "Error during cleanup.", e1);
  573. }
  574. }
  575. class CleanupTask implements Runnable
  576. {
  577. /**
  578. * @see java.lang.Runnable#run()
  579. */
  580. public void run()
  581. {
  582. try
  583. {
  584. // we are going to manually save the char bellow thus we can force the cancel
  585. if (_autoSaveInDB != null)
  586. {
  587. _autoSaveInDB.cancel(true);
  588. ThreadPoolManager.getInstance().removeGeneral((Runnable) _autoSaveInDB);
  589. }
  590. L2PcInstance player = L2GameClient.this.getActiveChar();
  591. if (player != null) // this should only happen on connection loss
  592. {
  593. if (player.isLocked())
  594. {
  595. _log.log(Level.WARNING, "Player "+player.getName()+" still performing subclass actions during disconnect.");
  596. }
  597. // we store all data from players who are disconnected while in an event in order to restore it in the next login
  598. if (player.atEvent)
  599. {
  600. EventData data = new EventData(player.eventX, player.eventY, player.eventZ, player.eventkarma, player.eventpvpkills, player.eventpkkills, player.eventTitle, player.kills,
  601. player.eventSitForced);
  602. L2Event.connectionLossData.put(player.getName(), data);
  603. }
  604. // to prevent call cleanMe() again
  605. setDetached(false);
  606. player.logout();
  607. player.setClient(null);
  608. }
  609. L2GameClient.this.setActiveChar(null);
  610. }
  611. catch (Exception e1)
  612. {
  613. _log.log(Level.WARNING, "Error while cleanup client.", e1);
  614. }
  615. finally
  616. {
  617. LoginServerThread.getInstance().sendLogout(L2GameClient.this.getAccountName());
  618. }
  619. }
  620. }
  621. class AutoSaveTask implements Runnable
  622. {
  623. public void run()
  624. {
  625. try
  626. {
  627. L2PcInstance player = L2GameClient.this.getActiveChar();
  628. if (player != null && player.isOnline() > 0) // safety precaution
  629. {
  630. saveCharToDisk(player, true);
  631. if (player.getPet() != null)
  632. player.getPet().store();
  633. }
  634. }
  635. catch (Exception e)
  636. {
  637. _log.log(Level.SEVERE, "Error on AutoSaveTask.", e);
  638. }
  639. }
  640. }
  641. public boolean isProtocolOk()
  642. {
  643. return _protocol;
  644. }
  645. public void setProtocolOk(boolean b)
  646. {
  647. _protocol = b;
  648. }
  649. public boolean handleCheat(String punishment)
  650. {
  651. if (_activeChar != null)
  652. {
  653. Util.handleIllegalPlayerAction(_activeChar, toString()+": "+punishment, Config.DEFAULT_PUNISH);
  654. return true;
  655. }
  656. Logger _logAudit = Logger.getLogger("audit");
  657. _logAudit.log(Level.INFO, "AUDIT: Client "+toString()+" kicked for reason: "+punishment);
  658. closeNow();
  659. return false;
  660. }
  661. }