Addition of PlayerAutoSaveTaskManager.
This commit is contained in:
+8
-28
@@ -342,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -805,8 +806,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6769,7 +6768,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8092,32 +8092,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11192,7 +11176,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14030,11 +14015,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -344,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -807,8 +808,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6776,7 +6775,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8099,32 +8099,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11199,7 +11183,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14037,11 +14022,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -346,6 +346,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -809,8 +810,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6778,7 +6777,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8101,32 +8101,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11201,7 +11185,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14040,11 +14025,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -350,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -814,8 +815,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6773,7 +6772,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8096,32 +8096,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11182,7 +11166,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14012,11 +13997,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -348,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -810,8 +811,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6752,7 +6751,8 @@ public class PlayerInstance extends Playable
|
||||
player.startRecoGiveTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8075,32 +8075,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11169,7 +11153,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13974,11 +13959,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -348,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -810,8 +811,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6752,7 +6751,8 @@ public class PlayerInstance extends Playable
|
||||
player.startRecoGiveTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8075,32 +8075,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11172,7 +11156,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13977,11 +13962,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -348,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -810,8 +811,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6753,7 +6752,8 @@ public class PlayerInstance extends Playable
|
||||
player.startRecoGiveTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8076,32 +8076,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11178,7 +11162,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13983,11 +13968,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -355,6 +355,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookC
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -817,8 +818,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6707,7 +6706,8 @@ public class PlayerInstance extends Playable
|
||||
player.startRecoGiveTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8084,32 +8084,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11179,7 +11163,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13991,11 +13976,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -349,6 +349,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -811,8 +812,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6735,7 +6734,8 @@ public class PlayerInstance extends Playable
|
||||
player.startRecoGiveTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8112,32 +8112,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11220,7 +11204,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14032,11 +14017,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+6
-22
@@ -220,6 +220,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradePressOwnOk;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import org.l2jmobius.gameserver.util.IllegalPlayerAction;
|
||||
@@ -521,7 +522,6 @@ public class PlayerInstance extends Playable
|
||||
private final HashMap<Integer, Long> _confirmDlgRequests = new HashMap<>();
|
||||
private int _currentMultiSellId = -1;
|
||||
private int _partyroom = 0;
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S). */
|
||||
private static final int[] EXPERTISE_LEVELS =
|
||||
@@ -8133,7 +8133,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
player.restoreFriendList();
|
||||
|
||||
player.startAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -9409,31 +9409,15 @@ public class PlayerInstance extends Playable
|
||||
return _hennaDEX;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
store();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13612,7 +13596,7 @@ public class PlayerInstance extends Playable
|
||||
// Remove WorldObject object from _allObjects of World
|
||||
World.getInstance().removeObject(this);
|
||||
World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
|
||||
stopAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
private class ShortBuffTask implements Runnable
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+6
-22
@@ -228,6 +228,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradePressOwnOk;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import org.l2jmobius.gameserver.util.IllegalPlayerAction;
|
||||
@@ -535,7 +536,6 @@ public class PlayerInstance extends Playable
|
||||
private final HashMap<Integer, Long> _confirmDlgRequests = new HashMap<>();
|
||||
private int _currentMultiSellId = -1;
|
||||
private int _partyroom = 0;
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S). */
|
||||
private static final int[] EXPERTISE_LEVELS =
|
||||
@@ -8284,7 +8284,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
player.restoreFriendList();
|
||||
|
||||
player.startAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -9566,31 +9566,15 @@ public class PlayerInstance extends Playable
|
||||
return _hennaDEX;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
store();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13934,7 +13918,7 @@ public class PlayerInstance extends Playable
|
||||
// Remove WorldObject object from _allObjects of World
|
||||
World.getInstance().removeObject(this);
|
||||
World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
|
||||
stopAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
private class ShortBuffTask implements Runnable
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+7
-28
@@ -321,6 +321,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -806,8 +807,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile int _actionMask;
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
private Map<Stat, Double> _servitorShare;
|
||||
|
||||
/**
|
||||
@@ -7118,7 +7117,8 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8313,31 +8313,15 @@ public class PlayerInstance extends Playable
|
||||
return _hennaDEX;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11606,7 +11590,7 @@ public class PlayerInstance extends Playable
|
||||
LOGGER.log(Level.WARNING, "Exception on deleteMe() notifyFriends: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
stopAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14441,11 +14425,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+7
-28
@@ -326,6 +326,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -825,8 +826,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile int _actionMask;
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
private Map<Stat, Double> _servitorShare;
|
||||
|
||||
/**
|
||||
@@ -7010,7 +7009,8 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8196,32 +8196,16 @@ public class PlayerInstance extends Playable
|
||||
return _hennaDEX;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations(false);
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11499,7 +11483,7 @@ public class PlayerInstance extends Playable
|
||||
LOGGER.log(Level.WARNING, "Exception on deleteMe() notifyFriends: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
stopAutoSaveTask();
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -14535,11 +14519,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -342,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -800,8 +801,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6725,7 +6724,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7986,32 +7986,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11075,7 +11059,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13786,11 +13771,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -342,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -800,8 +801,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6725,7 +6724,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7986,32 +7986,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11075,7 +11059,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13786,11 +13771,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -340,6 +340,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -798,8 +799,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6711,7 +6710,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7972,32 +7972,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11061,7 +11045,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13771,11 +13756,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -344,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -805,8 +806,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6727,7 +6726,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7999,32 +7999,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11091,7 +11075,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13820,11 +13805,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -344,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -805,8 +806,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6727,7 +6726,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7999,32 +7999,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11091,7 +11075,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13820,11 +13805,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -352,6 +352,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -813,8 +814,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6670,7 +6669,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7943,32 +7943,16 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11023,7 +11007,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13798,11 +13783,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -342,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -802,8 +803,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6727,7 +6726,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -7988,32 +7988,16 @@ public class PlayerInstance extends Playable
|
||||
return isInCategory(CategoryType.SIXTH_CLASS_GROUP);
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11096,7 +11080,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13807,11 +13792,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
+8
-28
@@ -357,6 +357,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -827,8 +828,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private final Fishing _fishing = new Fishing(this);
|
||||
|
||||
private Future<?> _autoSaveTask = null;
|
||||
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
@@ -6744,7 +6743,8 @@ public class PlayerInstance extends Playable
|
||||
player.startOnlineTimeUpdateTask();
|
||||
|
||||
player.setOnlineStatus(true, false);
|
||||
player.startAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().add(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -8022,32 +8022,16 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startAutoSaveTask()
|
||||
{
|
||||
if ((Config.CHAR_DATA_STORE_INTERVAL > 0) && (_autoSaveTask == null))
|
||||
{
|
||||
_autoSaveTask = ThreadPool.scheduleAtFixedRate(this::autoSave, Config.CHAR_DATA_STORE_INTERVAL, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoSaveTask()
|
||||
{
|
||||
if (_autoSaveTask != null)
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoSave()
|
||||
public void autoSave()
|
||||
{
|
||||
storeMe();
|
||||
storeRecommendations();
|
||||
|
||||
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||
{
|
||||
_inventory.updateDatabase();
|
||||
getInventory().updateDatabase();
|
||||
getWarehouse().updateDatabase();
|
||||
getFreight().updateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11126,7 +11110,8 @@ public class PlayerInstance extends Playable
|
||||
// Stop all passives and augment options
|
||||
getEffectList().stopAllPassives(false, false);
|
||||
getEffectList().stopAllOptions(false, false);
|
||||
stopAutoSaveTask();
|
||||
|
||||
PlayerAutoSaveTaskManager.getInstance().remove(this);
|
||||
|
||||
return super.deleteMe();
|
||||
}
|
||||
@@ -13989,11 +13974,6 @@ public class PlayerInstance extends Playable
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
|
||||
{
|
||||
_autoSaveTask.cancel(false);
|
||||
_autoSaveTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerAutoSaveTaskManager
|
||||
{
|
||||
private static final Map<PlayerInstance, Long> PLAYER_TIMES = new ConcurrentHashMap<>();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PlayerAutoSaveTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
SEARCH: for (Entry<PlayerInstance, Long> entry : PLAYER_TIMES.entrySet())
|
||||
{
|
||||
if (time > entry.getValue().longValue())
|
||||
{
|
||||
final PlayerInstance player = entry.getKey();
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.autoSave();
|
||||
PLAYER_TIMES.put(entry.getKey(), time + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
break SEARCH; // Prevent SQL flood.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.put(player, System.currentTimeMillis() + Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYER_TIMES.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerAutoSaveTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerAutoSaveTaskManager INSTANCE = new PlayerAutoSaveTaskManager();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user