本文整理汇总了Java中com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService类的典型用法代码示例。如果您正苦于以下问题:Java YggdrasilAuthenticationService类的具体用法?Java YggdrasilAuthenticationService怎么用?Java YggdrasilAuthenticationService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YggdrasilAuthenticationService类属于com.mojang.authlib.yggdrasil包,在下文中一共展示了YggdrasilAuthenticationService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的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");
}
示例2: attemptLogin
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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()));
}
示例3: createSession
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的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;
}
}
示例4: loginPassword
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的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;
}
示例5: loginPassword
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的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;
}
示例6: login
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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());
}
示例7: DedicatedServer
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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)
{
;
}
}
}
};
}
示例8: login
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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());
}
示例9: Minecraft
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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();
}
示例10: MinecraftServer
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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");
}
示例11: attemptLogin
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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());
}
示例12: DedicatedServer
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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) {
;
}
}
}
};
}
示例13: getUUID
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
@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;
}
示例14: MinecraftServer
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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();
}
示例15: Minecraft
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; //导入依赖的package包/类
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();
}