Skip to content

Commit

Permalink
Cleaned up ProfileProperties.java slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MF42-DZH committed Aug 28, 2019
1 parent a0bc58f commit 1c71311
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/zeroxfc/nullpo/custom/libs/ProfileProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@ private String getStorageName(String name) {
* @param name Name to test
* @return Available?
*/
private boolean testUsernameAvailability(String name, long number) {
private boolean testUsernameTaken(String name, long number) {
String nCap = getStorageName(name);
return !PROP_PROFILE.getProperty(PREFIX_NAME + nCap + "." + number, false);
return PROP_PROFILE.getProperty(PREFIX_NAME + nCap + "." + number, false);
}

/**
* Tests to see if a name has not already been taken on the local machine.
* @param name Name to test
* @return Available?
*/
private boolean testUsernameAvailability(String name) {
String nCap = getStorageName(name);
return !PROP_PROFILE.getProperty(PREFIX_NAME + nCap + "." + 0, false);
}

/**
Expand All @@ -168,7 +178,7 @@ private boolean testPasswordCrash(String name, int[] buttonPresses) {
boolean crash = false;
long number = 0;

while (!testUsernameAvailability(name, number)) {
while (testUsernameTaken(name, number)) {
if (!PROP_PROFILE.getProperty(PREFIX_NAME + nCap + "." + number, false)) return false;
else {
crash = true;
Expand All @@ -187,16 +197,6 @@ private boolean testPasswordCrash(String name, int[] buttonPresses) {
return crash;
}

/**
* Tests to see if a name has already been taken on the local machine.
* @param name Name to test
* @return Available?
*/
private boolean testUsernameAvailability(String name) {
String nCap = getStorageName(name);
return !PROP_PROFILE.getProperty(PREFIX_NAME + nCap + "." + 0, false);
}

/**
* Attempt to log into an account with a name and password.
* @param name Account name
Expand All @@ -214,7 +214,7 @@ private boolean attemptLogIn(String name, int[] buttonPresses) {
boolean login = false;

long number = 0;
while (!testUsernameAvailability(nCap, number)) {
while (testUsernameTaken(nCap, number)) {
int pass = PROP_PROFILE.getProperty(PREFIX_PASS + nCap + "." + number, 0);

for (int i = 0; i < buttonPresses.length; i++) {
Expand Down Expand Up @@ -256,7 +256,7 @@ private boolean createAccount(String name, int[] buttonPresses) {
String nCapDisplay = name.toUpperCase();

long number = 0;
while (!testUsernameAvailability(nCap, number)) {
while (testUsernameTaken(nCap, number)) {
log.warn("Creation of " + nCapDisplay + " " + number + " failed. Name and number taken.");
number++;
}
Expand Down Expand Up @@ -562,6 +562,7 @@ public boolean isLoggedIn() {
* Screen to draw. Use it inside onCustom and renderLast.
*/
public static class LoginScreen {
/** Screen states */
private static final int CUSTOM_STATE_INITIAL_SCREEN = 0,
CUSTOM_STATE_NAME_INPUT = 1,
CUSTOM_STATE_PASSWORD_INPUT = 2,
Expand Down

0 comments on commit 1c71311

Please sign in to comment.