@Override public UUID getUUID() { return user.getUniqueId(); }
public Optional<Account> getAccount(User player) { return Optional.ofNullable(cache.get(player.getUniqueId())); }
public Optional<Account> remove(User player) { return Optional.ofNullable(cache.remove(player.getUniqueId())); }
public Optional<Account> loadAccount(User player) { Optional<Account> optAcc = loadAccount(player.getUniqueId()); optAcc.ifPresent(account -> cache.put(player.getUniqueId(), account)); return optAcc; }
/** * Gets the {@link Home}s for the specified user, identified by their UUID. * * @param user The {@link UUID} * @return The homes. */ default List<Home> getHomes(User user) { return getHomes(user.getUniqueId()); }
public CachedPlayer(User user) { super(null); this.uuid = UUID.fromString(user.getUniqueId().toString()); this.name = user.getName(); this.isOnline = false; } public CachedPlayer(Player player) {
/** * Gets the user metadata for a player with the specified {@link User}. * @param user The {@link User}. * @return The {@link Result} if the user exists. */ default Optional<Result> getUserData(User user) { return getUserData(user.getUniqueId()); }
/** * Gets the number of homes the player currently has. * * @param user The {@link User} * @return The number of homes. */ default int getHomeCount(User user) { return getHomeCount(user.getUniqueId()); }
default Optional<Home> getHome(User user, String name) { return getHome(user.getUniqueId(), name); }
/** * Create a filter that restricts the mail to the senders provided. * * <p> * Multiple player filters can be provided - this will return messages authored by all specified players. * </p> * * @param includeConsole If <code>true</code>, include the console/plugins in any returned mail. * @param player The {@link UUID}s of the players. * @return The {@link MailFilter} */ default MailFilter createSenderFilter(boolean includeConsole, final Collection<UUID> player) { return m -> m.getSender().map(x -> player.contains(x.getUniqueId())).orElse(includeConsole); }
default void modifyHome(Cause cause, User user, String name, Location<World> location, Vector3d rotation) throws NucleusException { modifyHome(cause, user.getUniqueId(), name, location, rotation); }
@Override public Optional<Account> loadAccount(User player) { Optional<Account> optAcc = loadAccount(player.getName()); optAcc.ifPresent(account -> cache.put(player.getUniqueId(), account)); return optAcc; }
/** * Gets the passed user as a cached object. This method first tries to get the user from the cache, and if * it is not found uses the {@link #updatePlayer(User)} method to convert it into a cached object. * @param user The user which is returned in it's cached form. * @return The cached version of the specified user. */ public CachedPlayer getPlayer(User user) { Optional<CachedPlayer> p = getPlayer(user.getUniqueId()); return p.orElseGet(() -> updatePlayer(user)); }
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { User user = args.<User>getOne("user").get(); String password = args.<String>getOne("password").get(); uuidRegister(user.getUniqueId(), src, password); return CommandResult.success(); }
@Override public CommandResult execute(CommandSource src, CommandContext args) { User username = args.<User>getOne("user").get(); UUID sender = null; if (src instanceof Identifiable) { sender = ((Identifiable) src).getUniqueId(); } UUID finalSender = sender; CompletableFuture.supplyAsync(() -> plugin.getDatabase().loadAccount(username.getUniqueId()), asyncExecutor) .thenAcceptAsync(optAcc -> onAccLoaded(finalSender, optAcc.orElse(null)), syncExecutor); return CommandResult.success(); }
@Override public CommandResult execute(CommandSource src, CommandContext args) { User user = args.<User>getOne("user").get(); String password = args.<String>getOne("password").get(); //check if the account is a valid player name Task.builder() //Async as it could run a SQL query .async() .execute(new UUIDResetPwTask(plugin, src, password, user.getUniqueId())) .submit(plugin); return CommandResult.success(); }
@Override public CommandResult execute(CommandSource src, CommandContext args) { if (args.hasAny("a")) { Task.builder().execute(plugin.getDatabase()::clearTable).async().submit(plugin); src.sendMessage(settings.getText().getTableCleared()); return CommandResult.success(); } User user = args.<User>getOne("user").get(); Task.builder() //Async as it could run a SQL query .async() .execute(new UnregisterTask(plugin, src, user.getUniqueId())) .submit(plugin); return CommandResult.success(); }