类net.minecraft.util.Session源码实例Demo

下面列出了怎么用net.minecraft.util.Session的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: seppuku   文件: NameCommand.java
@Override
public void exec(String input) {
    if (!this.clamp(input, 2, 2)) {
        this.printUsage();
        return;
    }

    final String[] split = input.split(" ");

    if(split[1].equalsIgnoreCase(Minecraft.getMinecraft().session.getUsername())) {
        Minecraft.getMinecraft().session = new Session(split[1], Minecraft.getMinecraft().session.getPlayerID(), Minecraft.getMinecraft().session.getToken(), "mojang");
        Seppuku.INSTANCE.logChat("Set username to " + split[1]);
    }else{
        Seppuku.INSTANCE.errorChat("Name must match");
    }
}
 
源代码2 项目: LiquidBounce   文件: GuiChangeName.java
@Override
protected void actionPerformed(GuiButton button) throws IOException {
    switch(button.id) {
        case 0:
            mc.displayGuiScreen(prevGui);
            break;
        case 1:
            if(name.getText().isEmpty()) {
                status = "§cEnter a name!";
                return;
            }

            if(!name.getText().equalsIgnoreCase(mc.getSession().getUsername())) {
                status = "§cJust change the upper and lower case!";
                return;
            }

            mc.session = new Session(name.getText(), mc.getSession().getPlayerID(), mc.getSession().getToken(), mc.getSession().getSessionType().name());
            LiquidBounce.eventManager.callEvent(new SessionEvent());
            status = "§aChanged name to §7" + name.getText() + "§c.";
            prevGui.status = status;
            mc.displayGuiScreen(prevGui);
            break;
    }
    super.actionPerformed(button);
}
 
源代码3 项目: ClientBase   文件: Utils.java
public static Session createSession(String username, String password, @NotNull Proxy proxy) throws Exception {
    YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(proxy, "");
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
            .createUserAuthentication(Agent.MINECRAFT);

    auth.setUsername(username);
    auth.setPassword(password);

    auth.logIn();
    return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
            auth.getAuthenticatedToken(), "mojang");
}
 
源代码4 项目: ClientBase   文件: LoginCommand.java
@Override
public void run(String alias, @NotNull String[] args) {
    if (args.length < 1) {
        throw new CommandException("Usage: ." + alias + " <username:password> or <username> <password>");
    }
    String username;
    String password;

    if (args.length == 1) {
        if (!args[0].contains(":"))
            throw new CommandException("Usage: ." + alias + " <username:password> or <username> <password>");

        String split[] = args[0].split(":");

        if (split.length != 2) {
            throw new CommandException("Usage: ." + alias + " <username:password> or <username> <password>");
        }

        username = split[0];
        password = split[1];
    } else {
        username = args[0];
        password = args[1];
    }
    try {
        Session session = Utils.createSession(username, password, Proxy.NO_PROXY);

        ((IMixinMinecraft) Minecraft.getMinecraft()).setSession(session);

        ChatUtils.success("Logged in. New IGN: " + session.getUsername());
    } catch (Exception e) {
        throw new CommandException(e.getMessage());
    }

}
 
源代码5 项目: Hyperium   文件: SessionManager.java
public void login() {
    Session session = autotip.getMinecraft().getSession();
    GameProfile profile = session.getProfile();

    String uuid = profile.getId().toString().replace("-", "");
    String serverHash = HashUtil.hash(uuid + HashUtil.getNextSalt());

    int statusCode = authenticate(session.getToken(), uuid, serverHash);
    if (statusCode / 100 != 2) {
        messageUtil.send("&cError {} during authentication: Session servers down?", statusCode);
        return;
    }

    StatsRange all = autotip.getStatsManager().getAll();
    LoginRequest request = LoginRequest.of(autotip, profile, serverHash, all.getTipsTotalInt());

    long lastLogin = autotip.getEvent(EventClientConnection.class).getLastLogin();
    long delay = lastLogin + 5000 - System.currentTimeMillis();
    delay /= 1000;

    reply = taskManager.scheduleAndAwait(request::execute, (delay < 1) ? 1 : delay);
    if (reply == null || !reply.isSuccess()) {
        messageUtil.send("&cError during login: {}", reply == null ? "null" : reply.getCause());
        return;
    }

    sessionKey = reply.getSessionKey();

    loggedIn = true;

    long keepAlive = reply.getKeepAliveRate();
    long tipWave = reply.getTipWaveRate();

    taskManager.addRepeatingTask(TaskType.KEEP_ALIVE, this::keepAlive, keepAlive, keepAlive);
    taskManager.addRepeatingTask(TaskType.TIP_WAVE, this::tipWave, 0, tipWave);
}
 
源代码6 项目: malmo   文件: AuthenticationHelper.java
public static boolean setPlayerName(Session currentSession, String newPlayerName)
{
    if (currentSession.getUsername().equals(newPlayerName))
        return true;

    // Create new session object:
    Session newSession = new Session(newPlayerName, currentSession.getPlayerID(), currentSession.getToken(), "mojang"/*currentSession.getSessionType().toString()*/);
    newSession.setProperties(new com.mojang.authlib.properties.PropertyMap());  // Prevents calls to the session service to get profile properties
    return setSession(newSession);
}
 
源代码7 项目: LiquidBounce   文件: MixinGuiDisconnected.java
@Inject(method = "actionPerformed", at = @At("HEAD"))
private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
    switch (button.id) {
        case 1:
            ServerUtils.connectToLastServer();
            break;
        case 3:
            if (!GuiTheAltening.Companion.getApiKey().isEmpty()) {
                final String apiKey = GuiTheAltening.Companion.getApiKey();
                final TheAltening theAltening = new TheAltening(apiKey);

                try {
                    final AccountData account = theAltening.getAccountData();
                    GuiAltManager.altService.switchService(AltService.EnumAltService.THEALTENING);

                    final YggdrasilUserAuthentication yggdrasilUserAuthentication = new YggdrasilUserAuthentication(new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""), Agent.MINECRAFT);
                    yggdrasilUserAuthentication.setUsername(account.getToken());
                    yggdrasilUserAuthentication.setPassword(LiquidBounce.CLIENT_NAME);
                    yggdrasilUserAuthentication.logIn();

                    mc.session = new Session(yggdrasilUserAuthentication.getSelectedProfile().getName(), yggdrasilUserAuthentication.getSelectedProfile().getId().toString(), yggdrasilUserAuthentication.getAuthenticatedToken(), "mojang");
                    LiquidBounce.eventManager.callEvent(new SessionEvent());
                    ServerUtils.connectToLastServer();
                    break;
                } catch (final Throwable throwable) {
                    ClientUtils.getLogger().error("Failed to login into random account from TheAltening.", throwable);
                }
            }

            final List<MinecraftAccount> accounts = LiquidBounce.fileManager.accountsConfig.getAccounts();
            if (accounts.isEmpty()) break;

            final MinecraftAccount minecraftAccount = accounts.get(new Random().nextInt(accounts.size()));
            GuiAltManager.login(minecraftAccount);
            ServerUtils.connectToLastServer();
            break;
        case 4:
            LoginUtils.loginCracked(RandomUtils.randomString(RandomUtils.nextInt(5, 16)));
            ServerUtils.connectToLastServer();
            break;
        case 5:
            AntiForge.enabled = !AntiForge.enabled;
            forgeBypassButton.displayString = "Bypass AntiForge: " + (AntiForge.enabled ? "On" : "Off");
            LiquidBounce.fileManager.saveConfig(LiquidBounce.fileManager.valuesConfig);
            break;
    }
}
 
源代码8 项目: ClientBase   文件: MixinMinecraft.java
@Override
public Session getSession() {
    return session;
}
 
源代码9 项目: ClientBase   文件: MixinMinecraft.java
@Override
public void setSession(Session session) {
    this.session = session;
}
 
源代码10 项目: ClientBase   文件: WrapperSession.java
public WrapperSession(Session var1) {
    this.real = var1;
}
 
源代码11 项目: ClientBase   文件: WrapperSession.java
public Session unwrap() {
    return this.real;
}
 
源代码12 项目: ClientBase   文件: IMixinMinecraft.java
Session getSession(); 
源代码13 项目: ClientBase   文件: IMixinMinecraft.java
void setSession(Session session); 
 类所在包
 类方法
 同包方法