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


Java UserStorageService类代码示例

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


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

示例1: execute

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Override
public void execute(User user, CommandContext args, MessageChannel channel) {
    String code = (String) args.getOne("code").get();
    //link successful
    if (this.bot.getCodes().containsKey(code)) {
        org.spongepowered.api.entity.living.player.User spongeUser = Sponge.getServiceManager().provideUnchecked(UserStorageService.class)
                .get(bot.getCodes().get(code)).get();
        spongeUser.getSubjectData().setOption(SubjectData.GLOBAL_CONTEXT, "discord-user", user.getId());

        AccountConfigData data = (AccountConfigData) this.phonon.getAllConfigs().get(AccountConfigData.class);
        data.getAccounts().put(user.getId(), spongeUser.getUniqueId());
        data.save();

        channel.sendMessage("You have successfully linked " + user.getName() + "#" +user.getDiscriminator()
                + " to " + spongeUser.getName()).queue();
    } else {
        channel.sendMessage("That is not a valid code!").queue();
    }

}
 
开发者ID:NucleusPowered,项目名称:Phonon,代码行数:21,代码来源:ConfirmAccountLinkCommand.java

示例2: Defaults

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public Defaults(EconomyService service, JavascriptManager manager, PlaceholderService s) {
	if (service != null) {
		eco = true;
		this.service = service;
		this.def = service.getDefaultCurrency();
		service.getCurrencies().forEach(this::putCur);
	} else {
		eco = false;
	}
	this.manager = manager;
	try {
		manager.reloadScripts();
	} catch (Exception e) {
	}
	server = PlaceholderAPIPlugin.getInstance().getGame().getServer();
	this.s = s;
	Optional<UserStorageService> o = Sponge.getServiceManager().provide(UserStorageService.class);
	if (o.isPresent()) {
		this.storage = o.get();
		changed = true;
		sync();
	}
	current = new Uptime();
	current.start();
}
 
开发者ID:rojo8399,项目名称:PlaceholderAPI,代码行数:26,代码来源:Defaults.java

示例3: getAllAnnointedUsers

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public static Stream<User> getAllAnnointedUsers() {
    if (cachedService == null) {
        Sponge.getServiceManager().provide(UserStorageService.class)
                .ifPresent(x -> cachedService = x);
        if (cachedService == null) {
            // We can't tell who's annointed yet - no one is!
            return Stream.empty();
        }
    }
    if (cachedUserListInvalid.get() || ignoreCachedUserListAlways.get()) {
        cachedAnnointedUsers.clear();
        cachedAnnointedUsers.addAll(generateAnnointedUsersCollection());
        cachedUserListInvalid.set(false);
    }
    return cachedAnnointedUsers.stream();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:17,代码来源:AnnointmentDataManager.java

示例4: renderSubject

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
Text renderSubject(Subject subject) {
    HoverAction<?> hover = null;
    if (this.collection.getIdentifier().equals(PermissionService.SUBJECTS_USER)) {
        try {
            UUID uuid = UUID.fromString(subject.getIdentifier());
            Optional<User> user = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid);
            if (user.isPresent()) {
                hover = TextActions.showText(Text.of(user.get().getName()));
            }
        } catch (Exception e) {
        }
    }
    return Text.builder(subject.getIdentifier())
            .onHover(hover)
            .onClick(ExtraUtils.clickAction(() -> {
                this.tab.getSubjViewer().setActive(subject, true);
                this.tab.setRoot(this.tab.getSubjViewer());
            }, SubjectListPane.this.tab)).build();
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:20,代码来源:SubjectListPane.java

示例5: getPlayer

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Override
public Optional<ICachedPlayer> getPlayer(String nameOrUuid) {
    if (Util.isValidUUID(nameOrUuid)) {
        return getPlayer(UUID.fromString(nameOrUuid));
    }

    Optional<CachedPlayer> player = players.values().stream().filter(p -> p.getName().equalsIgnoreCase(nameOrUuid)).findAny();
    if (player.isPresent())
        return player.flatMap(p -> getPlayer(p.getUUID()));

    return WebAPI.runOnMain(() -> {
        Optional<UserStorageService> optSrv = Sponge.getServiceManager().provide(UserStorageService.class);
        if (!optSrv.isPresent())
            return null;

        Optional<User> optUser = optSrv.get().get(nameOrUuid);
        return optUser.<ICachedPlayer>map(CachedPlayer::new).orElse(null);
    });
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:20,代码来源:CacheService.java

示例6: getActiveVipInfo

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
/**Return player's vip info.<p>
 * [0] = Duration, [1] = Vip Group, [2] = Player Group, [3] = Is Active, [4] = Player Nick
 * @param puuid Player UUID as string or nickname.
 * @return {@code String[5]}
 */
public String[] getActiveVipInfo(String playName){
	User offp = null;	
	UserStorageService uss = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get();
	
	try{
		UUID puuid = UUID.fromString(playName);			
		if (uss.get(puuid).isPresent()){
			offp = uss.get(puuid).get();
		} 
	} catch (IllegalArgumentException ex){
		if (uss.get(playName).isPresent()){
			offp = uss.get(playName).get();	
		}						
	}
	if (offp != null){
		for (String[] vips:getVipInfo(offp.getUniqueId().toString())){
			if (vips[3].equals("true")){
				return vips;
			}
		}
	}
	return new String[5];
}
 
开发者ID:FabioZumbi12,项目名称:PixelVip,代码行数:29,代码来源:PVConfig.java

示例7: getOrCreateUser

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的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

示例8: getOwnerOfEntity

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public static Optional<User> getOwnerOfEntity(net.minecraft.entity.Entity entity) {
    NBTTagCompound nbt = new NBTTagCompound();
    entity.writeToNBT(nbt);
    if (nbt.hasKey(FORGE_DATA)) {
        NBTTagCompound forgeNBT = nbt.getCompoundTag(FORGE_DATA);
        if (forgeNBT.hasKey(SPONGE_DATA) && forgeNBT.getCompoundTag(SPONGE_DATA).hasKey(SPONGE_ENTITY_CREATOR)) {
            NBTTagCompound creatorNBT = forgeNBT.getCompoundTag(SPONGE_DATA).getCompoundTag(SPONGE_ENTITY_CREATOR);
            UUID uuid = new UUID(creatorNBT.getLong("uuid_most"), creatorNBT.getLong("uuid_least"));
            // get player if online
            EntityPlayer player = entity.world.getPlayerEntityByUUID(uuid);
            if (player != null) {
                return Optional.of((User) player);
            }
            // player is not online, get user from storage if one exists
            return Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().get(uuid);
        }
    }
    return Optional.empty();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:20,代码来源:NbtDataHelper.java

示例9: lookupPlayerName

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public static String lookupPlayerName(UUID playerID) {
    // parameter validation
    if (playerID == null) {
        return "somebody";
    }

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

示例10: LanternPlayer

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public LanternPlayer(LanternGameProfile gameProfile, NetworkSession session) {
    super((ProxyUser) Sponge.getServiceManager().provideUnchecked(UserStorageService.class).getOrCreate(gameProfile));
    this.gameProfile = gameProfile;
    this.interactionHandler = new PlayerInteractionHandler(this);
    this.inventory = VanillaInventoryArchetypes.PLAYER.builder()
            .withCarrier(this).build(Lantern.getMinecraftPlugin());
    this.inventoryContainer = new PlayerInventoryContainer(this.inventory,
            AbstractOrderedInventory.viewBuilder()
                    .title(this.inventory.getName())
                    .inventory(VanillaInventoryArchetypes.CRAFTING.builder()
                            .build(Lantern.getMinecraftPlugin()))
                    .inventory(this.inventory.getEquipment())
                    .inventory(this.inventory.getOffhand())
                    .shiftClickBehavior(PlayerInventoryShiftClickBehavior.INSTANCE)
                    .build(Lantern.getMinecraftPlugin()));
    this.containerSession = new PlayerContainerSession(this);
    this.session = session;
    // Load the advancements
    this.advancementsProgress.init();
    resetIdleTimeoutCounter();
    setBoundingBoxBase(BOUNDING_BOX_BASE);
    // Attach this player to the proxy user and load player data
    getProxyUser().setInternalUser(this);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:LanternPlayer.java

示例11: sendAll

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Alias(value = "sendallmail")
@Command(desc = "Sends mails to all players.")
public void sendAll(CommandSource context, final @Greed(INFINITE) String message)
{
    Collection<Player> users = Sponge.getServer().getOnlinePlayers();
    final Set<UUID> alreadySend = new HashSet<>();
    for (User user : users)
    {
        getMails(user).addMail(context, message);
        alreadySend.add(user.getUniqueId());
    }
    taskManager.runAsynchronousTaskDelayed(MailModule.class, () ->
        Sponge.getServiceManager().provideUnchecked(UserStorageService.class).getAll().stream()
            .filter(p -> alreadySend.contains(p.getUniqueId()))
            .forEach(p -> new PlayerMails(p.getUniqueId(), db).addMail(context, message)), 0);
    i18n.send(context,  POSITIVE, "Sent mail to everyone!");
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:MailCommand.java

示例12: save

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> save(CompletableFuture<Boolean> c)
{
    return c.thenApply(changed -> {
        if (changed)
        {
            cacheOptions();
            cachePermissions();
            cacheParents();
            // Serialize Data
            List<String> parents = serializeToList(this.parents);
            Map<String, Boolean> permissions = serializeToMap(this.permissions);
            Map<String, String> options = serializeToMap(this.options);

            // Get User for Storage
            UserStorageService storage = Sponge.getServiceManager().provide(UserStorageService.class).get();
            User user = storage.get(uuid).get();
            // Save Data in User
            user.offer(new PermissionData(parents, permissions, options));
            // actually save Data in Player til -> TODO remove once saving data on user is implemented
            user.getPlayer().map(User.class::cast).orElse(user).offer(new PermissionData(parents, permissions, options));
        }
        return changed;
    });
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:UserSubjectData.java

示例13: parse

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Override
public PlayerAccess parse(Class clazz, CommandInvocation invocation) throws ParserException
{
    String token = invocation.currentToken();
    boolean admin = token.startsWith("@");
    boolean add = !token.startsWith("-");

    token = admin || !add ? token.substring(1) : token;

    User user = Sponge.getServer().getPlayer(token)
                      .map(User.class::cast)
                      .orElse(Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(token)
                    .orElse(null));

    if (user == null)
    {
        throw new IllegalArgumentException("User not found");
    }
    invocation.consume(1);

    return new PlayerAccess(user, admin, add);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:23,代码来源:PlayerAccess.java

示例14: notifyKeyUsage

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
public void notifyKeyUsage(Player user)
{
    if (lastKeyNotify == null)
    {
        this.lastKeyNotify = new HashMap<>();
    }
    User owner = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(model.getValue(TABLE_LOCKS.OWNER_ID)).get();
    if (owner.equals(user))
    {
        return;
    }
    Long last = this.lastKeyNotify.get(owner.getUniqueId());
    if (last == null || TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - last) > 60) // 60 sec config ?
    {
        this.lastKeyNotify.put(owner.getUniqueId(), System.currentTimeMillis());
        if (owner.isOnline())
        {
            i18n.send(owner.getPlayer().get(), NEUTRAL, "{user} used a KeyBook to access one of your protections!", user);
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:22,代码来源:Lock.java

示例15: parseValue

import org.spongepowered.api.service.user.UserStorageService; //导入依赖的package包/类
@Nullable
@Override
public User parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String player = args.next();
    Optional<Player> t = Selector.one(source, player);
    if (t.isPresent()) {
        return t.get();
    } else {
        try {
            UserStorageService service = Sponge.getServiceManager().provide(UserStorageService.class).get();
            GameProfile profile = Sponge.getServer().getGameProfileManager().get(player).get();
            return service.get(profile).get();
        } catch (Exception ex) {
            throw args.createError(Messages.getFormatted("core.playernotfound", "%player%", player));
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:18,代码来源:UserArgument.java


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