mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 16:59:37 +01:00
Created a variable for player name.
This commit is contained in:
parent
35565bb021
commit
e9ea0e0389
@ -61,11 +61,13 @@ public class PlayerProfile {
|
|||||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
|
private String playerName;
|
||||||
private final static String location = mcMMO.usersFile;
|
private final static String location = mcMMO.usersFile;
|
||||||
|
|
||||||
public PlayerProfile(Player player, boolean addNew) {
|
public PlayerProfile(Player player, boolean addNew) {
|
||||||
hud = SpoutConfig.getInstance().defaulthud;
|
hud = SpoutConfig.getInstance().defaulthud;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.playerName = player.getName();
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
@ -98,7 +100,7 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
public boolean loadMySQL() {
|
public boolean loadMySQL() {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + player.getName() + "'");
|
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
||||||
|
|
||||||
this.userid = id;
|
this.userid = id;
|
||||||
|
|
||||||
@ -180,8 +182,8 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
public void addMySQLPlayer() {
|
public void addMySQLPlayer() {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + player.getName() + "'," + System.currentTimeMillis() / 1000 +")");
|
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
||||||
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + player.getName() + "'");
|
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
||||||
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
||||||
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
|
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
|
||||||
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
|
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
|
||||||
@ -200,7 +202,7 @@ public class PlayerProfile {
|
|||||||
//Find if the line contains the player we want.
|
//Find if the line contains the player we want.
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
if(!character[0].equals(player.getName())){continue;}
|
if(!character[0].equals(playerName)){continue;}
|
||||||
|
|
||||||
//Get Mining
|
//Get Mining
|
||||||
if(character.length > 1 && Misc.isInt(character[1]))
|
if(character.length > 1 && Misc.isInt(character[1]))
|
||||||
@ -352,12 +354,12 @@ public class PlayerProfile {
|
|||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
//Read the line in and copy it to the output it's not the player
|
//Read the line in and copy it to the output it's not the player
|
||||||
//we want to edit
|
//we want to edit
|
||||||
if (!line.split(":")[0].equalsIgnoreCase(player.getName())) {
|
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Otherwise write the new player information
|
//Otherwise write the new player information
|
||||||
writer.append(player.getName() + ":");
|
writer.append(playerName + ":");
|
||||||
writer.append(skills.get(SkillType.MINING) + ":");
|
writer.append(skills.get(SkillType.MINING) + ":");
|
||||||
writer.append("" + ":");
|
writer.append("" + ":");
|
||||||
writer.append(party+":");
|
writer.append(party+":");
|
||||||
@ -439,7 +441,7 @@ public class PlayerProfile {
|
|||||||
BufferedWriter out = new BufferedWriter(file);
|
BufferedWriter out = new BufferedWriter(file);
|
||||||
|
|
||||||
//Add the player to the end
|
//Add the player to the end
|
||||||
out.append(player.getName() + ":");
|
out.append(playerName + ":");
|
||||||
out.append(0 + ":"); //mining
|
out.append(0 + ":"); //mining
|
||||||
out.append(""+":");
|
out.append(""+":");
|
||||||
out.append(party+":");
|
out.append(party+":");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user