Java Code Examples for com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService

The following are top voted examples for showing how to use com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ClientAPI   File: SessionBuilder.java   Source Code and License 6 votes vote down vote up
/**
 * Attempts to login with the specified username and password.
 * If the login is successful then a session will be created. If
 * not, {@code null} will be returned
 *
 * @return A valid session, if able to login, otherwise {@code null}
 */
@Override
public Session build() {
    UserAuthentication auth = new YggdrasilAuthenticationService(this.proxy, "").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(this.username);
    auth.setPassword(this.password);

    try {
        auth.logIn();
    } catch (AuthenticationException e) {
        return null;
    }

    GameProfile profile = auth.getSelectedProfile();
    return new Session(profile.getName(), profile.getId().toString(), auth.getAuthenticatedToken(), "MOJANG");
}
 
Example 2
Project: Proyecto-DASI   File: GradleStart.java   Source Code and License 6 votes vote down vote up
private void attemptLogin(Map<String, String> argMap)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(argMap.get("username"));
    auth.setPassword(argMap.get("password"));
    argMap.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    argMap.put("accessToken", auth.getAuthenticatedToken());
    argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    argMap.put("username", auth.getSelectedProfile().getName());
    argMap.put("userType", auth.getUserType().getName());
    
    // 1.8 only apperantly.. -_-
    argMap.put("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
 
Example 3
Project: SerenityCE   File: LoginThread.java   Source Code and License 6 votes vote down vote up
private final Session createSession(String username, String password) {
    if (password.isEmpty()) {
        return new Session(username, mc.getSession().getPlayerID(),
                "topkek memes", "mojang");
    }
    final YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(
            Proxy.NO_PROXY, "");
    final YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
            .createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(username);
    auth.setPassword(password);
    try {
        auth.logIn();
        return new Session(auth.getSelectedProfile().getName(), UUIDTypeAdapter.fromUUID(auth
                .getSelectedProfile().getId()),
                auth.getAuthenticatedToken(), "mojang");
    } catch (final Exception e) {
        return null;
    }
}
 
Example 4
Project: Backmemed   File: Manager.java   Source Code and License 6 votes vote down vote up
public static Session loginPassword(String username, String password)
{
    if(username == null || username.length() <= 0 || password == null || password.length() <= 0)
        return null;

    YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication b = (YggdrasilUserAuthentication)a.createUserAuthentication(Agent.MINECRAFT);
    b.setUsername(username);
    b.setPassword(password);
    try
    {
        b.logIn();
        return new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "LEGACY");
    } catch (AuthenticationException e)
    {
    	altScreen.dispErrorString = "".concat("\247cBad Login \2477(").concat(username).concat(")");
        e.printStackTrace();
    }
    return null;
}
 
Example 5
Project: Backmemed   File: YggdrasilPayload.java   Source Code and License 6 votes vote down vote up
public static Session loginPassword(String username, String password) {
    if (username == null || username.length() <= 0 || password == null || password.length() <= 0)
        return null;

    YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication b = (YggdrasilUserAuthentication) a.createUserAuthentication(Agent.MINECRAFT);
    b.setUsername(username);
    b.setPassword(password);
    try {
        b.logIn();
        return new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "LEGACY");
    } catch (AuthenticationException e) {
        e.printStackTrace();
        System.out.println("Failed login: " + username + ":" + password);
    }
    return null;
}
 
Example 6
Project: CustomWorldGen   File: Yggdrasil.java   Source Code and License 6 votes vote down vote up
public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // don't set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}
 
Example 7
Project: CustomWorldGen   File: DedicatedServer.java   Source Code and License 6 votes vote down vote up
public DedicatedServer(File anvilFileIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    super(anvilFileIn, Proxy.NO_PROXY, dataFixerIn, authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn);
    Thread thread = new Thread("Server Infinisleeper")
    {
        {
            this.setDaemon(true);
            this.start();
        }
        public void run()
        {
            while (true)
            {
                try
                {
                    Thread.sleep(2147483647L);
                }
                catch (InterruptedException var2)
                {
                    ;
                }
            }
        }
    };
}
 
Example 8
Project: CustomWorldGen   File: GradleStart.java   Source Code and License 6 votes vote down vote up
private void attemptLogin(Map<String, String> argMap)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(argMap.get("username"));
    auth.setPassword(argMap.get("password"));
    argMap.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    argMap.put("accessToken", auth.getAuthenticatedToken());
    argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    argMap.put("username", auth.getSelectedProfile().getName());
    argMap.put("userType", auth.getUserType().getName());
    
    // 1.8 only apperantly.. -_-
    argMap.put("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
 
Example 9
Project: TRHS_Club_Mod_2016   File: Yggdrasil.java   Source Code and License 6 votes vote down vote up
public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}
 
Example 10
Project: PopularMMOS-EpicProportions-Mod   File: Yggdrasil.java   Source Code and License 6 votes vote down vote up
public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}
 
Example 11
Project: ExpandedRailsMod   File: GradleStart.java   Source Code and License 6 votes vote down vote up
private void attemptLogin(Map<String, String> argMap)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(argMap.get("username"));
    auth.setPassword(argMap.get("password"));
    argMap.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    argMap.put("accessToken", auth.getAuthenticatedToken());
    argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    argMap.put("username", auth.getSelectedProfile().getName());
    argMap.put("userType", auth.getUserType().getName());
    
    // 1.8 only apperantly.. -_-
    argMap.put("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
 
Example 12
Project: Cauldron   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public Minecraft(Session p_i1103_1_, int p_i1103_2_, int p_i1103_3_, boolean p_i1103_4_, boolean p_i1103_5_, File p_i1103_6_, File p_i1103_7_, File p_i1103_8_, Proxy p_i1103_9_, String p_i1103_10_, Multimap p_i1103_11_, String p_i1103_12_)
{
    theMinecraft = this;
    this.mcDataDir = p_i1103_6_;
    this.fileAssets = p_i1103_7_;
    this.fileResourcepacks = p_i1103_8_;
    this.launchedVersion = p_i1103_10_;
    this.field_152356_J = p_i1103_11_;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(p_i1103_7_, p_i1103_12_)).func_152782_a());
    this.addDefaultResourcePack();
    this.proxy = p_i1103_9_ == null ? Proxy.NO_PROXY : p_i1103_9_;
    this.field_152355_az = (new YggdrasilAuthenticationService(p_i1103_9_, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.startTimerHackThread();
    this.session = p_i1103_1_;
    logger.info("Setting user: " + p_i1103_1_.getUsername());
    this.isDemo = p_i1103_5_;
    this.displayWidth = p_i1103_2_;
    this.displayHeight = p_i1103_3_;
    this.tempDisplayWidth = p_i1103_2_;
    this.tempDisplayHeight = p_i1103_3_;
    this.fullscreen = p_i1103_4_;
    this.jvm64bit = isJvm64bit();
    ImageIO.setUseCache(false);
    Bootstrap.func_151354_b();
}
 
Example 13
Project: Cauldron   File: MinecraftServer.java   Source Code and License 6 votes vote down vote up
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
{
    this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
    mcServer = this;
    this.serverProxy = p_i45281_2_;
    this.anvilFile = p_i45281_1_;
    this.field_147144_o = new NetworkSystem(this);
    this.commandManager = new ServerCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(p_i45281_1_);
    this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
    this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
    this.field_152365_W = this.field_152364_T.createProfileRepository();
    this.primaryThread = new Thread(this, "Server thread"); // CraftBukkit
    this.cauldronConfig = new CauldronConfig("cauldron.yml", "cauldron");
    this.tileEntityConfig = new TileEntityConfig("tileentities.yml", "cauldron_te");
}
 
Example 14
Project: Cauldron   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public Minecraft(Session p_i1103_1_, int p_i1103_2_, int p_i1103_3_, boolean p_i1103_4_, boolean p_i1103_5_, File p_i1103_6_, File p_i1103_7_, File p_i1103_8_, Proxy p_i1103_9_, String p_i1103_10_, Multimap p_i1103_11_, String p_i1103_12_)
{
    theMinecraft = this;
    this.mcDataDir = p_i1103_6_;
    this.fileAssets = p_i1103_7_;
    this.fileResourcepacks = p_i1103_8_;
    this.launchedVersion = p_i1103_10_;
    this.field_152356_J = p_i1103_11_;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(p_i1103_7_, p_i1103_12_)).func_152782_a());
    this.addDefaultResourcePack();
    this.proxy = p_i1103_9_ == null ? Proxy.NO_PROXY : p_i1103_9_;
    this.field_152355_az = (new YggdrasilAuthenticationService(p_i1103_9_, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.startTimerHackThread();
    this.session = p_i1103_1_;
    logger.info("Setting user: " + p_i1103_1_.getUsername());
    this.isDemo = p_i1103_5_;
    this.displayWidth = p_i1103_2_;
    this.displayHeight = p_i1103_3_;
    this.tempDisplayWidth = p_i1103_2_;
    this.tempDisplayHeight = p_i1103_3_;
    this.fullscreen = p_i1103_4_;
    this.jvm64bit = isJvm64bit();
    ImageIO.setUseCache(false);
    Bootstrap.func_151354_b();
}
 
Example 15
Project: Forbidden   File: GradleStart.java   Source Code and License 6 votes vote down vote up
private static void attemptLogin(GradleStart args)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.values.get("username"));
    auth.setPassword(args.values.get("password"));
    args.values.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    args.values.put("accessToken", auth.getAuthenticatedToken());
    args.values.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.values.put("username", auth.getSelectedProfile().getName());
    //@@[email protected]@
    args.values.put("userProperties", auth.getUserProperties().toString());
}
 
Example 16
Project: SpigotSource   File: DedicatedServer.java   Source Code and License 6 votes vote down vote up
public DedicatedServer(joptsimple.OptionSet options, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
    super(options, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
    // CraftBukkit end
    Thread thread = new Thread("Server Infinisleeper") {
        {
            this.setDaemon(true);
            this.start();
        }

        public void run() {
            while (true) {
                try {
                    Thread.sleep(2147483647L);
                } catch (InterruptedException interruptedexception) {
                    ;
                }
            }
        }
    };
}
 
Example 17
Project: CreeperHostGui   File: Client.java   Source Code and License 5 votes vote down vote up
@Override
public UUID getUUID()
{
    if (cache != null)
        return cache;
    Minecraft mc = Minecraft.getMinecraft();
    Session session = mc.getSession();
    boolean online = true;
    if (session.getToken().length() != 32 || session.getPlayerID().length() != 32)
    {
        online = false;
    }

    UUID uuid;

    if (online)
    {
        YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(mc.getProxy(), UUID.randomUUID().toString());
        GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
        PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(mc.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName()));
        uuid = playerprofilecache.getGameProfileForUsername(Minecraft.getMinecraft().getSession().getUsername()).getId();
    }
    else
    {
        uuid = EntityPlayer.getOfflineUUID(session.getUsername().toLowerCase());
    }
    cache = uuid;
    return uuid;
}
 
Example 18
Project: DecompiledMinecraft   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File workDir, Proxy proxy, File profileCacheDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = workDir;
    this.networkSystem = new NetworkSystem(this);
    this.profileCache = new PlayerProfileCache(this, profileCacheDir);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(workDir);
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 19
Project: DecompiledMinecraft   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.field_181038_N = gameConfig.userInfo.field_181172_c;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex)).getResourceMap());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    logger.info("Setting user: " + this.session.getUsername());
    logger.info("(Session ID is " + this.session.getSessionID() + ")");
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = new IntegratedServer(this);

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
}
 
Example 20
Project: DecompiledMinecraft   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(Proxy proxy, File workDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = null;
    this.networkSystem = null;
    this.profileCache = new PlayerProfileCache(this, workDir);
    this.commandManager = null;
    this.anvilConverterForAnvilFile = null;
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 21
Project: DecompiledMinecraft   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File workDir, Proxy proxy, File profileCacheDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = workDir;
    this.networkSystem = new NetworkSystem(this);
    this.profileCache = new PlayerProfileCache(this, profileCacheDir);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(workDir);
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 22
Project: BaseClient   File: LoginThread.java   Source Code and License 5 votes vote down vote up
private Session createSession(String email, String pass) {
    YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication authentication = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
    authentication.setUsername(email);
    authentication.setPassword(pass);
    try {
        authentication.logIn();
        return new Session(authentication.getSelectedProfile().getName(), authentication.getSelectedProfile().getId().toString(), authentication.getAuthenticatedToken(), "legacy");
    }
    catch (AuthenticationException e) {
        return null;
    }
}
 
Example 23
Project: BaseClient   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.field_181038_N = gameConfig.userInfo.field_181172_c;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex)).getResourceMap());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    logger.info("Setting user: " + this.session.getUsername());
    logger.info("(Session ID is " + this.session.getSessionID() + ")");
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = new IntegratedServer(this);

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
}
 
Example 24
Project: BaseClient   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(Proxy proxy, File workDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = null;
    this.networkSystem = null;
    this.profileCache = new PlayerProfileCache(this, workDir);
    this.commandManager = null;
    this.anvilConverterForAnvilFile = null;
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 25
Project: BaseClient   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File workDir, Proxy proxy, File profileCacheDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = workDir;
    this.networkSystem = new NetworkSystem(this);
    this.profileCache = new PlayerProfileCache(this, profileCacheDir);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(workDir);
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 26
Project: BaseClient   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig) {
	theMinecraft = this;
	this.mcDataDir = gameConfig.folderInfo.mcDataDir;
	this.fileAssets = gameConfig.folderInfo.assetsDir;
	this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
	this.launchedVersion = gameConfig.gameInfo.version;
	this.twitchDetails = gameConfig.userInfo.userProperties;
	this.field_181038_N = gameConfig.userInfo.field_181172_c;
	this.mcDefaultResourcePack = new DefaultResourcePack(
			(new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex))
					.getResourceMap());
	this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
	this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy,
			UUID.randomUUID().toString())).createMinecraftSessionService();
	this.session = gameConfig.userInfo.session;
	logger.info("Setting user: " + this.session.getUsername());
	logger.info("(Session ID is " + this.session.getSessionID() + ")");
	this.isDemo = gameConfig.gameInfo.isDemo;
	this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
	this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
	this.tempDisplayWidth = gameConfig.displayInfo.width;
	this.tempDisplayHeight = gameConfig.displayInfo.height;
	this.fullscreen = gameConfig.displayInfo.fullscreen;
	this.jvm64bit = isJvm64bit();
	this.theIntegratedServer = new IntegratedServer(this);

	if (gameConfig.serverInfo.serverName != null) {
		this.serverName = gameConfig.serverInfo.serverName;
		this.serverPort = gameConfig.serverInfo.serverPort;
	}

	ImageIO.setUseCache(false);
	Bootstrap.register();
}
 
Example 27
Project: BaseClient   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(Proxy proxy, File workDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = null;
    this.networkSystem = null;
    this.profileCache = new PlayerProfileCache(this, workDir);
    this.commandManager = null;
    this.anvilConverterForAnvilFile = null;
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 28
Project: BaseClient   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File workDir, Proxy proxy, File profileCacheDir)
{
    this.serverProxy = proxy;
    mcServer = this;
    this.anvilFile = workDir;
    this.networkSystem = new NetworkSystem(this);
    this.profileCache = new PlayerProfileCache(this, profileCacheDir);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(workDir);
    this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
    this.sessionService = this.authService.createMinecraftSessionService();
    this.profileRepo = this.authService.createProfileRepository();
}
 
Example 29
Project: Zombe-Modpack   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    LOGGER.debug("(Session ID is {})", new Object[] {this.session.getSessionID()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
    
    //-ZMod-core----------------------------------------------------------
    ZHandle.onMinecraftInit(this);
    //--------------------------------------------------------------------
}
 
Example 30
Project: Backmemed   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    LOGGER.debug("(Session ID is {})", new Object[] {this.session.getSessionID()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Locale.setDefault(Locale.ROOT);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
}
 
Example 31
Project: Backmemed   File: IntegratedServer.java   Source Code and License 5 votes vote down vote up
public IntegratedServer(Minecraft clientIn, String folderNameIn, String worldNameIn, WorldSettings worldSettingsIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    super(new File(clientIn.mcDataDir, "saves"), clientIn.getProxy(), clientIn.getDataFixer(), authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn);
    this.setServerOwner(clientIn.getSession().getUsername());
    this.setFolderName(folderNameIn);
    this.setWorldName(worldNameIn);
    this.setDemo(clientIn.isDemo());
    this.canCreateBonusChest(worldSettingsIn.isBonusChestEnabled());
    this.setBuildLimit(256);
    this.setPlayerList(new IntegratedPlayerList(this));
    this.mc = clientIn;
    this.theWorldSettings = this.isDemo() ? DemoWorldServer.DEMO_WORLD_SETTINGS : worldSettingsIn;
}
 
Example 32
Project: Backmemed   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File anvilFileIn, Proxy proxyIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    this.serverProxy = proxyIn;
    this.authService = authServiceIn;
    this.sessionService = sessionServiceIn;
    this.profileRepo = profileRepoIn;
    this.profileCache = profileCacheIn;
    this.anvilFile = anvilFileIn;
    this.networkSystem = new NetworkSystem(this);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(anvilFileIn, dataFixerIn);
    this.dataFixer = dataFixerIn;
}
 
Example 33
Project: CustomWorldGen   File: Minecraft.java   Source Code and License 5 votes vote down vote up
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
}
 
Example 34
Project: CustomWorldGen   File: IntegratedServer.java   Source Code and License 5 votes vote down vote up
public IntegratedServer(Minecraft clientIn, String folderNameIn, String worldNameIn, WorldSettings worldSettingsIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    super(new File(clientIn.mcDataDir, "saves"), clientIn.getProxy(), clientIn.getDataFixer(), authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn);
    this.setServerOwner(clientIn.getSession().getUsername());
    this.setFolderName(folderNameIn);
    this.setWorldName(worldNameIn);
    this.setDemo(clientIn.isDemo());
    this.canCreateBonusChest(worldSettingsIn.isBonusChestEnabled());
    this.setBuildLimit(256);
    this.setPlayerList(new IntegratedPlayerList(this));
    this.mc = clientIn;
    this.theWorldSettings = this.isDemo() ? DemoWorldServer.DEMO_WORLD_SETTINGS : worldSettingsIn;
}
 
Example 35
Project: CustomWorldGen   File: MinecraftServer.java   Source Code and License 5 votes vote down vote up
public MinecraftServer(File anvilFileIn, Proxy proxyIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    this.serverProxy = proxyIn;
    this.authService = authServiceIn;
    this.sessionService = sessionServiceIn;
    this.profileRepo = profileRepoIn;
    this.profileCache = profileCacheIn;
    this.anvilFile = anvilFileIn;
    this.networkSystem = new NetworkSystem(this);
    this.commandManager = this.createNewCommandManager();
    this.anvilConverterForAnvilFile = new AnvilSaveConverter(anvilFileIn, dataFixerIn);
    this.dataFixer = dataFixerIn;
}
 
Example 36
Project: Basin   File: SinkActivator.java   Source Code and License 5 votes vote down vote up
@Nonnull
private DedicatedServer constructServerInstance(@Nonnull BundleContext ctx) {
  logger.info("Initializing Minecraft %s", FaucetVersion.API_VERSION);
  Bootstrap.register(); // apparently this is how the registries work ... don't question it

  // log some environment information
  logger.info("Running on Java v%s supplied by %s", System.getProperty("java.version", "Unknown"),
      System.getProperty("java.vendor"));

  // TODO: Integrate with plugins here?
  YggdrasilAuthenticationService var15 = new YggdrasilAuthenticationService(Proxy.NO_PROXY,
      UUID.randomUUID().toString());
  MinecraftSessionService var16 = var15.createMinecraftSessionService();
  GameProfileRepository var17 = var15.createProfileRepository();
  PlayerProfileCache var18 = new PlayerProfileCache(var17, new File(".", "usercache.json"));

  DedicatedServer server = new DedicatedServer(new File("."), DataFixesManager.createFixer(),
      var15, var16, var17, var18);

  // TODO: Re-introduce configuration

  if (!GraphicsEnvironment.isHeadless()) {
    logger.info("Server GUI has been disabled or is unavailable in this environment");
    // TODO: Custom GUI
  } else {
    logger
        .info("Server GUI has been disabled or is not available within the current environment");
  }

  return server;
}
 
Example 37
Project: placementpreview   File: FakeServer.java   Source Code and License 5 votes vote down vote up
public FakeServer(Minecraft clientIn, String folderNameIn, String worldNameIn, WorldSettings worldSettingsIn,
        YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn,
        GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    super(new File(clientIn.mcDataDir, "saves"), null, clientIn.getDataFixer(), authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn);

    this.setPlayerList(new FakePlayerList(this));
}
 
Example 38
Project: OpenModLoader   File: OpenModLoaderClient.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) {
    File file = new File(".gradle/minecraft/natives/");
    if (!file.exists()) {
        file = new File("../.gradle/minecraft/natives/");
    }
    System.setProperty("org.lwjgl.librarypath", file.getAbsolutePath());
    OMLStrippableTransformer.SIDE = Side.CLIENT;
    LaunchArguments arguments = new LaunchArguments(args);

    if (arguments.containsArgument("password")) {
        YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) (new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1")).createUserAuthentication(Agent.MINECRAFT);
        auth.setUsername(arguments.getArgument("username"));
        auth.setPassword(arguments.getArgument("password"));
        arguments.removeArgument("password");

        try {
            auth.logIn();
        } catch (AuthenticationException e) {
            e.printStackTrace();
            return;
        }

        arguments.addArgument("accessToken", auth.getAuthenticatedToken());
        arguments.addArgument("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
        arguments.addArgument("username", auth.getSelectedProfile().getName());
        arguments.addArgument("userType", auth.getUserType().getName());
        arguments.addArgument("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
    }

    arguments.addArgument("version", "1.10.2");
    arguments.addArgument("assetIndex", "1.10");
    arguments.addArgument("tweakClass", "xyz.openmodloader.launcher.OMLTweaker");

    if (arguments.containsArgument("accessToken")) {
        arguments.addArgument("accessToken", "OpenModLoader");
    }

    Launch.main(arguments.getArguments());
}
 
Example 39
Project: Sink   File: SinkActivator.java   Source Code and License 5 votes vote down vote up
@Nonnull
private DedicatedServer constructServerInstance(@Nonnull BundleContext ctx) {
  logger.info("Initializing Minecraft %s", FaucetVersion.API_VERSION);
  Bootstrap.register(); // apparently this is how the registries work ... don't question it

  // log some environment information
  logger.info("Running on Java v%s supplied by %s", System.getProperty("java.version", "Unknown"),
      System.getProperty("java.vendor"));

  // TODO: Integrate with plugins here?
  YggdrasilAuthenticationService var15 = new YggdrasilAuthenticationService(Proxy.NO_PROXY,
      UUID.randomUUID().toString());
  MinecraftSessionService var16 = var15.createMinecraftSessionService();
  GameProfileRepository var17 = var15.createProfileRepository();
  PlayerProfileCache var18 = new PlayerProfileCache(var17, new File(".", "usercache.json"));

  DedicatedServer server = new DedicatedServer(new File("."), DataFixesManager.createFixer(),
      var15, var16, var17, var18);

  // TODO: Re-introduce configuration

  if (!GraphicsEnvironment.isHeadless()) {
    logger.info("Server GUI has been disabled or is unavailable in this environment");
    // TODO: Custom GUI
  } else {
    logger
        .info("Server GUI has been disabled or is not available within the current environment");
  }

  return server;
}
 
Example 40
Project: Providence   File: Client.java   Source Code and License 5 votes vote down vote up
public static void login(String username, String password) {
    try {
        YggdrasilUserAuthentication auth = new YggdrasilUserAuthentication(new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID
                .randomUUID().toString()), Agent.MINECRAFT);
        auth.setUsername(username);
        auth.setPassword(password);
        auth.logIn();
        Session session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
                auth.getAuthenticatedToken(), Session.Type.MOJANG.name());
        Minecraft.getMinecraft().session = session;
    } catch (Exception e) {
        e.printStackTrace();
    }
}