MCPcopy Create free account
hub / github.com/TheCyaniteProject/exit_code_java / create

Method create

src/main/java/exitcode/LoginScreen.java:454–496  ·  view source on GitHub ↗
(Boolean usepassword, String password, String username)

Source from the content-addressed store, hash-verified

452 }
453
454 public static void create(Boolean usepassword, String password, String username) {
455 File file = new File("./profiles/" + username.trim().toLowerCase() + "/player.xml");
456 Boolean b = false;
457 if (!file.exists()) {
458 b = file.getParentFile().mkdirs();
459 if (b) {
460 System.out.println("[Created new profile directory]");
461 try {
462 b = file.createNewFile();
463 } catch (Exception e) {
464 System.err.println(e.getMessage());
465 }
466 if (b) {
467 System.out.println("[Created new player.xml]");
468 try {
469 PrintWriter out = new PrintWriter("./profiles/" + username.trim().toLowerCase() + "/player.xml");
470 String pass;
471 if (usepassword) {
472 pass = ExitParser.passHasher(password);
473 } else {
474 pass = ExitParser.passHasher(username);
475 }
476 out.printf(
477 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" +
478 "<data>%n" +
479 " <playerdata>%n" +
480 " <username>%s</username>%n" +
481 " <password type=\"sha256\">%s</password>%n" +
482 " </playerdata>%n" +
483 "</data>", username.trim(), pass);
484 out.close();
485 Account.exit();
486 } catch (Exception e) {
487 System.err.println(e.getMessage());
488 }
489 } else {
490 System.out.println("[Failed to create profile]");
491 }
492 } else {
493 System.out.println("[Failed to create profile directory]");
494 }
495 }
496 }
497
498 public static void cancel() {
499 Main.main_primaryStage.getScene().setRoot(LoginScreen.main_root); // Changes the scene to the Login screen

Callers 2

handleMethod · 0.95
startMethod · 0.95

Calls 3

passHasherMethod · 0.95
exitMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected