Addition of PlayerInstance auto save task.
This commit is contained in:
parent
9d3904e755
commit
c31c85e2a3
@ -550,6 +550,18 @@ SaveDroppedItemInterval = 60
|
|||||||
# WARNING: only works when SaveDroppedItem = False
|
# WARNING: only works when SaveDroppedItem = False
|
||||||
ClearDroppedItemTable = False
|
ClearDroppedItemTable = False
|
||||||
|
|
||||||
|
# This is the interval (in minutes), that the gameserver will update a players information such as location.
|
||||||
|
# The higher you set this number, there will be less character information saving so you will have less accessing of the database and your hard drive(s).
|
||||||
|
# The lower you set this number, there will be more frequent character information saving so you will have more access to the database and your hard drive(s).
|
||||||
|
# A value of 0 disables periodic saving.
|
||||||
|
# Independent of this setting the character is always saved after leaving the world.
|
||||||
|
# Default: 15
|
||||||
|
CharacterDataStoreInterval = 15
|
||||||
|
|
||||||
|
# When enabled, this forces (even if using lazy item updates) the items owned by the character to be updated into DB when saving its character.
|
||||||
|
# Default: True
|
||||||
|
UpdateItemsOnCharStore = True
|
||||||
|
|
||||||
# Remove broken quests player
|
# Remove broken quests player
|
||||||
AutoDeleteInvalidQuestData = False
|
AutoDeleteInvalidQuestData = False
|
||||||
|
|
||||||
|
@ -194,6 +194,10 @@ public class Config
|
|||||||
public static int DUMP_INTERVAL_SECONDS = 60;
|
public static int DUMP_INTERVAL_SECONDS = 60;
|
||||||
public static int DEFAULT_PUNISH;
|
public static int DEFAULT_PUNISH;
|
||||||
public static int DEFAULT_PUNISH_PARAM;
|
public static int DEFAULT_PUNISH_PARAM;
|
||||||
|
|
||||||
|
public static int CHAR_DATA_STORE_INTERVAL;
|
||||||
|
public static boolean UPDATE_ITEMS_ON_CHAR_STORE;
|
||||||
|
|
||||||
public static boolean AUTODELETE_INVALID_QUEST_DATA;
|
public static boolean AUTODELETE_INVALID_QUEST_DATA;
|
||||||
public static boolean GRIDS_ALWAYS_ON;
|
public static boolean GRIDS_ALWAYS_ON;
|
||||||
public static int GRID_NEIGHBOR_TURNON_TIME;
|
public static int GRID_NEIGHBOR_TURNON_TIME;
|
||||||
@ -1631,6 +1635,7 @@ public class Config
|
|||||||
{
|
{
|
||||||
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
|
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
DESTROY_DROPPED_PLAYER_ITEM = Boolean.parseBoolean(generalSettings.getProperty("DestroyPlayerDroppedItem", "false"));
|
DESTROY_DROPPED_PLAYER_ITEM = Boolean.parseBoolean(generalSettings.getProperty("DestroyPlayerDroppedItem", "false"));
|
||||||
DESTROY_EQUIPABLE_PLAYER_ITEM = Boolean.parseBoolean(generalSettings.getProperty("DestroyEquipableItem", "false"));
|
DESTROY_EQUIPABLE_PLAYER_ITEM = Boolean.parseBoolean(generalSettings.getProperty("DestroyEquipableItem", "false"));
|
||||||
SAVE_DROPPED_ITEM = Boolean.parseBoolean(generalSettings.getProperty("SaveDroppedItem", "false"));
|
SAVE_DROPPED_ITEM = Boolean.parseBoolean(generalSettings.getProperty("SaveDroppedItem", "false"));
|
||||||
@ -1687,6 +1692,9 @@ public class Config
|
|||||||
|
|
||||||
FORCE_COMPLETE_STATUS_UPDATE = Boolean.parseBoolean(generalSettings.getProperty("ForceCompletePlayerStatusUpdate", "true"));
|
FORCE_COMPLETE_STATUS_UPDATE = Boolean.parseBoolean(generalSettings.getProperty("ForceCompletePlayerStatusUpdate", "true"));
|
||||||
|
|
||||||
|
CHAR_DATA_STORE_INTERVAL = Integer.parseInt(generalSettings.getProperty("CharacterDataStoreInterval", "15")) * 60 * 1000;
|
||||||
|
UPDATE_ITEMS_ON_CHAR_STORE = Boolean.parseBoolean(generalSettings.getProperty("UpdateItemsOnCharStore", "false"));
|
||||||
|
|
||||||
AUTODELETE_INVALID_QUEST_DATA = Boolean.parseBoolean(generalSettings.getProperty("AutoDeleteInvalidQuestData", "false"));
|
AUTODELETE_INVALID_QUEST_DATA = Boolean.parseBoolean(generalSettings.getProperty("AutoDeleteInvalidQuestData", "false"));
|
||||||
|
|
||||||
DELETE_DAYS = Integer.parseInt(generalSettings.getProperty("DeleteCharAfterDays", "7"));
|
DELETE_DAYS = Integer.parseInt(generalSettings.getProperty("DeleteCharAfterDays", "7"));
|
||||||
|
@ -537,6 +537,7 @@ public class PlayerInstance extends Playable
|
|||||||
private final HashMap<Integer, Long> confirmDlgRequests = new HashMap<>();
|
private final HashMap<Integer, Long> confirmDlgRequests = new HashMap<>();
|
||||||
private int _currentMultiSellId = -1;
|
private int _currentMultiSellId = -1;
|
||||||
private int _partyroom = 0;
|
private int _partyroom = 0;
|
||||||
|
private Future<?> _autoSaveTask = null;
|
||||||
|
|
||||||
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S). */
|
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S). */
|
||||||
private static final int[] EXPERTISE_LEVELS =
|
private static final int[] EXPERTISE_LEVELS =
|
||||||
@ -602,7 +603,6 @@ public class PlayerInstance extends Playable
|
|||||||
|
|
||||||
// Add the player in the characters table of the database
|
// Add the player in the characters table of the database
|
||||||
final boolean ok = player.createDb();
|
final boolean ok = player.createDb();
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -921,7 +921,6 @@ public class PlayerInstance extends Playable
|
|||||||
*/
|
*/
|
||||||
public class HerbTask implements Runnable
|
public class HerbTask implements Runnable
|
||||||
{
|
{
|
||||||
|
|
||||||
/** The _process. */
|
/** The _process. */
|
||||||
private final String _process;
|
private final String _process;
|
||||||
|
|
||||||
@ -8927,6 +8926,8 @@ public class PlayerInstance extends Playable
|
|||||||
player.refreshOverloaded();
|
player.refreshOverloaded();
|
||||||
|
|
||||||
player.restoreFriendList();
|
player.restoreFriendList();
|
||||||
|
|
||||||
|
player.startAutoSaveTask();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -9234,8 +9235,7 @@ public class PlayerInstance extends Playable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update PlayerInstance stats in the characters table of the database.<BR>
|
* Update PlayerInstance stats in the characters table of the database.
|
||||||
* <BR>
|
|
||||||
*/
|
*/
|
||||||
public synchronized void store()
|
public synchronized void store()
|
||||||
{
|
{
|
||||||
@ -10251,6 +10251,34 @@ public class PlayerInstance extends Playable
|
|||||||
return _hennaDEX;
|
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()
|
||||||
|
{
|
||||||
|
store();
|
||||||
|
|
||||||
|
if (Config.UPDATE_ITEMS_ON_CHAR_STORE)
|
||||||
|
{
|
||||||
|
_inventory.updateDatabase();
|
||||||
|
getWarehouse().updateDatabase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return True if the PlayerInstance is autoAttackable.<BR>
|
* Return True if the PlayerInstance is autoAttackable.<BR>
|
||||||
* <BR>
|
* <BR>
|
||||||
@ -14713,6 +14741,8 @@ public class PlayerInstance extends Playable
|
|||||||
// Remove WorldObject object from _allObjects of World
|
// Remove WorldObject object from _allObjects of World
|
||||||
World.getInstance().removeObject(this);
|
World.getInstance().removeObject(this);
|
||||||
World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
|
World.getInstance().removeFromAllPlayers(this); // force remove in case of crash during teleport
|
||||||
|
|
||||||
|
stopAutoSaveTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ShortBuffTask implements Runnable
|
private class ShortBuffTask implements Runnable
|
||||||
|
Loading…
Reference in New Issue
Block a user