• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RequestException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.steveice10.mc.auth.exception.request.RequestException的典型用法代码示例。如果您正苦于以下问题:Java RequestException类的具体用法?Java RequestException怎么用?Java RequestException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RequestException类属于com.github.steveice10.mc.auth.exception.request包,在下文中一共展示了RequestException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: connect

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
public void connect(String host, int port) throws RequestException {
    Client client = new Client(host, port, account.getProtocol(), new TcpSessionFactory(proxy));
    this.session = client.getSession();

    switch (account.getGameVersion()) {
        case VERSION_1_11:
            client.getSession().addListener(new SessionListener111(this));
            break;
        case VERSION_1_12:
            client.getSession().addListener(new SessionListener112(this));
            break;
        default:
            throw new IllegalStateException("Unknown session listener");
    }

    client.getSession().connect();
}
 
开发者ID:games647,项目名称:LambdaAttack,代码行数:18,代码来源:Bot.java


示例2: fillProfileProperties

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Fills in the properties of a profile.
 *
 * @param profile Profile to fill in the properties of.
 * @return The given profile, after filling in its properties.
 * @throws ProfileException If the property lookup fails.
 */
public GameProfile fillProfileProperties(GameProfile profile) throws ProfileException {
    if(profile.getId() == null) {
        return profile;
    }

    try {
        MinecraftProfileResponse response = HTTP.makeRequest(this.proxy, PROFILE_URL + "/" + UUIDSerializer.fromUUID(profile.getId()) + "?unsigned=false", null, MinecraftProfileResponse.class);
        if(response == null) {
            throw new ProfileNotFoundException("Couldn't fetch profile properties for " + profile + " as the profile does not exist.");
        }

        if(response.properties != null) {
            profile.getProperties().addAll(response.properties);
        }

        return profile;
    } catch(RequestException e) {
        throw new ProfileLookupException("Couldn't look up profile properties for " + profile + ".", e);
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:28,代码来源:SessionService.java


示例3: login

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Logs the service in.
 *
 * @throws RequestException If an error occurs while making the request.
 */
public void login() throws RequestException {
    if(this.username == null || this.username.equals("")) {
        throw new InvalidCredentialsException("Invalid username.");
    } else {
        if(this.accessToken != null && !this.accessToken.equals("")) {
            this.loginWithToken();
        } else {
            if(this.password == null || this.password.equals("")) {
                throw new InvalidCredentialsException("Invalid password.");
            }

            this.loginWithPassword();
        }
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:21,代码来源:AuthenticationService.java


示例4: logout

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Logs the service out.
 *
 * @throws RequestException If an error occurs while making the request.
 */
public void logout() throws RequestException {
    if(!this.loggedIn) {
        throw new IllegalStateException("Cannot log out while not logged in.");
    }

    InvalidateRequest request = new InvalidateRequest(this.clientToken, this.accessToken);
    HTTP.makeRequest(this.proxy, INVALIDATE_URL, request);

    this.accessToken = null;
    this.loggedIn = false;
    this.id = null;
    this.properties.clear();
    this.profiles.clear();
    this.selectedProfile = null;
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:21,代码来源:AuthenticationService.java


示例5: selectGameProfile

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Selects a game profile.
 *
 * @param profile Profile to select.
 * @throws RequestException If an error occurs while making the request.
 */
public void selectGameProfile(GameProfile profile) throws RequestException {
    if(!this.loggedIn) {
        throw new RequestException("Cannot change game profile while not logged in.");
    } else if(this.selectedProfile != null) {
        throw new RequestException("Cannot change game profile when it is already selected.");
    } else if(profile != null && this.profiles.contains(profile)) {
        RefreshRequest request = new RefreshRequest(this.clientToken, this.accessToken, profile);
        RefreshResponse response = HTTP.makeRequest(this.proxy, REFRESH_URL, request, RefreshResponse.class);
        if(response.clientToken.equals(this.clientToken)) {
            this.accessToken = response.accessToken;
            this.selectedProfile = response.selectedProfile;
        } else {
            throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
        }
    } else {
        throw new IllegalArgumentException("Invalid profile '" + profile + "'.");
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:25,代码来源:AuthenticationService.java


示例6: authenticate

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
public UniversalProtocol authenticate(String username, String password) throws RequestException {
        UniversalProtocol protocol;
        if (!password.isEmpty()) {
            throw new UnsupportedOperationException("Not implemented");
//            protocol = new MinecraftProtocol(username, password);
//            LOGGER.info("Successfully authenticated user");
        } else {
            protocol = UniversalFactory.authenticate(gameVersion, username);
        }

        return protocol;
    }
 
开发者ID:games647,项目名称:LambdaAttack,代码行数:13,代码来源:LambdaAttack.java


示例7: authenticate

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
public void authenticate(String email, String password) {
    proxy.getGeneralThreadPool().execute(() -> {
        try {
            protocol = new MinecraftProtocol(email, password, false);
        } catch (RequestException ex) {
            if (ex.getMessage().toLowerCase().contains("invalid")) {
                sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_LOGIN_FAILD));
                disconnect(proxy.getLang().get(Lang.MESSAGE_ONLINE_LOGIN_FAILD));
                return;
            } else {
                sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_ERROR));
                disconnect(proxy.getLang().get(Lang.MESSAGE_ONLINE_ERROR));
                return;
            }
        }

        if (!username.equals(protocol.getProfile().getName())) {
            username = protocol.getProfile().getName();
            sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_USERNAME, username));
        }

        sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_LOGIN_SUCCESS, username));

        proxy.getLogger().info(
            proxy.getLang().get(Lang.MESSAGE_ONLINE_LOGIN_SUCCESS_CONSOLE, username, remoteAddress, username));
        connectToServer(proxy.getConfig().remote_servers.get(proxy.getConfig().default_server));
    });
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:29,代码来源:UpstreamSession.java


示例8: getProfileByServer

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Gets the profile of the given user if they are currently logged in to the given server.
 *
 * @param name     Name of the user to get the profile of.
 * @param serverId ID of the server to check if they're logged in to.
 * @return The profile of the given user, or null if they are not logged in to the given server.
 * @throws RequestException If an error occurs while making the request.
 */
public GameProfile getProfileByServer(String name, String serverId) throws RequestException {
    HasJoinedResponse response = HTTP.makeRequest(this.proxy, HAS_JOINED_URL + "?username=" + name + "&serverId=" + serverId, null, HasJoinedResponse.class);
    if(response != null && response.id != null) {
        GameProfile result = new GameProfile(response.id, name);
        if(response.properties != null) {
            result.getProperties().addAll(response.properties);
        }

        return result;
    } else {
        return null;
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:22,代码来源:SessionService.java


示例9: loginWithPassword

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
private void loginWithPassword() throws RequestException {
    if(this.username == null || this.username.isEmpty()) {
        throw new InvalidCredentialsException("Invalid username.");
    } else if(this.password == null || this.password.isEmpty()) {
        throw new InvalidCredentialsException("Invalid password.");
    } else {
        AuthenticationRequest request = new AuthenticationRequest(this.username, this.password, this.clientToken);
        AuthenticationResponse response = HTTP.makeRequest(this.proxy, AUTHENTICATE_URL, request, AuthenticationResponse.class);
        if(response.clientToken.equals(this.clientToken)) {
            if(response.user != null && response.user.id != null) {
                this.id = response.user.id;
            } else {
                this.id = this.username;
            }

            this.loggedIn = true;
            this.accessToken = response.accessToken;
            this.profiles = response.availableProfiles != null ? Arrays.asList(response.availableProfiles) : Collections.<GameProfile>emptyList();
            this.selectedProfile = response.selectedProfile;
            this.properties.clear();
            if(response.user != null && response.user.properties != null) {
                this.properties.addAll(response.user.properties);
            }
        } else {
            throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
        }
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:29,代码来源:AuthenticationService.java


示例10: loginWithToken

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
private void loginWithToken() throws RequestException {
    if(this.id == null || this.id.isEmpty()) {
        if(this.username == null || this.username.isEmpty()) {
            throw new InvalidCredentialsException("Invalid uuid and username.");
        }

        this.id = this.username;
    }

    if(this.accessToken == null || this.accessToken.equals("")) {
        throw new InvalidCredentialsException("Invalid access token.");
    } else {
        RefreshRequest request = new RefreshRequest(this.clientToken, this.accessToken, null);
        RefreshResponse response = HTTP.makeRequest(this.proxy, REFRESH_URL, request, RefreshResponse.class);
        if(response.clientToken.equals(this.clientToken)) {
            if(response.user != null && response.user.id != null) {
                this.id = response.user.id;
            } else {
                this.id = this.username;
            }

            this.loggedIn = true;
            this.accessToken = response.accessToken;
            this.profiles = response.availableProfiles != null ? Arrays.asList(response.availableProfiles) : Collections.<GameProfile>emptyList();
            this.selectedProfile = response.selectedProfile;
            this.properties.clear();
            if(response.user != null && response.user.properties != null) {
                this.properties.addAll(response.user.properties);
            }
        } else {
            throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
        }
    }
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:35,代码来源:AuthenticationService.java


示例11: makeRequest

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Makes an HTTP request.
 *
 * @param proxy Proxy to use when making the request.
 * @param url   URL to make the request to.
 * @param input Input to provide in the request.
 * @param clazz Class to provide the response as.
 * @param <T> Type to provide the response as.
 * @return The response of the request.
 * @throws RequestException If an error occurs while making the request.
 */
public static <T> T makeRequest(Proxy proxy, String url, Object input, Class<T> clazz) throws RequestException {
    JsonElement response = null;
    try {
        String jsonString = input == null ? performGetRequest(proxy, url) : performPostRequest(proxy, url, GSON.toJson(input), "application/json");
        response = GSON.fromJson(jsonString, JsonElement.class);
    } catch(Exception e) {
        throw new ServiceUnavailableException("Could not make request to '" + url + "'.", e);
    }

    if(response != null) {
        if(response.isJsonObject()) {
            JsonObject object = response.getAsJsonObject();
            if(object.has("error")) {
                String error = object.get("error").getAsString();
                String cause = object.has("cause") ? object.get("cause").getAsString() : "";
                String errorMessage = object.has("errorMessage") ? object.get("errorMessage").getAsString() : "";
                if(!error.equals("")) {
                    if(error.equals("ForbiddenOperationException")) {
                        if(cause != null && cause.equals("UserMigratedException")) {
                            throw new UserMigratedException(errorMessage);
                        } else {
                            throw new InvalidCredentialsException(errorMessage);
                        }
                    } else {
                        throw new RequestException(errorMessage);
                    }
                }
            }
        }

        if(clazz != null) {
            return GSON.fromJson(response, clazz);
        }
    }

    return null;
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:49,代码来源:HTTP.java


示例12: makeRequest

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Makes an HTTP request.
 *
 * @param proxy Proxy to use when making the request.
 * @param url   URL to make the request to.
 * @param input Input to provide in the request.
 * @param clazz Class to provide the response as.
 * @param <T>   Type to provide the response as.
 * @return The response of the request.
 * @throws RequestException If an error occurs while making the request.
 */
public static <T> T makeRequest(Proxy proxy, String url, Object input, Class<T> clazz) throws RequestException {
    JsonElement response = null;
    try {
        String jsonString = input == null ? performGetRequest(proxy, url) : performPostRequest(proxy, url, GSON.toJson(input), "application/json");
        response = GSON.fromJson(jsonString, JsonElement.class);
    } catch(Exception e) {
        throw new ServiceUnavailableException("Could not make request to '" + url + "'.", e);
    }

    if(response != null) {
        if(response.isJsonObject()) {
            JsonObject object = response.getAsJsonObject();
            if(object.has("error")) {
                String error = object.get("error").getAsString();
                String cause = object.has("cause") ? object.get("cause").getAsString() : "";
                String errorMessage = object.has("errorMessage") ? object.get("errorMessage").getAsString() : "";
                if(!error.equals("")) {
                    if(error.equals("ForbiddenOperationException")) {
                        if(cause != null && cause.equals("UserMigratedException")) {
                            throw new UserMigratedException(errorMessage);
                        } else {
                            throw new InvalidCredentialsException(errorMessage);
                        }
                    } else {
                        throw new RequestException(errorMessage);
                    }
                }
            }
        }

        if(clazz != null) {
            return GSON.fromJson(response, clazz);
        }
    }

    return null;
}
 
开发者ID:Steveice10,项目名称:MCAuthLib,代码行数:49,代码来源:HTTP.java


示例13: connect

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
@Override
public void connect() {
    try {
        this.conn = new Client(this.host, this.port, new MinecraftProtocol(this.username, this.password, false), new TcpSessionFactory());
        this.conn.getSession().addListener(new BotListener());
        this.conn.getSession().connect();
    } catch(RequestException e) {
        throw new BotException("Failed to authenticate MinecraftModule.", e);
    }
}
 
开发者ID:Steveice10,项目名称:LibBot,代码行数:11,代码来源:MinecraftModule.java


示例14: ProtocolWrapper

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
public ProtocolWrapper(String username, String password) throws RequestException {
    super(username, password);
}
 
开发者ID:games647,项目名称:LambdaAttack,代码行数:4,代码来源:ProtocolWrapper.java


示例15: start

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
public void start(String host, int port, int amount, int delay, String nameFormat) throws RequestException {
    running = true;

    for (int i = 0; i < amount; i++) {
        String username = String.format(nameFormat, i);
        if (names != null) {
            if (names.size() <= i) {
                LOGGER.warning("Amount is higher than the name list size. Limitting amount size now...");
                break;
            }

            username = names.get(i);
        }

        UniversalProtocol account = authenticate(username, "");

        Bot bot;
        if (proxies != null) {
            Proxy proxy = proxies.get(i % proxies.size());
            bot = new Bot(account, proxy);
        } else {
            bot = new Bot(account);
        }

        this.clients.add(bot);
    }

    for (Bot client : clients) {
        try {
            TimeUnit.MILLISECONDS.sleep(delay);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }

        if (!running) {
            break;
        }

        client.connect(host, port);
    }
}
 
开发者ID:games647,项目名称:LambdaAttack,代码行数:42,代码来源:LambdaAttack.java


示例16: joinServer

import com.github.steveice10.mc.auth.exception.request.RequestException; //导入依赖的package包/类
/**
 * Joins a server.
 *
 * @param profile             Profile to join the server with.
 * @param authenticationToken Authentication token to join the server with.
 * @param serverId            ID of the server to join.
 * @throws RequestException If an error occurs while making the request.
 */
public void joinServer(GameProfile profile, String authenticationToken, String serverId) throws RequestException {
    JoinServerRequest request = new JoinServerRequest(authenticationToken, profile.getId(), serverId);
    HTTP.makeRequest(this.proxy, JOIN_URL, request, null);
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:13,代码来源:SessionService.java



注:本文中的com.github.steveice10.mc.auth.exception.request.RequestException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Issue类代码示例发布时间:2022-05-22
下一篇:
Java Javadoc类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap