mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Option to disable explorer database saving
This commit is contained in:
parent
cbff3e6138
commit
75ca0929df
@ -586,6 +586,7 @@ public final class Jobs extends JavaPlugin {
|
||||
getPlayerManager().clearMaps();
|
||||
getPlayerManager().clearCache();
|
||||
|
||||
if (Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase)
|
||||
dao.saveExplore();
|
||||
// Do we really need to convert Block protection?
|
||||
// Jobs.getJobsDAO().saveBlockProtection();
|
||||
@ -890,9 +891,8 @@ public final class Jobs extends JavaPlugin {
|
||||
CMIMessages.consoleMessage(prefix);
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
if (dao != null) {
|
||||
if (dao != null && Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase)
|
||||
dao.saveExplore();
|
||||
}
|
||||
|
||||
blockOwnerShipsMaterial.values().forEach(BlockOwnerShip::save);
|
||||
ToggleBarHandling.save();
|
||||
|
@ -39,21 +39,21 @@ public class ExploreManager {
|
||||
}
|
||||
|
||||
public void setExploreEnabled() {
|
||||
if (!exploreEnabled) {
|
||||
exploreEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!exploreEnabled)
|
||||
return;
|
||||
|
||||
if (Jobs.getGeneralConfigManager().ExploreSaveIntoDatabase) {
|
||||
CMIMessages.consoleMessage("&eLoading explorer data");
|
||||
Long time = System.currentTimeMillis();
|
||||
Jobs.getJobsDAO().loadExplore();
|
||||
int size = getSize();
|
||||
CMIMessages.consoleMessage("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms");
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Map<String, ExploreRegion>> getWorlds() {
|
||||
return worlds;
|
||||
|
@ -107,7 +107,7 @@ public class GeneralConfigManager {
|
||||
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
|
||||
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver,
|
||||
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,
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
|
||||
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");
|
||||
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",
|
||||
"This is still in development and in future it will expand");
|
||||
LoggingUse = c.get("Logging.Use", false);
|
||||
|
@ -2558,6 +2558,8 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest2 = null;
|
||||
try {
|
||||
|
||||
CMIMessages.consoleMessage("&e[Jobs] Preparing explorer data save.");
|
||||
|
||||
prest2 = conn.prepareStatement("INSERT INTO `" + DBTables.ExploreDataTable.getTableName() + "` (`" + ExploreDataTableFields.worldid.getCollumn()
|
||||
+ "`, `" + ExploreDataTableFields.chunkX.getCollumn()
|
||||
+ "`, `" + ExploreDataTableFields.chunkZ.getCollumn()
|
||||
@ -2570,11 +2572,13 @@ public abstract class JobsDAO {
|
||||
Map<String, Map<String, ExploreRegion>> temp = new HashMap<>(Jobs.getExploreManager().getWorlds());
|
||||
|
||||
for (Entry<String, Map<String, ExploreRegion>> worlds : temp.entrySet()) {
|
||||
for (Entry<String, ExploreRegion> region : worlds.getValue().entrySet()) {
|
||||
JobsWorld jobsWorld = Util.getJobsWorld(worlds.getKey());
|
||||
|
||||
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()) {
|
||||
ExploreChunk chunk = oneChunk.getValue();
|
||||
if (chunk.getDbId() != -1)
|
||||
|
Loading…
Reference in New Issue
Block a user