当前位置: 首页>>代码示例>>Java>>正文


Java Session类代码示例

本文整理汇总了Java中net.minecraft.util.Session的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Session类属于net.minecraft.util包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import net.minecraft.util.Session; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:23,代码来源:SessionBuilder.java

示例2: createSession

import net.minecraft.util.Session; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:21,代码来源:LoginThread.java

示例3: run

import net.minecraft.util.Session; //导入依赖的package包/类
@Override
public void run() {
    status = "Logging in...";

    final Session auth = createSession(account.getAuthName(), account.getAuthPassword());
    if (auth == null) {
        status = EnumChatFormatting.RED + "Failed.";
    } else {
        status = String.format(EnumChatFormatting.GREEN + "Success. (Logged in as %s.)", auth.getUsername());

        if (account instanceof MigratedAccount) {
            ((MigratedAccount) account).setDisplay(auth.getUsername());
        }

        ((MinecraftExtension) mc).setSession(auth);
    }
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:18,代码来源:LoginThread.java

示例4: loginPassword

import net.minecraft.util.Session; //导入依赖的package包/类
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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:Manager.java

示例5: loginPassword

import net.minecraft.util.Session; //导入依赖的package包/类
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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:YggdrasilPayload.java

示例6: login

import net.minecraft.util.Session; //导入依赖的package包/类
public boolean login() {
    if (Password != "" && Password != null) {
        Session AuthResponse = Payload.loginPassword(this.Username, this.Password);
        if (AuthResponse != null) {
            session = (AuthResponse);
            return true;
        }

    } else {
        Session AuthResponseCrack = Payload.loginCrack(this.Username);
        session = (AuthResponseCrack);
        return true;
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:YggdrasilAuthenticator.java

示例7: preInit

import net.minecraft.util.Session; //导入依赖的package包/类
@Override
public void preInit(final @Nonnull FMLPreInitializationEvent event) {
	super.preInit(event);

	Log.log = event.getModLog();
	Config.init(event.getSuggestedConfigurationFile());

	// Setup stencil clip
	// StencilClip.init();

	// Setup location
	Client.initLocation(new Locations(event.getSourceFile(), getDataDirectory()));

	// Get Id
	final String id = Client.mc.getSession().getPlayerID();
	try {
		final Object o = UUIDTypeAdapter.fromString(id);
		if (o!=null) {
			Client.id = id;
			final Session s = Client.mc.getSession();
			Client.name = s.getUsername();
			Client.token = s.getToken();
		}
	} catch (final IllegalArgumentException e) {
	}
}
 
开发者ID:Team-Fruit,项目名称:SignPicture,代码行数:27,代码来源:ClientProxy.java

示例8: setSession

import net.minecraft.util.Session; //导入依赖的package包/类
public static void setSession(Session s) throws Exception {
	Class<? extends Minecraft> mc = Minecraft.getMinecraft().getClass();
	try {
		Field session = null;

		for (Field f : mc.getDeclaredFields()) {
			if (f.getType().isInstance(s)) {
				session = f;
				System.out.println("Found field " + f.toString() + ", injecting...");
			}
		}

		if (session == null) {
			throw new IllegalStateException("No field of type " + Session.class.getCanonicalName() + " declared.");
		}

		session.setAccessible(true);
		session.set(Minecraft.getMinecraft(), s);
		session.setAccessible(false);
	} catch (Exception e) {
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:In-Game-Account-Switcher,代码行数:25,代码来源:MR.java

示例9: setSession

import net.minecraft.util.Session; //导入依赖的package包/类
public static void setSession(Session newSession) throws Exception {
	Class<? extends Minecraft> mc = Minecraft.getMinecraft().getClass();
	try {
		Field session = null;

		for (Field field : mc.getDeclaredFields()) {
			if (field.getType().isInstance(newSession)) {
				session = field;
				System.out.println("Attempting Injection into Session.");
			}
		}

		if (session == null) {
			throw new IllegalStateException("No field of type " + Session.class.getCanonicalName() + " declared.");
		}

		session.setAccessible(true);
		session.set(Minecraft.getMinecraft(), newSession);
		session.setAccessible(false);
	} catch (Exception exeption) {
		exeption.printStackTrace();
		throw exeption;
	}
}
 
开发者ID:Its-its,项目名称:AltManager,代码行数:25,代码来源:SessionChanger.java

示例10: initGui

import net.minecraft.util.Session; //导入依赖的package包/类
/**
 * Adds the buttons (and other controls) to the screen in question.
 */
public void initGui()
{
    Keyboard.enableRepeatEvents(true);
    this.buttonList.clear();
    this.field_146844_r = new GuiScreenBackup.SelectionList();
    (new Thread("MCO Backup Requester #" + field_146845_a.incrementAndGet())
    {
        private static final String __OBFID = "CL_00000767";
        public void run()
        {
            Session var1 = GuiScreenBackup.this.mc.getSession();
            McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());

            try
            {
                GuiScreenBackup.this.field_146847_i = var2.func_148704_d(GuiScreenBackup.this.field_146846_h).theBackupList;
            }
            catch (ExceptionMcoService var4)
            {
                GuiScreenBackup.logger.error("Couldn\'t request backups", var4);
            }
        }
    }).start();
    this.func_146840_h();
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:29,代码来源:GuiScreenBackup.java

示例11: func_146821_q

import net.minecraft.util.Session; //导入依赖的package包/类
private void func_146821_q()
{
    Session var1 = this.mc.getSession();
    McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());

    try
    {
        String var3 = var2.func_148708_h(this.field_146846_h);
        Clipboard var4 = Toolkit.getDefaultToolkit().getSystemClipboard();
        var4.setContents(new StringSelection(var3), (ClipboardOwner)null);
        this.func_146823_a(var3);
    }
    catch (ExceptionMcoService var5)
    {
        logger.error("Couldn\'t download world data");
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:18,代码来源:GuiScreenBackup.java

示例12: initGui

import net.minecraft.util.Session; //导入依赖的package包/类
/**
 * Adds the buttons (and other controls) to the screen in question.
 */
public void initGui()
{
    Keyboard.enableRepeatEvents(true);
    this.buttonList.clear();
    this.field_146957_r = new GuiScreenMcoWorldTemplate.SelectionList();
    (new Thread("MCO World Creator #" + field_146958_a.incrementAndGet())
    {
        private static final String __OBFID = "CL_00000787";
        public void run()
        {
            Session var1 = GuiScreenMcoWorldTemplate.this.mc.getSession();
            McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());

            try
            {
                GuiScreenMcoWorldTemplate.this.field_146960_i = var2.func_148693_e().field_148782_a;
            }
            catch (ExceptionMcoService var4)
            {
                GuiScreenMcoWorldTemplate.logger.error("Couldn\'t fetch templates");
            }
        }
    }).start();
    this.func_146952_h();
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:29,代码来源:GuiScreenMcoWorldTemplate.java

示例13: initGui

import net.minecraft.util.Session; //导入依赖的package包/类
/**
 * Adds the buttons (and other controls) to the screen in question.
 */
public void initGui()
{
    Keyboard.enableRepeatEvents(true);
    this.buttonList.clear();
    this.field_146733_h = new GuiScreenPendingInvitation.List();
    (new Thread("MCO List Invites #" + field_146732_a.incrementAndGet())
    {
        private static final String __OBFID = "CL_00000798";
        public void run()
        {
            Session var1 = GuiScreenPendingInvitation.this.mc.getSession();
            McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());

            try
            {
                GuiScreenPendingInvitation.this.field_146734_i = var2.func_148710_g().field_148768_a;
            }
            catch (ExceptionMcoService var4)
            {
                GuiScreenPendingInvitation.logger.error("Couldn\'t list invites");
            }
        }
    }).start();
    this.func_146728_h();
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:29,代码来源:GuiScreenPendingInvitation.java

示例14: func_146724_i

import net.minecraft.util.Session; //导入依赖的package包/类
private void func_146724_i()
{
    if (this.field_146731_r >= 0 && this.field_146731_r < this.field_146734_i.size())
    {
        (new Thread("MCO Reject Invite #" + field_146732_a.incrementAndGet())
        {
            private static final String __OBFID = "CL_00000800";
            public void run()
            {
                try
                {
                    Session var1 = GuiScreenPendingInvitation.this.mc.getSession();
                    McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());
                    var2.func_148706_b(((PendingInvite)GuiScreenPendingInvitation.this.field_146734_i.get(GuiScreenPendingInvitation.this.field_146731_r)).field_148776_a);
                    GuiScreenPendingInvitation.this.func_146718_q();
                }
                catch (ExceptionMcoService var3)
                {
                    GuiScreenPendingInvitation.logger.error("Couldn\'t reject invite");
                }
            }
        }).start();
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:25,代码来源:GuiScreenPendingInvitation.java

示例15: func_146723_p

import net.minecraft.util.Session; //导入依赖的package包/类
private void func_146723_p()
{
    if (this.field_146731_r >= 0 && this.field_146731_r < this.field_146734_i.size())
    {
        (new Thread("MCO Accept Invite #" + field_146732_a.incrementAndGet())
        {
            private static final String __OBFID = "CL_00000801";
            public void run()
            {
                try
                {
                    Session var1 = GuiScreenPendingInvitation.this.mc.getSession();
                    McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());
                    var2.func_148691_a(((PendingInvite)GuiScreenPendingInvitation.this.field_146734_i.get(GuiScreenPendingInvitation.this.field_146731_r)).field_148776_a);
                    GuiScreenPendingInvitation.this.func_146718_q();
                }
                catch (ExceptionMcoService var3)
                {
                    GuiScreenPendingInvitation.logger.error("Couldn\'t accept invite");
                }
            }
        }).start();
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:25,代码来源:GuiScreenPendingInvitation.java


注:本文中的net.minecraft.util.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。