Java源码示例:net.minecraft.util.Session
示例1
@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
@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
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
@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
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
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
@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
@Override
public Session getSession() {
return session;
}
示例9
@Override
public void setSession(Session session) {
this.session = session;
}
示例10
public WrapperSession(Session var1) {
this.real = var1;
}
示例11
public Session unwrap() {
return this.real;
}
示例12示例13
void setSession(Session session);