本文整理汇总了Java中org.spongepowered.api.service.user.UserStorageService.get方法的典型用法代码示例。如果您正苦于以下问题:Java UserStorageService.get方法的具体用法?Java UserStorageService.get怎么用?Java UserStorageService.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.service.user.UserStorageService
的用法示例。
在下文中一共展示了UserStorageService.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUser
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
private static Optional<User> getUser(UUID playerUUID)
{
UserStorageService userStorageService = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
Optional<User> oUser = userStorageService.get(playerUUID);
if(oUser.isPresent())
{
return oUser;
}
else return Optional.empty();
}
示例2: getNameForUuid
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
private static Optional<String> getNameForUuid(UUID uuid) {
UserStorageService uss = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
Optional<User> userOptional = uss.get(uuid);
if (userOptional.isPresent()) {
// the name with which that player has been online the last time
String name = userOptional.get().getName();
return Optional.of(name);
} else {
// a player with that uuid has never been on your server
return Optional.empty();
}
}
示例3: parseValue
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException
{
String user = args.next();
// Check for exact match from the GameProfile service first.
UserStorageService uss = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get();
Optional<GameProfile> ogp = uss.getAll().stream().filter(f -> f.getName().isPresent() && f.getName().get()
.equalsIgnoreCase(user)).findFirst();
if (ogp.isPresent())
{
Optional<User> retUser = uss.get(ogp.get());
if (retUser.isPresent())
{
return retUser.get();
}
}
// No match. Check against all online players only.
List<User> listUser = Sponge.getGame().getServer().getOnlinePlayers().stream()
.filter(x -> x.getName().toLowerCase().startsWith(user.toLowerCase())).collect(Collectors.toList());
if (listUser.isEmpty())
{
throw args.createError(Text.of(TextColors.RED, "Could not find user with the name " + user));
}
if (listUser.size() == 1)
{
return listUser.get(0);
}
return listUser;
}
示例4: buyHandler
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void buyHandler(Player player, long value, Region r) {
if (r.isLeader(RPUtil.PlayerToUUID(player.getName()))){
RPLang.sendMessage(player, "economy.region.buy.own");
return;
}
UniqueAccount acc = RedProtect.get().econ.getOrCreateAccount(player.getUniqueId()).get();
Double money = acc.getBalance(RedProtect.get().econ.getDefaultCurrency()).doubleValue();
if (money >= value){
String rname = r.getName();
ArrayList<String> sellers = new ArrayList<>(r.getLeaders());
if (RPEconomy.BuyRegion(r, RPUtil.PlayerToUUID(player.getName()))){
acc.withdraw(RedProtect.get().econ.getDefaultCurrency(), BigDecimal.valueOf(value), RedProtect.get().getPVHelper().getCause(player));
for (String seller : sellers){
UserStorageService uss = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get();
Optional<User> offp = uss.get(RPUtil.UUIDtoPlayer(seller));
if (!seller.equals(RedProtect.get().cfgs.getString("region-settings.default-leader")) && offp.isPresent()){
UniqueAccount offAcc = RedProtect.get().econ.getOrCreateAccount(offp.get().getUniqueId()).get();
offAcc.deposit(RedProtect.get().econ.getDefaultCurrency(), BigDecimal.valueOf(value), RedProtect.get().getPVHelper().getCause(player));
if (offp.get().isOnline()){
RPLang.sendMessage(offp.get().getPlayer().get(), RPLang.get("economy.region.buy.bought").replace("{player}", player.getName()).replace("{region}", rname).replace("{world}", r.getWorld()));
}
}
}
RPLang.sendMessage(player, RPLang.get("economy.region.buy.success").replace("{region}", r.getName()).replace("{value}", String.valueOf(value)).replace("{ecosymbol}", RedProtect.get().cfgs.getEcoString("economy-name")));
} else {
RPLang.sendMessage(player, "economy.region.error");
}
} else {
RPLang.sendMessage(player, "economy.region.buy.nomoney");
}
}
示例5: getPlayer
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
/**
* Gets a player by the {@link UUID}
*
* @param uuid The {@link UUID}
* @return The {@link WrappedPlayer} if it exists, otherwise <code>null</code>
*/
@Override
public WrappedPlayer getPlayer(UUID uuid) {
UserStorageService service = game.getServiceManager().provide(UserStorageService.class).get();
Optional<User> player = service.get(uuid);
if (player.isPresent()) {
return new SpongeWrappedPlayer(player.get());
}
return null;
}
示例6: getUser
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
public Optional<User> getUser(String name){
UserStorageService uss = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get();
return uss.get(name);
}
示例7: onVote
import org.spongepowered.api.service.user.UserStorageService; //导入方法依赖的package包/类
@Listener
public void onVote(VotifierEvent event) throws ExecutionException, InterruptedException
{
final com.vexsoftware.votifier.model.Vote vote = event.getVote();
UserStorageService uss = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
Optional<User> user = uss.get(vote.getUsername());
if (!user.isPresent())
{
if (vote.getUsername() == null || vote.getUsername().trim().isEmpty())
{
logger.info("{} voted but is not known to the server!", vote.getUsername());
}
return;
}
final DSLContext dsl = db.getDSL();
db.queryOne(dsl.selectFrom(TABLE_VOTE).where(TABLE_VOTE.ID.eq(user.get().getUniqueId()))).thenAcceptAsync((voteModel) -> {
if (voteModel != null)
{
if (voteModel.timePassed(config.voteBonusTime.toMillis()))
{
voteModel.setVotes(1);
}
else
{
voteModel.addVote();
}
voteModel.update();
}
else
{
voteModel = dsl.newRecord(TABLE_VOTE).newVote(user.get());
voteModel.insert();
}
UniqueAccount acc = economy.getOrCreateAccount(user.get().getUniqueId()).get();
final int voteAmount = voteModel.getVotes();
double money = this.config.voteReward * pow(1 + 1.5 / voteAmount, voteAmount - 1);
acc.deposit(economy.getDefaultCurrency(), new BigDecimal(money), Cause.of(EventContext.empty(), event.getVote()));
Text moneyFormat = economy.getDefaultCurrency().format(new BigDecimal(money));
bc.broadcastMessage(NONE, ChatFormat.parseFormats(this.config.voteBroadcast)
.replace("{PLAYER}", vote.getUsername())
.replace("{MONEY}", moneyFormat.toPlain()).replace("{AMOUNT}", String.valueOf(voteAmount))
.replace("{VOTEURL}", this.config.voteUrl));
user.get().getPlayer().ifPresent(p -> p.sendMessage(Text.of(ChatFormat.parseFormats(this.config.voteMessage
.replace("{PLAYER}", vote.getUsername())
.replace("{MONEY}", moneyFormat.toPlain())
.replace("{AMOUNT}", String.valueOf(voteAmount))
.replace("{VOTEURL}", this.config.voteUrl)))));
});
}