本文整理汇总了Java中org.spongepowered.api.entity.living.player.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.spongepowered.api.entity.living.player包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
final Optional<User> optionalUser = args.getOne("player");
if (!optionalUser.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify an existing user."));
}
final Optional<InetAddress> optionalIP = args.getOne("ip");
if (!optionalIP.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify a proper IP address."));
}
final User user = optionalUser.get();
final InetAddress ip = optionalIP.get();
Sponge.getScheduler().createAsyncExecutor(IPLog.getPlugin()).execute(() -> IPLog.getPlugin().getStorage().purgeConnection(ip, user.getUniqueId()));
src.sendMessage(Text.of(TextColors.YELLOW, "You have successfully removed the specified connection from the database."));
return CommandResult.success();
}
示例2: execute
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
return super.executeTransaction(src, args, (player, arg, shop) -> {
Optional<User> userArgumentOptional = arg.getOne(CommandArgs.USER_ARGUMENT);
if (userArgumentOptional.isPresent()) {
User userArg = userArgumentOptional.get();
ShopTransactionResult transactionResult = shop.removeManager(player, userArg.getUniqueId());
if (transactionResult == ShopTransactionResult.SUCCESS) {
SQLDataUtil.deleteShopManager(userArg.getUniqueId(), shop.getUUID(), plugin.getLogger());
}
return transactionResult;
}
return ShopTransactionResult.EMPTY;
}, Messages.REMOVE_MANAGER_CONSOLE_REJECT);
}
示例3: getPlayer
import org.spongepowered.api.entity.living.player.User; //导入依赖的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);
});
}
示例4: getPlayerDB
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
public HashMap<String, Object> getPlayerDB(User p){
HashMap<String, Object> pdb = new HashMap<String, Object>();
if (useUUIDs() && stats.getNode(p.getUniqueId().toString(),"PlayerName").getString() != null){
pdb.put("PlayerName", stats.getNode(p.getUniqueId().toString(),"PlayerName").getString());
pdb.put("JoinDate", stats.getNode(p.getUniqueId().toString(),"JoinDate").getString());
pdb.put("LastVisist", stats.getNode(p.getUniqueId().toString(),"LastVisist").getString());
pdb.put("TimePlayed", stats.getNode(p.getUniqueId().toString(),"TimePlayed").getString());
return pdb;
} else if (stats.getNode(p.getName(),"PlayerName").getString() != null){
pdb.put("PlayerName", stats.getNode(p.getUniqueId().toString(),"PlayerName").getString());
pdb.put("JoinDate", stats.getNode(p.getUniqueId().toString(),"JoinDate").getString());
pdb.put("LastVisist", stats.getNode(p.getUniqueId().toString(),"LastVisist").getString());
pdb.put("TimePlayed", stats.getNode(p.getUniqueId().toString(),"TimePlayed").getString());
return pdb;
}
return null;
}
示例5: getHighestGroup
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
public Subject getHighestGroup(User player){
HashMap<Integer, Subject> subs = new HashMap<Integer, Subject>();
try {
for (SubjectReference sub:player.getParents()){
if (sub.getCollectionIdentifier().equals(getGroups().getIdentifier()) && (sub.getSubjectIdentifier() != null)){
Subject subj;
subj = sub.resolve().get();
subs.put(subj.getParents().size(), subj);
}
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
if (!subs.isEmpty()){
return subs.get(Collections.max(subs.keySet()));
}
return null;
}
示例6: vipTime
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
/**Command to check the vip time.
*
* @return CommandSpec
*/
public CommandSpec vipTime() {
return CommandSpec.builder()
.description(Text.of("Use to check the vip time."))
.permission("pixelvip.cmd.player")
.arguments(GenericArguments.optional(GenericArguments.user(Text.of("player"))))
.executor((src, args) -> { {
if (!(src instanceof Player) && !args.hasAny("player")){
throw new CommandException(plugin.getUtil().toText(plugin.getConfig().getLang("_pluginTag","onlyPlayers")), true);
}
if (src.hasPermission("pixelvip.cmd.player.others") && args.hasAny("player")){
Optional<User> optp = args.<User>getOne("player");
if (optp.isPresent()){
User p = optp.get();
return plugin.getUtil().sendVipTime(src, p.getUniqueId().toString(), p.getName());
} else {
throw new CommandException(plugin.getUtil().toText(plugin.getConfig().getLang("_pluginTag","noPlayersByName")));
}
} else {
return plugin.getUtil().sendVipTime(src, ((Player)src).getUniqueId().toString(), ((Player)src).getName());
}
}
})
.build();
}
示例7: executeBalanceOthers
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
public CompletableFuture<Boolean> executeBalanceOthers(final CommandSource staff, final User user) {
// La source et le joueur sont différent
if (!user.getIdentifier().equals(staff.getIdentifier()) || !(staff instanceof EPlayer)){
Optional<UniqueAccount> account = this.plugin.getService().getOrCreateAccount(user.getUniqueId());
// Le compte existe
if (account.isPresent()) {
BigDecimal balance = account.get().getBalance(this.plugin.getService().getDefaultCurrency());
EEMessages.BALANCE_OTHERS.sender()
.replace(this.plugin.getService().getReplaces())
.replace("{player}", () -> user.getName())
.replace("{solde}", () -> this.plugin.getService().getDefaultCurrency().cast(balance))
.replace("{solde_format}", () -> this.plugin.getService().getDefaultCurrency().format(balance))
.sendTo(staff);
return CompletableFuture.completedFuture(true);
// Le compte est introuvable
} else {
EAMessages.ACCOUNT_NOT_FOUND.sender()
.prefix(EEMessages.PREFIX)
.sendTo(staff);
}
// La source et le joueur sont identique
} else {
return this.executeBalance((EPlayer) staff);
}
return CompletableFuture.completedFuture(false);
}
示例8: execute
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
throws CommandException {
List<User> annointedUsers = AnnointmentDataManager
.getAllAnnointedUsers().collect(Collectors.toList());
if (annointedUsers.isEmpty()) {
src.sendMessage(
Texts.of(TextColors.RED, "No one has been annointed."));
} else {
PaginationBuilder builder = Sponge.getServiceManager()
.provideUnchecked(PaginationService.class).builder();
builder.title(Texts.of(TextColors.GREEN,
"Annointed Users [Name (UUID) [Flags]]"));
builder.contents(annointedUsersToContents(annointedUsers));
builder.sendTo(src);
}
return CommandResult.success();
}
示例9: getActiveVipInfo
import org.spongepowered.api.entity.living.player.User; //导入依赖的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];
}
示例10: onPlayerJoin
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Login e){
User p = e.getTargetUser();
if (getConfig().queueCmds()){
game.getScheduler().createSyncExecutor(this).schedule(new Runnable(){
@Override
public void run() {
List<String> qcmds = getConfig().getQueueCmds(p.getUniqueId().toString());
qcmds.forEach((cmd)->{
game.getScheduler().createSyncExecutor(this).schedule(new Runnable(){
@Override
public void run() {
Sponge.getCommandManager().process(Sponge.getServer().getConsole(), cmd);
}
}, 500, TimeUnit.MILLISECONDS);
});
}
}, 3, TimeUnit.SECONDS);
}
}
示例11: addVip
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
/**Command to add a vip for a player without key.
* @return
*
* @return CommandSpec
*/
public CommandSpec addVip() {
return CommandSpec.builder()
.description(Text.of("Use to add a vip for a player without key."))
.permission("pixelvip.cmd.addvip")
.arguments(
GenericArguments.user(Text.of("player")),
GenericArguments.choices(Text.of("vip"), plugin.getConfig().getCmdChoices()),
GenericArguments.longNum(Text.of("days")))
.executor((src, args) -> { {
User p = args.<User>getOne("player").get();
String group = args.<String>getOne(Text.of("vip")).get();
long days = args.<Long>getOne(Text.of("days")).get();
return plugin.getConfig().activateVip(p, null, group, days, p.getName());
}
})
.build();
}
示例12: onServerListPing
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
@Listener
public void onServerListPing(ClientPingServerEvent event) {
UUID uuid = getDatabaseManager().getPlayerUUID(event.getClient().getAddress().getAddress().getHostAddress());
if (uuid != null) {
User user = userStorageService.get(uuid).get();
try {
event.getResponse().setFavicon(Sponge.getRegistry().loadFavicon(getImageHandler().getImageForUser(user.getUniqueId(), user.getName())));
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例13: getUser
import org.spongepowered.api.entity.living.player.User; //导入依赖的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();
}
示例14: isPlayerOnline
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
public static boolean isPlayerOnline(UUID playerUUID)
{
Optional<User> oUser = getUser(playerUUID);
if(oUser.isPresent())
{
return oUser.get().isOnline();
}
else return false;
}
示例15: getMaxPersonalChunks
import org.spongepowered.api.entity.living.player.User; //导入依赖的package包/类
public static int getMaxPersonalChunks(User user) {
try {
return Integer.parseInt(PERMISSION_SERVICE.getUserSubjects().get(user.getIdentifier()).getOption(user.getActiveContexts(), MAX_PERSONAL_CHUNKS).orElse(DEFAULT_MAX));
} catch (NumberFormatException ignored) {
return -1;
}
}