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


Java GameProfile类代码示例

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


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

示例1: toContainer

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
@Override
public DataContainer toContainer() {
    List<String> ownerContainers = new ArrayList<String>();
    for (GameProfile profile : owners) {
        ownerContainers.add(profile.getUniqueId().toString());
    }

    DataContainer data = new MemoryDataContainer();
    data.set(DataQueries.Uuid, uuid.toString());
    data.set(DataQueries.ZoneName, name);
    data.set(DataQueries.Owners, ownerContainers);
    data.set(DataQueries.ZonePermissions, permissions);

    // Zone permissions
    Map<String, DataContainer> profileMap = new HashMap<String, DataContainer>();
    for (Entry<GameProfile, ZonePermissions> entry : userPermissions.entrySet()) {
        profileMap.put(entry.getKey().getUniqueId().toString(), entry.getValue().toContainer());
    }

    data.set(DataQueries.UserPermissions, profileMap);

    // Volume
    data.set(DataQueries.Volume, volume.toContainer());

    return data;
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:27,代码来源:Zone.java

示例2: onClientLogin

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:27,代码来源:SpongeConnectionListener.java

示例3: execute

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
    AbstractTagObject target = entry.getArgumentObject(queue, 0);
    if (target instanceof PlayerTag) {
        GameProfile profile = ((PlayerTag) target).getInternal().getProfile();
        if (queue.shouldShowGood()) {
            queue.outGood("Pardoning player " + ColorSet.emphasis + profile.getName().get() + ColorSet.good + "!");
        }
        Sponge.getServiceManager().provide(BanService.class).get().pardon(profile);
    }
    else {
        try {
            InetAddress address = InetAddress.getByName(target.toString());
            if (queue.shouldShowGood()) {
                queue.outGood("Pardoning IP " + ColorSet.emphasis + address.getHostName() + ColorSet.good + "!");
            }
            Sponge.getServiceManager().provide(BanService.class).get().pardon(address);
        }
        catch (UnknownHostException e) {
            queue.handleError(entry, "Invalid IP address provided!");
        }
    }
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:24,代码来源:PardonCommand.java

示例4: listLockOwner

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
protected void listLockOwner(Player player, Location<World> location) throws SQLException {
    if (player.hasPermission("keys.mod")) {
        List<Lock> masters = Keys.getStorageAdapter().getMasterLocks(location);

        for (Lock master : masters) {
            if (master.getUserId().equals(player.getUniqueId())) {
                continue;
            }

            CompletableFuture<GameProfile> future = Keys.getGame().getServer().getGameProfileManager().get(master.getUserId());
            future.thenAccept((profile) -> {
                player.sendMessage(Format.message("This block is locked by ", TextColors.LIGHT_PURPLE, profile.getName().orElse(profile.getUniqueId().toString())));
            });
        }
    }
}
 
开发者ID:prism,项目名称:Keys,代码行数:17,代码来源:InteractBlockListener.java

示例5: getGameProfile

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
public Optional<GameProfile> getGameProfile(String identifier) {
	Preconditions.checkNotNull(identifier, "identifier");
	
	try {
		if (identifier.length() == EServer.UUID_LENGTH) {
			return this.getGameProfile(UUID.fromString(identifier));
		} else {
			Optional<Player> player = this.getPlayer(identifier);
			if (player.isPresent()) {
				return Optional.ofNullable(player.get().getProfile());
			} else {
				return Optional.ofNullable(this.plugin.getEServer().getGameProfileManager().get(identifier).get());
			}
		}
	} catch(IllegalArgumentException | InterruptedException | ExecutionException e) {}
	return Optional.empty();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:18,代码来源:EServer.java

示例6: commandUUIDOthersName

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
private CompletableFuture<Boolean> commandUUIDOthersName(final CommandSource staff, final GameProfile profile) {
	// La source et le joueur sont identique
	if (staff instanceof EPlayer && profile.getUniqueId().equals(((EPlayer) staff).getUniqueId())) {
		return this.commandUUIDPlayerName((EPlayer) staff);
	}
	
	// Joueur introuvable
	if(!profile.getName().isPresent()) {
		EAMessages.PLAYER_NOT_FOUND.sender()
			.prefix(EEMessages.PREFIX)
			.replace("{player}", profile.getUniqueId().toString())
			.sendTo(staff);
		return CompletableFuture.completedFuture(false);
	}
	
	EEMessages.UUID_OTHERS_PLAYER_NAME.sender()
		.replace("{uuid}", this.getButtonUUID(profile.getUniqueId()))
		.replace("{name}", this.getButtonName(profile.getName().get()))
		.sendTo(staff);				
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:22,代码来源:EEUuid.java

示例7: commandWhitelistRemove

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
private CompletableFuture<Boolean> commandWhitelistRemove(final CommandSource player, final String identifier) {
	Optional<GameProfile> gameprofile = this.plugin.getEServer().getGameProfile(identifier);
	// Le joueur existe
	if (!gameprofile.isPresent()) {
		EAMessages.PLAYER_NOT_FOUND.sender()
			.prefix(EEMessages.PREFIX)
			.replace("{player}", identifier)
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	if (!this.plugin.getEverAPI().getManagerService().getWhitelist().removeProfile(gameprofile.get())) {
		EEMessages.WHITELIST_REMOVE_ERROR.sender()
			.replace("{player}", gameprofile.get().getName().orElse(identifier))
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	EEMessages.WHITELIST_REMOVE_PLAYER.sender()
		.replace("{player}", gameprofile.get().getName().orElse(identifier))
		.sendTo(player);
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:24,代码来源:EEWhitelistRemove.java

示例8: commandWhitelistAdd

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
private boolean commandWhitelistAdd(final CommandSource player, final String identifier) {
	Optional<GameProfile> gameprofile = this.plugin.getEServer().getGameProfile(identifier);
	// Le joueur existe
	if (!gameprofile.isPresent()) {
		EAMessages.PLAYER_NOT_FOUND.sender()
			.prefix(EEMessages.PREFIX)
			.replace("{player}", identifier)
			.sendTo(player);
		return false;
	}
			
	if (this.plugin.getEverAPI().getManagerService().getWhitelist().addProfile(gameprofile.get())) {
		EEMessages.WHITELIST_ADD_ERROR.sender()
			.replace("{player}", gameprofile.get().getName().orElse(identifier))
			.sendTo(player);
		return false;
	}
	
	EEMessages.WHITELIST_ADD_PLAYER.sender()
		.replace("{player}", gameprofile.get().getName().orElse(identifier))
		.sendTo(player);
	return true;
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:24,代码来源:EEWhitelistAdd.java

示例9: getOrCreateUser

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
public static User getOrCreateUser(UUID uuid) {
    if (uuid == null) {
        return null;
    }

    if (uuid == WORLD_USER_UUID) {
        return WORLD_USER;
    }

    // check the cache
    Optional<User> player = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().get(uuid);
    if (player.isPresent()) {
        return player.get();
    } else {
        try {
            GameProfile gameProfile = Sponge.getServer().getGameProfileManager().get(uuid).get();
            return Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().getOrCreate(gameProfile);
        } catch (Exception e) {
            return null;
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:23,代码来源:GriefPreventionPlugin.java

示例10: onPlayerConnection

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
/**
 * Runs when a player has been authenticated with the Mojang services.
 *
 * @param event The event to fire.
 */
@Listener
public void onPlayerConnection(ClientConnectionEvent.Auth event) {
    getServices();
    try {
        GameProfile pl = event.getProfile();
        String host = event.getConnection().getAddress().getAddress().getHostAddress();

        User user = storageService.getOrCreate(pl);
        HammerText text = eventCore.handleEvent(
                new SpongeWrappedPlayer(user),
                host);

        if (text != null) {
            event.setCancelled(true);
            event.setMessage(HammerTextConverter.constructMessage(text));
        }
    } catch (HammerException e) {
        logger.error("Connection to the MySQL database failed. Falling back to the Minecraft ban list.");
        e.printStackTrace();
    }
}
 
开发者ID:dualspiral,项目名称:Hammer,代码行数:27,代码来源:PlayerConnectListener.java

示例11: placeBlock

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
@Override
public boolean placeBlock(int x, int y, int z, BlockState block, Direction side, @Nullable GameProfile profile) {
    final BehaviorPipeline<Behavior> pipeline = ((LanternBlockType) block.getType()).getPipeline();

    final CauseStack causeStack = CauseStack.current();
    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        frame.addContext(ContextKeys.USED_BLOCK_STATE, block);
        frame.addContext(ContextKeys.INTERACTION_FACE, side);
        frame.addContext(ContextKeys.BLOCK_LOCATION, new Location<>(this, x, y, z));
        frame.addContext(ContextKeys.BLOCK_TYPE, block.getType());
        if (profile != null) {
            frame.addContext(EventContextKeys.PLAYER_SIMULATED, profile);
        }
        final BehaviorContextImpl context = new BehaviorContextImpl(causeStack);
        // Just pass an object trough to make sure that a value is present when successful
        if (context.process(pipeline.pipeline(PlaceBlockBehavior.class),
                (ctx, behavior) -> behavior.tryPlace(pipeline, ctx)).isSuccess()) {
            context.accept();
            return true;
        }
        context.revert();
        return false;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:LanternWorld.java

示例12: digBlock

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
private boolean digBlock(int x, int y, int z, @Nullable GameProfile profile, @Nullable ItemStack itemStack) {
    final LanternBlockType blockType = ((LanternBlockType) getBlockType(x, y, z));
    final BehaviorPipeline<Behavior> pipeline = blockType.getPipeline();

    final CauseStack causeStack = CauseStack.current();
    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        frame.addContext(ContextKeys.BLOCK_LOCATION, new Location<>(this, x, y, z));
        frame.addContext(ContextKeys.BLOCK_TYPE, blockType);
        if (profile != null) {
            frame.addContext(EventContextKeys.PLAYER_SIMULATED, profile);
        }
        if (itemStack != null) {
            frame.addContext(ContextKeys.USED_ITEM_STACK, itemStack);
        }
        final BehaviorContextImpl context = new BehaviorContextImpl(causeStack);
        // Just pass an object trough to make sure that a value is present when successful
        if (context.process(pipeline.pipeline(BreakBlockBehavior.class),
                (ctx, behavior) -> behavior.tryBreak(pipeline, ctx)).isSuccess()) {
            context.accept();
            return true;
        }
        context.revert();
        return false;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:26,代码来源:LanternWorld.java

示例13: getBlockDigTimeWith

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
public int getBlockDigTimeWith(int x, int y, int z, @Nullable GameProfile profile, @Nullable ItemStack itemStack) {
    // Check if the user has the creative game mode
    if (profile != null) {
        final Optional<User> optUser = Lantern.getGame().getUserStorageService().get(profile);
        if (optUser.isPresent()) {
            final User user = optUser.get();
            if (user.get(Keys.GAME_MODE).orElse(GameModes.NOT_SET) == GameModes.CREATIVE) {
                return 0;
            }
        }
    }
    final Optional<UnbreakableProperty> optUnbreakableProperty = getProperty(x, y, z, UnbreakableProperty.class);
    if (optUnbreakableProperty.isPresent() && optUnbreakableProperty.get().getValue() == Boolean.TRUE) {
        return -1;
    }
    final Optional<HardnessProperty> optHardnessProperty = getProperty(x, y, z, HardnessProperty.class);
    if (optHardnessProperty.isPresent()) {
        final Double value = optHardnessProperty.get().getValue();
        double hardness = value == null ? 0 : value;
        // TODO: Calculate the duration
        return hardness <= 0 ? 0 : 1;
    }
    return 0;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:LanternWorld.java

示例14: createPlayers

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
public static ClientPingServerEvent.Response.Players createPlayers(LanternServer server) {
    // Get the online players
    final Collection<LanternPlayer> players = server.getRawOnlinePlayers();

    final int online = players.size();
    final int max = server.getMaxPlayers();

    // Create a list with the players
    List<LanternPlayer> playersList = new ArrayList<>(players);

    // Randomize the players list
    Collections.shuffle(playersList);

    // Limit the maximum amount of displayed players
    if (playersList.size() > DEFAULT_MAX_PLAYERS_DISPLAYED) {
        playersList = playersList.subList(0, DEFAULT_MAX_PLAYERS_DISPLAYED);
    }

    // Get all the game profiles and create a copy
    final List<GameProfile> gameProfiles = Lists2.nonNullOf(playersList.stream()
            .map(player -> ((LanternGameProfile) player.getProfile()).copyWithoutProperties())
            .collect(Collectors.toList()));

    return SpongeEventFactory.createClientPingServerEventResponsePlayers(gameProfiles, max, online);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:26,代码来源:LanternStatusHelper.java

示例15: get

import org.spongepowered.api.profile.GameProfile; //导入依赖的package包/类
@Override
public CompletableFuture<GameProfile> get(String name, boolean useCache) {
    checkNotNull(name, "name");
    return Lantern.getScheduler().submitAsyncTask(() -> {
        if (useCache) {
            final Optional<GameProfile> optProfile = this.gameProfileCache.getOrLookupByName(name);
            if (optProfile.isPresent()) {
                return optProfile.get();
            }
            throw new ProfileNotFoundException("Unable to find a profile for the name: " + name);
        }
        final Map<String, UUID> result = GameProfileQuery.queryUUIDByName(Collections.singletonList(name));
        if (!result.containsKey(name)) {
            throw new ProfileNotFoundException("Unable to find a profile for the name: " + name);
        }
        return GameProfileQuery.queryProfileByUUID(result.get(name), true);
    });
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:19,代码来源:LanternGameProfileManager.java


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