Inspect now checks if player exists in Database

This commit is contained in:
nossr50 2012-02-29 13:02:24 -08:00
parent 4641e4701c
commit 906bc01b91
3 changed files with 51 additions and 3 deletions

View File

@ -117,7 +117,7 @@ public class Users {
} }
public static PlayerProfile getOfflineProfile(String playerName){ public static PlayerProfile getOfflineProfile(String playerName){
return new PlayerProfile(playerName); return new PlayerProfile(playerName, false);
} }
public static Users getInstance() { public static Users getInstance() {

View File

@ -93,6 +93,15 @@ public class InspectCommand implements CommandExecutor {
} }
PlayerProfile PPt = Users.getOfflineProfile(args[0]); PlayerProfile PPt = Users.getOfflineProfile(args[0]);
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
return true;
}
System.out.println(PPt.isLoaded());
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]); sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]);
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-"); sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");

View File

@ -46,7 +46,7 @@ public class PlayerProfile
private String party, invite; private String party, invite;
//TOGGLES //TOGGLES
private boolean partyhud = true, spoutcraft = false, filling = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true, private boolean loaded = false, partyhud = true, spoutcraft = false, filling = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode; serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode;
@ -96,10 +96,43 @@ public class PlayerProfile
loadMySQL();//This is probably not needed anymore, could just delete loadMySQL();//This is probably not needed anymore, could just delete
} }
} else { } else {
if(!load()) { addPlayer(); } if(!load()) { addPlayer();}
} }
lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue(); lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue();
} }
public PlayerProfile(String name, boolean addNew)
{
hud = LoadProperties.defaulthud;
//Setup the HashMap for ability DATS
for(AbilityType abilityType : AbilityType.values())
{
skillsDATS.put(abilityType, 0);
}
//Setup the HashMap for the skills
for(SkillType skillType : SkillType.values())
{
if(skillType != SkillType.ALL)
{
skills.put(skillType, 0);
skillsXp.put(skillType, 0);
}
}
playerName = name;
if (LoadProperties.useMySQL)
{
if(!loadMySQL() && addNew) {
addMySQLPlayer();
loadMySQL();//This is probably not needed anymore, could just delete
}
} else {
if(!load() && addNew) { addPlayer(); loaded = true; }
}
lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue();
}
public int getLastLogin() public int getLastLogin()
{ {
return lastlogin; return lastlogin;
@ -183,6 +216,7 @@ public class PlayerProfile
skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9))); skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9)));
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10))); skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10)));
skillsXp.put(SkillType.FISHING, Integer.valueOf(experience.get(1).get(11))); skillsXp.put(SkillType.FISHING, Integer.valueOf(experience.get(1).get(11)));
loaded = true;
return true; return true;
} }
else { else {
@ -291,6 +325,7 @@ public class PlayerProfile
if(character.length > 35) if(character.length > 35)
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35])); skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
in.close(); in.close();
loaded = true;
return true; return true;
} }
in.close(); in.close();
@ -500,6 +535,10 @@ public class PlayerProfile
{ {
partyhud = !partyhud; partyhud = !partyhud;
} }
public boolean isLoaded()
{
return loaded;
}
public boolean getPartyHUD() public boolean getPartyHUD()
{ {
return partyhud; return partyhud;