Changeset View
Changeset View
Standalone View
Standalone View
src/main/java/net/wildfyre/api/WildFyre.java
package net.wildfyre.api; | package net.wildfyre.api; | ||||
Lint: Lint: :compileKotlin [01;31m[KFAILED[m[K | |||||
import net.wildfyre.http.Request; | import net.wildfyre.http.Request; | ||||
import net.wildfyre.users.LoggedUser; | import net.wildfyre.users.LoggedUser; | ||||
import net.wildfyre.users.Users; | import net.wildfyre.users.Users; | ||||
import net.wildfyre.utils.InvalidCredentialsException; | import net.wildfyre.utils.InvalidCredentialsException; | ||||
/** | /** | ||||
Show All 9 Lines | public class WildFyre { | ||||
* @param password the user's password | * @param password the user's password | ||||
* @return Your own user. See also {@link Users#me()}. | * @return Your own user. See also {@link Users#me()}. | ||||
*/ | */ | ||||
public static LoggedUser connect(String username, String password) | public static LoggedUser connect(String username, String password) | ||||
throws Request.CantConnectException, InvalidCredentialsException { | throws Request.CantConnectException, InvalidCredentialsException { | ||||
Internal.requestToken(username, password); | Internal.requestToken(username, password); | ||||
Internal.init(); | Internal.init(); | ||||
return Users.me(); | return Users.INSTANCE.me(); | ||||
} | } | ||||
/** | /** | ||||
* Connects to the server with the specified token. | * Connects to the server with the specified token. | ||||
* This method is NOT executed concurrently, because no action can be taken by the client while the cache is empty | * This method is NOT executed concurrently, because no action can be taken by the client while the cache is empty | ||||
* anyway. | * anyway. | ||||
* @param token the token | * @param token the token | ||||
* @return Your own user. See also {@link Users#me()}. | * @return Your own user. See also {@link Users#me()}. | ||||
*/ | */ | ||||
public static LoggedUser connect(String token) throws Request.CantConnectException { | public static LoggedUser connect(String token) throws Request.CantConnectException { | ||||
if(token == null) | if(token == null) | ||||
throw new NullPointerException("Cannot connect to the token 'null'"); | throw new NullPointerException("Cannot connect to the token 'null'"); | ||||
Internal.setToken(token); | Internal.setToken(token); | ||||
Internal.init(); | Internal.init(); | ||||
return Users.me(); | return Users.INSTANCE.me(); | ||||
} | } | ||||
/** | /** | ||||
* Disconnects the API from the currently-logged-in user. | * Disconnects the API from the currently-logged-in user. | ||||
*/ | */ | ||||
public static void disconnect(){ | public static void disconnect(){ | ||||
Internal.reset(); | Internal.reset(); | ||||
} | } | ||||
Show All 13 Lines |
:compileKotlin [01;31m[KFAILED[m[K