1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-27 09:43:22 +01:00

Option to disable explorer database saving

This commit is contained in:
Zrips 2023-09-25 16:36:00 +03:00
parent cbff3e6138
commit 75ca0929df
4 changed files with 117 additions and 108 deletions

View File

@ -586,6 +586,7 @@ public final class Jobs extends JavaPlugin {
getPlayerManager().clearMaps(); getPlayerManager().clearMaps();
getPlayerManager().clearCache(); getPlayerManager().clearCache();
if (Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase)
dao.saveExplore(); dao.saveExplore();
// Do we really need to convert Block protection? // Do we really need to convert Block protection?
// Jobs.getJobsDAO().saveBlockProtection(); // Jobs.getJobsDAO().saveBlockProtection();
@ -890,9 +891,8 @@ public final class Jobs extends JavaPlugin {
CMIMessages.consoleMessage(prefix); CMIMessages.consoleMessage(prefix);
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
if (dao != null) { if (dao != null && Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase)
dao.saveExplore(); dao.saveExplore();
}
blockOwnerShipsMaterial.values().forEach(BlockOwnerShip::save); blockOwnerShipsMaterial.values().forEach(BlockOwnerShip::save);
ToggleBarHandling.save(); ToggleBarHandling.save();

View File

@ -39,21 +39,21 @@ public class ExploreManager {
} }
public void setExploreEnabled() { public void setExploreEnabled() {
if (!exploreEnabled) {
exploreEnabled = true; exploreEnabled = true;
} }
}
public void load() { public void load() {
if (!exploreEnabled) if (!exploreEnabled)
return; return;
if (Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase) {
CMIMessages.consoleMessage("&eLoading explorer data"); CMIMessages.consoleMessage("&eLoading explorer data");
Long time = System.currentTimeMillis(); Long time = System.currentTimeMillis();
Jobs.getJobsDAO().loadExplore(); Jobs.getJobsDAO().loadExplore();
int size = getSize(); int size = getSize();
CMIMessages.consoleMessage("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms"); CMIMessages.consoleMessage("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms");
} }
}
public Map<String, Map<String, ExploreRegion>> getWorlds() { public Map<String, Map<String, ExploreRegion>> getWorlds() {
return worlds; return worlds;

View File

@ -107,7 +107,7 @@ public class GeneralConfigManager {
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving, DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver, EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver,
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers, hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse, BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, ExploreSaveIntoDatabase = false, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled, DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting; payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting;
@ -427,6 +427,11 @@ public class GeneralConfigManager {
"By setting this to true when there is max amount of players explored a chunk then it will be marked as fully explored and exact players who explored it will not be saved to save some memory"); "By setting this to true when there is max amount of players explored a chunk then it will be marked as fully explored and exact players who explored it will not be saved to save some memory");
ExploreCompact = c.get("Optimizations.Explore.Compact", true); ExploreCompact = c.get("Optimizations.Explore.Compact", true);
c.addComment("Optimizations.Explore.SaveIntoDatabase",
"While enabled explored chunk data will be saved into database and will persist over server restarts",
"While disabled expored chunk data resets on every server startup which will freeup memory and speedup server startups and stop in some cases");
ExploreSaveIntoDatabase = c.get("Optimizations.Explore.SaveIntoDatabase", false);
c.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics", c.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics",
"This is still in development and in future it will expand"); "This is still in development and in future it will expand");
LoggingUse = c.get("Logging.Use", false); LoggingUse = c.get("Logging.Use", false);

View File

@ -2558,6 +2558,8 @@ public abstract class JobsDAO {
PreparedStatement prest2 = null; PreparedStatement prest2 = null;
try { try {
CMIMessages.consoleMessage("&e[Jobs] Preparing explorer data save.");
prest2 = conn.prepareStatement("INSERT INTO `" + DBTables.ExploreDataTable.getTableName() + "` (`" + ExploreDataTableFields.worldid.getCollumn() prest2 = conn.prepareStatement("INSERT INTO `" + DBTables.ExploreDataTable.getTableName() + "` (`" + ExploreDataTableFields.worldid.getCollumn()
+ "`, `" + ExploreDataTableFields.chunkX.getCollumn() + "`, `" + ExploreDataTableFields.chunkX.getCollumn()
+ "`, `" + ExploreDataTableFields.chunkZ.getCollumn() + "`, `" + ExploreDataTableFields.chunkZ.getCollumn()
@ -2570,11 +2572,13 @@ public abstract class JobsDAO {
Map<String, Map<String, ExploreRegion>> temp = new HashMap<>(Jobs.getExploreManager().getWorlds()); Map<String, Map<String, ExploreRegion>> temp = new HashMap<>(Jobs.getExploreManager().getWorlds());
for (Entry<String, Map<String, ExploreRegion>> worlds : temp.entrySet()) { for (Entry<String, Map<String, ExploreRegion>> worlds : temp.entrySet()) {
for (Entry<String, ExploreRegion> region : worlds.getValue().entrySet()) {
JobsWorld jobsWorld = Util.getJobsWorld(worlds.getKey()); JobsWorld jobsWorld = Util.getJobsWorld(worlds.getKey());
int id = jobsWorld == null ? 0 : jobsWorld.getId(); int id = jobsWorld == null ? 0 : jobsWorld.getId();
if (id != 0) if (id == 0)
continue;
for (Entry<String, ExploreRegion> region : worlds.getValue().entrySet()) {
for (Entry<Short, ExploreChunk> oneChunk : region.getValue().getChunks().entrySet()) { for (Entry<Short, ExploreChunk> oneChunk : region.getValue().getChunks().entrySet()) {
ExploreChunk chunk = oneChunk.getValue(); ExploreChunk chunk = oneChunk.getValue();
if (chunk.getDbId() != -1) if (chunk.getDbId() != -1)