Added support for Mojang API calls in ApiClient
Added Mojang API call to retreive Player profile
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.*;
|
import eu.crushedpixel.replaymod.api.mojang.MojangApiMethods;
|
||||||
|
import eu.crushedpixel.replaymod.api.mojang.holders.Profile;
|
||||||
|
import eu.crushedpixel.replaymod.api.replay.ReplayModApiMethods;
|
||||||
|
import eu.crushedpixel.replaymod.api.replay.SearchQuery;
|
||||||
|
import eu.crushedpixel.replaymod.api.replay.holders.*;
|
||||||
import eu.crushedpixel.replaymod.utils.StreamTools;
|
import eu.crushedpixel.replaymod.utils.StreamTools;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
@@ -15,6 +20,7 @@ import java.net.URL;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
@@ -22,7 +28,7 @@ public class ApiClient {
|
|||||||
private static final JsonParser jsonParser = new JsonParser();
|
private static final JsonParser jsonParser = new JsonParser();
|
||||||
|
|
||||||
public AuthKey getLogin(String username, String password) throws IOException, ApiException {
|
public AuthKey getLogin(String username, String password) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.login);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.login);
|
||||||
builder.put("user", username);
|
builder.put("user", username);
|
||||||
builder.put("pw", password);
|
builder.put("pw", password);
|
||||||
builder.put("mod", true);
|
builder.put("mod", true);
|
||||||
@@ -31,7 +37,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AuthKey register(String username, String mail, String password) throws IOException, ApiException {
|
public AuthKey register(String username, String mail, String password) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.register);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.register);
|
||||||
builder.put("username", username);
|
builder.put("username", username);
|
||||||
builder.put("email", mail);
|
builder.put("email", mail);
|
||||||
builder.put("password", password);
|
builder.put("password", password);
|
||||||
@@ -41,7 +47,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
public AuthConfirmation checkAuthkey(String auth) {
|
public AuthConfirmation checkAuthkey(String auth) {
|
||||||
try {
|
try {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.check_authkey);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.check_authkey);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
AuthConfirmation conf = invokeAndReturn(builder, AuthConfirmation.class);
|
AuthConfirmation conf = invokeAndReturn(builder, AuthConfirmation.class);
|
||||||
return conf;
|
return conf;
|
||||||
@@ -51,7 +57,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean logout(String auth) throws IOException, ApiException {
|
public boolean logout(String auth) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.logout);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.logout);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
builder.put("mod", true);
|
builder.put("mod", true);
|
||||||
Success succ = invokeAndReturn(builder, Success.class);
|
Success succ = invokeAndReturn(builder, Success.class);
|
||||||
@@ -59,7 +65,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDonated(String uuid) throws IOException, ApiException {
|
public boolean hasDonated(String uuid) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.check_auth);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.check_auth);
|
||||||
builder.put("uuid", uuid);
|
builder.put("uuid", uuid);
|
||||||
Donated succ = invokeAndReturn(builder, Donated.class);
|
Donated succ = invokeAndReturn(builder, Donated.class);
|
||||||
return succ.hasDonated();
|
return succ.hasDonated();
|
||||||
@@ -72,18 +78,15 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo[] getFileInfo(List<Integer> ids) throws IOException, ApiException {
|
public FileInfo[] getFileInfo(List<Integer> ids) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.file_details);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.file_details);
|
||||||
builder.put("id", buildListString(ids));
|
builder.put("id", buildListString(ids));
|
||||||
FileInfo[] info = invokeAndReturn(builder, FileInfo[].class);
|
FileInfo[] info = invokeAndReturn(builder, FileInfo[].class);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo[] searchFiles(SearchQuery query) throws IOException, ApiException {
|
public FileInfo[] searchFiles(SearchQuery query) throws IOException, ApiException {
|
||||||
StringBuilder sb = new StringBuilder();
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.search);
|
||||||
|
StringBuilder sb = new StringBuilder(builder.toString());
|
||||||
// build base url
|
|
||||||
sb.append(QueryBuilder.API_BASE_URL);
|
|
||||||
sb.append("search");
|
|
||||||
sb.append(query.buildQuery());
|
sb.append(query.buildQuery());
|
||||||
|
|
||||||
FileInfo[] info = invokeAndReturn(sb.toString(), SearchResult.class).getResults();
|
FileInfo[] info = invokeAndReturn(sb.toString(), SearchResult.class).getResults();
|
||||||
@@ -91,21 +94,21 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getTranslation(String languageCode) throws IOException, ApiException {
|
public String getTranslation(String languageCode) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.get_language);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_language);
|
||||||
builder.put("language", languageCode);
|
builder.put("language", languageCode);
|
||||||
String properties = SimpleApiClient.invokeUrl(builder.toString());
|
String properties = SimpleApiClient.invokeUrl(builder.toString());
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadThumbnail(int file, File target) throws IOException {
|
public void downloadThumbnail(int file, File target) throws IOException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.get_thumbnail);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_thumbnail);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
URL url = new URL(builder.toString());
|
URL url = new URL(builder.toString());
|
||||||
FileUtils.copyURLToFile(url, target);
|
FileUtils.copyURLToFile(url, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadFile(String auth, int file, File target) throws IOException {
|
public void downloadFile(String auth, int file, File target) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.download_file);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.download_file);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
String url = builder.toString();
|
String url = builder.toString();
|
||||||
@@ -122,13 +125,14 @@ public class ApiClient {
|
|||||||
if(err.getDesc() != null) {
|
if(err.getDesc() != null) {
|
||||||
throw new ApiException(err);
|
throw new ApiException(err);
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(JsonParseException e) {
|
||||||
|
throw new ApiException(StreamTools.readStreamtoString(is));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rateFile(String auth, int file, boolean like) throws IOException, ApiException {
|
public void rateFile(String auth, int file, boolean like) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.rate_file);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.rate_file);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
builder.put("like", like);
|
builder.put("like", like);
|
||||||
@@ -136,7 +140,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void favFile(String auth, int file, boolean fav) throws IOException, ApiException {
|
public void favFile(String auth, int file, boolean fav) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.fav_file);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.fav_file);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
builder.put("fav", fav);
|
builder.put("fav", fav);
|
||||||
@@ -144,19 +148,28 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int[] getFavorites(String auth) throws IOException, ApiException {
|
public int[] getFavorites(String auth) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.get_favorites);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_favorites);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
|
|
||||||
return invokeAndReturn(builder, Favorites.class).getFavorited();
|
return invokeAndReturn(builder, Favorites.class).getFavorited();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFile(String auth, int file) throws IOException, ApiException {
|
public void removeFile(String auth, int file) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.remove_file);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.remove_file);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
invokeAndReturn(builder, Success.class);
|
invokeAndReturn(builder, Success.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
MOJANG API CALLS
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Profile getProfileFromUUID(UUID uuid) throws IOException, ApiException {
|
||||||
|
String url = String.format(MojangApiMethods.userprofile+"%s", uuid.toString().replace("-", ""));
|
||||||
|
return invokeAndReturn(url, Profile.class);
|
||||||
|
}
|
||||||
|
|
||||||
private <T> T invokeAndReturn(QueryBuilder builder, Class<T> classOfT) throws IOException, ApiException {
|
private <T> T invokeAndReturn(QueryBuilder builder, Class<T> classOfT) throws IOException, ApiException {
|
||||||
return invokeAndReturn(builder.toString(), classOfT);
|
return invokeAndReturn(builder.toString(), classOfT);
|
||||||
}
|
}
|
||||||
31
src/main/java/eu/crushedpixel/replaymod/api/ApiException.java
Executable file
31
src/main/java/eu/crushedpixel/replaymod/api/ApiException.java
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
||||||
|
|
||||||
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 349073390504232810L;
|
||||||
|
|
||||||
|
private ApiError error;
|
||||||
|
private String errorMsg;
|
||||||
|
|
||||||
|
public ApiException(ApiError error) {
|
||||||
|
super(error.getTranslatedDesc());
|
||||||
|
this.error = error;
|
||||||
|
this.errorMsg = error.getTranslatedDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiException(String error) {
|
||||||
|
super(error);
|
||||||
|
this.errorMsg = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiError getError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMsg() {
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@@ -7,8 +7,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class QueryBuilder {
|
public class QueryBuilder {
|
||||||
|
|
||||||
public static final String API_BASE_URL = "http://ReplayMod.com/api/";
|
|
||||||
|
|
||||||
public String apiMethod;
|
public String apiMethod;
|
||||||
public Map<String, String> paramMap;
|
public Map<String, String> paramMap;
|
||||||
|
|
||||||
@@ -71,7 +69,6 @@ public class QueryBuilder {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
// build base url
|
// build base url
|
||||||
sb.append(API_BASE_URL);
|
|
||||||
sb.append(apiMethod);
|
sb.append(apiMethod);
|
||||||
|
|
||||||
// process parameters
|
// process parameters
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.ApiError;
|
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
||||||
import eu.crushedpixel.replaymod.utils.StreamTools;
|
import eu.crushedpixel.replaymod.utils.StreamTools;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -92,8 +93,12 @@ public class SimpleApiClient {
|
|||||||
} else {
|
} else {
|
||||||
responseContent = "";
|
responseContent = "";
|
||||||
}
|
}
|
||||||
JsonObject response = jsonParser.parse(responseContent).getAsJsonObject();
|
try {
|
||||||
throw new ApiException(gson.fromJson(response, ApiError.class));
|
JsonObject response = jsonParser.parse(responseContent).getAsJsonObject();
|
||||||
|
throw new ApiException(gson.fromJson(response, ApiError.class));
|
||||||
|
} catch(JsonParseException e) {
|
||||||
|
throw new ApiException(responseContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is = httpUrlConnection.getInputStream();
|
is = httpUrlConnection.getInputStream();
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.ApiError;
|
|
||||||
|
|
||||||
public class ApiException extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 349073390504232810L;
|
|
||||||
|
|
||||||
private ApiError error;
|
|
||||||
|
|
||||||
public ApiException(ApiError error) {
|
|
||||||
super(error.getDesc());
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiError getError() {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
|
||||||
|
|
||||||
public class ApiMethods {
|
|
||||||
|
|
||||||
public static final String register = "register";
|
|
||||||
public static final String check_authkey = "check_authkey";
|
|
||||||
public static final String login = "login";
|
|
||||||
public static final String logout = "logout";
|
|
||||||
public static final String file_details = "file_details";
|
|
||||||
public static final String upload_file = "upload_file";
|
|
||||||
public static final String download_file = "download_file";
|
|
||||||
public static final String get_thumbnail = "get_thumbnail";
|
|
||||||
public static final String remove_file = "remove_file";
|
|
||||||
public static final String rate_file = "rate_file";
|
|
||||||
public static final String fav_file = "fav_file";
|
|
||||||
public static final String get_favorites = "get_favorites";
|
|
||||||
public static final String check_auth = "check_auth";
|
|
||||||
public static final String get_language = "get_language";
|
|
||||||
}
|
|
||||||
7
src/main/java/eu/crushedpixel/replaymod/api/mojang/MojangApiMethods.java
Executable file
7
src/main/java/eu/crushedpixel/replaymod/api/mojang/MojangApiMethods.java
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang;
|
||||||
|
|
||||||
|
public class MojangApiMethods {
|
||||||
|
|
||||||
|
public static final String userprofile = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
|
import eu.crushedpixel.replaymod.api.ApiException;
|
||||||
|
import eu.crushedpixel.replaymod.api.mojang.holders.Profile;
|
||||||
|
import eu.crushedpixel.replaymod.api.mojang.holders.Properties;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class SkinDownloader {
|
||||||
|
|
||||||
|
public static ITextureObject getDownloadImageSkin(ResourceLocation resourceLocationIn, UUID uuid) throws IOException, ApiException {
|
||||||
|
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||||
|
ITextureObject object = texturemanager.getTexture(resourceLocationIn);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(object == null) {
|
||||||
|
Profile profile = ReplayMod.apiClient.getProfileFromUUID(uuid);
|
||||||
|
|
||||||
|
if(profile.getProperties() != null && profile.getProperties().length > 0) {
|
||||||
|
List<Properties> plist = Arrays.asList(profile.getProperties());
|
||||||
|
Collections.reverse(plist);
|
||||||
|
|
||||||
|
for(Properties p : plist) {
|
||||||
|
if(p.getName().equals("textures")) {
|
||||||
|
object = new ThreadDownloadImageData((File) null,
|
||||||
|
p.getTextureValue().getTextures().getSKIN().getUrl(),
|
||||||
|
DefaultPlayerSkin.getDefaultSkin(uuid), new ImageBufferDownload());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
object = new ThreadDownloadImageData((File)null,
|
||||||
|
null,
|
||||||
|
DefaultPlayerSkin.getDefaultSkin(uuid), new ImageBufferDownload());
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang.holders;
|
||||||
|
|
||||||
|
public class Profile {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private Properties[] properties;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties[] getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(Properties[] properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang.holders;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.codec.binary.StringUtils;
|
||||||
|
|
||||||
|
public class Properties {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
private String signature;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureValue getTextureValue() {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
return gson.fromJson(StringUtils.newStringUtf8(Base64.decodeBase64(value)), TextureValue.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignature() {
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignature(String signature) {
|
||||||
|
this.signature = signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang.holders;
|
||||||
|
|
||||||
|
public class TextureValue {
|
||||||
|
private long timestamp;
|
||||||
|
private String profileId;
|
||||||
|
private String profileName;
|
||||||
|
private boolean isPublic;
|
||||||
|
private Textures textures;
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(long timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileId() {
|
||||||
|
return profileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfileId(String profileId) {
|
||||||
|
this.profileId = profileId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileName() {
|
||||||
|
return profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfileName(String profileName) {
|
||||||
|
this.profileName = profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPublic() {
|
||||||
|
return isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublic(boolean isPublic) {
|
||||||
|
this.isPublic = isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Textures getTextures() {
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextures(Textures textures) {
|
||||||
|
this.textures = textures;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang.holders;
|
||||||
|
|
||||||
|
public class Textures {
|
||||||
|
private UrlHolder SKIN;
|
||||||
|
private UrlHolder CAPE;
|
||||||
|
|
||||||
|
public UrlHolder getSKIN() {
|
||||||
|
return SKIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSKIN(UrlHolder SKIN) {
|
||||||
|
this.SKIN = SKIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UrlHolder getCAPE() {
|
||||||
|
return CAPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCAPE(UrlHolder CAPE) {
|
||||||
|
this.CAPE = CAPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.mojang.holders;
|
||||||
|
|
||||||
|
public class UrlHolder {
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api.replay;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.ApiError;
|
import eu.crushedpixel.replaymod.api.ApiException;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.Category;
|
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
||||||
|
import eu.crushedpixel.replaymod.api.replay.holders.Category;
|
||||||
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
22
src/main/java/eu/crushedpixel/replaymod/api/replay/ReplayModApiMethods.java
Executable file
22
src/main/java/eu/crushedpixel/replaymod/api/replay/ReplayModApiMethods.java
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.crushedpixel.replaymod.api.replay;
|
||||||
|
|
||||||
|
public class ReplayModApiMethods {
|
||||||
|
|
||||||
|
public static final String REPLAYMOD_BASE_URL = "http://ReplayMod.com/api/";
|
||||||
|
|
||||||
|
public static final String register = REPLAYMOD_BASE_URL+"register";
|
||||||
|
public static final String check_authkey = REPLAYMOD_BASE_URL+"check_authkey";
|
||||||
|
public static final String login = REPLAYMOD_BASE_URL+"login";
|
||||||
|
public static final String logout = REPLAYMOD_BASE_URL+"logout";
|
||||||
|
public static final String file_details = REPLAYMOD_BASE_URL+"file_details";
|
||||||
|
public static final String upload_file = REPLAYMOD_BASE_URL+"upload_file";
|
||||||
|
public static final String download_file = REPLAYMOD_BASE_URL+"download_file";
|
||||||
|
public static final String get_thumbnail = REPLAYMOD_BASE_URL+"get_thumbnail";
|
||||||
|
public static final String remove_file = REPLAYMOD_BASE_URL+"remove_file";
|
||||||
|
public static final String rate_file = REPLAYMOD_BASE_URL+"rate_file";
|
||||||
|
public static final String fav_file = REPLAYMOD_BASE_URL+"fav_file";
|
||||||
|
public static final String get_favorites = REPLAYMOD_BASE_URL+"get_favorites";
|
||||||
|
public static final String check_auth = REPLAYMOD_BASE_URL+"check_auth";
|
||||||
|
public static final String get_language = REPLAYMOD_BASE_URL+"get_language";
|
||||||
|
public static final String search = REPLAYMOD_BASE_URL+"search";
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client;
|
package eu.crushedpixel.replaymod.api.replay;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class AuthConfirmation {
|
public class AuthConfirmation {
|
||||||
private String username;
|
private String username;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class AuthKey {
|
public class AuthKey {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class Donated {
|
public class Donated {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class Favorites {
|
public class Favorites {
|
||||||
private int[] favorited;
|
private int[] favorited;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class Rating {
|
public class Rating {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class SearchResult {
|
public class SearchResult {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class Success {
|
public class Success {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class UserFiles {
|
public class UserFiles {
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.pagination;
|
package eu.crushedpixel.replaymod.api.replay.pagination;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.pagination;
|
package eu.crushedpixel.replaymod.api.replay.pagination;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.pagination;
|
package eu.crushedpixel.replaymod.api.replay.pagination;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.pagination;
|
package eu.crushedpixel.replaymod.api.replay.pagination;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.api.client.SearchQuery;
|
import eu.crushedpixel.replaymod.api.replay.SearchQuery;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
Reference in New Issue
Block a user