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


Java UUIDTypeAdapter类代码示例

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


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

示例1: getProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public static GameProfile getProfile(UUID uuid, String name, String skinUrl, String capeUrl)
{
    GameProfile profile = new GameProfile(uuid, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<Object>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(uuid));
    args.add(name);
    args.add(skinUrl);
    if (cape)
    {
        args.add(capeUrl);
    }

    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:19,代码来源:GameProfileBuilder.java

示例2: getProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
/**
 * Builds a GameProfile for the specified args
 *
 * @param name    The name
 * @param skinUrl Url from the skin image
 * @param capeUrl Url from the cape image
 * @return A GameProfile built from the arguments
 * @see GameProfile
 */
public static GameProfile getProfile(String name, String skinUrl, String capeUrl) {
    UUID id = UUID.randomUUID();
    GameProfile profile = new GameProfile(id, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(id));
    args.add(name);
    args.add(skinUrl);
    if (cape) args.add(capeUrl);

    profile.getProperties().clear();
    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:26,代码来源:GameProfileBuilder.java

示例3: createSession

import com.mojang.util.UUIDTypeAdapter; //导入依赖的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

示例4: preInit

import com.mojang.util.UUIDTypeAdapter; //导入依赖的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

示例5: fetch

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
/**
 * Don't run in main thread!
 * <p>
 * Fetches the GameProfile from the Mojang servers
 *
 * @param uuid     The player uuid
 * @param forceNew If true the cache is ignored
 * @return The GameProfile
 * @throws IOException If something wents wrong while fetching
 * @see GameProfile
 */
public static GameProfile fetch(UUID uuid, boolean forceNew) throws IOException {
    if (!forceNew && cache.containsKey(uuid) && cache.get(uuid).isValid()) {
        return cache.get(uuid).profile;
    } else {
        HttpURLConnection connection = (HttpURLConnection) new URL(String.format(SERVICE_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
        connection.setReadTimeout(5000);

        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            String json = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();

            GameProfile result = gson.fromJson(json, GameProfile.class);
            cache.put(uuid, new CachedProfile(result));
            return result;
        } else {
            if (!forceNew && cache.containsKey(uuid)) {
                return cache.get(uuid).profile;
            }
            JsonObject error = (JsonObject) new JsonParser().parse(new BufferedReader(new InputStreamReader(connection.getErrorStream())).readLine());
            throw new IOException(error.get("error").getAsString() + ": " + error.get("errorMessage").getAsString());
        }
    }
}
 
开发者ID:grzegorz2047,项目名称:ControlCheaters,代码行数:34,代码来源:NPC.java

示例6: getName

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
/**
 * Fetches the name synchronously and returns it
 *
 * @param uuid The uuid
 * @return The name
 */
public static String getName(UUID uuid) {
    if (nameCache.containsKey(uuid)) {
        return nameCache.get(uuid);
    }
    try {
        HttpURLConnection connection = (HttpURLConnection) new URL(String.format(NAME_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
        connection.setReadTimeout(5000);
        UUIDFetcher[] nameHistory = gson.fromJson(new BufferedReader(new InputStreamReader(connection.getInputStream())), UUIDFetcher[].class);
        UUIDFetcher currentNameData = nameHistory[nameHistory.length - 1];

        uuidCache.put(currentNameData.name.toLowerCase(), uuid);
        nameCache.put(uuid, currentNameData.name);

        return currentNameData.name;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:grzegorz2047,项目名称:ControlCheaters,代码行数:27,代码来源:NPC.java

示例7: fillGameProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
protected GameProfile fillGameProfile(GameProfile profile, boolean requireSecure) {
    try {
        URL url = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(profile.getId()));
        url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
        MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse)this.getAuthenticationService().makeRequest(url, (Object)null, MinecraftProfilePropertiesResponse.class);
        if (response == null) {
            LOGGER.debug("Couldn't fetch profile properties for " + profile + " as the profile does not exist");
            return profile;
        } else {
            GameProfile result = new GameProfile(response.getId(), response.getName());
            result.getProperties().putAll(response.getProperties());
            profile.getProperties().putAll(response.getProperties());
            LOGGER.debug("Successfully fetched profile properties for " + profile);
            return result;
        }
    } catch (AuthenticationException var6) {
        LOGGER.warn("Couldn't look up profile properties for " + profile, var6);
        return profile;
    }
}
 
开发者ID:DarkLBP,项目名称:Krothium-Launcher,代码行数:21,代码来源:YggdrasilMinecraftSessionService.java

示例8: onProcessHandshake

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
@Inject(method = "processHandshake", at = @At(value = "HEAD"), cancellable = true)
private void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    if (packetIn.getRequestedState().equals(EnumConnectionState.LOGIN)) {
        final String[] split = packetIn.ip.split("\00");

        if (split.length >= 3) {
            packetIn.ip = split[0];
            ((IMixinNetworkManager_Bungee) this.networkManager).setRemoteAddress(new InetSocketAddress(split[1],
                            ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort()));
            ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2]));

            if (split.length == 4) {
                ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedProfile(GSON.fromJson(split[3], Property[].class));
            }
        } else {
            final ChatComponentText chatcomponenttext =
                    new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
            this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
            this.networkManager.closeChannel(chatcomponenttext);
        }
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:23,代码来源:MixinNetHandlerHandshakeTCP_Bungee.java

示例9: initializeMainframe

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public void initializeMainframe(String name, int i, int j, int k)
{
    Minecraft mc = Minecraft.getMinecraft();
    mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));

    int oriScale = mc.gameSettings.guiScale;
    mc.gameSettings.guiScale = mc.gameSettings.guiScale == 1 ? 1 : 2;
    mainframe = new Mainframe();
    UUID uuid;
    try
    {
        uuid = UUIDTypeAdapter.fromString(mc.getSession().getPlayerID());
    }
    catch(IllegalArgumentException e)
    {
        uuid = UUIDTypeAdapter.fromString("deadbeef-dead-beef-dead-beefdeadbeef");
    }
    mainframe.addListener(mc.getSession().getUsername(), true);

    FMLClientHandler.instance().showGuiScreen(new GuiWorkspace(oriScale, false, true, name, i, j, k));
}
 
开发者ID:iChun,项目名称:Tabula,代码行数:22,代码来源:TickHandlerClient.java

示例10: fetch

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public static GameProfile fetch(UUID uuid, boolean forceNew) throws IOException
{
    if (!forceNew && cache.containsKey(uuid) && cache.get(uuid).isValid())
    {
        return cache.get(uuid).profile;
    }
    else
    {
        HttpURLConnection connection = (HttpURLConnection) new URL(String.format(SERVICE_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
        connection.setReadTimeout(5000);

        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK)
        {
            InputStreamReader response = new InputStreamReader(connection.getInputStream());
            GameProfile result = gson.fromJson(new BufferedReader(response), GameProfile.class);

            cache.put(uuid, new CachedProfile(result));
            return result;
        }
        else
        {
            if (!forceNew && cache.containsKey(uuid))
            {
                return cache.get(uuid).profile;
            }

            JsonObject error = (JsonObject) new JsonParser().parse(new BufferedReader(new InputStreamReader(connection.getErrorStream())).readLine());
            throw new IOException(error.get("error").getAsString() + ": " + error.get("errorMessage").getAsString());
        }
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:32,代码来源:GameProfileBuilder.java

示例11: bindFace

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public static void bindFace(String p_bindFace_0_, String p_bindFace_1_)
{
    ResourceLocation resourcelocation = AbstractClientPlayer.getLocationSkin(p_bindFace_1_);

    if (resourcelocation == null)
    {
        resourcelocation = DefaultPlayerSkin.getDefaultSkin(UUIDTypeAdapter.fromString(p_bindFace_0_));
    }

    AbstractClientPlayer.getDownloadImageSkin(resourcelocation, p_bindFace_1_);
    Minecraft.getMinecraft().getTextureManager().bindTexture(resourcelocation);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:RealmsScreen.java

示例12: getProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public GameProfile getProfile()
{
    try
    {
        UUID uuid = UUIDTypeAdapter.fromString(this.getPlayerID());
        return new GameProfile(uuid, this.getUsername());
    }
    catch (IllegalArgumentException var2)
    {
        return new GameProfile((UUID)null, this.getUsername());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:Session.java

示例13: getName

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
/**
 * Gets the name of a {@link UUID} sync
 *
 * @param uuid the {@link UUID} of the {@link Player}
 * @see UUIDFetcher#getName(UUID, Consumer<String>)
 */
public static String getName(UUID uuid) {
    if (NAMES.containsKey(uuid))
        return NAMES.get(uuid);

    try {
        HttpURLConnection connection = (HttpURLConnection) new URL(
                String.format(NAME_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
        connection.setReadTimeout(5000);

        PlayerUUID[] allUserNames = GSON.fromJson(
                new BufferedReader(new InputStreamReader(connection.getInputStream())), PlayerUUID[].class);
        PlayerUUID currentName = allUserNames[allUserNames.length - 1];

        if (currentName == null)
            return Bukkit.getOfflinePlayer(uuid).getName();

        if (currentName.getName() == null)
            return Bukkit.getOfflinePlayer(uuid).getName();

        NAMES.put(uuid, currentName.getName());

        return currentName.getName();
    } catch (Exception e) {
        Bukkit.getLogger().log(Level.SEVERE, "Your server has no connection to the mojang servers or is runnig slowly. Using offline UUID now");
        return Bukkit.getOfflinePlayer(uuid).getName();
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:34,代码来源:UUIDFetcher.java

示例14: getProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public GameProfile getProfile()
{
    try
    {
        UUID uuid = UUIDTypeAdapter.fromString(this.getPlayerID());
        GameProfile ret = new GameProfile(uuid, this.getUsername());    //Forge: Adds cached GameProfile properties to returned GameProfile.
        if (properties != null) ret.getProperties().putAll(properties); // Helps to cut down on calls to the session service,
        return ret;                                                     // which helps to fix MC-52974.
    }
    catch (IllegalArgumentException var2)
    {
        return new GameProfile(net.minecraft.entity.player.EntityPlayer.getUUID(new GameProfile((UUID)null, this.getUsername())), this.getUsername());
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:Session.java

示例15: getGSonProfile

import com.mojang.util.UUIDTypeAdapter; //导入依赖的package包/类
public static Gson getGSonProfile(){
	if(gsonProfile == null){
		GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(GameProfile.class, new GameProfileSerializer());
        builder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer());
        builder.registerTypeAdapter(UUID.class, new UUIDTypeAdapter());
        builder.registerTypeAdapter(ProfileSearchResultsResponse.class, new ProfileSearchResultsResponse.Serializer());
        gsonProfile = builder.create();
	}
	return gsonProfile;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:12,代码来源:ProfileUtil.java


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