1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Fixed when the db cleaning for users not works

Fixes #814
This commit is contained in:
montlikadani 2020-06-12 08:56:15 +02:00
parent ea70a33342
commit 8644910fef
3 changed files with 10 additions and 13 deletions

View File

@ -479,7 +479,6 @@ public class Jobs extends JavaPlugin {
getPlayerManager().addPlayerToCache(jPlayer);
}
dao.getMap().clear();
if (!getPlayerManager().getPlayersCache().isEmpty())
consoleMsg("&e[Jobs] Preloaded " + getPlayerManager().getPlayersCache().size() + " players data in " +
((int) (((System.currentTimeMillis() - time) / 1000d) * 100) / 100D));

View File

@ -5,6 +5,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -801,19 +802,18 @@ public abstract class JobsDAO {
return map;
}
private HashMap<Integer, ArrayList<JobsDAOData>> map = new HashMap<>();
public List<JobsDAOData> getAllJobs(PlayerInfo pInfo) {
return map.getOrDefault(pInfo.getID(), new ArrayList<JobsDAOData>());
}
public void cleanUsers() {
if (!Jobs.getGCManager().DBCleaningUsersUse)
return;
JobsConnection conn = getConnection();
if (conn == null)
return;
long mark = System.currentTimeMillis() - (Jobs.getGCManager().DBCleaningUsersDays * 24 * 60 * 60 * 1000);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -Jobs.getGCManager().DBCleaningUsersDays);
long mark = cal.getTimeInMillis();
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("DELETE FROM `" + DBTables.UsersTable.getTableName() + "` WHERE `" + UserTableFields.seen.getCollumn() + "` < ?;");
@ -829,9 +829,11 @@ public abstract class JobsDAO {
public void cleanJobs() {
if (!Jobs.getGCManager().DBCleaningJobsUse)
return;
JobsConnection conn = getConnection();
if (conn == null)
return;
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("DELETE FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.level.getCollumn() + "` <= ?;");
@ -2695,10 +2697,6 @@ public abstract class JobsDAO {
}
}
public HashMap<Integer, ArrayList<JobsDAOData>> getMap() {
return map;
}
public String getJobsTableName() {
return DBTables.JobsTable.getTableName();
}

View File

@ -1362,7 +1362,7 @@ public class JobsPaymentListener implements Listener {
return;
Location loc = event.getLocation();
Collection<Entity> ents = Version.isCurrentEqualOrLower(Version.v1_8_R1)
Collection<Entity> ents = Version.isCurrentEqualOrLower(Version.v1_8_R1) || loc.getWorld() == null
? null : loc.getWorld().getNearbyEntities(loc, 4, 4, 4);
if (ents == null) {
return;