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

Explore data should no longer check by players name for performance

reasons
This commit is contained in:
Zrips 2022-03-08 15:08:11 +02:00
parent 3cc8183ccb
commit fe2b70bdc0
5 changed files with 28 additions and 10 deletions

View File

@ -59,6 +59,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.NBT.CMINBT;
import net.Zrips.CMILib.Version.Version;
@ -190,9 +191,16 @@ public class PlayerManager {
return playerUUIDMap.get(jPlayer.getUniqueId());
}
JobsPlayer jPlayer = playersNameCache.get(name.toLowerCase());
if (jPlayer != null) {
return playerUUIDMap.get(jPlayer.getUniqueId());
}
UUID playerUUID = Bukkit.getPlayerUniqueId(name);
if (playerUUID == null)
return null;
return playerUUIDMap.get(playerUUID);
}
@ -380,10 +388,22 @@ public class PlayerManager {
return playersNameCache.get(playerName.toLowerCase());
}
JobsPlayer jPlayer = playersNameCache.get(playerName.toLowerCase());
if (jPlayer != null) {
return jPlayer;
}
UUID playerUUID = Bukkit.getPlayerUniqueId(playerName);
if (playerUUID == null)
return null;
JobsPlayer jPlayer = playersUUID.get(playerUUID);
jPlayer = playersUUID.get(playerUUID);
if (jPlayer != null) {
playersNameCache.put(playerName.toLowerCase(), jPlayer);
}
return jPlayer != null ? jPlayer : playersUUIDCache.get(playerUUID);
}

View File

@ -1,9 +1,9 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.config.ExploreManager;
import org.bukkit.command.CommandSender;
public class resetexploreregion implements Cmd {

View File

@ -47,10 +47,10 @@ public class ExploreManager {
return;
Jobs.consoleMsg("&eLoading explorer data");
Long time = System.currentTimeMillis();
Jobs.getJobsDAO().loadExplore();
int size = getSize();
Jobs.consoleMsg("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : "."));
Jobs.consoleMsg("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms");
}
public Map<String, Map<String, ExploreRegion>> getWorlds() {

View File

@ -79,10 +79,6 @@ public class ExploreChunk {
playerIds.add(id);
} catch (NumberFormatException e) {
updated = true;
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
if (jp != null)
playerIds.add(jp.getUserId());
}
}

View File

@ -42,6 +42,7 @@ import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
public abstract class JobsDAO {
@ -1328,7 +1329,7 @@ public abstract class JobsDAO {
* @param userName - the player being searched for
* @return list of all of the names of the jobs the players are part of.
*/
public synchronized List<JobsDAOData> getAllJobsOffline(String userName) {
public synchronized List<JobsDAOData> getAllJobsOffline2(String userName) {
List<JobsDAOData> jobs = new ArrayList<>();
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(userName);
@ -2581,6 +2582,7 @@ public abstract class JobsDAO {
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.ExploreDataTable.getTableName() + "`;");
res = prest.executeQuery();
Set<Integer> missingWorlds = new HashSet<>();
while (res.next()) {
int worldId = res.getInt(ExploreDataTableFields.worldid.getCollumn());
JobsWorld jworld = Util.getJobsWorld(worldId);