@Override public UUID getUUID() { if (source instanceof Identifiable) { return ((Identifiable) source).getUniqueId(); } else { return UUID.fromString(getName()); } }
@Override public @NotNull UUID getUniqueId() { if (this.source instanceof Identifiable) { return ((Identifiable) source).getUniqueId(); } //generate a unique id based of the name (like for the console command sender) return UUID.nameUUIDFromBytes(source.getName().getBytes(StandardCharsets.UTF_8)); }
@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(); }