diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index e5fdd661..727b17e6 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -63,7 +63,6 @@ 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; @@ -284,6 +283,8 @@ public class PlayerManager { jPlayer.onConnect(); jPlayer.reloadHonorific(); Jobs.getPermissionHandler().recalculatePermissions(jPlayer); + + addPlayerToCache(jPlayer); } /** diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 2c916ec6..f098a2a5 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.UUID; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; @@ -92,6 +93,16 @@ public class JobsPlayer { private PlayerPoints pointsData = new PlayerPoints(); + public JobsPlayer(OfflinePlayer player) { + this.userName = player.getName() == null ? "Unknown" : player.getName(); + this.playerUUID = player.getUniqueId(); + } + + public JobsPlayer(Player player) { + this.userName = player.getName() == null ? "Unknown" : player.getName(); + this.playerUUID = player.getUniqueId(); + } + public JobsPlayer(String userName) { this.userName = userName == null ? "Unknown" : userName; } @@ -1368,7 +1379,7 @@ public class JobsPlayer { String perm = "jobs.max" + (type == BlockTypes.FURNACE ? "furnaces" : type == BlockTypes.BLAST_FURNACE ? "blastfurnaces" : type == BlockTypes.SMOKER ? "smokers" - : type == BlockTypes.BREWING_STAND ? "brewingstands" : ""); + : type == BlockTypes.BREWING_STAND ? "brewingstands" : ""); maxV = Jobs.getPermissionManager().getMaxPermission(this, perm); diff --git a/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java b/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java index 001b9595..c8e9bd1d 100644 --- a/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java @@ -22,6 +22,8 @@ public class PlayerInfo { this.questsDone = questsDone; this.questProgression = questProgression; player = Jobs.getPlayerManager().getJobsPlayer(uuid); + if (player != null) + player.setUserId(id); } public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone) { diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 2e718050..124a4dc8 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -914,8 +914,7 @@ public abstract class JobsDAO { res2 = prestt.getGeneratedKeys(); - Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, res2.next() ? res2.getInt(1) : 0, - uuid, System.currentTimeMillis(), 0)); + Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, res2.next() ? res2.getInt(1) : 0, uuid, System.currentTimeMillis(), 0)); } catch (SQLException e) { e.printStackTrace(); } finally { @@ -1845,8 +1844,7 @@ public abstract class JobsDAO { } public JobsPlayer loadFromDao(OfflinePlayer player) { - JobsPlayer jPlayer = new JobsPlayer(player.getName()); - jPlayer.setPlayerUUID(player.getUniqueId()); + JobsPlayer jPlayer = new JobsPlayer(player); return loadFromDao(jPlayer); }