use of com.rs.entity.player.PlayerAttributes in project runesource by PureCS.
the class JsonPlayerFileHandler method load.
@Override
public LoadResponse load(Player player) throws Exception {
// Checking if file exists
File file = new File(getStorageDirectory() + player.getAttributes().getUsername() + ".json");
if (!file.exists()) {
return LoadResponse.NOT_FOUND;
}
// Reading file
JsonReader reader = new JsonReader(new FileInputStream(file));
PlayerAttributes attributes = (PlayerAttributes) reader.readObject();
reader.close();
// Checking password
if (!attributes.getPassword().equals(player.getAttributes().getPassword())) {
return LoadResponse.INVALID_CREDENTIALS;
}
player.setAttributes(attributes);
return LoadResponse.SUCCESS;
}
Aggregations