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

Recording player database ID at moment we got to avoid duplicates

This commit is contained in:
Zrips 2021-09-13 13:08:18 +03:00
parent 7a07869131
commit 6643a456e5
4 changed files with 18 additions and 6 deletions

View File

@ -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);
}
/**

View File

@ -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);

View File

@ -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) {

View File

@ -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);
}