package com.mojang.realmsclient.util.task;

import com.mojang.realmsclient.exception.RealmsServiceException;
import com.mojang.realmsclient.client.RealmsClient;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.gui.screens.Screen;

public class WorldCreationTask extends LongRunningTask {
    private final String name;
    private final String motd;
    private final long worldId;
    private final Screen lastScreen;
    
    public WorldCreationTask(final long long1, final String string2, final String string3, final Screen dqs) {
        this.worldId = long1;
        this.name = string2;
        this.motd = string3;
        this.lastScreen = dqs;
    }
    
    @Override
    public void run() {
        final String string2 = I18n.get("mco.create.world.wait");
        this.setTitle(string2);
        final RealmsClient dia3 = RealmsClient.create();
        try {
            dia3.initializeWorld(this.worldId, this.name, this.motd);
            LongRunningTask.setScreen(this.lastScreen);
        }
        catch (RealmsServiceException djh4) {
            WorldCreationTask.LOGGER.error("Couldn't create world");
            this.error(djh4.toString());
        }
        catch (Exception exception4) {
            WorldCreationTask.LOGGER.error("Could not create world");
            this.error(exception4.getLocalizedMessage());
        }
    }
}
