1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Lets clear out block protection by set days limit on plugin load

This commit is contained in:
Zrips 2019-10-28 13:02:52 +02:00
parent 8e7a959f39
commit 0b1c035c4b
2 changed files with 17 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.container.BlockProtection; import com.gamingmesh.jobs.container.BlockProtection;
import com.gamingmesh.jobs.container.DBAction; import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.stuff.Debug;
public class BlockProtectionManager { public class BlockProtectionManager {
@ -100,7 +101,7 @@ public class BlockProtectionManager {
locations.put(v, Bp); locations.put(v, Bp);
if (locations.size() > 100) { if (locations.size() > 10) {
Jobs.getJobsDAO().saveBlockProtection(loc.getWorld().getName(), new HashMap<String, BlockProtection>(locations)); Jobs.getJobsDAO().saveBlockProtection(loc.getWorld().getName(), new HashMap<String, BlockProtection>(locations));
locations.clear(); locations.clear();
} }

View File

@ -35,6 +35,7 @@ import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.TopList; import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType; import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
@ -1048,7 +1049,6 @@ public abstract class JobsDAO {
close(limitsStatement); close(limitsStatement);
} }
} }
public void recordNewJobName(Job job) { public void recordNewJobName(Job job) {
@ -2187,10 +2187,22 @@ public abstract class JobsDAO {
if (conn == null) if (conn == null)
return; return;
PreparedStatement prest = null; PreparedStatement prest = null;
PreparedStatement prestDel = null;
ResultSet res = null; ResultSet res = null;
Jobs.getBpManager().timer = 0L; Jobs.getBpManager().timer = 0L;
try {
Long mark = System.currentTimeMillis() - (Jobs.getGCManager().BlockProtectionDays * 24L * 60L * 60L * 1000L);
prestDel = conn.prepareStatement("DELETE FROM `" + DBTables.BlocksTable.getTableName() + "` WHERE `" + BlockTableFields.recorded.getCollumn() + "` < ?;");
prestDel.setLong(1, mark);
prestDel.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
close(prestDel);
}
try { try {
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.BlocksTable.getTableName() + "`;"); prest = conn.prepareStatement("SELECT * FROM `" + DBTables.BlocksTable.getTableName() + "`;");
res = prest.executeQuery(); res = prest.executeQuery();