Search in sources :

Example 1 with JavaCrashesUploader

use of io.xol.chunkstories.bugsreporter.JavaCrashesUploader in project chunkstories by Hugobros3.

the class LoginPrompt method connect.

private void connect() {
    if (usernameForm.getText().equals("OFFLINE")) {
        Client.offline = true;
        Client.username = "OfflineUser" + (int) (Math.random() * 1000);
        gameWindow.setLayer(new MainMenu(gameWindow, parentLayer));
    } else {
        logging_in = true;
        RequestResultAction postAction = (result) -> {
            gameWindow.getClient().logger().debug("Received login answer");
            logging_in = false;
            if (result == null) {
                failed_login = true;
                message = "Can't connect to server.";
                return;
            }
            if (result.startsWith("ok")) {
                String session = result.split(":")[1];
                Client.username = usernameForm.getText();
                Client.session_key = session;
                Client.getInstance().getConfiguration().getOption("client.login.auto").trySetting("ok");
                Client.getInstance().getConfiguration().getOption("client.login.username").trySetting(usernameForm.getText());
                Client.getInstance().getConfiguration().getOption("client.login.password").trySetting(passwordForm.getText());
                if (Client.username.equals("Gobrosse") || Client.username.equals("kektest")) {
                    ClientLimitations.isDebugAllowed = true;
                }
                // If the user didn't opt-out, look for crash files and upload those
                if (Client.getInstance().getConfiguration().getStringOption("client.game.log-policy").equals("send")) {
                    JavaCrashesUploader t = new JavaCrashesUploader(Client.getInstance());
                    t.start();
                }
                can_next = true;
            } else if (result.startsWith("ko")) {
                failed_login = true;
                String reason = result.split(":")[1];
                if (reason.equals("notpremium"))
                    message = ("User is not premium");
                else if (reason.equals("invalidcredentials"))
                    message = ("Invalid credentials");
            } else {
                message = ("Unknown error");
            }
        };
        new SimplePostRequest("https://chunkstories.xyz/api/login.php", "user=" + usernameForm.getText() + "&pass=" + passwordForm.getText(), postAction);
    }
}
Also used : RequestResultAction(io.xol.chunkstories.net.http.RequestResultAction) JavaCrashesUploader(io.xol.chunkstories.bugsreporter.JavaCrashesUploader) LanguageSelectionScreen(io.xol.chunkstories.gui.layer.config.LanguageSelectionScreen) ObjectRenderer(io.xol.chunkstories.renderer.opengl.util.ObjectRenderer) Layer(io.xol.chunkstories.api.gui.Layer) ClientLimitations(io.xol.chunkstories.client.ClientLimitations) RenderingInterface(io.xol.chunkstories.api.rendering.RenderingInterface) SimplePostRequest(io.xol.chunkstories.net.http.SimplePostRequest) BaseButton(io.xol.chunkstories.api.gui.elements.BaseButton) GuiElement(io.xol.chunkstories.api.gui.GuiElement) InputText(io.xol.chunkstories.api.gui.elements.InputText) Client(io.xol.chunkstories.client.Client) Input(io.xol.chunkstories.api.input.Input) GameWindow(io.xol.chunkstories.api.rendering.GameWindow) FocusableGuiElement(io.xol.chunkstories.api.gui.FocusableGuiElement) Vector4f(org.joml.Vector4f) RequestResultAction(io.xol.chunkstories.net.http.RequestResultAction) SimplePostRequest(io.xol.chunkstories.net.http.SimplePostRequest) JavaCrashesUploader(io.xol.chunkstories.bugsreporter.JavaCrashesUploader)

Aggregations

FocusableGuiElement (io.xol.chunkstories.api.gui.FocusableGuiElement)1 GuiElement (io.xol.chunkstories.api.gui.GuiElement)1 Layer (io.xol.chunkstories.api.gui.Layer)1 BaseButton (io.xol.chunkstories.api.gui.elements.BaseButton)1 InputText (io.xol.chunkstories.api.gui.elements.InputText)1 Input (io.xol.chunkstories.api.input.Input)1 GameWindow (io.xol.chunkstories.api.rendering.GameWindow)1 RenderingInterface (io.xol.chunkstories.api.rendering.RenderingInterface)1 JavaCrashesUploader (io.xol.chunkstories.bugsreporter.JavaCrashesUploader)1 Client (io.xol.chunkstories.client.Client)1 ClientLimitations (io.xol.chunkstories.client.ClientLimitations)1 LanguageSelectionScreen (io.xol.chunkstories.gui.layer.config.LanguageSelectionScreen)1 RequestResultAction (io.xol.chunkstories.net.http.RequestResultAction)1 SimplePostRequest (io.xol.chunkstories.net.http.SimplePostRequest)1 ObjectRenderer (io.xol.chunkstories.renderer.opengl.util.ObjectRenderer)1 Vector4f (org.joml.Vector4f)1