當前位置: 首頁>>代碼示例>>Java>>正文


Java GameProfile類代碼示例

本文整理匯總了Java中com.mojang.authlib.GameProfile的典型用法代碼示例。如果您正苦於以下問題:Java GameProfile類的具體用法?Java GameProfile怎麽用?Java GameProfile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GameProfile類屬於com.mojang.authlib包,在下文中一共展示了GameProfile類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        GameProfile gameprofile = server.getPlayerList().getOppedPlayers().getGameProfileFromName(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.deop.failed", new Object[] {args[0]});
        }
        else
        {
            server.getPlayerList().removeOp(gameprofile);
            notifyCommandListener(sender, this, "commands.deop.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.deop.usage", new Object[0]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:CommandDeOp.java

示例2: constructProfile

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
private static GameProfile constructProfile(JsonObject p_152643_0_)
{
    if (p_152643_0_.has("uuid") && p_152643_0_.has("name"))
    {
        String s = p_152643_0_.get("uuid").getAsString();
        UUID uuid;

        try
        {
            uuid = UUID.fromString(s);
        }
        catch (Throwable var4)
        {
            return null;
        }

        return new GameProfile(uuid, p_152643_0_.get("name").getAsString());
    }
    else
    {
        return null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:UserListOpsEntry.java

示例3: getTabCompletionOptions

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if (args.length == 1)
    {
        String s = args[args.length - 1];
        List<String> list = Lists.<String>newArrayList();

        for (GameProfile gameprofile : server.getGameProfiles())
        {
            if (!server.getPlayerList().canSendCommands(gameprofile) && doesStringStartWith(s, gameprofile.getName()))
            {
                list.add(gameprofile.getName());
            }
        }

        return list;
    }
    else
    {
        return Collections.<String>emptyList();
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:CommandOp.java

示例4: addBan

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
@Override
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
    Validate.notNull(target, "Ban target cannot be null");

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(target);
    if (profile == null) {
        return null;
    }

    UserListBansEntry entry = new UserListBansEntry(profile, new Date(),
            StringUtils.isBlank(source) ? null : source, expires,
            StringUtils.isBlank(reason) ? null : reason);

    list.func_152687_a(entry);

    try {
        list.func_152678_f();
    } catch (IOException ex) {
        MinecraftServer.getLogger().error("Failed to save banned-players.json, " + ex.getMessage());
    }

    return new CraftProfileBanEntry(profile, entry, list);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:24,代碼來源:CraftProfileBanList.java

示例5: gameProfileFromJsonObject

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
private static GameProfile gameProfileFromJsonObject(JsonObject p_152646_0_)
{
    if (p_152646_0_.has("uuid") && p_152646_0_.has("name"))
    {
        String s = p_152646_0_.get("uuid").getAsString();
        UUID uuid;

        try
        {
            uuid = UUID.fromString(s);
        }
        catch (Throwable var4)
        {
            return null;
        }

        return new GameProfile(uuid, p_152646_0_.get("name").getAsString());
    }
    else
    {
        return null;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:UserListWhitelistEntry.java

示例6: getProfile

import com.mojang.authlib.GameProfile; //導入依賴的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

示例7: getProfile

import com.mojang.authlib.GameProfile; //導入依賴的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

示例8: func_152648_b

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
private static GameProfile func_152648_b(JsonObject p_152648_0_)
{
    if (p_152648_0_.has("uuid") && p_152648_0_.has("name"))
    {
        String s = p_152648_0_.get("uuid").getAsString();
        UUID uuid;

        try
        {
            uuid = UUID.fromString(s);
        }
        catch (Throwable var4)
        {
            return null;
        }

        return new GameProfile(uuid, p_152648_0_.get("name").getAsString());
    }
    else
    {
        return null;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:UserListBansEntry.java

示例9: removeUser

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
private void removeUser(GameProfile profile)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    Gson gson = new Gson();
    final ArrayList<String> tempHash = new ArrayList<String>();

    try
    {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");

        byte[] hash = digest.digest(profile.getId().toString().getBytes(Charset.forName("UTF-8")));

        tempHash.add((new HexBinaryAdapter()).marshal(hash));
    }
    catch (NoSuchAlgorithmException e)
    {
        e.printStackTrace();
    }

    CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
    invite.hash = tempHash;
    invite.id = CreeperHostServer.updateID;
    CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to revoke endpoint");
    String resp = Util.putWebResponse("https://api.creeper.host/serverlist/revokeinvite", gson.toJson(invite), true, true);
    CreeperHostServer.logger.debug("Response from revoke endpoint " + resp);
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:27,代碼來源:CommandInvite.java

示例10: toGameProfile

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
/**
 * Convert a {@linkplain com.google.gson.JsonObject JsonObject} into a {@linkplain com.mojang.authlib.GameProfile}.
 * The json object must have {@code uuid} and {@code name} attributes or {@code null} will be returned.
 */
private static GameProfile toGameProfile(JsonObject json)
{
    if (json.has("uuid") && json.has("name"))
    {
        String s = json.get("uuid").getAsString();
        UUID uuid;

        try
        {
            uuid = UUID.fromString(s);
        }
        catch (Throwable var4)
        {
            return null;
        }

        return new GameProfile(uuid, json.get("name").getAsString());
    }
    else
    {
        return null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:UserListBansEntry.java

示例11: processCommand

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.op.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().addOp(gameprofile);
            notifyOperators(sender, this, "commands.op.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.op.usage", new Object[0]);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:CommandOp.java

示例12: deserialize

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
    ServerStatusResponse.PlayerCountData serverstatusresponse$playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));

    if (JsonUtils.isJsonArray(jsonobject, "sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1, "id");
                agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
            }

            serverstatusresponse$playercountdata.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$playercountdata;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:ServerStatusResponse.java

示例13: getAccessText

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
private List<String> getAccessText() {
    List<String> textList = new ArrayList<String>();
    textList.add("                                      ");
    textList.add("");
    for (GameProfile user : te.sharedUsers) {
        textList.add(TextFormatting.BLACK + "-" + user.getName());
    }
    return textList;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:GuiSecurityStationInventory.java

示例14: getByUUID

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
/**
 * Get a {@link ProfileEntry} by UUID
 */
private PlayerProfileCache.ProfileEntry getByUUID(UUID uuid)
{
    PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = (PlayerProfileCache.ProfileEntry)this.uuidToProfileEntryMap.get(uuid);

    if (playerprofilecache$profileentry != null)
    {
        GameProfile gameprofile = playerprofilecache$profileentry.getGameProfile();
        this.gameProfiles.remove(gameprofile);
        this.gameProfiles.addFirst(gameprofile);
    }

    return playerprofilecache$profileentry;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:PlayerProfileCache.java

示例15: EntityPlayer

import com.mojang.authlib.GameProfile; //導入依賴的package包/類
public EntityPlayer(World worldIn, GameProfile gameProfileIn)
{
    super(worldIn);
    this.entityUniqueID = getUUID(gameProfileIn);
    this.gameProfile = gameProfileIn;
    this.inventoryContainer = new ContainerPlayer(this.inventory, !worldIn.isRemote, this);
    this.openContainer = this.inventoryContainer;
    BlockPos blockpos = worldIn.getSpawnPoint();
    this.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)(blockpos.getY() + 1), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F);
    this.field_70741_aB = 180.0F;
    this.fireResistance = 20;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:EntityPlayer.java


注:本文中的com.mojang.authlib.GameProfile類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。