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

Simplifying method to get jobs player by name to avoid web calls

This commit is contained in:
Zrips 2022-05-25 13:00:50 +03:00
parent 9694b6b0a5
commit 2689a69c78

View File

@ -39,6 +39,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.jetbrains.annotations.Nullable;
import com.gamingmesh.jobs.api.JobsJoinEvent;
import com.gamingmesh.jobs.api.JobsLeaveEvent;
@ -64,6 +65,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;
@ -188,24 +190,10 @@ public class PlayerManager {
* @return {@link PlayerInfo}
*/
public PlayerInfo getPlayerInfo(String name) {
if (Version.isCurrentEqualOrLower(Version.v1_11_R1) || !Version.isPaper()) {
JobsPlayer jPlayer = playersNameCache.get(name.toLowerCase());
if (jPlayer == null)
return null;
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)
if (jPlayer == null)
return null;
return playerUUIDMap.get(playerUUID);
return playerUUIDMap.get(jPlayer.getUniqueId());
}
/**
@ -388,27 +376,7 @@ public class PlayerManager {
* @return {@link JobsPlayer} the player job info of the player
*/
public JobsPlayer getJobsPlayer(String playerName) {
if (Version.isCurrentEqualOrLower(Version.v1_11_R1) || !Version.isPaper()) {
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;
jPlayer = playersUUID.get(playerUUID);
if (jPlayer != null) {
playersNameCache.put(playerName.toLowerCase(), jPlayer);
}
return jPlayer != null ? jPlayer : playersUUIDCache.get(playerUUID);
return playersNameCache.get(playerName.toLowerCase());
}
/**