本文整理汇总了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]);
}
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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]);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}