Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from Petschko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Petschko authored Mar 15, 2021
2 parents b7917c3 + 181611f commit f422c51
Show file tree
Hide file tree
Showing 60 changed files with 2,160 additions and 1,582 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ hs_err_pid*
.idea/

#Output
target/
output/
out/

#Other
config.pref
updateCache.pref
RPG Maker MV Decrypter.iml
pom.xml
4 changes: 4 additions & 0 deletions deployment/start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
java -jar "RPG Maker MV Decrypter.jar"
echo.
pause
1 change: 1 addition & 0 deletions deployment/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar "RPG Maker MV Decrypter.jar"
Binary file added deployment/update.jar
Binary file not shown.
File renamed without changes.
52 changes: 52 additions & 0 deletions src/main/java/org/petschko/lib/CellRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.petschko.lib;

import javax.swing.*;
import java.awt.*;
import java.io.File;

/**
* @author trenton-telge
*/
public class CellRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = 1L;
private String relativePath = null;

@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof File) {
File file = (File) value;
String fileText = file.getName();

if(relativePath != null)
fileText = file.getPath().replace(relativePath, "");

setText(fileText);

if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}

setEnabled(list.isEnabled());
setFont(list.getFont());
setOpaque(true);
}

return this;
}

/**
* Sets the Relative Path of the Project
*
* @param path - Path of the Project
*/
public void setRelativePath(String path) {
if(path != null)
path = org.petschko.lib.File.ensureDSonEndOfPath(path);

this.relativePath = path;
}
}
21 changes: 21 additions & 0 deletions src/main/java/org/petschko/lib/Const.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.petschko.lib;

/**
* @author Peter Dragicevic
*/
public class Const {
public static final String CREATOR = "Petschko";
public static final String CREATOR_URL = "https://petschko.org/";
public static final String CREATOR_DONATION_URL = "https://www.paypal.me/petschko";

// System Constance's
public static final String DS = System.getProperty("file.separator");
public static final String NEW_LINE = System.getProperty("line.separator");

/**
* Constructor
*/
private Const() {
// VOID - This is a Static-Class
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.petschko.lib;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.petschko.lib.exceptions.PathException;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
Expand All @@ -11,14 +11,7 @@
import java.util.ArrayList;

/**
* Author: Peter Dragicevic [peter@petschko.org]
* Authors-Website: http://petschko.org/
* Date: 11.12.2016
* Time: 20:23
* Update: -
* Version: 0.0.1
*
* Notes: File Class
* @author Peter Dragicevic
*/
public class File {
private String name;
Expand All @@ -32,7 +25,12 @@ public class File {
* @param filePath - Path of the File
* @throws Exception - Invalid File-Path
*/
public File(@NotNull String filePath) throws Exception {
public File(String filePath) throws Exception {
if(filePath == null) {
PathException pe = new PathException("filePath can't be null!", (String) null);
pe.printStackTrace();
}

this.setFilePath(filePath);

// Extract Name and Extension
Expand All @@ -53,7 +51,7 @@ public String getName() {
*
* @param name - New Name for the File without ext
*/
private void setName(@NotNull String name) {
private void setName(String name) {
this.name = name;
}

Expand All @@ -62,7 +60,13 @@ private void setName(@NotNull String name) {
*
* @param newName - New Name for the File (without ext)
*/
public void changeName(@NotNull String newName) {
public void changeName(String newName) {
if(newName == null) {
Exception e = new Exception("newName can't be null!");
e.printStackTrace();
return;
}

this.setFilePath(this.getFileDirectoryPath() + newName +
((this.getExtension() != null) ? "." + this.getExtension() : ""));
this.setName(newName);
Expand All @@ -82,7 +86,7 @@ public String getExtension() {
*
* @param extension - New Extension of the File
*/
private void setExtension(@Nullable String extension) {
private void setExtension(String extension) {
if(extension != null) {
if (extension.equals(""))
extension = null;
Expand All @@ -98,7 +102,7 @@ private void setExtension(@Nullable String extension) {
*
* @param newExtension - New Extension for the File
*/
public void changeExtension(@Nullable String newExtension) {
public void changeExtension(String newExtension) {
if(newExtension != null) {
if (newExtension.equals(""))
newExtension = null;
Expand All @@ -123,7 +127,7 @@ public byte[] getContent() {
*
* @param content - New File-Content
*/
public void setContent(@Nullable byte[] content) {
public void setContent(byte[] content) {
this.content = content;
}

Expand All @@ -141,7 +145,13 @@ public String getFilePath() {
*
* @param filePath - New path of the File
*/
public void setFilePath(@NotNull String filePath) {
public void setFilePath(String filePath) {
if(filePath == null) {
PathException pe = new PathException("filePath can't be null!", (String) null);
pe.printStackTrace();
return;
}

this.filePath = filePath;
}

Expand All @@ -160,7 +170,7 @@ public String getFullFileName() {
* @return - File Directory-Path
*/
public String getFileDirectoryPath() {
int lastDSChar = this.getFilePath().lastIndexOf(Const.ds);
int lastDSChar = this.getFilePath().lastIndexOf(Const.DS);

if(lastDSChar == -1)
return "";
Expand All @@ -173,7 +183,7 @@ public String getFileDirectoryPath() {
*
* @param newPath - New Directory of the File
*/
public void changePathToFile(@Nullable String newPath) {
public void changePathToFile(String newPath) {
if(newPath == null)
newPath = "";

Expand Down Expand Up @@ -298,7 +308,7 @@ else if(! file.exists()) {
*/
private void extractInfosFromPath() throws Exception {
int filePathLen = this.getFilePath().length();
int lastDSCharPos = this.getFilePath().lastIndexOf(Const.ds);
int lastDSCharPos = this.getFilePath().lastIndexOf(Const.DS);
int lastDotPos = this.getFilePath().lastIndexOf(".");
String fileName = this.getFilePath();

Expand Down Expand Up @@ -363,9 +373,15 @@ public static ArrayList<java.io.File> readDirFiles(java.io.File dir, boolean rec
* @param path - Unchecked Path-String
* @return - Checked and may corrected Path-String
*/
public static String ensureDSonEndOfPath(@NotNull String path) {
if(! path.substring(path.length() - 1).equals(Const.ds))
path = path + Const.ds;
public static String ensureDSonEndOfPath(String path) {
if(path == null) {
PathException pe = new PathException("path can't be null!", (String) null);
pe.printStackTrace();
return null;
}

if(! path.substring(path.length() - 1).equals(Const.DS))
path = path + Const.DS;

return path;
}
Expand All @@ -376,7 +392,13 @@ public static String ensureDSonEndOfPath(@NotNull String path) {
* @param path - Path of the Directory
* @return - true if Directory exists else false
*/
public static boolean existsDir(@NotNull String path) {
public static boolean existsDir(String path) {
if(path == null) {
PathException pe = new PathException("path can't be null!", (String) null);
pe.printStackTrace();
return false;
}

return existsDir(path, false);
}

Expand All @@ -387,7 +409,13 @@ public static boolean existsDir(@NotNull String path) {
* @param createMissing - true if the function should create missing Directories
* @return - true if the Directory exists (or was successfully created) else false
*/
public static boolean existsDir(@NotNull String path, boolean createMissing) {
public static boolean existsDir(String path, boolean createMissing) {
if(path == null) {
PathException pe = new PathException("path can't be null!", (String) null);
pe.printStackTrace();
return false;
}

java.io.File dir = new java.io.File(path);

if(! dir.exists()) {
Expand All @@ -405,7 +433,13 @@ public static boolean existsDir(@NotNull String path, boolean createMissing) {
* @param filePath - Path of the File
* @return - true if File exists else false
*/
public static boolean existsFile(@NotNull String filePath) {
public static boolean existsFile(String filePath) {
if(filePath == null) {
PathException pe = new PathException("filePath can't be null!", (String) null);
pe.printStackTrace();
return false;
}

return existsFile(filePath, false);
}

Expand All @@ -416,7 +450,13 @@ public static boolean existsFile(@NotNull String filePath) {
* @param createMissing - true if the function should create missing Files
* @return - true if the File exists (or was successfully created) else false
*/
public static boolean existsFile(@NotNull String filePath, boolean createMissing) {
public static boolean existsFile(String filePath, boolean createMissing) {
if(filePath == null) {
PathException pe = new PathException("filePath can't be null!", (String) null);
pe.printStackTrace();
return false;
}

java.io.File file = new java.io.File(filePath);

if(! file.exists()) {
Expand Down Expand Up @@ -447,7 +487,13 @@ public static boolean existsFile(@NotNull String filePath, boolean createMissing
* @param deleteOwn - Specify if it should delete itself too or just clearing
* @return - true on success else false
*/
private static boolean deleteDirectoryOperation(@NotNull String directoryPath, boolean recursive, boolean deleteOwn) {
private static boolean deleteDirectoryOperation(String directoryPath, boolean recursive, boolean deleteOwn) {
if(directoryPath == null) {
PathException pe = new PathException("directoryPath can't be null!", (String) null);
pe.printStackTrace();
return false;
}

java.io.File dir = new java.io.File(directoryPath);
java.io.File[] dirContent;

Expand Down Expand Up @@ -481,7 +527,7 @@ private static boolean deleteDirectoryOperation(@NotNull String directoryPath, b
* @param directoryPath - Path to the Directory
* @return - true on success else false
*/
public static boolean deleteDirectory(@NotNull String directoryPath) {
public static boolean deleteDirectory(String directoryPath) {
return File.deleteDirectoryOperation(directoryPath, true, true);
}

Expand All @@ -491,7 +537,7 @@ public static boolean deleteDirectory(@NotNull String directoryPath) {
* @param directoryPath - Path to the Directory
* @return - true on success else false
*/
public static boolean deleteFilesInDir(@NotNull String directoryPath) {
public static boolean deleteFilesInDir(String directoryPath) {
return File.deleteDirectoryOperation(directoryPath, false, false);
}

Expand All @@ -501,7 +547,13 @@ public static boolean deleteFilesInDir(@NotNull String directoryPath) {
* @param directoryPath - Path of the new Directory
* @return - true if a Directory was created else false
*/
public static boolean createDirectory(@NotNull String directoryPath) {
public static boolean createDirectory(String directoryPath) {
if(directoryPath == null) {
PathException pe = new PathException("directoryPath can't be null!", (String) null);
pe.printStackTrace();
return false;
}

java.io.File dir = new java.io.File(directoryPath);

return ! dir.exists() && dir.mkdirs();
Expand All @@ -513,7 +565,7 @@ public static boolean createDirectory(@NotNull String directoryPath) {
* @param directoryPath - Path to the Directory
* @return - true if Directory was cleared else false
*/
public static boolean clearDirectory(@NotNull String directoryPath) {
public static boolean clearDirectory(String directoryPath) {
return File.deleteDirectoryOperation(directoryPath, true, false);
}

Expand Down
Loading

0 comments on commit f422c51

Please sign in to comment.