diff --git a/build.gradle b/build.gradle index 0ac4867b..d9682793 100755 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,8 @@ configurations { } dependencies { + compile 'org.projectlombok:lombok:1.16.4' + shade fileTree(dir: 'libs', includes: ['*.jar']) // you may put jars on which you depend on in ./libs // or you may define them like so.. diff --git a/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java b/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java index 43784a49..ee8c4fb9 100755 --- a/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java +++ b/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java @@ -26,6 +26,8 @@ import eu.crushedpixel.replaymod.utils.ReplayFileIO; import eu.crushedpixel.replaymod.utils.TooltipRenderer; import eu.crushedpixel.replaymod.video.frame.*; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.settings.GameSettings; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; @@ -39,12 +41,16 @@ import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import org.apache.commons.io.FilenameUtils; import java.io.File; import java.io.IOException; +import java.util.List; +import java.util.Map; import java.util.Queue; +import static org.apache.commons.io.FileUtils.forceDelete; +import static org.apache.commons.io.FileUtils.listFiles; + @Mod(modid = ReplayMod.MODID, useMetadata = true) public class ReplayMod { @@ -148,8 +154,10 @@ public class ReplayMod { tooltipRenderer = new TooltipRenderer(); - mc.getRenderManager().skinMap.put("default", new InvisibilityRender(mc.getRenderManager())); - mc.getRenderManager().skinMap.put("slim", new InvisibilityRender(mc.getRenderManager(), true)); + @SuppressWarnings("unchecked") + Map skinMap = mc.getRenderManager().skinMap; + skinMap.put("default", new InvisibilityRender(mc.getRenderManager())); + skinMap.put("slim", new InvisibilityRender(mc.getRenderManager(), true)); //clean up replay_recordings folder removeTmcprFiles(); @@ -158,7 +166,9 @@ public class ReplayMod { @Override public void run() { try { - mc.defaultResourcePacks.add(new LocalizedResourcePack()); + @SuppressWarnings("unchecked") + List defaultResourcePacks = mc.defaultResourcePacks; + defaultResourcePacks.add(new LocalizedResourcePack()); mc.addScheduledTask(new Runnable() { @Override public void run() { @@ -319,12 +329,14 @@ public class ReplayMod { } private void removeTmcprFiles() { + try { File folder = ReplayFileIO.getReplayFolder(); - for(File f : folder.listFiles()) { - if(("." + FilenameUtils.getExtension(f.getAbsolutePath())).equals(ReplayFile.TEMP_FILE_EXTENSION)) { - f.delete(); - } + for (File file : listFiles(folder, new String[]{ReplayFile.TEMP_FILE_EXTENSION.substring(1)}, false)) { + forceDelete(file); + } + } catch (IOException e) { + e.printStackTrace(); } } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/ApiClient.java b/src/main/java/eu/crushedpixel/replaymod/api/ApiClient.java index cf23072e..6a3f5fab 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/ApiClient.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/ApiClient.java @@ -5,13 +5,10 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; import com.mojang.authlib.exceptions.AuthenticationException; -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.online.authentication.AuthenticationHash; -import eu.crushedpixel.replaymod.utils.StreamTools; import net.minecraft.client.Minecraft; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -20,7 +17,6 @@ import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; -import java.util.UUID; public class ApiClient { @@ -33,8 +29,7 @@ public class ApiClient { builder.put("user", username); builder.put("pw", password); builder.put("mod", true); - AuthKey auth = invokeAndReturn(builder, AuthKey.class); - return auth; + return invokeAndReturn(builder, AuthKey.class); } public AuthKey register(String username, String mail, String password, String uuid) @@ -50,8 +45,7 @@ public class ApiClient { builder.put("mcusername", authenticationHash.username); builder.put("timelong", authenticationHash.currentTime); builder.put("randomlong", authenticationHash.randomLong); - AuthKey auth = invokeAndReturn(builder, AuthKey.class); - return auth; + return invokeAndReturn(builder, AuthKey.class); } private AuthenticationHash sessionserverJoin() throws AuthenticationException { @@ -67,8 +61,7 @@ public class ApiClient { try { QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.check_authkey); builder.put("auth", auth); - AuthConfirmation conf = invokeAndReturn(builder, AuthConfirmation.class); - return conf; + return invokeAndReturn(builder, AuthConfirmation.class); } catch(Exception e) { return null; } @@ -89,33 +82,21 @@ public class ApiClient { return succ.hasDonated(); } - @Deprecated - public UserFiles getUserFiles(String auth, String user) throws IOException, ApiException { - //TODO if required - return null; - } - public FileInfo[] getFileInfo(List ids) throws IOException, ApiException { QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.file_details); builder.put("id", buildListString(ids)); - FileInfo[] info = invokeAndReturn(builder, FileInfo[].class); - return info; + return invokeAndReturn(builder, FileInfo[].class); } public FileInfo[] searchFiles(SearchQuery query) throws IOException, ApiException { QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.search); - StringBuilder sb = new StringBuilder(builder.toString()); - sb.append(query.buildQuery()); - - FileInfo[] info = invokeAndReturn(sb.toString(), SearchResult.class).getResults(); - return info; + return invokeAndReturn(builder.toString() + query.buildQuery(), SearchResult.class).getResults(); } public String getTranslation(String languageCode) throws IOException, ApiException { QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_language); builder.put("language", languageCode); - String properties = SimpleApiClient.invokeUrl(builder.toString()); - return properties; + return SimpleApiClient.invokeUrl(builder.toString()); } public void downloadThumbnail(int file, File target) throws IOException { @@ -142,14 +123,14 @@ public class ApiClient { out.close(); } } else { - JsonElement element = jsonParser.parse(StreamTools.readStreamtoString(is)); + JsonElement element = jsonParser.parse(IOUtils.toString(is)); try { ApiError err = gson.fromJson(element, ApiError.class); if(err.getDesc() != null) { throw new ApiException(err); } } catch(JsonParseException e) { - throw new ApiException(StreamTools.readStreamtoString(is)); + throw new ApiException(IOUtils.toString(is)); } } } @@ -191,15 +172,6 @@ public class ApiClient { 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 invokeAndReturn(QueryBuilder builder, Class classOfT) throws IOException, ApiException { return invokeAndReturn(builder.toString(), classOfT); } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/ApiException.java b/src/main/java/eu/crushedpixel/replaymod/api/ApiException.java index cf08c875..a4c19825 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/ApiException.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/ApiException.java @@ -1,31 +1,28 @@ package eu.crushedpixel.replaymod.api; import eu.crushedpixel.replaymod.api.replay.holders.ApiError; +import lombok.Data; +import lombok.EqualsAndHashCode; +@Data +@EqualsAndHashCode(callSuper = true) 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; - } - } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/GsonApiClient.java b/src/main/java/eu/crushedpixel/replaymod/api/GsonApiClient.java index 49952713..524b3f69 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/GsonApiClient.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/GsonApiClient.java @@ -4,7 +4,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import java.io.IOException; -import java.util.Map; public class GsonApiClient { @@ -20,18 +19,7 @@ public class GsonApiClient { return wrapWithJson(apiResult); } - public static JsonElement invokeJson(String apiKey, String method, Map paramMap) throws IOException, ApiException { - String apiResult = SimpleApiClient.invoke(method, paramMap); - return wrapWithJson(apiResult); - } - - public static JsonElement invokeJson(String apiKey, String method) throws IOException, ApiException { - String apiResult = SimpleApiClient.invoke(method, null); - return wrapWithJson(apiResult); - } - private static JsonElement wrapWithJson(String apiResult) { - JsonElement element = parser.parse(apiResult); - return element; + return parser.parse(apiResult); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/QueryBuilder.java b/src/main/java/eu/crushedpixel/replaymod/api/QueryBuilder.java index 5df1e031..6c3bd5ec 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/QueryBuilder.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/QueryBuilder.java @@ -10,32 +10,10 @@ public class QueryBuilder { public String apiMethod; public Map paramMap; - public QueryBuilder() { - this(null); - } - public QueryBuilder(String apiMethod) { this.apiMethod = apiMethod; } - public QueryBuilder(String apiMethod, String key, String value) { - this(apiMethod); - put(key, value); - } - - public QueryBuilder(String apiMethod, String key1, String value1, String key2, String value2) { - this(apiMethod); - put(key1, value1); - put(key2, value2); - } - - public QueryBuilder(String apiMethod, String key1, String value1, String key2, String value2, String key3, String value3) { - this(apiMethod); - put(key1, value1); - put(key2, value2); - put(key3, value3); - } - public void put(String key, Object value) { if(key != null && value != null) { if(paramMap == null) { @@ -45,17 +23,6 @@ public class QueryBuilder { } } - public void put(String key1, Object value1, String key2, Object value2) { - put(key1, value1); - put(key2, value2); - } - - public void put(String key1, Object value1, String key2, Object value2, String key3, Object value3) { - put(key1, value1); - put(key2, value2); - put(key3, value3); - } - public void put(Map paraMap) { if(paraMap == null) return; for(String key : paraMap.keySet()) { diff --git a/src/main/java/eu/crushedpixel/replaymod/api/SimpleApiClient.java b/src/main/java/eu/crushedpixel/replaymod/api/SimpleApiClient.java index 7dee1e8f..a3f23c43 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/SimpleApiClient.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/SimpleApiClient.java @@ -5,7 +5,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; import eu.crushedpixel.replaymod.api.replay.holders.ApiError; -import eu.crushedpixel.replaymod.utils.StreamTools; +import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; @@ -88,7 +88,7 @@ public class SimpleApiClient { if(responseCode != 200) { is = httpUrlConnection.getErrorStream(); if(is != null) { - responseContent = StreamTools.readStreamtoString(is, "UTF-8"); + responseContent = IOUtils.toString(is, "UTF-8"); } else { responseContent = ""; } @@ -102,10 +102,8 @@ public class SimpleApiClient { is = httpUrlConnection.getInputStream(); - responseContent = StreamTools.readStreamtoString(is, "UTF-8"); + responseContent = IOUtils.toString(is, "UTF-8"); - } catch(IOException e) { - throw e; } finally { if(is != null) { is.close(); diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/MojangApiMethods.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/MojangApiMethods.java deleted file mode 100755 index 73ffa9bd..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/MojangApiMethods.java +++ /dev/null @@ -1,8 +0,0 @@ -package eu.crushedpixel.replaymod.api.mojang; - -public class MojangApiMethods { - - public static final String userprofile = "https://sessionserver.mojang.com/session/minecraft/profile/"; - public static final String joinServer = "https://sessionserver.mojang.com/session/minecraft/join"; - -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/SkinDownloader.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/SkinDownloader.java deleted file mode 100644 index 0e10f1ce..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/SkinDownloader.java +++ /dev/null @@ -1,57 +0,0 @@ -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 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; - } - - -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Profile.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Profile.java deleted file mode 100644 index 199ccdf9..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Profile.java +++ /dev/null @@ -1,32 +0,0 @@ -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; - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Properties.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Properties.java deleted file mode 100644 index f559b59a..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Properties.java +++ /dev/null @@ -1,42 +0,0 @@ -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; - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/TextureValue.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/TextureValue.java deleted file mode 100644 index e7baa704..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/TextureValue.java +++ /dev/null @@ -1,49 +0,0 @@ -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; - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Textures.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Textures.java deleted file mode 100644 index 15b25288..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/Textures.java +++ /dev/null @@ -1,22 +0,0 @@ -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; - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/UrlHolder.java b/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/UrlHolder.java deleted file mode 100644 index 5ed43dfc..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/api/mojang/holders/UrlHolder.java +++ /dev/null @@ -1,13 +0,0 @@ -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; - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/FileUploader.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/FileUploader.java index 66af1cf3..784de2d1 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/FileUploader.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/FileUploader.java @@ -11,7 +11,6 @@ import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; -import java.util.HashMap; import java.util.List; public class FileUploader { @@ -21,14 +20,8 @@ public class FileUploader { private long filesize; private long current; - private String attachmentName = "file"; - private String attachmentFileName = "file.mcpr"; - private String crlf = "\r\n"; - private String twoHyphens = "--"; - private boolean cancel = false; - private String boundary = "*****"; private GuiUploadFile parent; public void uploadFile(GuiUploadFile gui, String auth, String filename, List tags, File file, Category category, String description) @@ -62,7 +55,7 @@ public class FileUploader { postData += "&name=" + URLEncoder.encode(filename, "UTF-8"); - String url = "http://ReplayMod.com/api/upload_file" + postData; + String url = ReplayModApiMethods.upload_file + postData; HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(); con.setUseCaches(false); con.setDoOutput(true); @@ -70,18 +63,18 @@ public class FileUploader { con.setChunkedStreamingMode(1024); con.setRequestProperty("Connection", "Keep-Alive"); con.setRequestProperty("Cache-Control", "no-cache"); - con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + this.boundary); - - HashMap params = new HashMap(); - params.put("auth", auth); - params.put("name", filename); - params.put("category", category.getId() + ""); + String boundary = "*****"; + con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); DataOutputStream request = new DataOutputStream(con.getOutputStream()); - request.writeBytes(this.twoHyphens + this.boundary + this.crlf); - request.writeBytes("Content-Disposition: form-data; name=\"" + this.attachmentName + "\";filename=\"" + this.attachmentFileName + "\"" + this.crlf); - request.writeBytes(this.crlf); + String crlf = "\r\n"; + String twoHyphens = "--"; + request.writeBytes(twoHyphens + boundary + crlf); + String attachmentName = "file"; + String attachmentFileName = "file.mcpr"; + request.writeBytes("Content-Disposition: form-data; name=\"" + attachmentName + "\";filename=\"" + attachmentFileName + "\"" + crlf); + request.writeBytes(crlf); byte[] buf = new byte[1024]; FileInputStream fis = new FileInputStream(file); @@ -102,8 +95,8 @@ public class FileUploader { } fis.close(); - request.writeBytes(this.crlf); - request.writeBytes(this.twoHyphens + this.boundary + this.twoHyphens + this.crlf); + request.writeBytes(crlf); + request.writeBytes(twoHyphens + boundary + twoHyphens + crlf); request.flush(); request.close(); diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/SearchQuery.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/SearchQuery.java index f81f9e5d..9a4a8bfe 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/SearchQuery.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/SearchQuery.java @@ -1,32 +1,17 @@ package eu.crushedpixel.replaymod.api.replay; +import lombok.AllArgsConstructor; + import java.lang.reflect.Field; import java.net.URLEncoder; +@AllArgsConstructor public class SearchQuery { public Boolean order, singleplayer; public String player, tag, version, server, name, auth; public Integer category, offset; - public SearchQuery() { - } - - public SearchQuery(Boolean order, Boolean singleplayer, String player, - String tag, String version, String server, String name, - String auth, Integer category, Integer offset) { - this.order = order; - this.singleplayer = singleplayer; - this.player = player; - this.tag = tag; - this.version = version; - this.server = server; - this.name = name; - this.auth = auth; - this.category = category; - this.offset = offset; - } - public String buildQuery() { String query = ""; boolean first = true; diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/ApiError.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/ApiError.java index 125a3232..357cfcd1 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/ApiError.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/ApiError.java @@ -1,7 +1,9 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; import net.minecraft.client.resources.I18n; +@Data public class ApiError { private int id; @@ -9,27 +11,6 @@ public class ApiError { private String key; private String[] objects; - public ApiError(int id, String desc) { - this.id = id; - this.desc = desc; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - public String getTranslatedDesc() { try { return I18n.format(key, (Object[]) objects); diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthConfirmation.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthConfirmation.java index 97afd8ff..038436cd 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthConfirmation.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthConfirmation.java @@ -1,10 +1,9 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class AuthConfirmation { private String username; private int id; - - public String getUsername() { - return username; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthKey.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthKey.java index 67d928ee..e88ec46d 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthKey.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/AuthKey.java @@ -1,14 +1,12 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor public class AuthKey { - private String auth; - - public AuthKey(String authkey) { - this.auth = authkey; - } - - public String getAuthkey() { - return auth; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Donated.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Donated.java index 22c0f272..ab11d3d2 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Donated.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Donated.java @@ -1,7 +1,13 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Getter; + +@Data public class Donated { + @Getter(AccessLevel.NONE) private boolean donated = false; public boolean hasDonated() { diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Favorites.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Favorites.java index 05f5b4d4..d509c940 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Favorites.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Favorites.java @@ -1,7 +1,8 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class Favorites { private int[] favorited; - - public int[] getFavorited() { return favorited; } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileInfo.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileInfo.java index a712f9dd..87b65807 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileInfo.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileInfo.java @@ -1,9 +1,14 @@ package eu.crushedpixel.replaymod.api.replay.holders; import eu.crushedpixel.replaymod.recording.ReplayMetaData; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; +@Data +@AllArgsConstructor public class FileInfo { - private int id; private ReplayMetaData metadata; private String owner; @@ -11,67 +16,12 @@ public class FileInfo { private int size; private int category; private int downloads; - private int favorites; private String name; + @Getter(AccessLevel.NONE) private boolean thumbnail; - - - public FileInfo(int id, ReplayMetaData metadata, String owner, - Rating ratings, int size, int category, int downloads, String name, - boolean thumbnail, int favorites) { - this.id = id; - this.metadata = metadata; - this.owner = owner; - this.ratings = ratings; - this.size = size; - this.category = category; - this.downloads = downloads; - this.name = name; - this.thumbnail = thumbnail; - this.favorites = favorites; - } - - public int getId() { - return id; - } - - public ReplayMetaData getMetadata() { - return metadata; - } - - public String getOwner() { - return owner; - } - - public Rating getRatings() { - return ratings; - } - - public int getSize() { - return size; - } - - public int getCategory() { - return category; - } - - public int getDownloads() { - return downloads; - } - - public int getFavorites() { return favorites; } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } + private int favorites; public boolean hasThumbnail() { return thumbnail; } - - } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileRating.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileRating.java index 76638622..cf5a3a52 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileRating.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/FileRating.java @@ -1,5 +1,8 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class FileRating { private int file; @@ -9,6 +12,7 @@ public class FileRating { return file; } + // TODO Will be changed later public boolean getRating() { return rating; } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/RatedFiles.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/RatedFiles.java index 2659cd74..71640972 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/RatedFiles.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/RatedFiles.java @@ -1,10 +1,8 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class RatedFiles { - private FileRating[] rated; - - public FileRating[] getRated() { - return rated; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Rating.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Rating.java index 6a83e974..2c24f8d1 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Rating.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Rating.java @@ -1,17 +1,11 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class Rating { - private int negative, positive; - public int getNegative() { - return negative; - } - - public int getPositive() { - return positive; - } - public enum RatingType { LIKE("like"), DISLIKE("dislike"), NEUTRAL("neutral"); diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/SearchResult.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/SearchResult.java index ec7e18d8..706bd6bb 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/SearchResult.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/SearchResult.java @@ -1,10 +1,8 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class SearchResult { - private FileInfo[] results; - - public FileInfo[] getResults() { - return results; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Success.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Success.java index 6085d2da..6fd781c5 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Success.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/Success.java @@ -1,10 +1,8 @@ package eu.crushedpixel.replaymod.api.replay.holders; +import lombok.Data; + +@Data public class Success { - private boolean success = false; - - public boolean isSuccess() { - return success; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/UserFiles.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/UserFiles.java index 669c9bdb..eee7c0ae 100755 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/UserFiles.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/holders/UserFiles.java @@ -1,22 +1,10 @@ package eu.crushedpixel.replaymod.api.replay.holders; -public class UserFiles { +import lombok.Data; +@Data +public class UserFiles { private String user; private FileInfo[] files; private int total_size; - - public String getUser() { - return user; - } - - public FileInfo[] getFiles() { - return files; - } - - public int getTotal_size() { - return total_size; - } - - } diff --git a/src/main/java/eu/crushedpixel/replaymod/api/replay/pagination/Pagination.java b/src/main/java/eu/crushedpixel/replaymod/api/replay/pagination/Pagination.java index 66adcfff..b4477857 100644 --- a/src/main/java/eu/crushedpixel/replaymod/api/replay/pagination/Pagination.java +++ b/src/main/java/eu/crushedpixel/replaymod/api/replay/pagination/Pagination.java @@ -5,11 +5,11 @@ import eu.crushedpixel.replaymod.api.replay.holders.FileInfo; import java.util.List; public interface Pagination { - public List getFiles(); + List getFiles(); - public int getLoadedPages(); + int getLoadedPages(); - public boolean fetchPage(); + boolean fetchPage(); - public static final int PAGE_SIZE = 30; //defined by the Website API + int PAGE_SIZE = 30; //defined by the Website API } diff --git a/src/main/java/eu/crushedpixel/replaymod/chat/ChatMessageHandler.java b/src/main/java/eu/crushedpixel/replaymod/chat/ChatMessageHandler.java index 56cf8d23..78508337 100755 --- a/src/main/java/eu/crushedpixel/replaymod/chat/ChatMessageHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/chat/ChatMessageHandler.java @@ -29,20 +29,16 @@ public class ChatMessageHandler { private boolean active = true; - private boolean alive = true; private Queue requests = new ConcurrentLinkedQueue(); private EntityPlayerSP player = null; public Thread t = new Thread(new Runnable() { @Override public void run() { - while(alive) { + while(!Thread.currentThread().isInterrupted()) { while(active) { try { while(player == null) { - if(!alive) { - break; - } Thread.sleep(100); player = Minecraft.getMinecraft().thePlayer; } @@ -67,6 +63,7 @@ public class ChatMessageHandler { }, "replaymod-chat-message-handler"); public ChatMessageHandler() { + t.setDaemon(true); t.start(); } diff --git a/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java b/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java index da72b042..db8c65f8 100755 --- a/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java +++ b/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java @@ -20,17 +20,17 @@ public class EnchantmentTimerCT implements IClassTransformer { public byte[] transform(String name, String transformedName, byte[] basicClass) { if(name.equals("cqh")) { - return patchRenderEffectMethod(name, basicClass, true); + return patchRenderEffectMethod(basicClass, true); } if(name.equals("net.minecraft.client.renderer.entity.RenderItem")) { - return patchRenderEffectMethod(name, basicClass, false); + return patchRenderEffectMethod(basicClass, false); } return basicClass; } - public byte[] patchRenderEffectMethod(String name, byte[] bytes, boolean obfuscated) { + public byte[] patchRenderEffectMethod(byte[] bytes, boolean obfuscated) { System.out.println("REPLAY MOD CORE PATCHER: Inside RenderItem class"); String methodName = obfuscated ? "a" : "renderEffect"; @@ -46,18 +46,16 @@ public class EnchantmentTimerCT implements IClassTransformer { List> toInsert = new ArrayList>(); - Iterator iterator = classNode.methods.iterator(); - while(iterator.hasNext()) { - MethodNode m = iterator.next(); - if(m.name.equals(methodName) && m.desc.equals(classDescriptor)) { + for (MethodNode m : classNode.methods) { + if (m.name.equals(methodName) && m.desc.equals(classDescriptor)) { System.out.println("REPLAY MOD CORE PATCHER: Inside renderEffect method"); Iterator nodeIterator = m.instructions.iterator(); - while(nodeIterator.hasNext()) { + while (nodeIterator.hasNext()) { AbstractInsnNode node = nodeIterator.next(); - if(node instanceof MethodInsnNode) { + if (node instanceof MethodInsnNode) { MethodInsnNode min = (MethodInsnNode) node; - if(min.getOpcode() == Opcodes.INVOKESTATIC && min.name.equals(getSystemTime) && + if (min.getOpcode() == Opcodes.INVOKESTATIC && min.name.equals(getSystemTime) && min.owner.equals(minecraftClass) && min.desc.equals(sysTimeDesc)) { MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, "eu/crushedpixel/replaymod/timer/EnchantmentTimer", "getEnchantmentTime", @@ -67,7 +65,7 @@ public class EnchantmentTimerCT implements IClassTransformer { } } - for(Pair pair : toInsert) { + for (Pair pair : toInsert) { m.instructions.insertBefore(pair.first(), pair.second()); m.instructions.remove(pair.first()); } diff --git a/src/main/java/eu/crushedpixel/replaymod/events/handlers/GuiEventHandler.java b/src/main/java/eu/crushedpixel/replaymod/events/handlers/GuiEventHandler.java index 1294ec4c..ebc29eae 100755 --- a/src/main/java/eu/crushedpixel/replaymod/events/handlers/GuiEventHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/handlers/GuiEventHandler.java @@ -97,15 +97,17 @@ public class GuiEventHandler { @SubscribeEvent public void onInit(InitGuiEvent event) { + @SuppressWarnings("unchecked") + List buttonList = event.buttonList; if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) { ReplayMod.replaySender.setReplaySpeed(0); - for(GuiButton b : new ArrayList(event.buttonList)) { + for(GuiButton b : new ArrayList(buttonList)) { if(b.id == 1) { b.displayString = I18n.format("replaymod.gui.exit"); b.yPosition -= 24 * 2; b.id = GuiConstants.EXIT_REPLAY_BUTTON; } else if(b.id >= 5 && b.id <= 7) { - event.buttonList.remove(b); + buttonList.remove(b); } else if(b.id != 4) { b.yPosition -= 24 * 2; } @@ -113,7 +115,7 @@ public class GuiEventHandler { } else if(event.gui instanceof GuiMainMenu) { int i1 = event.gui.height / 4 + 24 + 10; - for(GuiButton b : (List) event.buttonList) { + for(GuiButton b : buttonList) { if(b.id != 0 && b.id != 4 && b.id != 5) { b.yPosition = b.yPosition - 2 * 24 + 10; } @@ -122,23 +124,23 @@ public class GuiEventHandler { GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2 * 24, I18n.format("replaymod.gui.replayviewer")); rm.width = rm.width / 2 - 2; //rm.enabled = AuthenticationHandler.isAuthenticated(); - event.buttonList.add(rm); + buttonList.add(rm); replayCount = ReplayFileIO.getAllReplayFiles().size(); GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2 * 24, I18n.format("replaymod.gui.replayeditor")); re.width = re.width / 2 - 2; re.enabled = VersionValidator.isValid && replayCount > 0; - event.buttonList.add(re); + buttonList.add(re); editorButton = re; GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3 * 24, I18n.format("replaymod.gui.replaycenter")); rc.enabled = true; - event.buttonList.add(rc); + buttonList.add(rc); } else if(event.gui instanceof GuiOptions) { - event.buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID, + buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID, event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, I18n.format("replaymod.gui.settings.title"))); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/events/handlers/MinecraftTicker.java b/src/main/java/eu/crushedpixel/replaymod/events/handlers/MinecraftTicker.java index 972ea7a1..ceb575a7 100755 --- a/src/main/java/eu/crushedpixel/replaymod/events/handlers/MinecraftTicker.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/handlers/MinecraftTicker.java @@ -6,7 +6,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; import net.minecraft.crash.CrashReport; -import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import net.minecraft.util.ReportedException; import net.minecraftforge.client.event.MouseEvent; @@ -116,26 +115,6 @@ public class MinecraftTicker { mc.refreshResources(); } - if(i == 17 && Keyboard.isKeyDown(61)) { - ; - } - - if(i == 18 && Keyboard.isKeyDown(61)) { - ; - } - - if(i == 47 && Keyboard.isKeyDown(61)) { - ; - } - - if(i == 38 && Keyboard.isKeyDown(61)) { - ; - } - - if(i == 22 && Keyboard.isKeyDown(61)) { - ; - } - if(i == 20 && Keyboard.isKeyDown(61)) { mc.refreshResources(); } @@ -179,10 +158,12 @@ public class MinecraftTicker { mc.gameSettings.thirdPersonView = 0; } - if(mc.gameSettings.thirdPersonView == 0) { - mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity()); - } else if(mc.gameSettings.thirdPersonView == 1) { - mc.entityRenderer.loadEntityShader((Entity) null); + if (mc.entityRenderer != null) { + if (mc.gameSettings.thirdPersonView == 0) { + mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity()); + } else if (mc.gameSettings.thirdPersonView == 1) { + mc.entityRenderer.loadEntityShader(null); + } } } @@ -222,30 +203,23 @@ public class MinecraftTicker { mc.playerController.onStoppedUsingItem(mc.thePlayer); } - label435: - while(true) { if(!mc.gameSettings.keyBindAttack.isPressed()) { - while(mc.gameSettings.keyBindUseItem.isPressed()) { - ; - } - while(true) { - if(mc.gameSettings.keyBindPickBlock.isPressed()) { - continue; + if (!mc.gameSettings.keyBindUseItem.isPressed() + && !mc.gameSettings.keyBindPickBlock.isPressed()) { + break; } - - break label435; } + break; } } } - if(mc != null && mc.thePlayer != null) + if(mc.thePlayer != null) mc.sendClickBlockToController(mc.currentScreen == null && mc.gameSettings.keyBindAttack.isKeyDown() && mc.inGameHasFocus); - if(mc != null) - mc.systemTime = Minecraft.getSystemTime(); + mc.systemTime = Minecraft.getSystemTime(); } catch (ReportedException e) { throw e; } catch (Exception e) { diff --git a/src/main/java/eu/crushedpixel/replaymod/events/handlers/RecordingHandler.java b/src/main/java/eu/crushedpixel/replaymod/events/handlers/RecordingHandler.java index 440a5ae4..3a4ca257 100755 --- a/src/main/java/eu/crushedpixel/replaymod/events/handlers/RecordingHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/handlers/RecordingHandler.java @@ -24,16 +24,12 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; -import java.util.ArrayList; -import java.util.List; - public class RecordingHandler { public static final int entityID = Integer.MIN_VALUE + 9001; private final Minecraft mc = Minecraft.getMinecraft(); private Double lastX = null, lastY = null, lastZ = null; - private List lastEffects = new ArrayList(); private ItemStack[] playerItems = new ItemStack[5]; private int ticksSinceLastCorrection = 0; private boolean wasSleeping = false; @@ -81,7 +77,7 @@ public class RecordingHandler { PacketBuffer pb = new PacketBuffer(bb); pb.writeVarIntToBuffer(entityID); - pb.writeUuid(player.getUUID(player.getGameProfile())); + pb.writeUuid(EntityPlayer.getUUID(player.getGameProfile())); pb.writeInt(MathHelper.floor_double(player.posX * 32.0D)); pb.writeInt(MathHelper.floor_double(player.posY * 32.0D)); @@ -106,7 +102,6 @@ public class RecordingHandler { public void resetVars() { lastX = lastY = lastZ = null; rotationYawHeadBefore = null; - lastEffects = new ArrayList(); playerItems = new ItemStack[5]; } @@ -139,7 +134,7 @@ public class RecordingHandler { lastY = e.player.posY; lastZ = e.player.posZ; - Packet packet = null; + Packet packet; if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) { int x = MathHelper.floor_double(e.player.posX * 32.0D); int y = MathHelper.floor_double(e.player.posY * 32.0D); @@ -148,14 +143,9 @@ public class RecordingHandler { byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F)); packet = new S18PacketEntityTeleport(entityID, x, y, z, yaw, pitch, e.player.onGround); } else { - byte oldYaw = (byte) ((int) (e.player.prevRotationYaw * 256.0F / 360.0F)); byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F)); - byte oldPitch = (byte) ((int) (e.player.prevRotationPitch * 256.0F / 360.0F)); byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F)); - byte dPitch = (byte) (newPitch - oldPitch); - byte dYaw = (byte) (newYaw - oldYaw); - packet = new S17PacketEntityLookMove(entityID, (byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32), newYaw, newPitch, e.player.onGround); diff --git a/src/main/java/eu/crushedpixel/replaymod/events/handlers/TickAndRenderListener.java b/src/main/java/eu/crushedpixel/replaymod/events/handlers/TickAndRenderListener.java index ba939e30..8b6d894b 100644 --- a/src/main/java/eu/crushedpixel/replaymod/events/handlers/TickAndRenderListener.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/handlers/TickAndRenderListener.java @@ -21,8 +21,6 @@ public class TickAndRenderListener { private static int requestScreenshot = 0; - //private boolean f1Down = false; - public static void requestScreenshot() { if(requestScreenshot == 0) requestScreenshot = 1; } @@ -82,17 +80,16 @@ public class TickAndRenderListener { @SubscribeEvent public void onMouseMove(MouseEvent event) { if(!ReplayHandler.isInReplay()) return; - boolean flag = true; mc.mcProfiler.startSection("mouse"); - if(flag && Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) { + if(Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) { Mouse.setGrabbed(false); Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2); Mouse.setGrabbed(true); } - if(mc.inGameHasFocus && flag && !(ReplayHandler.isInPath())) { + if(mc.inGameHasFocus && !(ReplayHandler.isInPath())) { mc.mouseHelper.mouseXYChange(); float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F; float f2 = f1 * f1 * f1 * 8.0F; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java index 8606bc4b..de654d90 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java @@ -15,16 +15,10 @@ public class GuiConstants { public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011; public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012; - public static final int UPLOAD_NAME_INPUT = 3001; - public static final int UPLOAD_CATEGORY_BUTTON = 3002; public static final int UPLOAD_START_BUTTON = 3003; public static final int UPLOAD_CANCEL_BUTTON = 3004; public static final int UPLOAD_BACK_BUTTON = 3005; public static final int UPLOAD_INFO_FIELD = 3006; - public static final int UPLOAD_TAG_INPUT = 3007; - public static final int UPLOAD_TAG_PLACEHOLDER = 3008; - public static final int UPLOAD_HIDE_SERVER_IP = 3009; - public static final int UPLOAD_NAME_PLACEHOLDER = 3010; public static final int EXIT_REPLAY_BUTTON = 4001; @@ -33,8 +27,6 @@ public class GuiConstants { public static final int REPLAY_MANAGER_BUTTON_ID = 9001; public static final int REPLAY_EDITOR_BUTTON_ID = 9002; public static final int REPLAY_CENTER_BUTTON_ID = 9003; - public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 9004; - public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 9005; public static final int LOGIN_OKAY_BUTTON = 1100; public static final int LOGIN_CANCEL_BUTTON = 1101; @@ -79,16 +71,11 @@ public class GuiConstants { public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007; public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008; public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009; - public static final int KEYFRAME_EDITOR_MIN_INPUT = 6010; - public static final int KEYFRAME_EDITOR_SEC_INPUT = 6011; - public static final int KEYFRAME_EDITOR_MS_INPUT = 6012; public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013; public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014; - public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015; - public static final int KEYFRAME_EDITOR_MARKER_NAME_INPUT = 6016; public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010; - public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101; + public static final int PLAYER_OVERVIEW_SHOW_ALL = 101; public static final int PLAYER_OVERVIEW_REMEMBER = -10; public static final int RENDER_SETTINGS_RENDERER_DROPDOWN = 9001; @@ -106,4 +93,13 @@ public class GuiConstants { public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013; public static final int RENDER_SETTINGS_COLOR_PICKER = 9014; public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015; + + public static final int REPLAY_SETTINGS_RECORDSERVER_ID = 9004; + public static final int REPLAY_SETTINGS_RECORDSP_ID = 9005; + public static final int REPLAY_SETTINGS_SEND_CHAT = 9006; + public static final int REPLAY_SETTINGS_FORCE_LINEAR = 9007; + public static final int REPLAY_SETTINGS_ENABLE_LIGHTING = 9008; + public static final int REPLAY_SETTINGS_RESOURCEPACK_ID = 9010; + public static final int REPLAY_SETTINGS_INDICATOR_ID = 9012; + public static final int REPLAY_SETTINGS_PATHPREVIEW_ID = 9013; } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java index 1e82eedb..6390cac5 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java @@ -42,12 +42,12 @@ public class GuiEditKeyframe extends GuiScreen { private Keyframe keyframeBackup; private boolean save; private boolean posKeyframe; - private boolean timeKeyframe; private boolean markerKeyframe; private Keyframe previous, next; - private int w, w2, w3; + private int w2; + private int w3; private int totalWidth; private int left; @@ -55,9 +55,9 @@ public class GuiEditKeyframe extends GuiScreen { public GuiEditKeyframe(Keyframe keyframe) { this.keyframe = keyframe; - this.keyframeBackup = keyframe.clone(); + this.keyframeBackup = keyframe.copy(); this.posKeyframe = keyframe instanceof PositionKeyframe; - this.timeKeyframe = keyframe instanceof TimeKeyframe; + boolean timeKeyframe = keyframe instanceof TimeKeyframe; this.markerKeyframe = keyframe instanceof MarkerKeyframe; ReplayHandler.selectKeyframe(null); @@ -152,14 +152,14 @@ public class GuiEditKeyframe extends GuiScreen { min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65; if(posKeyframe) { - w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")), + int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")), Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")), fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos")))); w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")), Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")), fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll")))); - totalWidth = w+100+w2+100+5+5+10; + totalWidth = w +100+w2+100+5+5+10; left = (this.width - totalWidth)/2; int x = w + left + 5; @@ -178,6 +178,9 @@ public class GuiEditKeyframe extends GuiScreen { saveButton.xPosition = this.width - 100 - 5 - 10; cancelButton.xPosition = saveButton.xPosition - 100 - 5; + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + buttonList.add(saveButton); buttonList.add(cancelButton); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiHelpOverlay.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiHelpOverlay.java deleted file mode 100644 index 9c03a5f9..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiHelpOverlay.java +++ /dev/null @@ -1,4 +0,0 @@ -package eu.crushedpixel.replaymod.gui; - -public class GuiHelpOverlay { -} diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiKeyframeRepository.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiKeyframeRepository.java index 66a5a90e..759d9301 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiKeyframeRepository.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiKeyframeRepository.java @@ -121,6 +121,9 @@ public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay saveButton.yPosition = keyframeSetList.yPosition+keyframeSetList.height-20; } + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + buttonList.add(removeButton); buttonList.add(loadButton); buttonList.add(saveButton); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiPlayerOverview.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiPlayerOverview.java index 5b7812a1..cca64532 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiPlayerOverview.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiPlayerOverview.java @@ -26,9 +26,7 @@ import org.lwjgl.input.Mouse; import java.awt.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; +import java.util.*; import java.util.List; public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoOverlay { @@ -150,6 +148,9 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO upperPlayer = 0; lowerBound = this.height - 10; + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + int i = 0; for(GuiCheckBox checkBox : checkBoxes) { checkBox.xPosition = (int)(this.width*0.7)-5; @@ -235,6 +236,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO GlStateManager.resetColor(); if(fitting >= checkBoxes.size()) { checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true)); + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; buttonList.add(checkBoxes.get(checkBoxes.size() - 1)); } checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID())); @@ -294,7 +297,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO } private PlayerVisibility getVisibilityInstance() { - return new PlayerVisibility(PlayerHandler.getHiddenPlayers()); + Set hidden = PlayerHandler.getHiddenPlayers(); + return new PlayerVisibility(hidden.toArray(new UUID[hidden.size()])); } @@ -302,7 +306,7 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO if(rememberHidden.isChecked()) { try { File f = File.createTempFile(ReplayFile.ENTRY_VISIBILITY, "json"); - ReplayFileIO.writePlayerVisibilityToFile(getVisibilityInstance(), f); + ReplayFileIO.write(getVisibilityInstance(), f); ReplayMod.replayFileAppender.registerModifiedFile(f, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile()); } catch(Exception e) { e.printStackTrace(); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiRenderSettings.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiRenderSettings.java index 0f7aa985..3ab0d809 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiRenderSettings.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiRenderSettings.java @@ -22,12 +22,12 @@ import java.util.ArrayList; import java.util.List; public class GuiRenderSettings extends GuiScreen { + private static final int LEFT_BORDER = 10; private GuiButton renderButton, cancelButton, advancedButton; private GuiDropdown rendererDropdown; private int virtualY, virtualHeight; - private int leftBorder = 10; private GuiCheckBox customResolution, ignoreCamDir, youtubeExport, enableGreenscreen; private GuiNumberInput xRes, yRes; @@ -42,7 +42,7 @@ public class GuiRenderSettings extends GuiScreen { private boolean advancedTab = false; - private int w1, w2, w3; + private int w1; private boolean initialized; @@ -170,18 +170,18 @@ public class GuiRenderSettings extends GuiScreen { rendererDropdown.yPosition = virtualY + 15 + 15; rendererDropdown.xPosition = (width-w1)/2 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10; - w2 = customResolution.width+5+xRes.width+5+fontRendererObj.getStringWidth("*")+5+yRes.width; + int w2 = customResolution.width + 5 + xRes.width + 5 + fontRendererObj.getStringWidth("*") + 5 + yRes.width; customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5; - customResolution.xPosition = (width-w2)/2; + customResolution.xPosition = (width- w2)/2; xRes.xPosition = customResolution.xPosition + customResolution.width + 5; yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5; xRes.yPosition = yRes.yPosition = customResolution.yPosition-3; - w3 = interpolation.width + 10 + forceChunks.width; + int w3 = interpolation.width + 10 + forceChunks.width; - interpolation.xPosition = (width-w3)/2; + interpolation.xPosition = (width- w3)/2; interpolation.yPosition = xRes.yPosition+20+10; forceChunks.xPosition = interpolation.xPosition+interpolation.width+10; @@ -224,7 +224,7 @@ public class GuiRenderSettings extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawGradientRect(leftBorder, virtualY, width - leftBorder, virtualY + virtualHeight, -1072689136, -804253680); + drawGradientRect(LEFT_BORDER, virtualY, width - LEFT_BORDER, virtualY + virtualHeight, -1072689136, -804253680); this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"), this.width / 2, virtualY + 5, Color.WHITE.getRGB()); @@ -252,7 +252,7 @@ public class GuiRenderSettings extends GuiScreen { @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - if(!rendererDropdown.mouseClickedResult(mouseX, mouseY, mouseButton)) { + if(!rendererDropdown.mouseClickedResult(mouseX, mouseY)) { xRes.mouseClicked(mouseX, mouseY, mouseButton); yRes.mouseClicked(mouseX, mouseY, mouseButton); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySettings.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySettings.java index 3a129ff7..8aaa7a4c 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySettings.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySettings.java @@ -12,21 +12,11 @@ import net.minecraftforge.fml.client.FMLClientHandler; import java.awt.*; import java.io.IOException; -public class GuiReplaySettings extends GuiScreen { +import static eu.crushedpixel.replaymod.gui.GuiConstants.*; - //TODO: Move to GuiConstants - private static final int RECORDSERVER_ID = 9004; - private static final int RECORDSP_ID = 9005; - private static final int SEND_CHAT = 9006; - private static final int FORCE_LINEAR = 9007; - private static final int ENABLE_LIGHTING = 9008; - private static final int RESOURCEPACK_ID = 9010; - private static final int INDICATOR_ID = 9012; - private static final int PATHPREVIEW_ID = 9013; +public class GuiReplaySettings extends GuiScreen { protected String screenTitle = I18n.format("replaymod.gui.settings.title"); private GuiScreen parentGuiScreen; - private GuiToggleButton recordServerButton, recordSPButton, sendChatButton, linearButton, lightingButton, - resourcePackButton, showIndicatorButton, pathPreviewButton; public GuiReplaySettings(GuiScreen parentGuiScreen) { this.parentGuiScreen = parentGuiScreen; @@ -34,8 +24,12 @@ public class GuiReplaySettings extends GuiScreen { public void initGui() { this.screenTitle = I18n.format("replaymod.gui.settings.title"); - this.buttonList.clear(); - this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done"))); + + @SuppressWarnings("unchecked") + java.util.List buttonList = this.buttonList; + + buttonList.clear(); + buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done"))); int i = 0; @@ -45,20 +39,20 @@ public class GuiReplaySettings extends GuiScreen { int yPos = this.height / 6 + 24 * (i >> 1); if(o == RecordingOptions.notifications) { - sendChatButton = new GuiSettingsOnOffButton(SEND_CHAT, xPos, yPos, 150, 20, o); - this.buttonList.add(sendChatButton); + GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o); + buttonList.add(sendChatButton); } else if(o == RecordingOptions.recordServer) { - recordServerButton = new GuiSettingsOnOffButton(RECORDSERVER_ID, xPos, yPos, 150, 20, o); - this.buttonList.add(recordServerButton); + GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o); + buttonList.add(recordServerButton); } else if(o == RecordingOptions.recordSingleplayer) { - recordSPButton = new GuiSettingsOnOffButton(RECORDSP_ID, xPos, yPos, 150, 20, o); - this.buttonList.add(recordSPButton); + GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o); + buttonList.add(recordSPButton); } else if(o == RecordingOptions.indicator) { - showIndicatorButton = new GuiSettingsOnOffButton(INDICATOR_ID, xPos, yPos, 150, 20, o); - this.buttonList.add(showIndicatorButton); + GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o); + buttonList.add(showIndicatorButton); } ++i; @@ -75,21 +69,21 @@ public class GuiReplaySettings extends GuiScreen { int yPos = this.height / 6 + 24 * (i >> 1); if(o == ReplayOptions.lighting) { - lightingButton = new GuiSettingsOnOffButton(ENABLE_LIGHTING, xPos, yPos, 150, 20, o); - this.buttonList.add(lightingButton); + GuiToggleButton lightingButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_ENABLE_LIGHTING, xPos, yPos, 150, 20, o); + buttonList.add(lightingButton); } else if(o == ReplayOptions.linear) { - linearButton = new GuiSettingsOnOffButton(FORCE_LINEAR, xPos, yPos, 150, 20, o, + GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o, I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic")); - this.buttonList.add(linearButton); + buttonList.add(linearButton); } else if(o == ReplayOptions.useResources) { - resourcePackButton = new GuiSettingsOnOffButton(RESOURCEPACK_ID, xPos, yPos, 150, 20, o); - this.buttonList.add(resourcePackButton); + GuiToggleButton resourcePackButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RESOURCEPACK_ID, xPos, yPos, 150, 20, o); + buttonList.add(resourcePackButton); } else if(o == ReplayOptions.previewPath) { - pathPreviewButton = new GuiSettingsOnOffButton(PATHPREVIEW_ID, xPos, yPos, 150, 20, o); - this.buttonList.add(pathPreviewButton); + GuiToggleButton pathPreviewButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_PATHPREVIEW_ID, xPos, yPos, 150, 20, o); + buttonList.add(pathPreviewButton); } ++i; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySpeedSlider.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySpeedSlider.java index 533d5684..bda8a412 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySpeedSlider.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiReplaySpeedSlider.java @@ -39,14 +39,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement { displayString = displayKey + ": 1x"; } - public static float convertScaleRet(float value) { - if(value <= 1) { - return Math.round(value * 10); - } - float steps = value - 1; - return Math.round(steps / 0.25f); - } - public static float convertScale(float value) { if(value == 10) { return 1; @@ -89,6 +81,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement { this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); } catch(Exception e) { + // TODO: Fix exception } } } @@ -121,6 +114,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement { this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20); this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); } catch(Exception e) { + // TODO: Fix exception } } } @@ -129,13 +123,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement { return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F); } - public float realToNormalized(float value) { - float min = 0 - valueMin; - float max = valueMax + min; - - return value / (max) - min; - } - public float denormalizeValue(float p_148262_1_) { return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F)); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiAdvancedButton.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiAdvancedButton.java index 6d8c00f8..ed1330d7 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiAdvancedButton.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiAdvancedButton.java @@ -5,22 +5,10 @@ import net.minecraft.client.gui.GuiButton; public class GuiAdvancedButton extends GuiButton implements GuiElement { - public GuiAdvancedButton(int x, int y, String buttonText) { - this(0, x, y, buttonText); - } - - public GuiAdvancedButton(int x, int y, int widthIn, int heightIn, String buttonText) { - this(0, x, y, widthIn, heightIn, buttonText); - } - public GuiAdvancedButton(int id, int x, int y, String buttonText) { super(id, x, y, buttonText); } - public GuiAdvancedButton(int id, int x, int y, int widthIn, int heightIn, String buttonText) { - super(id, x, y, widthIn, heightIn, buttonText); - } - @Override public void draw(Minecraft mc, int mouseX, int mouseY) { drawButton(mc, mouseX, mouseY); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiArrowButton.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiArrowButton.java index 34799657..ca8d6c75 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiArrowButton.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiArrowButton.java @@ -8,7 +8,7 @@ import java.awt.*; public class GuiArrowButton extends GuiButton { public enum Direction { - UP, DOWN, RIGHT, LEFT; + UP, DOWN, RIGHT, LEFT } private Direction dir; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiDropdown.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiDropdown.java index a8924b03..5e3df233 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiDropdown.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiDropdown.java @@ -134,11 +134,11 @@ public class GuiDropdown extends GuiTextField { @Override public void mouseClicked(int xPos, int yPos, int mouseButton) { - mouseClickedResult(xPos, yPos, mouseButton); + mouseClickedResult(xPos, yPos); } - public boolean mouseClickedResult(int xPos, int yPos, int mouseButton) { + public boolean mouseClickedResult(int xPos, int yPos) { boolean success = false; if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) { open = !open; @@ -146,8 +146,7 @@ public class GuiDropdown extends GuiTextField { if(xPos > xPosition && xPos < xPosition + width && open) { int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight); if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) { - int clickedIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex; - this.selectionIndex = clickedIndex; + this.selectionIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex; success = true; fireSelectionChangeEvent(); } @@ -217,10 +216,6 @@ public class GuiDropdown extends GuiTextField { this.selectionListeners.add(listener); } - public void removeSelectionListener(SelectionListener listener) { - this.selectionListeners.remove(listener); - } - public boolean isExpanded() { return open; } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiEntryList.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiEntryList.java index b4a0ef99..874592ed 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiEntryList.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiEntryList.java @@ -118,11 +118,6 @@ public class GuiEntryList extends GuiTextField { } } - public void clearElements() { - this.elements = new ArrayList(); - selectionIndex = -1; - } - public void addElement(T element) { this.elements.add(element); if(selectionIndex == -1) { @@ -172,8 +167,4 @@ public class GuiEntryList extends GuiTextField { this.selectionListeners.add(listener); } - public void removeSelectionListener(SelectionListener listener) { - this.selectionListeners.remove(listener); - } - } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiKeyframeTimeline.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiKeyframeTimeline.java index 47b90b27..33b97bf1 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiKeyframeTimeline.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiKeyframeTimeline.java @@ -185,11 +185,8 @@ public class GuiKeyframeTimeline extends GuiTimeline { //Draw Keyframe logos - ListIterator iterator = ReplayHandler.getKeyframes().listIterator(); - while(iterator.hasNext()) { - Keyframe kf = iterator.next(); - - if(kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe())) + for (Keyframe kf : ReplayHandler.getKeyframes()) { + if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe())) drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiLoadingListEntry.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiLoadingListEntry.java index ed6e8148..5be04c4f 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiLoadingListEntry.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiLoadingListEntry.java @@ -8,7 +8,6 @@ import java.awt.*; public class GuiLoadingListEntry implements IGuiListEntry { - boolean registered = false; private final Minecraft mc = Minecraft.getMinecraft(); private final String message = I18n.format("replaymod.gui.loading")+"..."; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java index 49946131..2ca56e4e 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java @@ -26,7 +26,7 @@ public class GuiNumberInput extends GuiTextField { public GuiNumberInput(int id, FontRenderer fontRenderer, int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) { - this(id, fontRenderer, xPos, yPos, width, new Double(minimum), new Double(maximum), new Double(defaultValue), acceptFloats); + this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats); } @Override @@ -42,15 +42,12 @@ public class GuiNumberInput extends GuiTextField { } else { val = Integer.valueOf(getText()); } - if(minimum != null && val < minimum) { - setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString()); - return; - } - if(maximum != null && val > maximum) { - setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString()); - return; - } + if(minimum != null && val < minimum) { + setText(acceptFloats ? minimum.toString() : Integer.toString((int) Math.round(minimum))); + } else if(maximum != null && val > maximum) { + setText(acceptFloats ? maximum.toString() : Integer.toString((int) Math.round(maximum))); + } } catch(NumberFormatException e) { setText(textBefore); setCursorPosition(cursorPositionBefore); @@ -81,12 +78,4 @@ public class GuiNumberInput extends GuiTextField { } } - public Double getPreciseValueNullable() { - try { - return Double.valueOf(getText()); - } catch(Exception e) { - return null; - } - } - } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiOnOffButton.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiOnOffButton.java index 3c9e0cba..7da7ea05 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiOnOffButton.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiOnOffButton.java @@ -6,10 +6,6 @@ public class GuiOnOffButton extends GuiToggleButton { private static final String[] values = new String[] {I18n.format("options.on"), I18n.format("options.off")}; - public GuiOnOffButton(int buttonId, int x, int y, String buttonText) { - super(buttonId, x, y, buttonText, values); - } - public GuiOnOffButton(int buttonId, int x, int y, int width, int height, String buttonText) { super(buttonId, x, y, width, height, buttonText, values); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiReplayListEntry.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiReplayListEntry.java index 3e02db6c..e797449e 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiReplayListEntry.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiReplayListEntry.java @@ -29,7 +29,6 @@ public class GuiReplayListEntry implements IGuiListEntry { private ResourceLocation textureResource; private DynamicTexture dynTex = null; private File imageFile; - private BufferedImage image = null; private GuiReplayListExtended parent; public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) { @@ -60,13 +59,13 @@ public class GuiReplayListEntry implements IGuiListEntry { registered = false; ResourceHelper.freeResource(textureResource); textureResource = null; - image = null; dynTex = null; } return; } else { if(!registered) { textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId()); + BufferedImage image; if(imageFile == null) { image = ResourceHelper.getDefaultThumbnail(); } else { @@ -122,7 +121,9 @@ public class GuiReplayListEntry implements IGuiListEntry { if(online) { Category category = Category.fromId(fileInfo.getCategory()); - + if (category == null) { + category = Category.MISCELLANEOUS; + } mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB()); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiSettingsOnOffButton.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiSettingsOnOffButton.java index 1c9386fa..7958bc1d 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiSettingsOnOffButton.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiSettingsOnOffButton.java @@ -11,7 +11,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton { super(buttonId, x, y, width, height, toChange.getName()+": "); this.toChange = toChange; if(toChange.getValue() instanceof Boolean) { - this.setValue((Boolean) toChange.getValue() == true ? 0 : 1); + this.setValue((Boolean) toChange.getValue() ? 0 : 1); } } @@ -19,7 +19,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton { super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue); this.toChange = toChange; if(toChange.getValue() instanceof Boolean) { - this.setValue((Boolean) toChange.getValue() == true ? 0 : 1); + this.setValue((Boolean) toChange.getValue() ? 0 : 1); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTexturedButton.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTexturedButton.java index 02343e4f..42d0d16b 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTexturedButton.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTexturedButton.java @@ -16,11 +16,6 @@ public class GuiTexturedButton extends GuiButton implements GuiElement { private final Runnable action; private final String hoverText; - public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture, - int u, int v, int textureWidth, int textureHeight, Runnable action) { - this(buttonId, x, y, width, height, texture, u, v, textureWidth, textureHeight, action, null); - } - public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture, int u, int v, int textureWidth, int textureHeight, Runnable action, String hoverText) { super(buttonId, x, y, width, height, ""); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTimeline.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTimeline.java index 15408424..31969562 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTimeline.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiTimeline.java @@ -212,7 +212,6 @@ public class GuiTimeline extends Gui implements GuiElement { int distance; int smallDistance; - int maximum = 10; MarkerType(int minimum, int smallDistance) { this.distance = minimum; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiLoginPrompt.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiLoginPrompt.java index f492293c..a0f7b9aa 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiLoginPrompt.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiLoginPrompt.java @@ -12,6 +12,7 @@ import org.lwjgl.input.Keyboard; import java.awt.*; import java.io.IOException; +import java.util.List; public class GuiLoginPrompt extends GuiScreen { @@ -78,12 +79,12 @@ public class GuiLoginPrompt extends GuiScreen { int tw = 150+5+strwidth; registerButton.xPosition = (width/2) - (tw/2) + strwidth+5; + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; buttonList.add(loginButton); buttonList.add(cancelButton); buttonList.add(registerButton); - strwidth2 = Math.max(fontRendererObj.getStringWidth(usernameLabel), fontRendererObj.getStringWidth(passwordLabel)); - initialized = true; } @@ -126,7 +127,6 @@ public class GuiLoginPrompt extends GuiScreen { private String usernameLabel = I18n.format("replaymod.gui.username"); private String passwordLabel = I18n.format("replaymod.gui.password"); - private int strwidth2 = 100; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiRegister.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiRegister.java index f9272629..2be7dc27 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiRegister.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiRegister.java @@ -26,9 +26,6 @@ public class GuiRegister extends GuiScreen { private boolean initialized = false; - private int strwidth = 0; - private int totalwidth = 0; - private String[] labels = new String[]{I18n.format("replaymod.gui.username"), I18n.format("replaymod.gui.mail"), I18n.format("replaymod.gui.password"), I18n.format("replaymod.gui.register.confirmpw")}; @@ -71,14 +68,16 @@ public class GuiRegister extends GuiScreen { inputFields.add(passwordInput); inputFields.add(passwordConfirmation); - strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])), + int strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])), Math.max(fontRendererObj.getStringWidth(labels[2]), fontRendererObj.getStringWidth(labels[3]))); - totalwidth = 145+10+strwidth; + int totalwidth = 145 + 10 + strwidth; for(GuiTextField f : inputFields) - f.xPosition = (width/2) - (totalwidth/2) + strwidth+5; + f.xPosition = (width/2) - (totalwidth /2) + strwidth +5; + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; buttonList.add(registerButton); buttonList.add(cancelButton); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java index 2308a3e0..9b718463 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java @@ -32,16 +32,13 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { null, null, null, null); private static final int LOGOUT_CALLBACK_ID = 1; private ReplayFileList currentList; - private Tab currentTab = Tab.RECENT_FILES; private GuiButton loadButton, favButton, likeButton, dislikeButton; private List replayButtonBar, bottomBar, topBar; - private GuiLoadingListEntry loadingListEntry; public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) { String s1 = I18n.format("replaymod.gui.center.logoutcallback"); - GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"), + return new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"), I18n.format("replaymod.gui.cancel"), p_152129_2_); - return guiyesno; } private boolean initialized = false; @@ -110,6 +107,9 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { currentList.height = height-60; } + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + int i = 0; for(GuiButton b : topBar) { int w = this.width - 30; @@ -355,7 +355,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { private void updateCurrentList(Pagination pagination) { elementSelected(-1); currentList = new ReplayFileList(mc, width, height, 50, height - 60, this); - loadingListEntry = new GuiLoadingListEntry(); + GuiLoadingListEntry loadingListEntry = new GuiLoadingListEntry(); currentList.addEntry(loadingListEntry); if(pagination.getLoadedPages() < 0) { @@ -381,7 +381,14 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { private Thread currentListLoader; private void cancelCurrentListLoader() { - if(currentListLoader != null && currentListLoader.isAlive()) currentListLoader.stop(); + if(currentListLoader != null && currentListLoader.isAlive()) { + currentListLoader.interrupt(); + try { + currentListLoader.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } } public void showOnlineRecent() { @@ -389,7 +396,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { currentListLoader = new Thread(new Runnable() { @Override public void run() { - currentTab = Tab.RECENT_FILES; updateCurrentList(new SearchPagination(recentFileSearchQuery)); } }, "replaymod-list-loader"); @@ -401,7 +407,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { currentListLoader = new Thread(new Runnable() { @Override public void run() { - currentTab = Tab.BEST_FILES; updateCurrentList(new SearchPagination(bestFileSearchQuery)); } }, "replaymod-list-loader"); @@ -413,7 +418,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { currentListLoader = new Thread(new Runnable() { @Override public void run() { - currentTab = Tab.DOWNLOADED_FILES; updateCurrentList(new DownloadedFilePagination()); } }, "replaymod-list-loader"); @@ -425,27 +429,10 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { currentListLoader = new Thread(new Runnable() { @Override public void run() { - currentTab = Tab.FAVORITED_FILES; ReplayMod.favoritedFileHandler.reloadFavorites(); updateCurrentList(new FavoritedFilePagination()); } }, "replaymod-list-loader"); currentListLoader.start(); } - - private enum Tab { - RECENT_FILES("replaymod.gui.center.tab.recent"), - BEST_FILES("replaymod.gui.center.tab.best"), - DOWNLOADED_FILES("replaymod.gui.center.tab.downloaded"), - FAVORITED_FILES("replaymod.gui.center.tab.favorited"), - SEARCH("replaymod.gui.center.tab.search"); - - private String title; - - Tab(String title) { - this.title = title; - } - - public String getTitle() { return I18n.format(title); } - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java index 591d7b1b..6922ad32 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java @@ -22,9 +22,11 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.util.ResourceLocation; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -54,7 +56,8 @@ public class GuiUploadFile extends GuiScreen { private boolean initialized; - private int columnWidth, columnLeft, columnMiddle, columnRight; + private int columnWidth; + private int columnRight; private GuiAdvancedTextField name, tags; private GuiToggleButton category; @@ -80,8 +83,6 @@ public class GuiUploadFile extends GuiScreen { private boolean lockUploadButton = false; - private final Logger logger = LogManager.getLogger(); - public GuiUploadFile(File file, GuiReplayViewer parent) { this.parent = parent; @@ -109,17 +110,15 @@ public class GuiUploadFile extends GuiScreen { e.printStackTrace(); } finally { if(archive != null) { - try { - archive.close(); - } catch(IOException e) { - } + IOUtils.closeQuietly(archive); } } } if(!correctFile) { + Logger logger = LogManager.getLogger(); logger.error("Invalid file provided to upload"); - mc.displayGuiScreen(parent); //TODO: Error message + mc.displayGuiScreen(parent); replayFile = null; return; } @@ -190,8 +189,8 @@ public class GuiUploadFile extends GuiScreen { } columnWidth = Math.min(200, (width - 60) / 3); - columnLeft = width / 2 - columnWidth / 2 * 3 - 10; - columnMiddle = width / 2 - columnWidth / 2; + int columnLeft = width / 2 - columnWidth / 2 * 3 - 10; + int columnMiddle = width / 2 - columnWidth / 2; columnRight = width / 2 + columnWidth / 2 + 10; name.xPosition = columnLeft; @@ -218,6 +217,8 @@ public class GuiUploadFile extends GuiScreen { } content = new ComposedElement(elements.toArray(new GuiElement[elements.size()])); + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; if(startUploadButton == null) { List bottomBar = new ArrayList(); startUploadButton = new GuiButton(GuiConstants.UPLOAD_START_BUTTON, 0, 0, I18n.format("replaymod.gui.upload.start")); @@ -316,7 +317,7 @@ public class GuiUploadFile extends GuiScreen { ReplayMetaData newMetaData = metaData.copy(); newMetaData.removeServer(); - ReplayFileIO.writeReplayMetaDataToFile(newMetaData, tmpMeta); + ReplayFileIO.write(newMetaData, tmpMeta); HashMap toAdd = new HashMap(); toAdd.put(ReplayFile.ENTRY_METADATA, tmpMeta); @@ -326,8 +327,8 @@ public class GuiUploadFile extends GuiScreen { uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, tmp, category, desc); - tmpMeta.delete(); - tmp.delete(); + FileUtils.deleteQuietly(tmpMeta); + FileUtils.deleteQuietly(tmp); } else { uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, replayFile, category, desc); } @@ -365,8 +366,9 @@ public class GuiUploadFile extends GuiScreen { Gui.drawScaledCustomSizeModalRect(columnRight, 20, 0, 0, 1280, 720, columnWidth, height, 1280, 720); if (!hasThumbnail) { + KeyBinding keyBinding = KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL); String str = I18n.format("replaymod.gui.upload.nothumbnail", - GameSettings.getKeyDisplayString(KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL).getKeyCode())); + keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode())); int y = 20 + height + 10; fontRendererObj.drawSplitString(str, columnRight, y, columnWidth, Color.RED.getRGB()); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java b/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java index 0b53f234..860c970d 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java @@ -513,7 +513,7 @@ public class GuiReplayOverlay extends Gui { /** * Dummy interface for GUI on which this replay overlay shall not be rendered. */ - public static interface NoOverlay { + public interface NoOverlay { } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiConnectPart.java b/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiConnectPart.java index b1048c4d..958d4087 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiConnectPart.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiConnectPart.java @@ -74,7 +74,7 @@ public class GuiConnectPart extends GuiStudioPart { @Override public void initGui() { if(!initialized) { - concatList = new GuiEntryList(1, fontRendererObj, 30, yPos, 150, 0); + concatList = new GuiEntryList(1, fontRendererObj, 30, yPos, 150, 0); filesToConcat = new ArrayList(); String selectedName = FilenameUtils.getBaseName(GuiReplayEditor.instance.getSelectedFile().getAbsolutePath()); filesToConcat.add(selectedName); @@ -82,7 +82,7 @@ public class GuiConnectPart extends GuiStudioPart { concatList.setSelectionIndex(0); - replayDropdown = new GuiDropdown(1, fontRendererObj, 250, yPos + 5, 0, 4); + replayDropdown = new GuiDropdown(1, fontRendererObj, 250, yPos + 5, 0, 4); replayDropdown.clearElements(); replayFiles = ReplayFileIO.getAllReplayFiles(); @@ -107,14 +107,15 @@ public class GuiConnectPart extends GuiStudioPart { filesToConcat.set(concatList.getSelectionIndex(), replayDropdown.getElement(selectionIndex)); concatList.setElements(filesToConcat); } catch(Exception e) { - } //Sorry, too lazy to properly avoid this Exception here + // TODO Prevent exception + } } }); concatList.addSelectionListener(new SelectionListener() { @Override public void onSelectionChanged(int selectionIndex) { - String selName = (String) concatList.getElement(selectionIndex); + String selName = concatList.getElement(selectionIndex); int i = 0; for(Object s : replayDropdown.getAllElements()) { String str = (String) s; @@ -130,14 +131,15 @@ public class GuiConnectPart extends GuiStudioPart { } }); + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + upButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_UP_BUTTON, 195, yPos + 40, "", GuiArrowButton.Direction.UP); buttonList.add(upButton); downButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_DOWN_BUTTON, 219, yPos + 40, "", GuiArrowButton.Direction.DOWN); buttonList.add(downButton); - int w = GuiReplayEditor.instance.width - 243 - 20 - 4; - removeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON, 249, yPos + 40, I18n.format("replaymod.gui.remove")); buttonList.add(removeButton); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiReplayEditor.java b/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiReplayEditor.java index fa6b55dc..17657554 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiReplayEditor.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replayeditor/GuiReplayEditor.java @@ -22,8 +22,8 @@ public class GuiReplayEditor extends GuiScreen { private static final int tabYPos = 110; public static GuiReplayEditor instance = null; private StudioTab currentTab = StudioTab.TRIM; - private GuiDropdown replayDropdown; - private GuiButton saveModeButton, saveButton; + private GuiDropdown replayDropdown; + private GuiButton saveModeButton; private boolean overrideSave = false; private boolean initialized = false; private List replayFiles = new ArrayList(); @@ -56,6 +56,8 @@ public class GuiReplayEditor extends GuiScreen { @Override public void initGui() { + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; List tabButtons = new ArrayList(); tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, I18n.format("replaymod.gui.editor.trim.title"))); @@ -79,7 +81,7 @@ public class GuiReplayEditor extends GuiScreen { int modeWidth = tabButtons.get(0).width; if(!initialized) { - replayDropdown = new GuiDropdown(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5); + replayDropdown = new GuiDropdown(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5); refreshReplayDropdown(); } else { replayDropdown.width = this.width - 30 - 8 - 80 - modeWidth - 4; @@ -98,7 +100,7 @@ public class GuiReplayEditor extends GuiScreen { backButton.width = 70; buttonList.add(backButton); - saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save")); + GuiButton saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save")); saveButton.width = 70; buttonList.add(saveButton); @@ -113,8 +115,6 @@ public class GuiReplayEditor extends GuiScreen { return overrideSave ? I18n.format("replaymod.gui.editor.savemode.override") : I18n.format("replaymod.gui.editor.savemode.newfile"); } - ; - @Override protected void actionPerformed(GuiButton button) throws IOException { if(!button.enabled) return; @@ -194,7 +194,7 @@ public class GuiReplayEditor extends GuiScreen { private GuiStudioPart studioPart; - private StudioTab(GuiStudioPart part) { + StudioTab(GuiStudioPart part) { this.studioPart = part; } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiRenameReplay.java b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiRenameReplay.java index 2c1d27c1..841cacde 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiRenameReplay.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiRenameReplay.java @@ -6,11 +6,13 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.resources.I18n; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.lwjgl.input.Keyboard; import java.io.File; import java.io.IOException; +import java.util.List; public class GuiRenameReplay extends GuiScreen { private GuiScreen field_146585_a; @@ -28,9 +30,11 @@ public class GuiRenameReplay extends GuiScreen { public void initGui() { Keyboard.enableRepeatEvents(true); - this.buttonList.clear(); - this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename"))); - this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel"))); + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + buttonList.clear(); + buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename"))); + buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel"))); String s = FilenameUtils.getBaseName(file.getAbsolutePath()); this.field_146583_f = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); this.field_146583_f.setFocused(true); @@ -55,7 +59,7 @@ public class GuiRenameReplay extends GuiScreen { renamed = new File(initRenamed.getAbsolutePath() + "_" + i); i++; } - file.renameTo(renamed); + FileUtils.moveFile(file, renamed); this.mc.displayGuiScreen(this.field_146585_a); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java index bcf710fd..9b974c35 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java @@ -20,7 +20,9 @@ import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.client.resources.I18n; import net.minecraft.util.Util; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.logging.log4j.LogManager; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; @@ -29,7 +31,6 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.net.URI; import java.util.*; import java.util.List; @@ -45,7 +46,10 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { private boolean initialized; private GuiReplayListExtended replayGuiList; private List, File>> replayFileList = new ArrayList, File>>(); - private GuiButton loadButton, uploadButton, folderButton, renameButton, deleteButton, cancelButton, settingsButton; + private GuiButton loadButton; + private GuiButton uploadButton; + private GuiButton renameButton; + private GuiButton deleteButton; private boolean delete_file = false; public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, String file, int p_152129_2_) { @@ -53,8 +57,7 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { String s2 = "\'" + file + "\' " + I18n.format("replaymod.gui.viewer.delete.lineb"); String s3 = I18n.format("replaymod.gui.delete"); String s4 = I18n.format("replaymod.gui.cancel"); - GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_); - return guiyesno; + return new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_); } private void reloadFiles() { @@ -132,13 +135,15 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { } private void createButtons() { - this.buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load"))); - this.buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload"))); - this.buttonList.add(folderButton = new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder"))); - this.buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename"))); - this.buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete"))); - this.buttonList.add(settingsButton = new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings"))); - this.buttonList.add(cancelButton = new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel"))); + @SuppressWarnings("unchecked") + List buttonList = this.buttonList; + buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load"))); + buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload"))); + buttonList.add(new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder"))); + buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename"))); + buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete"))); + buttonList.add(new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings"))); + buttonList.add(new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel"))); setButtonsEnabled(false); } @@ -207,24 +212,24 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { try { Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s}); return; - } catch(IOException ioexception1) { + } catch (IOException e) { + LogManager.getLogger().error("Cannot open file", e); } } else if(Util.getOSType() == Util.EnumOS.WINDOWS) { - String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s}); + String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s); try { Runtime.getRuntime().exec(s1); return; - } catch(IOException ioexception) { + } catch(IOException e) { + LogManager.getLogger().error("Cannot open file", e); } } boolean flag = false; try { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); - oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{file1.toURI()}); + Desktop.getDesktop().browse(file1.toURI()); } catch(Throwable throwable) { flag = true; } @@ -241,7 +246,11 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { this.delete_file = false; if(result) { - replayFileList.get(replayGuiList.selected).first().first().delete(); + try { + FileUtils.forceDelete(replayFileList.get(replayGuiList.selected).first().first()); + } catch (IOException e) { + e.printStackTrace(); + } replayFileList.remove(replayGuiList.selected); } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/Keyframe.java b/src/main/java/eu/crushedpixel/replaymod/holders/Keyframe.java index 03af54fa..c440d4e6 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/Keyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/Keyframe.java @@ -1,33 +1,15 @@ package eu.crushedpixel.replaymod.holders; -public class Keyframe { +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode +@AllArgsConstructor +public abstract class Keyframe { private int realTimestamp; - public Keyframe clone() { - return new Keyframe(realTimestamp); - } - - public Keyframe(int realTimestamp) { - this.realTimestamp = realTimestamp; - } - - public int getRealTimestamp() { - return realTimestamp; - } - - public void setRealTimestamp(int realTimestamp) { this.realTimestamp = realTimestamp; } - - @Override - public boolean equals(Object o2) { - if(o2 == null) return false; - if(!(o2 instanceof Keyframe)) return false; - Keyframe kf = (Keyframe)o2; - return hashCode() == kf.hashCode(); - } - - @Override - public int hashCode() { - return realTimestamp; - } + public abstract Keyframe copy(); } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/KeyframeSet.java b/src/main/java/eu/crushedpixel/replaymod/holders/KeyframeSet.java index 377465fc..900f9810 100644 --- a/src/main/java/eu/crushedpixel/replaymod/holders/KeyframeSet.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/KeyframeSet.java @@ -3,6 +3,7 @@ package eu.crushedpixel.replaymod.holders; import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class KeyframeSet { @@ -40,8 +41,8 @@ public class KeyframeSet { public Keyframe[] getKeyframes() { List kfList = new ArrayList(); - for(Keyframe kf : positionKeyframes) kfList.add(kf); - for(Keyframe kf : timeKeyframes) kfList.add(kf); + Collections.addAll(kfList, positionKeyframes); + Collections.addAll(kfList, timeKeyframes); return kfList.toArray(new Keyframe[kfList.size()]); } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/MarkerKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/holders/MarkerKeyframe.java index a98c0c47..67191be2 100644 --- a/src/main/java/eu/crushedpixel/replaymod/holders/MarkerKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/MarkerKeyframe.java @@ -1,49 +1,23 @@ package eu.crushedpixel.replaymod.holders; -import org.apache.commons.lang3.builder.HashCodeBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; -public class MarkerKeyframe extends Keyframe { +@Data +@EqualsAndHashCode(callSuper = true) +public final class MarkerKeyframe extends Keyframe { private Position position; private String name; - @Override - public Keyframe clone() { - return new MarkerKeyframe(this.getPosition(), this.getRealTimestamp(), this.getName()); - } - public MarkerKeyframe(Position position, int timestamp, String name) { super(timestamp); this.position = position; this.name = name; } - public Position getPosition() { - return position; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - @Override - public boolean equals(Object o2) { - if(o2 == null) return false; - if(!(o2 instanceof MarkerKeyframe)) return false; - MarkerKeyframe m2 = (MarkerKeyframe)o2; - return hashCode() == m2.hashCode(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(position) - .append(getRealTimestamp()) - .append(name) - .toHashCode(); + public Keyframe copy() { + return new MarkerKeyframe(position, getRealTimestamp(), name); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/PacketData.java b/src/main/java/eu/crushedpixel/replaymod/holders/PacketData.java index 8faa1f71..57696e1e 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/PacketData.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/PacketData.java @@ -1,30 +1,11 @@ package eu.crushedpixel.replaymod.holders; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor public class PacketData { - - private byte[] array; + private byte[] byteArray; private int timestamp; - - public PacketData(byte[] array, int timestamp) { - this.array = array; - this.timestamp = timestamp; - } - - public byte[] getByteArray() { - return array; - } - - public void setByteArray(byte[] array) { - this.array = array; - } - - public int getTimestamp() { - return timestamp; - } - - public void setTimestamp(int timestamp) { - this.timestamp = timestamp; - } - - } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/PlayerVisibility.java b/src/main/java/eu/crushedpixel/replaymod/holders/PlayerVisibility.java index 5c564293..fb26f223 100644 --- a/src/main/java/eu/crushedpixel/replaymod/holders/PlayerVisibility.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/PlayerVisibility.java @@ -1,18 +1,12 @@ package eu.crushedpixel.replaymod.holders; -import java.util.Collection; +import lombok.AllArgsConstructor; +import lombok.Data; + import java.util.UUID; +@Data +@AllArgsConstructor public class PlayerVisibility { - - public PlayerVisibility(Collection hidden) { - this.hidden = hidden.toArray(new UUID[hidden.size()]); - } - private UUID[] hidden; - - public UUID[] getHiddenPlayers() { - return hidden; - } - } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/Position.java b/src/main/java/eu/crushedpixel/replaymod/holders/Position.java index cf83f962..16ce25e8 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/Position.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/Position.java @@ -1,9 +1,12 @@ package eu.crushedpixel.replaymod.holders; +import lombok.AllArgsConstructor; +import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import org.apache.commons.lang3.builder.HashCodeBuilder; +@Data +@AllArgsConstructor public class Position { private double x, y, z; @@ -14,103 +17,17 @@ public class Position { } public Position(Entity e) { - this.x = e.posX; - this.y = e.posY; - this.z = e.posZ; - this.pitch = e.rotationPitch; - this.yaw = e.rotationYaw; - } - - public Position(double x, double y, double z, float pitch, float yaw, float roll) { - this.x = x; - this.y = y; - this.z = z; - this.pitch = pitch; - this.yaw = yaw; - this.roll = roll; + this(e.posX, e.posY, e.posZ, e.rotationPitch, e.rotationYaw); } public Position(double x, double y, double z, float pitch, float yaw) { - this.x = x; - this.y = y; - this.z = z; - this.pitch = pitch; - this.yaw = yaw; + this(x, y, z, pitch, yaw, 0); } - public double getX() { - return x; - } - - public void setX(double x) { - this.x = x; - } - - public double getY() { - return y; - } - - public void setY(double y) { - this.y = y; - } - - public double getZ() { - return z; - } - - public void setZ(double z) { - this.z = z; - } - - public float getPitch() { - return pitch; - } - - public void setPitch(float pitch) { - this.pitch = pitch; - } - - public float getYaw() { - return yaw; - } - - public void setYaw(float yaw) { - this.yaw = yaw; - } - - public float getRoll() { return roll; } - - public void setRoll(float roll) { this.roll = roll; } - public double distanceSquared(double x, double y, double z) { double dx = this.x - x; double dy = this.y - y; double dz = this.z - z; return dx * dx + dy * dy + dz * dz; } - - @Override - public String toString() { - return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch + ", Roll="+roll; - } - - @Override - public boolean equals(Object o2) { - if(o2 == null) return false; - if(!(o2 instanceof Position)) return false; - Position pos2 = (Position)o2; - return hashCode() == pos2.hashCode(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(x) - .append(y) - .append(z) - .append(pitch) - .append(yaw) - .append(roll) - .toHashCode(); - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/PositionKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/holders/PositionKeyframe.java index b1b02a16..9862bddf 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/PositionKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/PositionKeyframe.java @@ -1,20 +1,17 @@ package eu.crushedpixel.replaymod.holders; -import org.apache.commons.lang3.builder.HashCodeBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; -public class PositionKeyframe extends Keyframe { +@Data +@EqualsAndHashCode(callSuper = true) +public final class PositionKeyframe extends Keyframe { private Position position; - private Integer spectatedEntityID = null; - - @Override - public Keyframe clone() { - return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID); - } + private Integer spectatedEntityID; public PositionKeyframe(int realTime, Position position) { - super(realTime); - this.position = position; + this(realTime, position, null); } public PositionKeyframe(int realTime, Position position, Integer spectatedEntityID) { @@ -27,28 +24,8 @@ public class PositionKeyframe extends Keyframe { this(realTime, new Position(spectatedEntityID), spectatedEntityID); } - public Position getPosition() { - return position; - } - - public void setPosition(Position position) { this.position = position; } - - public Integer getSpectatedEntityID() { return spectatedEntityID; } - @Override - public boolean equals(Object o2) { - if(o2 == null) return false; - if(!(o2 instanceof PositionKeyframe)) return false; - PositionKeyframe kf = (PositionKeyframe)o2; - return hashCode() == kf.hashCode(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(getPosition()) - .append(getRealTimestamp()) - .append(getSpectatedEntityID()) - .toHashCode(); + public Keyframe copy() { + return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID); } } \ No newline at end of file diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/TimeKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/holders/TimeKeyframe.java index b2a5fbd9..68e37806 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/TimeKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/TimeKeyframe.java @@ -1,38 +1,21 @@ package eu.crushedpixel.replaymod.holders; -import org.apache.commons.lang3.builder.HashCodeBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; -public class TimeKeyframe extends Keyframe { +@Data +@EqualsAndHashCode(callSuper = true) +public final class TimeKeyframe extends Keyframe { private final int timestamp; - @Override - public Keyframe clone() { - return new TimeKeyframe(this.getRealTimestamp(), this.getTimestamp()); - } - public TimeKeyframe(int realTime, int timestamp) { super(realTime); this.timestamp = timestamp; } - public int getTimestamp() { - return timestamp; - } - @Override - public boolean equals(Object o2) { - if(o2 == null) return false; - if(!(o2 instanceof TimeKeyframe)) return false; - TimeKeyframe kf = (TimeKeyframe)o2; - return hashCode() == kf.hashCode(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(getTimestamp()) - .append(getRealTimestamp()) - .toHashCode(); + public Keyframe copy() { + return new TimeKeyframe(getRealTimestamp(), getTimestamp()); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearInterpolation.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearInterpolation.java index ae4b0c6f..2e2f884e 100755 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearInterpolation.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearInterpolation.java @@ -24,10 +24,6 @@ public abstract class LinearInterpolation implements Interpolation { points.add(point); } - public void clearPoints() { - points = new ArrayList(); - } - protected Pair> getCurrentPoints(float position) { if(points.size() == 0) return null; position = position * (points.size() - 1); diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java index 986b715f..053f8e46 100755 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java @@ -24,8 +24,6 @@ public class LinearPoint extends LinearInterpolation { float rot = (float)getInterpolatedValue(first.getRoll(), second.getRoll(), perc); - Position inter = new Position(x, y, z, pitch, yaw, rot); - - return inter; + return new Position(x, y, z, pitch, yaw, rot); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearTimestamp.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearTimestamp.java index 8f3b7866..bcc2c2cf 100755 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearTimestamp.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearTimestamp.java @@ -14,8 +14,6 @@ public class LinearTimestamp extends LinearInterpolation { int first = pair.second().first(); int second = pair.second().second(); - int val = (int) getInterpolatedValue(first, second, perc); - - return val; + return (int) getInterpolatedValue(first, second, perc); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/SplinePoint.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/SplinePoint.java index 45206685..d9f33c93 100755 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/SplinePoint.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/SplinePoint.java @@ -7,7 +7,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.Vector; public class SplinePoint extends BasicSpline implements Interpolation { - private static final Object[] EMPTYOBJ = new Object[]{}; private Vector points; private Vector xCubics; private Vector yCubics; diff --git a/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHandler.java b/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHandler.java index fa339025..1c88f3ac 100755 --- a/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHandler.java @@ -31,6 +31,7 @@ public class AuthenticationHandler { } public static String getUsername() { return username; } + @SuppressWarnings("unused") public static boolean hasDonated(String uuid) throws IOException, ApiException { return apiClient.hasDonated(uuid); } @@ -42,12 +43,12 @@ public class AuthenticationHandler { AuthKey auth = apiClient.register(usrname, mail, password, mc.getSession().getProfile().getId().toString()); username = usrname; - authkey = auth.getAuthkey(); + authkey = auth.getAuth(); saveAuthkey(authkey); } public static void loadAuthkeyFromConfig() { - Property p = ReplayMod.instance.config.get("authkey", "authkey", "null"); + Property p = ReplayMod.config.get("authkey", "authkey", "null"); String key = null; if(!(p.getString().equals("null"))) { @@ -68,7 +69,7 @@ public class AuthenticationHandler { public static int authenticate(String usrname, String password) { try { - authkey = ReplayMod.apiClient.getLogin(usrname, password).getAuthkey(); + authkey = ReplayMod.apiClient.getLogin(usrname, password).getAuth(); username = usrname; saveAuthkey(authkey); return SUCCESS; @@ -94,8 +95,8 @@ public class AuthenticationHandler { } private static void saveAuthkey(String authkey) { - ReplayMod.instance.config.removeCategory(ReplayMod.config.getCategory("authkey")); - ReplayMod.instance.config.get("authkey", "authkey", authkey); - ReplayMod.instance.config.save(); + ReplayMod.config.removeCategory(ReplayMod.config.getCategory("authkey")); + ReplayMod.config.get("authkey", "authkey", authkey); + ReplayMod.config.save(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHash.java b/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHash.java index 0df1d80b..dc6955a7 100644 --- a/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHash.java +++ b/src/main/java/eu/crushedpixel/replaymod/online/authentication/AuthenticationHash.java @@ -21,19 +21,14 @@ public class AuthenticationHash { public final String hash; private String getAuthenticationHash() { - StringBuilder builder = new StringBuilder(); - builder.append(username); - builder.append(currentTime); - builder.append(randomLong); - - String md5 = builder.toString(); + String md5 = username + currentTime + randomLong; try { java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); byte[] array = md.digest(md5.getBytes()); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < array.length; ++i) { - sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3)); + StringBuilder sb = new StringBuilder(); + for (byte b : array) { + sb.append(Integer.toHexString((b & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { diff --git a/src/main/java/eu/crushedpixel/replaymod/recording/ConnectionEventHandler.java b/src/main/java/eu/crushedpixel/replaymod/recording/ConnectionEventHandler.java index 032544a9..4d5db3f1 100755 --- a/src/main/java/eu/crushedpixel/replaymod/recording/ConnectionEventHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/recording/ConnectionEventHandler.java @@ -6,7 +6,6 @@ import eu.crushedpixel.replaymod.gui.overlay.GuiRecordingOverlay; import eu.crushedpixel.replaymod.utils.ReplayFile; import eu.crushedpixel.replaymod.utils.ReplayFileIO; import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelPipeline; import net.minecraft.client.Minecraft; import net.minecraft.network.NetworkManager; @@ -23,23 +22,16 @@ import org.apache.logging.log4j.Logger; import java.io.File; import java.net.InetSocketAddress; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; public class ConnectionEventHandler { - private static final String decoderKey = "decoder"; private static final String packetHandlerKey = "packet_handler"; private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss"; private static final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); private static PacketListener packetListener = null; private static boolean isRecording = false; private final GuiRecordingOverlay guiOverlay = new GuiRecordingOverlay(Minecraft.getMinecraft()); - private File currentFile; - private String fileName; private static final Logger logger = LogManager.getLogger(); @@ -95,65 +87,26 @@ public class ConnectionEventHandler { } } NetworkManager nm = event.manager; - String worldName = ""; - if(!event.isLocal) { + String worldName; + if(event.isLocal) { + worldName = MinecraftServer.getServer().getWorldName(); + } else { worldName = ((InetSocketAddress) nm.getRemoteAddress()).getHostName(); } Channel channel = nm.channel(); ChannelPipeline pipeline = channel.pipeline(); - List channelHandlerKeys = new ArrayList(); - Iterator> it = pipeline.iterator(); - while(it.hasNext()) { - Entry entry = it.next(); - channelHandlerKeys.add(entry.getKey()); - } - File folder = ReplayFileIO.getReplayFolder(); - fileName = sdf.format(Calendar.getInstance().getTime()); - currentFile = new File(folder, fileName + ReplayFile.TEMP_FILE_EXTENSION); + String fileName = sdf.format(Calendar.getInstance().getTime()); + File currentFile = new File(folder, fileName + ReplayFile.TEMP_FILE_EXTENSION); - currentFile.createNewFile(); - - PacketListener insert = null; - - pipeline.addBefore(packetHandlerKey, "replay_recorder", insert = new PacketListener + pipeline.addBefore(packetHandlerKey, "replay_recorder", packetListener = new PacketListener (currentFile, fileName, worldName, System.currentTimeMillis(), event.isLocal)); ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingstarted", ChatMessageType.INFORMATION); isRecording = true; MinecraftForge.EVENT_BUS.register(guiOverlay); - - final PacketListener listener = insert; - - if(insert != null && event.isLocal) { - new Thread(new Runnable() { - - @Override - public void run() { - String worldName = null; - while (true) { - if (MinecraftServer.getServer() != null) { - worldName = MinecraftServer.getServer().getWorldName(); - } - if (worldName == null) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } else { - listener.setWorldName(worldName); - return; - } - } - } - }, "replaymod-world-name-fetcher").start(); - } - - packetListener = listener; - } catch(Exception e) { ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingfailed", ChatMessageType.WARNING); e.printStackTrace(); diff --git a/src/main/java/eu/crushedpixel/replaymod/recording/DataListener.java b/src/main/java/eu/crushedpixel/replaymod/recording/DataListener.java index 238564ea..62a49bb5 100755 --- a/src/main/java/eu/crushedpixel/replaymod/recording/DataListener.java +++ b/src/main/java/eu/crushedpixel/replaymod/recording/DataListener.java @@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.recording; import com.google.common.hash.Hashing; import com.google.common.io.Files; -import com.google.gson.Gson; import eu.crushedpixel.replaymod.ReplayMod; import eu.crushedpixel.replaymod.holders.MarkerKeyframe; import eu.crushedpixel.replaymod.holders.PacketData; @@ -37,7 +36,6 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter { protected Set players = new HashSet(); protected Set markers = new HashSet(); private boolean singleplayer; - private Gson gson = new Gson(); private int saveState = 0; //0: Idle, 1: Saving, 2: Saved @@ -72,10 +70,6 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter { }, "shutdown-hook-data-listener")); } - public void setWorldName(String worldName) { - this.worldName = worldName; - } - @Override public void channelInactive(ChannelHandlerContext ctx) { dataWriter.requestFinish(players, markers); @@ -181,11 +175,9 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter { File folder = ReplayFileIO.getReplayFolder(); File archive = new File(folder, name + ReplayFile.ZIP_FILE_EXTENSION); - archive.createNewFile(); - ReplayFileIO.writeReplayFile(archive, file, metaData, markers, resourcePacks, requestToHash); - file.delete(); + FileUtils.forceDelete(file); FileUtils.deleteDirectory(tempResourcePacksFolder); } catch(Exception e) { diff --git a/src/main/java/eu/crushedpixel/replaymod/recording/PacketSerializer.java b/src/main/java/eu/crushedpixel/replaymod/recording/PacketSerializer.java index 349be9a9..e8379a7a 100755 --- a/src/main/java/eu/crushedpixel/replaymod/recording/PacketSerializer.java +++ b/src/main/java/eu/crushedpixel/replaymod/recording/PacketSerializer.java @@ -1,7 +1,6 @@ package eu.crushedpixel.replaymod.recording; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import net.minecraft.network.*; import net.minecraft.util.MessageSerializer; @@ -14,14 +13,6 @@ public class PacketSerializer extends MessageSerializer { super(direction); } - public static ByteBuf toByteBuf(byte[] bytes) throws IOException, ClassNotFoundException { - ByteBuf bb; - bb = Unpooled.buffer(bytes.length); - bb.writeBytes(bytes); - - return bb; - } - @Override public void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf byteBuf) throws IOException { EnumConnectionState state = ((EnumConnectionState) ctx.channel().attr(NetworkManager.attrKeyConnectionState).get()); @@ -31,11 +22,9 @@ public class PacketSerializer extends MessageSerializer { public void encode(EnumConnectionState state, Packet packet, ByteBuf byteBuf) { Integer integer = state.getPacketId(EnumPacketDirection.CLIENTBOUND, packet); - if(integer == null) { - return; - } else { + if (integer != null) { PacketBuffer packetbuffer = new PacketBuffer(byteBuf); - packetbuffer.writeVarIntToBuffer(integer.intValue()); + packetbuffer.writeVarIntToBuffer(integer); try { packet.writePacketData(packetbuffer); diff --git a/src/main/java/eu/crushedpixel/replaymod/recording/ReplayMetaData.java b/src/main/java/eu/crushedpixel/replaymod/recording/ReplayMetaData.java index 48f913a2..1ba6d590 100755 --- a/src/main/java/eu/crushedpixel/replaymod/recording/ReplayMetaData.java +++ b/src/main/java/eu/crushedpixel/replaymod/recording/ReplayMetaData.java @@ -1,5 +1,10 @@ package eu.crushedpixel.replaymod.recording; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor public class ReplayMetaData { private boolean singleplayer; @@ -15,48 +20,5 @@ public class ReplayMetaData { this.duration, this.date, this.players, this.mcversion); } - public ReplayMetaData(boolean singleplayer, String serverName, String generator, - int duration, long date, String[] players, String mcversion) { - this.singleplayer = singleplayer; - this.serverName = serverName; - this.generator = generator; - this.duration = duration; - this.date = date; - this.players = players; - this.mcversion = mcversion; - } - public void removeServer() { this.serverName = null; } - - public boolean isSingleplayer() { - return singleplayer; - } - - public String getServerName() { - return serverName; - } - - public String getGenerator() { - return generator; - } - - public int getDuration() { - return duration; - } - - public void setDuration(int duration) { - this.duration = duration; - } - - public long getDate() { - return date; - } - - public String[] getPlayers() { - return players; - } - - public String getMCVersion() { - return mcversion; - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/DownloadedFileHandler.java b/src/main/java/eu/crushedpixel/replaymod/registry/DownloadedFileHandler.java index 59e8dddd..ce1040eb 100644 --- a/src/main/java/eu/crushedpixel/replaymod/registry/DownloadedFileHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/DownloadedFileHandler.java @@ -3,9 +3,11 @@ package eu.crushedpixel.replaymod.registry; import eu.crushedpixel.replaymod.ReplayMod; import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler; import eu.crushedpixel.replaymod.utils.ReplayFile; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import java.io.File; +import java.io.IOException; import java.util.HashMap; public class DownloadedFileHandler { @@ -16,18 +18,19 @@ public class DownloadedFileHandler { public DownloadedFileHandler() { downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath()); - downloadFolder.mkdirs(); + try { + FileUtils.forceMkdir(downloadFolder); - for(File f : downloadFolder.listFiles()) { - if(!FilenameUtils.getExtension(f.getAbsolutePath()).equals("mcpr")) continue; - try { - Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath())); - if(i != null) { - downloadedFiles.put(i, f); + for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) { + try { + int id = Integer.parseInt(FilenameUtils.getBaseName(f.getAbsolutePath())); + downloadedFiles.put(id, f); + } catch(NumberFormatException e) { + e.printStackTrace(); } - } catch(Exception e) { - e.printStackTrace(); } + } catch (IOException e) { + e.printStackTrace(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/PlayerHandler.java b/src/main/java/eu/crushedpixel/replaymod/registry/PlayerHandler.java index 44acc786..55812d8e 100755 --- a/src/main/java/eu/crushedpixel/replaymod/registry/PlayerHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/PlayerHandler.java @@ -17,8 +17,7 @@ public class PlayerHandler { private static Predicate playerPredicate = new Predicate() { @Override public boolean apply(EntityPlayer input) { - if(input instanceof CameraEntity || input == mc.thePlayer) return false; - return true; + return !(input instanceof CameraEntity || input == mc.thePlayer); } }; @@ -42,7 +41,7 @@ public class PlayerHandler { resetHiddenPlayers(); if(visibility != null) { GuiPlayerOverview.defaultSave = true; - Collections.addAll(hidden, visibility.getHiddenPlayers()); + Collections.addAll(hidden, visibility.getHidden()); } else { GuiPlayerOverview.defaultSave = false; } @@ -65,6 +64,7 @@ public class PlayerHandler { return; } + @SuppressWarnings("unchecked") List players = mc.theWorld.getEntities(EntityPlayer.class, playerPredicate); mc.displayGuiScreen(new GuiPlayerOverview(players)); } diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/RatedFileHandler.java b/src/main/java/eu/crushedpixel/replaymod/registry/RatedFileHandler.java index fa00ee05..c0e35f43 100644 --- a/src/main/java/eu/crushedpixel/replaymod/registry/RatedFileHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/RatedFileHandler.java @@ -19,10 +19,6 @@ public class RatedFileHandler { reloadRatings(); } - public HashMap getRated() { - return rated; - } - public Rating.RatingType getRating(int id) { return Rating.RatingType.fromBoolean(rated.get(id)); } diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/ReplayFileAppender.java b/src/main/java/eu/crushedpixel/replaymod/registry/ReplayFileAppender.java index 16234638..f47d66e4 100644 --- a/src/main/java/eu/crushedpixel/replaymod/registry/ReplayFileAppender.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/ReplayFileAppender.java @@ -6,9 +6,11 @@ import eu.crushedpixel.replaymod.gui.GuiReplaySaving; import eu.crushedpixel.replaymod.utils.ReplayFileIO; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.client.FMLClientHandler; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.tuple.Pair; import java.io.File; +import java.io.IOException; import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; @@ -17,7 +19,6 @@ public class ReplayFileAppender extends Thread { private Multimap> filesToMove = ArrayListMultimap.create(); private Queue filesToRewrite = new ConcurrentLinkedQueue(); - private boolean shutdown = false; private List listeners = new ArrayList(); //this is true if the DataListener is currently busy saving a newly recorded Replay File @@ -53,11 +54,9 @@ public class ReplayFileAppender extends Thread { public void registerModifiedFile(File toAdd, String name, File replayFile) { //first, remove any files with the same name assigned to this Replay File - if(filesToMove.get(replayFile) != null) { - for(Pair p : new ArrayList>((Collection>)filesToMove.get(replayFile))) { - if(p.getRight().equals(name)) { - filesToMove.remove(replayFile, p); - } + for (Iterator> iter = filesToMove.get(replayFile).iterator(); iter.hasNext(); ) { + if (iter.next().getRight().equals(name)) { + iter.remove(); } } @@ -71,7 +70,7 @@ public class ReplayFileAppender extends Thread { } public void shutdown() { - shutdown = true; + interrupt(); } public void addFinishListener(GuiReplaySaving gui) { @@ -80,7 +79,7 @@ public class ReplayFileAppender extends Thread { @Override public void run() { - while(!shutdown || !filesToRewrite.isEmpty()) { + while(!Thread.interrupted() || !filesToRewrite.isEmpty()) { File replayFile = filesToRewrite.poll(); if(replayFile != null) { if(replayFile.canWrite()) { @@ -96,7 +95,11 @@ public class ReplayFileAppender extends Thread { //delete all written files for(Pair p : filesToMove.get(replayFile)) { if(p.getLeft() != null) { - p.getLeft().delete(); + try { + FileUtils.forceDelete(p.getLeft()); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -114,7 +117,9 @@ public class ReplayFileAppender extends Thread { } try { Thread.sleep(1000); - } catch(Exception e) {} + } catch (InterruptedException e) { + interrupt(); + } } } diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/UploadedFileHandler.java b/src/main/java/eu/crushedpixel/replaymod/registry/UploadedFileHandler.java index 02c46863..72aaa1a6 100644 --- a/src/main/java/eu/crushedpixel/replaymod/registry/UploadedFileHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/UploadedFileHandler.java @@ -16,7 +16,7 @@ public class UploadedFileHandler { public UploadedFileHandler(File confDir) { try { File confFile = new File(confDir, "uploaded"); - confFile.createNewFile(); + FileUtils.touch(confFile); configuration = new Configuration(confFile); configuration.load(); diff --git a/src/main/java/eu/crushedpixel/replaymod/renderer/InvisibilityRender.java b/src/main/java/eu/crushedpixel/replaymod/renderer/InvisibilityRender.java index 4b661f14..af7d2c8e 100644 --- a/src/main/java/eu/crushedpixel/replaymod/renderer/InvisibilityRender.java +++ b/src/main/java/eu/crushedpixel/replaymod/renderer/InvisibilityRender.java @@ -20,8 +20,8 @@ public class InvisibilityRender extends RenderPlayer { @Override public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) { - if(PlayerHandler.isHidden(entity.getUniqueID()) || entity.isInvisible() || - (ReplayHandler.isInReplay() && entity == Minecraft.getMinecraft().thePlayer)) return false; - return super.shouldRender(entity, camera, camX, camY, camZ); + return !(PlayerHandler.isHidden(entity.getUniqueID()) || entity.isInvisible() || (ReplayHandler.isInReplay() + && entity == Minecraft.getMinecraft().thePlayer)) + && super.shouldRender(entity, camera, camX, camY, camZ); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/renderer/SafeEntityRenderer.java b/src/main/java/eu/crushedpixel/replaymod/renderer/SafeEntityRenderer.java index f5c0439e..19cc7708 100755 --- a/src/main/java/eu/crushedpixel/replaymod/renderer/SafeEntityRenderer.java +++ b/src/main/java/eu/crushedpixel/replaymod/renderer/SafeEntityRenderer.java @@ -15,8 +15,7 @@ public class SafeEntityRenderer extends EntityRenderer { super.updateCameraAndRender(partialTicks); } catch(Exception e) { e.printStackTrace(); - } //This is plain easier than doing proper error prevention. - //If Johni reads this, don't think I'm a bad programmer... Just a lazy one :P + } } @Override @@ -24,6 +23,7 @@ public class SafeEntityRenderer extends EntityRenderer { try { super.updateRenderer(); } catch(Exception e) { + e.printStackTrace(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/renderer/SpectatorRenderer.java b/src/main/java/eu/crushedpixel/replaymod/renderer/SpectatorRenderer.java index b178f88d..529e58da 100644 --- a/src/main/java/eu/crushedpixel/replaymod/renderer/SpectatorRenderer.java +++ b/src/main/java/eu/crushedpixel/replaymod/renderer/SpectatorRenderer.java @@ -7,7 +7,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.Entity; @@ -117,8 +116,10 @@ public class SpectatorRenderer { event.setCanceled(true); } + @SuppressWarnings("deprecation") public void renderItemInFirstPerson(float partialTicks) { EntityPlayer entityPlayer = getSpectatedPlayer(); + if (entityPlayer == null) return; float equippedProgressState = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks); float swingProgress = entityPlayer.getSwingProgress(partialTicks); @@ -171,7 +172,8 @@ public class SpectatorRenderer { mc.entityRenderer.itemRenderer.func_178096_b(equippedProgressState, swingProgress); } - mc.entityRenderer.itemRenderer.renderItem(entityPlayer, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON); + mc.entityRenderer.itemRenderer.renderItem(entityPlayer, itemToRender, + net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType.FIRST_PERSON); } else if (!entityPlayer.isInvisible()) { renderPlayerHand(entityPlayer, equippedProgressState, swingProgress); @@ -210,7 +212,7 @@ public class SpectatorRenderer { GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F); GlStateManager.translate(-1.0F, -1.0F, 0.0F); GlStateManager.scale(0.015625F, 0.015625F, 0.015625F); - this.mc.getTextureManager().bindTexture(mc.entityRenderer.itemRenderer.RES_MAP_BACKGROUND); + this.mc.getTextureManager().bindTexture(ItemRenderer.RES_MAP_BACKGROUND); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); GL11.glNormal3f(0.0F, 0.0F, -1.0F); @@ -229,7 +231,7 @@ public class SpectatorRenderer { public void renderMapArms(EntityPlayer entityPlayer) { bindPlayerTexture(entityPlayer); - Render render = mc.entityRenderer.itemRenderer.renderManager.getEntityRenderObject((EntityPlayer)ReplayHandler.getCurrentEntity()); + Render render = mc.entityRenderer.itemRenderer.renderManager.getEntityRenderObject(ReplayHandler.getCurrentEntity()); RenderPlayer renderplayer = (RenderPlayer)render; if(!entityPlayer.isInvisible()) { @@ -444,11 +446,7 @@ public class SpectatorRenderer { if(!itemToRender.getIsItemStackEqual(itemstack)) { flag = true; } - } else if(itemToRender == null && itemstack == null) { - flag = false; - } else { - flag = true; - } + } else flag = !(itemToRender == null && itemstack == null); float f = 0.4F; float f1 = flag ? 0.0F : 1.0F; @@ -484,7 +482,7 @@ public class SpectatorRenderer { for (int i = 0; i < 8; ++i) { - double d0 = player.posX + (double)(((float)((i >> 0) % 2) - 0.5F) * player.width * 0.8F); + double d0 = player.posX + (double)(((float)((i) % 2) - 0.5F) * player.width * 0.8F); double d1 = player.posY + (double)(((float)((i >> 1) % 2) - 0.5F) * 0.1F); double d2 = player.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * player.width * 0.8F); BlockPos blockpos = new BlockPos(d0, d1 + (double)player.getEyeHeight(), d2); @@ -516,7 +514,7 @@ public class SpectatorRenderer { } public void renderWaterOverlayTexture(float partialTicks, EntityPlayer player) { - this.mc.getTextureManager().bindTexture(mc.entityRenderer.itemRenderer.RES_UNDERWATER_OVERLAY); + this.mc.getTextureManager().bindTexture(ItemRenderer.RES_UNDERWATER_OVERLAY); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); float f1 = player.getBrightness(partialTicks); diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/OpenEmbeddedChannel.java b/src/main/java/eu/crushedpixel/replaymod/replay/OpenEmbeddedChannel.java index 5329e57c..0eb0794d 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/OpenEmbeddedChannel.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/OpenEmbeddedChannel.java @@ -27,8 +27,4 @@ public class OpenEmbeddedChannel extends EmbeddedChannel { } return pipeline().close(); } - - public ChannelFuture manualClose() { - return pipeline().close(); - } } diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java index 9a459a14..26d4205d 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java @@ -61,7 +61,7 @@ public class ReplayHandler { try { File tempFile = File.createTempFile(ReplayFile.ENTRY_PATHS, "json"); - ReplayFileIO.writeKeyframeRegistryToFile(repo, tempFile); + ReplayFileIO.write(repo, tempFile); ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_PATHS, getReplayFile()); } catch(Exception e) { @@ -82,15 +82,13 @@ public class ReplayHandler { for(Keyframe kf : new ArrayList(keyframes)) { if(kf instanceof MarkerKeyframe) keyframes.remove(kf); } - for(MarkerKeyframe marker : m) { - keyframes.add(marker); - } + Collections.addAll(keyframes, m); if(write) { try { File tempFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json"); - ReplayFileIO.writeMarkersToFile(m, tempFile); + ReplayFileIO.write(m, tempFile); ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_MARKERS, getReplayFile()); } catch(Exception e) { @@ -110,9 +108,7 @@ public class ReplayHandler { keyframes = new ArrayList(Arrays.asList(kfs)); - for(MarkerKeyframe mk : markers) { - keyframes.add(mk); - } + Collections.addAll(keyframes, markers); if(!(selectedKeyframe instanceof MarkerKeyframe)) selectedKeyframe = null; @@ -460,9 +456,7 @@ public class ReplayHandler { keyframes = new ArrayList(); if(!resetMarkers) { - for(MarkerKeyframe mk : markers) { - keyframes.add(mk); - } + Collections.addAll(keyframes, markers); if(!(selectedKeyframe instanceof MarkerKeyframe)) selectKeyframe(null); @@ -540,7 +534,9 @@ public class ReplayHandler { try { ReplayMod.overlay.resetUI(true); - } catch(Exception e) {} // TODO proper handling + } catch(Exception e) { + // TODO: Fix exceptionsudo + } //Load lighting and trigger update ReplayMod.replaySettings.setLightingEnabled(ReplayMod.replaySettings.isLightingEnabled()); @@ -594,7 +590,7 @@ public class ReplayHandler { currentReplayFile.close(); File markerFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json"); - ReplayFileIO.writeMarkersToFile(getMarkers(), markerFile); + ReplayFileIO.write(getMarkers(), markerFile); ReplayMod.replayFileAppender.registerModifiedFile(markerFile, ReplayFile.ENTRY_MARKERS, ReplayHandler.getReplayFile()); } catch (IOException e) { e.printStackTrace(); @@ -673,18 +669,6 @@ public class ReplayHandler { return null; } - public static PositionKeyframe getLastPositionKeyframe() { - ArrayList rev = new ArrayList(getKeyframes()); - Collections.reverse(rev); - - for(Keyframe k : rev) { - if(k instanceof PositionKeyframe) { - return (PositionKeyframe)k; - } - } - return null; - } - public static void syncTimeCursor(boolean shiftMode) { selectKeyframe(null); diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java index 93186e95..d771bce2 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java @@ -21,21 +21,15 @@ public class ReplayProcess { private static Minecraft mc = Minecraft.getMinecraft(); - private static long startRealTime; private static int lastRealReplayTime; private static long lastRealTime = 0; private static boolean linear = false; - private static Position lastPosition = null; - private static int lastTimestamp = -1; - private static SplinePoint motionSpline = null; private static LinearPoint motionLinear = null; private static LinearTimestamp timeLinear = null; - private static double lastSpeed = 1f; - private static double previousReplaySpeed = 0; private static boolean calculated = false; @@ -44,9 +38,6 @@ public class ReplayProcess { private static boolean blocked = false; private static boolean deepBlock = false; private static boolean requestFinish = false; - private static float lastPartialTicks, lastRenderPartialTicks; - private static int lastTicks; - private static boolean resetTimer = false; private static boolean firstTime = false; public static boolean isVideoRecording() { @@ -56,7 +47,6 @@ public class ReplayProcess { private static void resetProcess() { firstTime = true; - lastPosition = null; motionSpline = null; motionLinear = null; timeLinear = null; @@ -65,11 +55,8 @@ public class ReplayProcess { blocked = deepBlock = false; - startRealTime = System.currentTimeMillis(); - lastRealTime = startRealTime; + lastRealTime = System.currentTimeMillis(); lastRealReplayTime = 0; - lastTimestamp = -1; - lastSpeed = 1f; linear = ReplayMod.replaySettings.isLinearMovement(); previousReplaySpeed = ReplayMod.replaySender.getReplaySpeed(); @@ -162,9 +149,6 @@ public class ReplayProcess { if(firstTime) { firstTime = false; - lastPartialTicks = 100; - lastRenderPartialTicks = 100; - lastTicks = 100; mc.timer.renderPartialTicks = 100; mc.timer.elapsedPartialTicks = 100; mc.timer.elapsedTicks = 100; @@ -278,9 +262,7 @@ public class ReplayProcess { } if(!(nextTime == null || lastTime == null)) { - if(lastTimeStamp == nextTimeStamp) curSpeed = 0f; - else - curSpeed = ((double) ((nextTime.getTimestamp() - lastTime.getTimestamp()))) / ((double) ((nextTimeStamp - lastTimeStamp))); + curSpeed = ((double) ((nextTime.getTimestamp() - lastTime.getTimestamp()))) / ((double) ((nextTimeStamp - lastTimeStamp))); } if(lastTimeStamp == nextTimeStamp) { @@ -315,7 +297,9 @@ public class ReplayProcess { } } else { if(posCount == 1) { - pos = ReplayHandler.getFirstPositionKeyframe().getPosition(); + PositionKeyframe keyframe = ReplayHandler.getFirstPositionKeyframe(); + assert keyframe != null; + pos = keyframe.getPosition(); } } @@ -334,11 +318,6 @@ public class ReplayProcess { if(!isVideoRecording()) ReplayMod.replaySender.setReplaySpeed(curSpeed); //if(curSpeed > 0) - lastSpeed = curSpeed; - - lastPartialTicks = mc.timer.elapsedPartialTicks; - lastRenderPartialTicks = mc.timer.renderPartialTicks; - lastTicks = mc.timer.elapsedTicks; if(curTimestamp != null) ReplayMod.replaySender.sendPacketsTill(curTimestamp); diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java index f1a8b960..26fedc28 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java @@ -291,10 +291,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter { } } - if(p instanceof S03PacketTimeUpdate) { - p = TimeHandler.getTimePacket((S03PacketTimeUpdate) p); - } - if(p instanceof S48PacketResourcePackSend) { S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p; String url = packet.func_179783_a(); diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/TimeHandler.java b/src/main/java/eu/crushedpixel/replaymod/replay/TimeHandler.java deleted file mode 100755 index f118e81c..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/replay/TimeHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package eu.crushedpixel.replaymod.replay; - -import net.minecraft.network.play.server.S03PacketTimeUpdate; - -public class TimeHandler { - - private static long actualDaytime; - private static long desiredDaytime; - - private static boolean timeOverridden = false; - - public static boolean isTimeOverridden() { - return timeOverridden; - } - - public static void setTimeOverridden(boolean overridden) { - timeOverridden = overridden; - } - - public static void setDesiredDaytime(long ddt) { - desiredDaytime = ddt; - } - - public static S03PacketTimeUpdate getTimePacket(S03PacketTimeUpdate packet) { - if(!timeOverridden) return packet; - return new S03PacketTimeUpdate(packet.func_149366_c(), desiredDaytime, true); - } -} diff --git a/src/main/java/eu/crushedpixel/replaymod/settings/RenderOptions.java b/src/main/java/eu/crushedpixel/replaymod/settings/RenderOptions.java index d307f766..c2e093a3 100644 --- a/src/main/java/eu/crushedpixel/replaymod/settings/RenderOptions.java +++ b/src/main/java/eu/crushedpixel/replaymod/settings/RenderOptions.java @@ -1,10 +1,12 @@ package eu.crushedpixel.replaymod.settings; import eu.crushedpixel.replaymod.video.frame.FrameRenderer; +import lombok.Data; import net.minecraft.client.Minecraft; import static org.apache.commons.lang3.Validate.*; +@Data public final class RenderOptions { private FrameRenderer renderer; private String bitrate = "10M"; @@ -24,22 +26,10 @@ public final class RenderOptions { "-c:v libvpx -b:v %BITRATE% %FILENAME%.webm"; private int writerQueueSize = Integer.parseInt(System.getProperty("replaymod.render.writerQueueSize", "1")); - public FrameRenderer getRenderer() { - return renderer; - } - public void setRenderer(FrameRenderer renderer) { this.renderer = notNull(renderer); } - public String getBitrate() { - return bitrate; - } - - public void setBitrate(String bitrate) { - this.bitrate = bitrate; - } - public int getFps() { return fps; } @@ -49,74 +39,10 @@ public final class RenderOptions { this.fps = fps; } - public boolean isWaitForChunks() { - return waitForChunks; - } - - public void setWaitForChunks(boolean waitForChunks) { - this.waitForChunks = waitForChunks; - } - - public boolean isLinearMovement() { - return isLinearMovement; - } - - public void setLinearMovement(boolean isLinearMovement) { - this.isLinearMovement = isLinearMovement; - } - public boolean isDefaultSky() { return skyColor == -1; } - public int getSkyColor() { - return skyColor; - } - - public void setSkyColor(int skyColor) { - this.skyColor = skyColor; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public String getExportCommand() { - return exportCommand; - } - - public void setExportCommand(String exportCommand) { - this.exportCommand = exportCommand; - } - - public String getExportCommandArgs() { - return exportCommandArgs; - } - - public void setExportCommandArgs(String exportCommandArgs) { - this.exportCommandArgs = exportCommandArgs; - } - - public int getWriterQueueSize() { - return writerQueueSize; - } - - public void setWriterQueueSize(int writerQueueSize) { - this.writerQueueSize = writerQueueSize; - } - public RenderOptions copy() { RenderOptions copy = new RenderOptions(); copy.renderer = this.renderer; diff --git a/src/main/java/eu/crushedpixel/replaymod/sound/SoundHandler.java b/src/main/java/eu/crushedpixel/replaymod/sound/SoundHandler.java index 519de391..79af8271 100644 --- a/src/main/java/eu/crushedpixel/replaymod/sound/SoundHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/sound/SoundHandler.java @@ -10,6 +10,6 @@ public class SoundHandler { private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod:renderSuccess"); public void playRenderSuccessSound() { - mc.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(successSoundLocation, 1.0F)); + mc.getSoundHandler().playSound(PositionedSoundRecord.create(successSoundLocation, 1.0F)); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/studio/VersionValidator.java b/src/main/java/eu/crushedpixel/replaymod/studio/VersionValidator.java index 1786c6f4..755fd0a8 100755 --- a/src/main/java/eu/crushedpixel/replaymod/studio/VersionValidator.java +++ b/src/main/java/eu/crushedpixel/replaymod/studio/VersionValidator.java @@ -8,11 +8,7 @@ public class VersionValidator { String version = Runtime.class.getPackage().getSpecificationVersion(); if(version != null) { String[] split = version.split("\\."); - if(split.length > 1) { - isValid = Integer.valueOf(split[1]) >= 7; - } else { - isValid = false; - } + isValid = split.length > 1 && Integer.valueOf(split[1]) >= 7; } else { isValid = false; } diff --git a/src/main/java/eu/crushedpixel/replaymod/timer/EnchantmentTimer.java b/src/main/java/eu/crushedpixel/replaymod/timer/EnchantmentTimer.java index 27857e62..9d1fe939 100755 --- a/src/main/java/eu/crushedpixel/replaymod/timer/EnchantmentTimer.java +++ b/src/main/java/eu/crushedpixel/replaymod/timer/EnchantmentTimer.java @@ -19,6 +19,7 @@ public class EnchantmentTimer { recordingTime += amount; } + @SuppressWarnings("unused") // Called by ASM public static long getEnchantmentTime() { if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) { if(ReplayHandler.isInReplay()) { diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/EmailAddressUtils.java b/src/main/java/eu/crushedpixel/replaymod/utils/EmailAddressUtils.java index 8e4ebbc6..548d9f27 100644 --- a/src/main/java/eu/crushedpixel/replaymod/utils/EmailAddressUtils.java +++ b/src/main/java/eu/crushedpixel/replaymod/utils/EmailAddressUtils.java @@ -6,9 +6,6 @@ public class EmailAddressUtils { public static boolean isValidEmailAddress(String mail) { try { String[] spl1 = mail.split("@"); - String[] spl2 = spl1[1].split("\\."); - String suffix = spl2[1]; - return spl1[0].equals(URLEncoder.encode(spl1[0], "UTF-8")) && spl1[1].equals(URLEncoder.encode(spl1[1], "UTF-8")); } catch(Exception e) { return false; diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/MouseUtils.java b/src/main/java/eu/crushedpixel/replaymod/utils/MouseUtils.java index e75933e2..74e133b1 100755 --- a/src/main/java/eu/crushedpixel/replaymod/utils/MouseUtils.java +++ b/src/main/java/eu/crushedpixel/replaymod/utils/MouseUtils.java @@ -11,8 +11,8 @@ public class MouseUtils { public static Point getMousePos() { Point scaled = getScaledDimensions(); - int width = (int) scaled.getX(); - int height = (int) scaled.getY(); + int width = scaled.getX(); + int height = scaled.getY(); final int mouseX = (Mouse.getX() * width / mc.displayWidth); final int mouseY = (height - Mouse.getY() * height / mc.displayHeight); @@ -20,17 +20,6 @@ public class MouseUtils { return new Point(mouseX, mouseY); } - public static void moveMouse(int mouseX, int mouseY) { - Point scaled = getScaledDimensions(); - int width = (int) scaled.getX(); - int height = (int) scaled.getY(); - - int x = (int)Math.round(((mouseX+0.5)*mc.displayWidth)/width); - int y = (mouseY*mc.displayHeight)/height; - - Mouse.setCursorPosition(x, y); - } - public static Point getScaledDimensions() { ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); final int width = sr.getScaledWidth(); diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/ReplayFileIO.java b/src/main/java/eu/crushedpixel/replaymod/utils/ReplayFileIO.java index ecfb3f6d..dd298749 100755 --- a/src/main/java/eu/crushedpixel/replaymod/utils/ReplayFileIO.java +++ b/src/main/java/eu/crushedpixel/replaymod/utils/ReplayFileIO.java @@ -14,10 +14,7 @@ import net.minecraft.network.EnumConnectionState; import net.minecraft.network.EnumPacketDirection; import net.minecraft.network.Packet; import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import java.io.*; @@ -31,29 +28,26 @@ public class ReplayFileIO { private static final PacketSerializer packetSerializer = new PacketSerializer(EnumPacketDirection.CLIENTBOUND); private static final byte[] uniqueBytes = new byte[]{0, 1, 1, 2, 3, 5, 8}; - private static File lastReplayFile = null; - private static boolean lastContainsJoinPacket = false; - public static File getRenderFolder() { + public static File getRenderFolder() throws IOException { File folder = new File(ReplayMod.replaySettings.getRenderPath()); - folder.mkdirs(); + FileUtils.forceMkdir(folder); return folder; } - public static File getReplayFolder() { + public static File getReplayFolder() throws IOException { String path = ReplayMod.replaySettings.getRecordingPath(); File folder = new File(path); - folder.mkdirs(); + FileUtils.forceMkdir(folder); return folder; } public static List getAllReplayFiles() { List files = new ArrayList(); - File folder = getReplayFolder(); - for(File file : folder.listFiles()) { - if(("." + FilenameUtils.getExtension(file.getAbsolutePath())).equals(ReplayFile.ZIP_FILE_EXTENSION)) { - files.add(file); - } + try { + files.addAll(FileUtils.listFiles(getReplayFolder(), new String[]{"mcpr"}, false)); + } catch (IOException e) { + e.printStackTrace(); } return files; } @@ -62,10 +56,6 @@ public class ReplayFileIO { Map resourcePacks, Map resourcePackRequests) throws IOException { byte[] buffer = new byte[1024]; - if(!replayFile.exists()) { - replayFile.createNewFile(); - } - FileOutputStream fos = new FileOutputStream(replayFile); ZipOutputStream zos = new ZipOutputStream(fos); @@ -113,59 +103,6 @@ public class ReplayFileIO { zos.close(); } - public static ReplayMetaData getMetaData(File replayFile) throws IOException { - ReplayFile file = new ReplayFile(replayFile); - try { - return file.metadata().get(); - } finally { - file.close(); - } - } - - /** - * @param replayFile - * @return Whether the given Replay File contains a {@link S01PacketJoinGame}. - */ - public static boolean containsJoinPacket(File replayFile) { - DataInputStream dis = null; - if(replayFile == lastReplayFile) { - return lastContainsJoinPacket; - } - ReplayFile file = null; - - lastReplayFile = replayFile; - lastContainsJoinPacket = false; - try { - file = new ReplayFile(replayFile); - dis = new DataInputStream(file.recording().get()); - PacketData pd = readPacketData(dis); - while(dis.available() > 0) { - Packet p = deserializePacket(pd.getByteArray()); - if(p instanceof S01PacketJoinGame) { - lastContainsJoinPacket = true; - return lastContainsJoinPacket; - } - if(p instanceof S08PacketPlayerPosLook) { - lastContainsJoinPacket = false; - return lastContainsJoinPacket; - } - } - } catch(Exception e) { - e.printStackTrace(); - } finally { - try { - if(dis != null) { - dis.close(); - } - if (file != null) { - file.close(); - } - } catch(Exception ignored) {} - } - - return false; - } - public static PacketData readPacketData(DataInputStream dis) throws IOException { int timestamp = dis.readInt(); int bytes = dis.readInt(); @@ -209,135 +146,27 @@ public class ReplayFileIO { out.write(pd.getByteArray()); } - public static int getWrittenByteSize(PacketData pd) { - return (2 * 4) + pd.getByteArray().length; - } - - public static void writePackets(Collection p, DataOutput out) throws IOException { - for(PacketData pd : p) { - writePacket(pd, out); - } - } - - /** - * @param replayFile The File to reverse - * @param outputFile The File to save the reversed Packets in - * @param seekJoinPacket Whether a {@link S01PacketJoinGame} should be seeked in the Replay File. If containsJoinPacket is being - * called with the same File directly afterwards, this will reduce the amount of calculations. Only use if needed, - * because this consumes a significant amount of time! - * @param boundaries Two timestamps which make a boundary for excluded Packets - * @return Whether the action was successful - */ - public static boolean reversePackets(File replayFile, File outputFile, boolean seekJoinPacket, int... boundaries) { - lastReplayFile = replayFile; - lastContainsJoinPacket = false; - - RandomAccessFile raf = null; - DataInputStream dis = null; - ReplayFile file = null; - - boolean bounds = false; - int lower = 0, upper = 0; - if(boundaries.length >= 2) { - if(boundaries[0] > boundaries[1]) { - upper = boundaries[0]; - lower = boundaries[1]; - } else { - upper = boundaries[1]; - lower = boundaries[0]; - } - } - try { - if(!outputFile.exists()) { - outputFile.createNewFile(); - } - raf = new RandomAccessFile(outputFile, "rw"); - file = new ReplayFile(replayFile); - - dis = new DataInputStream(file.recording().get()); - long fileLength = file.recordingEntry().getSize(); - - raf.setLength(fileLength); - - long pointerBefore = fileLength; - - while(dis.available() > 0) { - try { - PacketData pd = readPacketData(dis); - - boolean write = true; - if(bounds) { - if(pd.getTimestamp() < lower || pd.getTimestamp() > upper) { - write = false; - } - } - - if(write) { - if(seekJoinPacket && !lastContainsJoinPacket) { - Packet p = deserializePacket(pd.getByteArray()); - if(p instanceof S01PacketJoinGame) lastContainsJoinPacket = true; - } - pointerBefore = pointerBefore - getWrittenByteSize(pd); - raf.seek(pointerBefore); - writePacket(pd, raf); - } - } catch(EOFException e) { - e.printStackTrace(); - break; - } - } - return true; - } catch(Exception e) { - e.printStackTrace(); - } finally { - try { - if(raf != null) { - raf.close(); - } - if(dis != null) { - dis.close(); - } - if(file != null) { - file.close(); - } - } catch(Exception ignored) {} - } - - return false; - } - private static final Gson gson = new Gson(); - public static void writeKeyframeRegistryToFile(KeyframeSet[] keyframeRegistry, File file) throws IOException { - file.mkdirs(); - file.createNewFile(); - - String json = gson.toJson(keyframeRegistry); + private static void write(Object obj, File file) throws IOException { + String json = gson.toJson(obj); FileUtils.write(file, json); } - public static void writePlayerVisibilityToFile(PlayerVisibility visibility, File file) throws IOException { - file.mkdirs(); - file.createNewFile(); - - String json = gson.toJson(visibility); - FileUtils.write(file, json); + public static void write(KeyframeSet[] keyframeRegistry, File file) throws IOException { + write((Object) keyframeRegistry, file); } - public static void writeReplayMetaDataToFile(ReplayMetaData metaData, File file) throws IOException { - file.mkdirs(); - file.createNewFile(); - - String json = gson.toJson(metaData); - FileUtils.write(file, json); + public static void write(PlayerVisibility visibility, File file) throws IOException { + write((Object) visibility, file); } - public static void writeMarkersToFile(MarkerKeyframe[] markers, File file) throws IOException { - file.mkdirs(); - file.createNewFile(); + public static void write(ReplayMetaData metaData, File file) throws IOException { + write((Object) metaData, file); + } - String json = gson.toJson(markers); - FileUtils.write(file, json); + public static void write(MarkerKeyframe[] markers, File file) throws IOException { + write((Object) markers, file); } /** @@ -406,7 +235,7 @@ public class ReplayFileIO { // Complete the ZIP file out.close(); - zipFile.delete(); - tempFile.renameTo(zipFile); + FileUtils.forceDelete(zipFile); + FileUtils.moveFile(tempFile, zipFile); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/StreamTools.java b/src/main/java/eu/crushedpixel/replaymod/utils/StreamTools.java deleted file mode 100755 index af886928..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/utils/StreamTools.java +++ /dev/null @@ -1,226 +0,0 @@ -/* Leichtathletik Daten Verarbeitung (LDV) - * Copyright (C) 2004 Marc Schunk - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package eu.crushedpixel.replaymod.utils; - -import java.io.*; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * @author Marc Schunk, created on 21.06.2004 - *

- * A Class to provide helpers of commonly user operations with binary - * and character Streams, such as read to an OutputStream/Writer, - * String, ByteArray. In addition streams can be compressed. - */ - -public class StreamTools { - - public static final String[] umlauteString = {"&", "ß", "ä", - "Ä", "ö", "Ö", "ü", "Ü", "ß"}; - public static final String[] umlauteReplacement = {"&", "ß", "ä", "Ä", "ö", - "Ö", "ü", "Ü", "ß"}; - - /** - * Checks weather the given array is contained in the first array - * - * @param ar1 - the containing array - * @param index1 - the index where the search starts - * @param ar2 - the array that schould be contained - * @return - true of ar2 is contained in ar1 - */ - public static final boolean arrayMatch(char[] ar1, int index1, char[] ar2) { - if((ar1.length - index1 - ar2.length) < 0) - return false; - for(int i = 0; i < ar2.length; i++) { - if(ar1[index1 + i] != ar2[i]) - return false; - } - return true; - } - - /** - * Reads inStream completly and writes it to outStream. Streams will not be - * closed. - * - * @param inStream - an InputStream to be read completely - * @param outStream - the destination Stream - * @throws IOException - */ - public static void readStream(InputStream inStream, OutputStream outStream) - throws IOException { - byte[] buffer = new byte[4096]; - int len = 0; - while((len = inStream.read(buffer, 0, buffer.length)) > -1) { - outStream.write(buffer, 0, len); - } - } - - /** - * Reads inStream completly into an byte[]. Streams will not be closed. - * - * @param inStream - an InputStream to be read completely - * @param outStream - the destination Stream - * @throws IOException - */ - public static byte[] readStream(InputStream inStream) throws IOException { - byte[] buffer = new byte[4096]; - int len = 0; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while((len = inStream.read(buffer, 0, buffer.length)) > -1) { - baos.write(buffer, 0, len); - } - return baos.toByteArray(); - } - - /** - * Reads the given Steam into an String * - * - * @throws IOException - */ - public static String readStreamtoString(InputStream inStream) - throws IOException { - StringWriter sw = new StringWriter(); - InputStreamReader isr = new InputStreamReader(inStream); - - char[] buffer = new char[4096]; - int len = 0; - while((len = isr.read(buffer, 0, buffer.length)) > -1) { - sw.write(buffer, 0, len); - } - return sw.toString(); - } - - /** - * Reads the given Steam into an String using the given encoding - * - * @throws IOException - */ - public static String readStreamtoString(InputStream inStream, String charSet) - throws IOException { - StringWriter sw = new StringWriter(); - InputStreamReader isr = new InputStreamReader(inStream, charSet); - - char[] buffer = new char[4096]; - int len = 0; - while((len = isr.read(buffer, 0, buffer.length)) > -1) { - sw.write(buffer, 0, len); - } - return sw.toString(); - } - - public static String stripComments(String inString, String newLineDelimiter) - throws IOException { - StringWriter sw = new StringWriter(); - // use both windows and linux/unix line seperators to be independent of the file orgin - String[] lines = inString.split("\r\n|\n"); - for(String line : lines) { - if((line.indexOf("#") == -1) && (line.trim().length() > 0)) { - sw.append(line).append(newLineDelimiter); - } - } - return sw.toString(); - } - - public static String replaceSpecialCharacters(String s) { - for(int i = 0; i < umlauteString.length; i++) { - s = s.replaceAll(umlauteString[i], umlauteReplacement[i]); - } - return s; - } - - /** - * Stores the given Stream in an byte[]. Stream is compressed on the fly. - * Streams will not be closed. - * - * @param inStream - an InputStream to be read completely - * @param outStream - the destination Stream - * @throws IOException - */ - public static byte[] compressStreamToByteArray(InputStream inStream) - throws IOException { - byte[] buffer = new byte[4096]; - int len = 0; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - GZIPOutputStream zos = new GZIPOutputStream(baos); - while((len = inStream.read(buffer, 0, buffer.length)) > -1) { - zos.write(buffer, 0, len); - } - zos.close(); - return baos.toByteArray(); - } - - /** - * Stores the given Stream in an byte[]. Stream is compressed on the fly. - * Streams will not be closed. - * - * @param inStream - an InputStream to be read completely - * @param outStream - the destination Stream - * @throws IOException - */ - public static byte[] compress(byte[] uncompressed) throws IOException { - ByteArrayInputStream bais = new ByteArrayInputStream(uncompressed); - return compressStreamToByteArray(bais); - } - - /** - * Stores the given Stream in an byte[]. Stream is decompressed on the fly. - * Thus, the input stream should contain compressed content. Streams will - * not be closed. - * - * @param inStream - an InputStream to be read completely - * @param outStream - the destination Stream - * @throws IOException - */ - public static byte[] decompressStreamToByteArray(InputStream inStream) - throws IOException { - byte[] buffer = new byte[4096]; - int len = 0; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GZIPInputStream gzis = new GZIPInputStream(inStream); - while((len = gzis.read(buffer, 0, buffer.length)) > -1) { - baos.write(buffer, 0, len); - } - inStream.close(); - return baos.toByteArray(); - } - - public static byte[] decompress(byte[] compressed) throws IOException { - ByteArrayInputStream bais = new ByteArrayInputStream(compressed); - return decompressStreamToByteArray(bais); - } - - /** - * Reads the given Steam into an String * - * - * @throws IOException - */ - public static String readReaderToString(Reader reader) throws IOException { - StringBuffer sb = new StringBuffer(); - - char[] buffer = new char[4096]; - int len = 0; - while((len = reader.read(buffer, 0, buffer.length)) > -1) { - sb.append(buffer, 0, len); - } - return sb.toString(); - } - -} diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/ZipFileUtils.java b/src/main/java/eu/crushedpixel/replaymod/utils/ZipFileUtils.java deleted file mode 100755 index 61a130bf..00000000 --- a/src/main/java/eu/crushedpixel/replaymod/utils/ZipFileUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -package eu.crushedpixel.replaymod.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -public class ZipFileUtils { - - public static void deleteZipEntry(File zipFile, - String[] files) throws IOException { - // get a temp file - File tempFile = File.createTempFile(zipFile.getName(), null); - // delete it, otherwise you cannot rename your existing zip to it. - tempFile.delete(); - tempFile.deleteOnExit(); - boolean renameOk = zipFile.renameTo(tempFile); - if(!renameOk) { - throw new RuntimeException("could not rename the file " + zipFile.getAbsolutePath() + " to " + tempFile.getAbsolutePath()); - } - byte[] buf = new byte[1024]; - - ZipInputStream zin = new ZipInputStream(new FileInputStream(tempFile)); - ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(zipFile)); - - ZipEntry entry = zin.getNextEntry(); - while(entry != null) { - String name = entry.getName(); - boolean toBeDeleted = false; - for(String f : files) { - if(f.equals(name)) { - toBeDeleted = true; - break; - } - } - if(!toBeDeleted) { - // Add ZIP entry to output stream. - zout.putNextEntry(new ZipEntry(name)); - // Transfer bytes from the ZIP file to the output file - int len; - while((len = zin.read(buf)) > 0) { - zout.write(buf, 0, len); - } - } - entry = zin.getNextEntry(); - } - // Close the streams - zin.close(); - // Compress the files - // Complete the ZIP file - zout.close(); - tempFile.delete(); - } - -} diff --git a/src/main/java/eu/crushedpixel/replaymod/video/ReplayScreenshot.java b/src/main/java/eu/crushedpixel/replaymod/video/ReplayScreenshot.java index d1e43296..19f9a1e3 100755 --- a/src/main/java/eu/crushedpixel/replaymod/video/ReplayScreenshot.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/ReplayScreenshot.java @@ -17,8 +17,6 @@ public class ReplayScreenshot { private static Minecraft mc = Minecraft.getMinecraft(); - private static long last_finish = -1; - private static boolean before; private static double beforeSpeed; private static GuiScreen beforeScreen; @@ -103,9 +101,5 @@ public class ReplayScreenshot { exception.printStackTrace(); ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.failedthumb", ChatMessageType.WARNING); } - - last_finish = System.currentTimeMillis(); } - - } diff --git a/src/main/java/eu/crushedpixel/replaymod/video/ScreenCapture.java b/src/main/java/eu/crushedpixel/replaymod/video/ScreenCapture.java index 415552a8..ab9bed81 100755 --- a/src/main/java/eu/crushedpixel/replaymod/video/ScreenCapture.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/ScreenCapture.java @@ -50,7 +50,7 @@ public class ScreenCapture { pixelBuffer.get(pixelValues); TextureUtil.processPixelValues(pixelValues, width, height); - BufferedImage bufferedimage = null; + BufferedImage bufferedimage; if(OpenGlHelper.isFramebufferEnabled()) { diff --git a/src/main/java/eu/crushedpixel/replaymod/video/VideoRenderer.java b/src/main/java/eu/crushedpixel/replaymod/video/VideoRenderer.java index 29a14fba..346fb6fe 100644 --- a/src/main/java/eu/crushedpixel/replaymod/video/VideoRenderer.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/VideoRenderer.java @@ -193,7 +193,9 @@ public class VideoRenderer { PositionKeyframe nextPos = null; if (movement == null || lastPos == null) { // Stay at one position, no movement - pos = ReplayHandler.getNextPositionKeyframe(-1).getPosition(); + PositionKeyframe keyframe = ReplayHandler.getNextPositionKeyframe(-1); + assert keyframe != null; + pos = keyframe.getPosition(); } else { // Position interpolation nextPos = ReplayHandler.getNextPositionKeyframe(videoTime); @@ -267,8 +269,7 @@ public class VideoRenderer { } if(!(nextTime == null || lastTime == null)) { - if(lastTimeStamp == nextTimeStamp) curSpeed = 0f; - else curSpeed = ((double)((nextTime.getTimestamp()-lastTime.getTimestamp())))/((double)((nextTimeStamp-lastTimeStamp))); + curSpeed = ((double)((nextTime.getTimestamp()-lastTime.getTimestamp())))/((double)((nextTimeStamp-lastTimeStamp))); } if(lastTimeStamp == nextTimeStamp) { diff --git a/src/main/java/eu/crushedpixel/replaymod/video/VideoWriter.java b/src/main/java/eu/crushedpixel/replaymod/video/VideoWriter.java index 6cf3b46c..ec8345dc 100755 --- a/src/main/java/eu/crushedpixel/replaymod/video/VideoWriter.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/VideoWriter.java @@ -132,10 +132,6 @@ public class VideoWriter { writerThread.start(); } - public void setQueueLimit(int limit) { - this.queueLimit = limit; - } - /** * Add the image to the writer queue. * @param image The image diff --git a/src/main/java/eu/crushedpixel/replaymod/video/entity/CubicEntityRenderer.java b/src/main/java/eu/crushedpixel/replaymod/video/entity/CubicEntityRenderer.java index c52ed1e5..46b15c70 100644 --- a/src/main/java/eu/crushedpixel/replaymod/video/entity/CubicEntityRenderer.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/entity/CubicEntityRenderer.java @@ -10,7 +10,7 @@ import net.minecraft.util.ResourceLocation; public class CubicEntityRenderer extends CustomEntityRenderer { - public static enum Direction { + public enum Direction { TOP(1), BOTTOM(9), LEFT(4), FRONT(5), RIGHT(6), BACK(7); private final int frame; diff --git a/src/main/java/eu/crushedpixel/replaymod/video/entity/CustomEntityRenderer.java b/src/main/java/eu/crushedpixel/replaymod/video/entity/CustomEntityRenderer.java index d6c7a429..cbe7779f 100644 --- a/src/main/java/eu/crushedpixel/replaymod/video/entity/CustomEntityRenderer.java +++ b/src/main/java/eu/crushedpixel/replaymod/video/entity/CustomEntityRenderer.java @@ -434,11 +434,11 @@ public abstract class CustomEntityRenderer { } } - public static interface GluPerspectiveHook { + public interface GluPerspectiveHook { void gluPerspective(float fovY, float aspect, float zNear, float zFar); } - public static interface LoadShaderHook { + public interface LoadShaderHook { void loadShader(ResourceLocation resourceLocation); } }