Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public synchronized void store()
- {
- store(false);
- }
- public synchronized void store(boolean items)
- {
- _log.warn("Store");
- Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- if (_jailTask != null)
- {
- long delay = _jailTask.getDelay(TimeUnit.MILLISECONDS);
- if (delay < 0)
- delay = 0;
- setJailTimer(delay);
- }
- try
- {
- storeCharBase(con);
- }
- catch(Exception e)
- {
- _log.error("L2PcInstance: Error saving character "+getName()+", bugload possible",e);
- e.printStackTrace();
- }
- try
- {
- storeCharSub(con);
- }
- catch(Exception e)
- {
- _log.error("L2PcInstance: Error saving character "+getName()+" subclasses, not fatal",e);
- }
- try
- {
- storeRecipeBook(con);
- }
- catch(Exception e)
- {
- _log.error("L2PcInstance: Error saving character "+getName()+" recipies, not fatal",e);
- }
- try
- {
- saveSettingInDb(con);
- }
- catch(Exception e)
- {
- _log.error("L2PcInstance: Error saving character "+getName()+" settings, not fatal",e);
- }
- if (items)
- {
- getInventory().updateDatabase();
- if(_warehouse!=null)
- _warehouse.updateDatabase();
- if(_freight!=null)
- _freight.updateDatabase();
- SQLQueue.getInstance().run();
- }
- }
- catch(SQLException e)
- {
- _log.error("L2PcInstance: Connection to DB lost",e);
- }
- finally
- {
- if(con!=null)
- try
- {
- con.close();
- }
- catch(SQLException e)
- {}
- }
- }
- private ScheduledFuture<?> _autoSaveTask;
- private class AutoSave implements Runnable
- {
- public void run()
- {
- store();
- }
- }
- public void startAutoSave()
- {
- if (Config.CHAR_STORE_INTERVAL > 0)
- {
- long delay = Config.CHAR_STORE_INTERVAL * 60000L;
- if (_autoSaveTask == null)
- _autoSaveTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoSave(), delay, delay);
- }
- }
- public void stopAutoSave()
- {
- if (_autoSaveTask != null)
- {
- _autoSaveTask.cancel(false);
- _autoSaveTask = null;
- }
- }
- }
Add Comment
Please, Sign In to add comment