mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Use multiple maps so we can get more accurate data
This commit is contained in:
parent
764cabd121
commit
8f0d598c98
@ -25,6 +25,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -465,16 +466,16 @@ public class Jobs extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int total = Jobs.getPlayerManager().getPlayerMap().size();
|
int total = Jobs.getPlayerManager().getMapSize();
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
for (Entry<String, PlayerInfo> one : Jobs.getPlayerManager().getPlayerMap().entrySet()) {
|
for (Entry<UUID, PlayerInfo> one : Jobs.getPlayerManager().getPlayersInfoUUIDMap().entrySet()) {
|
||||||
if (!running)
|
if (!running)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(one);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(one.getValue());
|
||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
continue;
|
continue;
|
||||||
Jobs.getPlayerManager().getPlayersCache().put(one.getValue().getName().toLowerCase(), jPlayer);
|
Jobs.getPlayerManager().addPlayerToCache(jPlayer);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -59,11 +59,15 @@ import com.gamingmesh.jobs.stuff.Perm;
|
|||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
// private Map<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||||
private ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<String, JobsPlayer>();
|
private ConcurrentHashMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<String, JobsPlayer>();
|
||||||
|
private ConcurrentHashMap<UUID, JobsPlayer> playersUUIDCache = new ConcurrentHashMap<UUID, JobsPlayer>();
|
||||||
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
||||||
|
private ConcurrentHashMap<UUID, JobsPlayer> playersUUID = new ConcurrentHashMap<UUID, JobsPlayer>();
|
||||||
private PointsData PointsDatabase = new PointsData();
|
private PointsData PointsDatabase = new PointsData();
|
||||||
private final String mobSpawnerMetadata = "jobsMobSpawner";
|
private final String mobSpawnerMetadata = "jobsMobSpawner";
|
||||||
|
|
||||||
private HashMap<String, PlayerInfo> PlayerMap = new HashMap<String, PlayerInfo>();
|
private HashMap<UUID, PlayerInfo> PlayerUUIDMap = new HashMap<UUID, PlayerInfo>();
|
||||||
|
private HashMap<Integer, PlayerInfo> PlayerIDMap = new HashMap<Integer, PlayerInfo>();
|
||||||
|
private HashMap<String, PlayerInfo> PlayerNameMap = new HashMap<String, PlayerInfo>();
|
||||||
Jobs plugin;
|
Jobs plugin;
|
||||||
|
|
||||||
public PlayerManager(Jobs plugin) {
|
public PlayerManager(Jobs plugin) {
|
||||||
@ -74,46 +78,68 @@ public class PlayerManager {
|
|||||||
return this.PointsDatabase;
|
return this.PointsDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, PlayerInfo> getPlayerMap() {
|
public int getMapSize() {
|
||||||
return this.PlayerMap;
|
return PlayerUUIDMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentHashMap<String, JobsPlayer> getPlayersCache() {
|
public void clearMaps() {
|
||||||
return this.playersCache;
|
PlayerUUIDMap.clear();
|
||||||
|
PlayerIDMap.clear();
|
||||||
|
PlayerNameMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentHashMap<String, JobsPlayer> getPlayers() {
|
public void addPlayerToMap(PlayerInfo info) {
|
||||||
return this.players;
|
this.PlayerUUIDMap.put(info.getUuid(), info);
|
||||||
|
this.PlayerIDMap.put(info.getID(), info);
|
||||||
|
this.PlayerNameMap.put(info.getName().toLowerCase(), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerIdByName(String name) {
|
public void addPlayerToCache(JobsPlayer jPlayer) {
|
||||||
for (Entry<String, PlayerInfo> one : this.PlayerMap.entrySet()) {
|
if (jPlayer.getUserName() != null)
|
||||||
if (one.getValue().getName() == null)
|
this.playersCache.put(jPlayer.getUserName(), jPlayer);
|
||||||
continue;
|
if (jPlayer.getPlayerUUID() != null)
|
||||||
if (one.getValue().getName().equalsIgnoreCase(name))
|
this.playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||||
return one.getValue().getID();
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry<String, PlayerInfo> getPlayerInfoByName(String name) {
|
public void addPlayer(JobsPlayer jPlayer) {
|
||||||
for (Entry<String, PlayerInfo> one : this.PlayerMap.entrySet()) {
|
if (jPlayer.getUserName() != null)
|
||||||
if (one.getValue().getName() == null)
|
this.players.put(jPlayer.getUserName(), jPlayer);
|
||||||
continue;
|
if (jPlayer.getPlayerUUID() != null)
|
||||||
if (one.getValue().getName().equalsIgnoreCase(name))
|
this.playersUUID.put(jPlayer.getPlayerUUID(), jPlayer);
|
||||||
return one;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry<String, PlayerInfo> getPlayerInfoById(int id) {
|
public ConcurrentHashMap<UUID, JobsPlayer> getPlayersCache() {
|
||||||
for (Entry<String, PlayerInfo> one : this.PlayerMap.entrySet()) {
|
return this.playersUUIDCache;
|
||||||
if (one.getValue().getName() == null)
|
|
||||||
continue;
|
|
||||||
if (one.getValue().getID() == id)
|
|
||||||
return one;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
// public ConcurrentHashMap<String, JobsPlayer> getPlayers() {
|
||||||
|
// return this.players;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public HashMap<UUID, PlayerInfo> getPlayersInfoUUIDMap() {
|
||||||
|
return this.PlayerUUIDMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerId(String name) {
|
||||||
|
PlayerInfo info = getPlayerInfo(name);
|
||||||
|
return info == null ? -1 : info.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerId(UUID uuid) {
|
||||||
|
PlayerInfo info = PlayerUUIDMap.get(uuid);
|
||||||
|
return info == null ? -1 : info.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerInfo getPlayerInfo(String name) {
|
||||||
|
return PlayerNameMap.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerInfo getPlayerInfo(int id) {
|
||||||
|
return PlayerIDMap.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerInfo getPlayerInfo(UUID uuid) {
|
||||||
|
return PlayerUUIDMap.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,7 +215,14 @@ public class PlayerManager {
|
|||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayer(Player player) {
|
public JobsPlayer getJobsPlayer(Player player) {
|
||||||
return getJobsPlayer(player.getName().toLowerCase());
|
return getJobsPlayer(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobsPlayer getJobsPlayer(UUID uuid) {
|
||||||
|
JobsPlayer jPlayer = this.playersUUID.get(uuid);
|
||||||
|
if (jPlayer != null)
|
||||||
|
return jPlayer;
|
||||||
|
return this.playersUUIDCache.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,19 +242,19 @@ public class PlayerManager {
|
|||||||
* @param player - the player who's job you're getting
|
* @param player - the player who's job you're getting
|
||||||
* @return the player job info of the player
|
* @return the player job info of the player
|
||||||
*/
|
*/
|
||||||
public JobsPlayer getJobsPlayerOffline(Entry<String, PlayerInfo> info) {
|
public JobsPlayer getJobsPlayerOffline(PlayerInfo info) {
|
||||||
|
|
||||||
if (info == null)
|
if (info == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (info.getValue().getName() == null)
|
if (info.getName() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
JobsPlayer jPlayer = new JobsPlayer(info.getValue().getName(), null);
|
JobsPlayer jPlayer = new JobsPlayer(info.getName(), null);
|
||||||
jPlayer.setPlayerUUID(UUID.fromString(info.getKey()));
|
jPlayer.setPlayerUUID(info.getUuid());
|
||||||
jPlayer.setUserId(info.getValue().getID());
|
jPlayer.setUserId(info.getID());
|
||||||
|
|
||||||
List<JobsDAOData> list = Jobs.getJobsDAO().getAllJobs(info.getValue());
|
List<JobsDAOData> list = Jobs.getJobsDAO().getAllJobs(info.getName(), info.getUuid());
|
||||||
for (JobsDAOData jobdata : list) {
|
for (JobsDAOData jobdata : list) {
|
||||||
if (Jobs.getJob(jobdata.getJobName()) == null)
|
if (Jobs.getJob(jobdata.getJobName()) == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -36,17 +36,17 @@ public class glog implements Cmd {
|
|||||||
|
|
||||||
for (Integer OneP : Jobs.getJobsDAO().getLognameList(time, time)) {
|
for (Integer OneP : Jobs.getJobsDAO().getLognameList(time, time)) {
|
||||||
|
|
||||||
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(OneP);
|
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(OneP);
|
||||||
|
|
||||||
if (info == null)
|
if (info == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String name = info.getValue().getName();
|
String name = info.getName();
|
||||||
|
|
||||||
if (name == null)
|
if (name == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(name);
|
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(info.getUuid());
|
||||||
|
|
||||||
if (JPlayer == null)
|
if (JPlayer == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -26,7 +26,9 @@ public class toggle implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String PlayerName = sender.getName();
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
String PlayerName = player.getName();
|
||||||
|
|
||||||
if (PlayerName == null || !args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
|
if (PlayerName == null || !args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) {
|
||||||
Jobs.getCommandManager().sendUsage(sender, "toggle");
|
Jobs.getCommandManager().sendUsage(sender, "toggle");
|
||||||
@ -53,7 +55,7 @@ public class toggle implements Cmd {
|
|||||||
Jobs.getBossBarToggleList().put(PlayerName, false);
|
Jobs.getBossBarToggleList().put(PlayerName, false);
|
||||||
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off"));
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(PlayerName);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
|
||||||
|
|
||||||
if (jPlayer != null)
|
if (jPlayer != null)
|
||||||
jPlayer.hideBossBars();
|
jPlayer.hideBossBars();
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package com.gamingmesh.jobs.container;
|
package com.gamingmesh.jobs.container;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerInfo {
|
public class PlayerInfo {
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
String name;
|
String name = "Unknown";
|
||||||
private Long seen;
|
private Long seen;
|
||||||
|
private UUID uuid;
|
||||||
|
|
||||||
public PlayerInfo(String name, int id, Long seen) {
|
public PlayerInfo(String name, int id, UUID uuid, Long seen) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.uuid = uuid;
|
||||||
this.seen = seen;
|
this.seen = seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,4 +27,8 @@ public class PlayerInfo {
|
|||||||
public Long getSeen() {
|
public Long getSeen() {
|
||||||
return seen;
|
return seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,18 @@
|
|||||||
package com.gamingmesh.jobs.container;
|
package com.gamingmesh.jobs.container;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
|
||||||
|
|
||||||
public final class TopList {
|
public final class TopList {
|
||||||
private int id;
|
|
||||||
private int level;
|
private int level;
|
||||||
private int exp;
|
private int exp;
|
||||||
|
private PlayerInfo info;
|
||||||
|
|
||||||
public TopList(int id, int level, int exp) {
|
public TopList(PlayerInfo info, int level, int exp) {
|
||||||
this.id = id;
|
this.info = info;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.exp = exp;
|
this.exp = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(this.id);
|
return this.info.getName();
|
||||||
if (info != null) {
|
|
||||||
if (info.getValue().getName() != null)
|
|
||||||
return info.getValue().getName();
|
|
||||||
}
|
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
|
@ -170,7 +170,7 @@ public abstract class JobsDAO {
|
|||||||
if (Jobs.getGCManager().MultiServerCompatability())
|
if (Jobs.getGCManager().MultiServerCompatability())
|
||||||
userData = loadPlayerData(uuid);
|
userData = loadPlayerData(uuid);
|
||||||
else
|
else
|
||||||
userData = Jobs.getPlayerManager().getPlayerMap().get(uuid.toString());
|
userData = Jobs.getPlayerManager().getPlayerInfo(uuid);
|
||||||
|
|
||||||
ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>();
|
ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>();
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ public abstract class JobsDAO {
|
|||||||
res = prest.executeQuery();
|
res = prest.executeQuery();
|
||||||
res.next();
|
res.next();
|
||||||
int id = res.getInt("id");
|
int id = res.getInt("id");
|
||||||
Jobs.getPlayerManager().getPlayerMap().put(uuid.toString(), new PlayerInfo(playerName, id, System.currentTimeMillis()));
|
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis()));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -364,7 +364,7 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>();
|
ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>();
|
||||||
|
|
||||||
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoByName(userName);
|
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(userName);
|
||||||
if (info == null)
|
if (info == null)
|
||||||
return jobs;
|
return jobs;
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ public abstract class JobsDAO {
|
|||||||
ResultSet res = null;
|
ResultSet res = null;
|
||||||
try {
|
try {
|
||||||
prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `userid` = ?;");
|
prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `userid` = ?;");
|
||||||
prest.setInt(1, info.getValue().getID());
|
prest.setInt(1, info.getID());
|
||||||
res = prest.executeQuery();
|
res = prest.executeQuery();
|
||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
jobs.add(new JobsDAOData(res.getString(2), res.getInt(3), res.getInt(4)));
|
jobs.add(new JobsDAOData(res.getString(2), res.getInt(3), res.getInt(4)));
|
||||||
@ -578,7 +578,7 @@ public abstract class JobsDAO {
|
|||||||
insert = conns.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`id`, `player_uuid`, `username`, `seen`) VALUES (?, ?, ?, ?);");
|
insert = conns.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`id`, `player_uuid`, `username`, `seen`) VALUES (?, ?, ?, ?);");
|
||||||
conns.setAutoCommit(false);
|
conns.setAutoCommit(false);
|
||||||
|
|
||||||
for (Entry<String, JobsPlayer> oneUser : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
|
for (Entry<UUID, JobsPlayer> oneUser : Jobs.getPlayerManager().getPlayersCache().entrySet()) {
|
||||||
insert.setInt(1, oneUser.getValue().getUserId());
|
insert.setInt(1, oneUser.getValue().getUserId());
|
||||||
insert.setString(2, oneUser.getValue().getPlayerUUID().toString());
|
insert.setString(2, oneUser.getValue().getPlayerUUID().toString());
|
||||||
insert.setString(3, oneUser.getValue().getUserName());
|
insert.setString(3, oneUser.getValue().getUserName());
|
||||||
@ -719,15 +719,15 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
|
|
||||||
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(res.getInt(1));
|
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(res.getInt("userid"));
|
||||||
|
|
||||||
if (info == null)
|
if (info == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (info.getValue().getName() == null)
|
if (info.getName() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TopList top = new TopList(res.getInt("userid"), res.getInt("totallvl"), 0);
|
TopList top = new TopList(info, res.getInt("totallvl"), 0);
|
||||||
|
|
||||||
names.add(top);
|
names.add(top);
|
||||||
}
|
}
|
||||||
@ -800,8 +800,8 @@ public abstract class JobsDAO {
|
|||||||
prest.setString(1, uuid.toString());
|
prest.setString(1, uuid.toString());
|
||||||
res = prest.executeQuery();
|
res = prest.executeQuery();
|
||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
pInfo = new PlayerInfo(res.getString("username"), res.getInt("id"), res.getLong("seen"));
|
pInfo = new PlayerInfo(res.getString("username"), res.getInt("id"), uuid, res.getLong("seen"));
|
||||||
Jobs.getPlayerManager().getPlayerMap().put(res.getString("player_uuid"), pInfo);
|
Jobs.getPlayerManager().addPlayerToMap(pInfo);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -813,7 +813,7 @@ public abstract class JobsDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadPlayerData() {
|
public void loadPlayerData() {
|
||||||
Jobs.getPlayerManager().getPlayerMap().clear();
|
Jobs.getPlayerManager().clearMaps();
|
||||||
JobsConnection conn = getConnection();
|
JobsConnection conn = getConnection();
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
@ -826,9 +826,9 @@ public abstract class JobsDAO {
|
|||||||
long seen = System.currentTimeMillis();
|
long seen = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
seen = res.getLong("seen");
|
seen = res.getLong("seen");
|
||||||
|
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(res.getString("username"), res.getInt("id"), UUID.fromString(res.getString("player_uuid")), seen));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
Jobs.getPlayerManager().getPlayerMap().put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"), seen));
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -864,14 +864,14 @@ public abstract class JobsDAO {
|
|||||||
}
|
}
|
||||||
jPlayer.reloadMaxExperience();
|
jPlayer.reloadMaxExperience();
|
||||||
jPlayer.reloadLimits();
|
jPlayer.reloadLimits();
|
||||||
jPlayer.setUserId(Jobs.getPlayerManager().getPlayerMap().get(player.getUniqueId().toString()).getID());
|
jPlayer.setUserId(Jobs.getPlayerManager().getPlayerId(player.getUniqueId()));
|
||||||
Jobs.getJobsDAO().loadPoints(jPlayer);
|
Jobs.getJobsDAO().loadPoints(jPlayer);
|
||||||
// }
|
// }
|
||||||
return jPlayer;
|
return jPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAllData() {
|
public void loadAllData() {
|
||||||
Jobs.getPlayerManager().getPlayerMap().clear();
|
Jobs.getPlayerManager().clearMaps();
|
||||||
JobsConnection conn = getConnection();
|
JobsConnection conn = getConnection();
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
@ -881,8 +881,11 @@ public abstract class JobsDAO {
|
|||||||
prest = conn.prepareStatement("SELECT * FROM `" + prefix + "users`;");
|
prest = conn.prepareStatement("SELECT * FROM `" + prefix + "users`;");
|
||||||
res = prest.executeQuery();
|
res = prest.executeQuery();
|
||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
Jobs.getPlayerManager().getPlayerMap().put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"), res.getLong(
|
try {
|
||||||
|
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(res.getString("username"), res.getInt("id"), UUID.fromString(res.getString("player_uuid")), res.getLong(
|
||||||
"seen")));
|
"seen")));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1412,16 +1415,15 @@ public abstract class JobsDAO {
|
|||||||
res = prest.executeQuery();
|
res = prest.executeQuery();
|
||||||
|
|
||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(res.getInt("userid"));
|
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(res.getInt("userid"));
|
||||||
|
|
||||||
if (info == null) {
|
if (info == null)
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.getValue().getName() == null)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String name = info.getValue().getName();
|
if (info.getName() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String name = info.getName();
|
||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|
||||||
@ -1430,10 +1432,10 @@ public abstract class JobsDAO {
|
|||||||
if (job != null && jobsinfo != null) {
|
if (job != null && jobsinfo != null) {
|
||||||
JobProgression prog = jobsinfo.getJobProgression(job);
|
JobProgression prog = jobsinfo.getJobProgression(job);
|
||||||
if (prog != null)
|
if (prog != null)
|
||||||
jobs.add(new TopList(jobsinfo.getUserId(), prog.getLevel(), (int) prog.getExperience()));
|
jobs.add(new TopList(info, prog.getLevel(), (int) prog.getExperience()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jobs.add(new TopList(res.getInt("userid"), res.getInt("level"), res.getInt("experience")));
|
jobs.add(new TopList(info, res.getInt("level"), res.getInt("experience")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -639,7 +640,7 @@ public class JobsDAOMySQL extends JobsDAO {
|
|||||||
prestUsersT = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
prestUsersT = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
||||||
res4 = prestUsersT.executeQuery();
|
res4 = prestUsersT.executeQuery();
|
||||||
while (res4.next()) {
|
while (res4.next()) {
|
||||||
tempPlayerMap.put(res4.getString("player_uuid"), new PlayerInfo(res4.getString("username"), res4.getInt("id"), System.currentTimeMillis()));
|
tempPlayerMap.put(res4.getString("player_uuid"), new PlayerInfo(res4.getString("username"), res4.getInt("id"), UUID.fromString(res4.getString("player_uuid")), System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||||
@ -625,7 +626,7 @@ public class JobsDAOSQLite extends JobsDAO {
|
|||||||
prestUsers2 = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
prestUsers2 = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
|
||||||
res4 = prestUsers2.executeQuery();
|
res4 = prestUsers2.executeQuery();
|
||||||
while (res4.next()) {
|
while (res4.next()) {
|
||||||
tempPlayerMap.put(res4.getString("player_uuid"), new PlayerInfo(res4.getString("username"), res4.getInt("id"), System.currentTimeMillis()));
|
tempPlayerMap.put(res4.getString("player_uuid"), new PlayerInfo(res4.getString("username"), res4.getInt("id"), UUID.fromString(res4.getString("player_uuid")), System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(res4);
|
close(res4);
|
||||||
|
@ -194,7 +194,7 @@ public class BufferedEconomy {
|
|||||||
// Action bar stuff
|
// Action bar stuff
|
||||||
Jobs.getActionBar().ShowActionBar(payment);
|
Jobs.getActionBar().ShowActionBar(payment);
|
||||||
if (payment.getOfflinePlayer().isOnline() && Jobs.getActionBar().getVersion() > 1900) {
|
if (payment.getOfflinePlayer().isOnline() && Jobs.getActionBar().getVersion() > 1900) {
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getUniqueId());
|
||||||
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user