Package com.mojang.authlib

Examples of com.mojang.authlib.GameProfile


public class TabletFakePlayer extends FakeThaumcraftPlayer {

  TileAnimationTablet tablet;

  public TabletFakePlayer(TileAnimationTablet tablet) { //,String name) {
    super(tablet.getWorldObj(), new GameProfile(UUID.fromString("a8f026a0-135b-11e4-9191-0800200c9a66"), "[ThaumcraftTablet]"));
    //super(tablet.getWorldObj(),"[ThaumcraftTablet]");
    this.tablet = tablet;
  }
View Full Code Here


  }

  @Override
  public Object toLua(ITypeConvertersRegistry registry, Object obj) {
    if (obj instanceof GameProfile) {
      GameProfile profile = (GameProfile)obj;
      Map<String, Object> map = Maps.newHashMap();
      map.put("name", profile.getName());
      map.put("uuid", profile.getId().toString());
      return map;
    }

    return null;
  }
View Full Code Here

    protected static LoginResponse authenticateWithAuthlib (String user, String pass, String mojangData, String selectedProfileName) {
        String displayName;
        boolean hasMojangData = false;
        boolean hasPassword = false;
        GameProfile selectedProfile = null;
        YggdrasilUserAuthentication authentication = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
        if (user != null) {
            Logger.logDebug(user.contains("@") ? "Email address given" : "Username given" + " Not 100% sure, mojangdata might contain different username");
            Logger.logInfo("Beginning authlib authentication attempt");
            Logger.logInfo("successfully created YggdrasilAuthenticationService");
            authentication.setUsername(user);
            if (pass != null && !pass.isEmpty()) {
                authentication.setPassword(pass);
                hasPassword = true;
            }
            if (mojangData != null && !mojangData.isEmpty()) {
                Logger.logDebug("mojangData was passed to current method");
                Map<String, Object> m = decode(mojangData);
                if (m != null) {
                    Logger.logDebug("Loading mojangData into authlib");
                    authentication.loadFromStorage(m);
                    hasMojangData = true;
                }
            } else {
                Logger.logDebug("mojangData is null or empty");
            }
            if (authentication.canLogIn()) {
                try {
                    authentication.logIn();
                } catch (UserMigratedException e) {
                    Logger.logError(e.toString());
                    ErrorUtils.tossError("Invalid credentials. You have migrated your account. Use account email instead of username");
                    return null;
                } catch (InvalidCredentialsException e) {
                    Logger.logError("Invalid credentials recieved for user: " + user, e);
                    if (hasMojangData && hasPassword) {
                        uniqueID = authentication.getSelectedProfile().getId().toString();
                        //could be bad or expired keys, etc. will re-run w/o auth data to refresh and error after password was entered
                    } else {
                        if (user.contains("@")) {
                            ErrorUtils.tossError("Invalid username or password. You need use your official and paid minecraft.net account credentials.");
                        } else {
                            ErrorUtils.tossError("Invalid username or password. You need use your official and paid minecraft.net account credentials. \nAlso try email address instead of username");
                        }
                        return null;
                    }
                } catch (AuthenticationUnavailableException e) {
                    Logger.logDebug("Error while authenticating, trying offline mode");
                    if (hasMojangData) {
                        //if the UUID is valid we can proceed to offline mode later
                        uniqueID = authentication.getSelectedProfile().getId().toString();
                        if (uniqueID != null && !uniqueID.isEmpty()) {
                            Logger.logDebug("Setting UUID");
                        }
                        UserManager.setUUID(user, uniqueID);
                    }
                    if (uniqueID != null && !uniqueID.isEmpty()) {
                        UserManager.setUUID(user, uniqueID);
                        Logger.logDebug("Setting UUID and creating and returning new LoginResponse");
                        return new LoginResponse(Integer.toString(authentication.getAgent().getVersion()), "token", user, null, uniqueID, authentication);
                    }
                    ErrorUtils.tossError("Minecraft authentication servers might be down. Check @ help.mojang.com");
                    Logger.logDebug("failed", e);
                    Logger.logDebug("AuthenticationUnavailableException caused by", e.getCause());
                    return null;
                } catch (AuthenticationException e) {
                    Logger.logError("Unknown error from authlib:", e);
                    Logger.logDebug("AuthenticationException caused by", e.getCause());
                } catch (Exception e) {
                    Logger.logError("Unknown error from authlib: ", e);
                    Logger.logDebug("Exception caused by", e.getCause());
                }
            } else {
                Logger.logDebug("authentication.canLogIn() returned false");
            }

            if (isValid(authentication)) {
                Logger.logDebug("Authentication is valid ");
                displayName = authentication.getSelectedProfile().getName();
                if ((authentication.isLoggedIn()) && (authentication.canPlayOnline())) {
                    Logger.logDebug("loggedIn() && CanPlayOnline()");
                    if ((authentication instanceof YggdrasilUserAuthentication)) {
                        UserManager.setStore(user, encode(authentication.saveForStorage()));
                        UserManager.setUUID(user, authentication.getSelectedProfile().getId().toString());//enables use of offline mode later if needed on newer MC Versions
                        Logger.logDebug("Authentication done, returning LoginResponse");
                        return new LoginResponse(Integer.toString(authentication.getAgent().getVersion()), "token", displayName, authentication.getAuthenticatedToken(), authentication
                                .getSelectedProfile().getId().toString(), authentication);
                    }
                }
                Logger.logDebug("this should never happen: isLoggedIn: " + authentication.isLoggedIn() + " canPlayOnline(): " + authentication.canPlayOnline());
            } else if (authentication.getSelectedProfile() == null && (authentication.getAvailableProfiles() != null && authentication.getAvailableProfiles().length != 0)) {
                // user has more than one profile in his mojang acoount
                Logger.logInfo("You seem to have multiple profiles in  your account. Please contact FTB Launcher team if profiles are not working!");
                Logger.logDebug("User has more than one profile: " + toString(authentication));
                for (GameProfile profile : authentication.getAvailableProfiles()) {
                    if (selectedProfileName.equals(profile.getName())) {
                        Logger.logInfo("Selected profile: " + profile.getName());
                        selectedProfile = profile;
                    }
                }
                if (selectedProfile == null) {
                    Logger.logInfo("Profile not found, defaulting to first");
                    selectedProfile = authentication.getAvailableProfiles()[0];
                }
                Logger.logDebug("Authentication done, returning LoginResponse");
                return new LoginResponse(Integer.toString(authentication.getAgent().getVersion()), "token", selectedProfile.getName(), authentication.getAuthenticatedToken(),
                        selectedProfile.getId().toString(), authentication);
            } else if (authentication.getSelectedProfile() == null && (authentication.getAvailableProfiles() != null && authentication.getAvailableProfiles().length == 0)) {
                // user has 0 paid profiles in mojang account
                Logger.logDebug("No paid profiles in mojang account: " + toString(authentication));
                Logger.logError("You need paid minecraft to play FTB Modpacks...");
                ErrorUtils.showClickableMessage("You need paid minecraft to play FTB Modpacks:"
View Full Code Here

  private class Attackera extends FakePlayer {

    ItemStack prevWeapon;

    public Attackera() {
      super(MinecraftServer.getServer().worldServerForDimension(getWorldObj().provider.dimensionId), new GameProfile(null,
          BlockKillerJoe.USERNAME + ":" + getLocation()));
      posX = xCoord + 0.5;
      posY = yCoord + 0.5;
      posZ = zCoord + 0.5;
    }
View Full Code Here

            ownerName = data.getString("owner");

        UUID ownerId = null;
        if (data.hasKey("ownerId"))
            ownerId = UUID.fromString(data.getString("ownerId"));
        return new GameProfile(ownerId, ownerName);
    }
View Full Code Here

  private class Target extends FakePlayer {

    ItemStack prevWeapon;

    public Target() {
      super(MinecraftServer.getServer().worldServerForDimension(getWorldObj().provider.dimensionId), new GameProfile(null,
          ModObject.blockAttractor.unlocalisedName + ":" + getLocation()));
      posX = xCoord + 0.5;
      posY = yCoord + 1.5;
      posZ = zCoord + 0.5;
    }
View Full Code Here

            {
              //It's a player name
              ((TileEntityTelemetry)tile).clientClass = EntityPlayerMP.class;
              String strName = name.substring(1);
              ((TileEntityTelemetry)tile).clientName = strName;
              GameProfile profile = FMLClientHandler.instance().getClientPlayerEntity().getGameProfile();
              if (!strName.equals(profile.getName()))
              {
                profile = PlayerUtil.getOtherPlayerProfile(strName);
                  if (profile == null)
                  {
                    String strUUID = (String) this.data.get(9);
                    profile = PlayerUtil.makeOtherPlayerProfile(strName, strUUID);
                  }
                  if (VersionUtil.mcVersionMatches("1.7.10") && !profile.getProperties().containsKey("textures"))
                    GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_REQUEST_PLAYERSKIN, new Object[] { strName }));
              }
              ((TileEntityTelemetry)tile).clientGameProfile = profile;
            }
            else
              ((TileEntityTelemetry)tile).clientClass = (Class) EntityList.stringToClassMapping.get(name);
            ((TileEntityTelemetry)tile).clientData = new int[5];
            for (int i = 4; i < 9; i++)
                {
                ((TileEntityTelemetry)tile).clientData[i - 4] = (Integer) this.data.get(i);
              }
          }
          break;
        case C_SEND_PLAYERSKIN:
          String strName = (String) this.data.get(0);
          String s1 = (String) this.data.get(1);
          String s2 = (String) this.data.get(2);
          String strUUID = (String) this.data.get(3);
          GameProfile gp = PlayerUtil.getOtherPlayerProfile(strName);
          if (gp == null)
          {
              gp = PlayerUtil.makeOtherPlayerProfile(strName, strUUID);
          }
          gp.getProperties().put("textures", new Property("textures", s1, s2));
          break;
        case C_SEND_OVERWORLD_IMAGE:
            try
            {
                byte[] bytes = (byte[]) this.data.get(0);
View Full Code Here

          EntityPlayerMP playerRequested = FMLServerHandler.instance().getServer().getConfigurationManager().func_152612_a(strName);
         
          //Player not online
          if (playerRequested == null) return;
         
          GameProfile gp = playerRequested.getGameProfile();
          if (gp == null) return;
         
            Property property = (Property)Iterables.getFirst(gp.getProperties().get("textures"), (Object)null);
            if (property == null)
            {
                return;
            }
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_SEND_PLAYERSKIN, new Object[] { strName, property.getValue(), property.getSignature(), playerRequested.getUniqueID().toString() }), playerBase);
View Full Code Here

    }

    @SideOnly(Side.CLIENT)
  public static GameProfile makeOtherPlayerProfile(String strName, String strUUID)
  {
    GameProfile profile = null;
    for (Object e : FMLClientHandler.instance().getWorldClient().getLoadedEntityList())
    {
      if (e instanceof AbstractClientPlayer)
      {
        GameProfile gp2 = ((AbstractClientPlayer)e).getGameProfile();
        if (gp2.getName().equals(strName))
        {
          profile = gp2;
          break;
        }
      }
View Full Code Here

    GuiMailboxInfo.instance = new GuiMailboxInfo();

    if (!Proxies.common.isSimulating(Proxies.common.getRenderWorld()))
      Proxies.net.sendToServer(new ForestryPacket(PacketIds.POBOX_INFO_REQUEST));
    else {
      GameProfile profile = Proxies.common.getClientInstance().thePlayer.getGameProfile();
      IMailAddress address = PostManager.postRegistry.getMailAddress(profile);
      POBox pobox = PostRegistry.getPOBox(Proxies.common.getRenderWorld(), address);
      if (pobox != null)
        setPOBoxInfo(Proxies.common.getRenderWorld(), address, pobox.getPOBoxInfo());
    }
View Full Code Here

TOP

Related Classes of com.mojang.authlib.GameProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.