Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hyperdefined/CustomLauncherRewrite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.9.2
Choose a base ref
...
head repository: hyperdefined/CustomLauncherRewrite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
2 changes: 1 addition & 1 deletion linux/customlauncherrewrite.desktop
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
Type=Application
Name=CustomLauncherRewrite
Comment=An all purpose custom TTR launcher.
Path=/opt/CustomLauncherRewrite
Path={INSTALL_DIR}
Icon=customlauncherrewrite-icon.png
Exec=bash run.sh
Terminal=false
20 changes: 12 additions & 8 deletions linux/installer.sh
Original file line number Diff line number Diff line change
@@ -19,24 +19,28 @@
# taken from https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8
DOWNLOADURL=$(curl -s https://api.github.com/repos/hyperdefined/CustomLauncherRewrite/releases/latest | grep "browser_download_url" | grep "tar.gz" | cut -d '"' -f 4)
OUTPUTFILE=${DOWNLOADURL##*/}
INSTALLDIR=/opt/CustomLauncherRewrite #In case support for a custom install directory is added

echo "Downloading latest version from ""$DOWNLOADURL"""

wget -q -P /tmp/ "$DOWNLOADURL"

echo "CustomLauncherRewrite will install itself to /opt/CustomLauncherRewrite by default. If you want to specify a different directory, enter one below."
echo "If you want to leave it default, just press enter."
read -r -p "Enter the installation directory (will create folder): " USER_INSTALLDIR < /dev/tty
INSTALLDIR=${USER_INSTALLDIR:-/opt/CustomLauncherRewrite}
echo "Creating $INSTALLDIR...".
sudo mkdir -p $INSTALLDIR
sudo mkdir -p "$INSTALLDIR"
echo "$INSTALLDIR" > ~/.customlauncherrewrite-location

echo "Extracting ""$OUTPUTFILE""..."
sudo tar -xf /tmp/"$OUTPUTFILE" -C $INSTALLDIR
sudo tar -xf /tmp/"$OUTPUTFILE" -C "$INSTALLDIR"

echo "Downloading desktop entry..."
# Create the icons directory just in case it doesn't exist
# Save the icon for the launcher
mkdir -p ~/.local/share/icons/
wget -q -O ~/.local/share/icons/customlauncherrewrite-icon.png https://raw.githubusercontent.com/hyperdefined/CustomLauncherRewrite/master/src/main/resources/icon.png
sudo wget -q -P /usr/share/applications https://raw.githubusercontent.com/hyperdefined/CustomLauncherRewrite/master/linux/customlauncherrewrite.desktop
sudo sed -i "s|{INSTALL_DIR}|$INSTALLDIR|g" /usr/share/applications/customlauncherrewrite.desktop

# Find the user's desktop
if command -v xdg-user-dir >/dev/null 2>&1; then
@@ -48,15 +52,15 @@ fi

# Symlink on desktop (e.g. desktop shortcut)
ln -s /usr/share/applications/customlauncherrewrite.desktop "$DESKTOP_DIR/customlauncherrewrite.desktop"
sudo chmod +x "$DESKTOP_DIR/customlauncherrewrite.desktop"
sudo chown "$USER":"$USER" "$DESKTOP_DIR/customlauncherrewrite.desktop"
chmod +x "$DESKTOP_DIR/customlauncherrewrite.desktop"

# Make sure the user owns the folder to run
echo "Setting correct perms to install location..."
sudo chown -R "$USER":"$USER" $INSTALLDIR
sudo chmod -R 755 $INSTALLDIR
sudo chown -R "$USER":"$USER" "$INSTALLDIR"
sudo chmod -R 755 "$INSTALLDIR"

# Delete any temp files
rm -rf /tmp/CustomLauncherRewrite*

echo "CustomLauncherRewrite has been installed!"
echo "CustomLauncherRewrite has been installed!"
14 changes: 13 additions & 1 deletion linux/run.sh
Original file line number Diff line number Diff line change
@@ -19,7 +19,19 @@
# Check if Java is installed and the version is at least 17
if (( $(java -version 2>&1 | grep -Po '(?<=")[0-9]{2}') >= 17 )); then
latest=$(find . -name "CustomLauncherRewrite-*.jar" -type f -printf "%T@ %p\n" | sort -nr | head -n1 | cut -d' ' -f2-)
java -jar "$latest"
java -jar "$latest" &
pid=$!

# This is only needed as I've see the jar run in the background and not get closed
cleanup() {
if kill -0 $pid 2>/dev/null; then
echo "Killing CustomLauncherRewrite for cleanup, process $pid"
kill $pid
fi
}

trap cleanup EXIT
wait $pid
else
if command -v notify-send &> /dev/null; then
notify-send -i stop "CustomLauncherRewrite" "Please update Java JRE to version 17 or higher!"
46 changes: 35 additions & 11 deletions linux/uninstaller.sh
Original file line number Diff line number Diff line change
@@ -16,27 +16,51 @@
# along with CustomLauncherRewrite. If not, see <https://www.gnu.org/licenses/>.
#

read -r -p "Before we uninstall, would you like to keep your TTR files? These include screenshots and resource packs. Enter 'Y' to keep them, 'N' to wipe them.: " input
read -r -p "Before we uninstall, would you like to keep your TTR files? These include screenshots and resource packs. Enter 'Y' to keep them, 'N' to wipe them.: " input < /dev/tty

# Convert to uppercase
input=$(echo "$input" | tr -d '[:space:]' | tr '[:lower:]' '[:upper:]')

if [ "$input" != "Y" ]; then
keep_ttr_files=false
else
keep_ttr_files=true
fi

# Read the install location
INSTALL_DIR=$(head -n1 ~/.customlauncherrewrite-location)

# Make sure the location is valid
if [ -z "$INSTALL_DIR" ]; then
echo "Installation location cannot be determined! Using default..."
INSTALL_DIR="/opt/CustomLauncherRewrite"
fi

# Delete all files in the root of the install location
sudo find "$INSTALL_DIR" -maxdepth 1 -type f -delete

if $keep_ttr_files; then
echo "Removing /opt/CustomLauncherRewrite but keeping TTR files..."
# remove everything but ttr-files folder
sudo find /opt/CustomLauncherRewrite/* -type d -not -name 'ttr-files' -exec rm -rf {} +
sudo rm /opt/CustomLauncherRewrite/CustomLauncherRewrite*
sudo rm /opt/CustomLauncherRewrite/run.sh
else
echo "Removing /opt/CustomLauncherRewrite..."
sudo rm -r /opt/CustomLauncherRewrite
echo "Removing $INSTALL_DIR but keeping TTR files..."
# Remove all folders but ttr-files folder
sudo find "$INSTALL_DIR" -mindepth 1 -maxdepth 1 -type d -not -name "ttr-files" -exec rm -rf {} +
else
# Remove the entire directory
echo "Removing $INSTALL_DIR..."
sudo rm -r "$INSTALL_DIR"
fi

# Find the user's desktop
if command -v xdg-user-dir >/dev/null 2>&1; then
DESKTOP_DIR=$(xdg-user-dir DESKTOP)
else
# If xdg-user-dir is not installed, just try to guess it
DESKTOP_DIR=~/Desktop
fi

echo "Removing the desktop entry..."
sudo rm ~/Desktop/customlauncherrewrite.desktop
sudo rm "$DESKTOP_DIR/customlauncherrewrite.desktop"
rm ~/.local/share/icons/customlauncherrewrite-icon.png
sudo rm /usr/share/applications/customlauncherrewrite.desktop
rm ~/.customlauncherrewrite-location

echo "CustomLauncherRewrite has been uninstalled!"
echo "CustomLauncherRewrite has been uninstalled!"
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -27,15 +27,15 @@
<packaging>jar</packaging>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
<executions>
<execution>
<id>auto-clean</id>
@@ -49,7 +49,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
@@ -81,7 +81,7 @@
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
<executions>
<execution>
<id>l4j-clui</id>
@@ -93,7 +93,7 @@
<headerType>gui</headerType>
<jar>${project.build.directory}/CustomLauncherRewrite-${project.version}.jar</jar>
<outfile>${project.build.directory}/CustomLauncherRewrite-${project.version}.exe</outfile>
<downloadUrl>https://adoptium.net/releases.html?variant=openjdk17&amp;jvmVariant=hotspot
<downloadUrl>https://adoptium.net/releases.html?variant=openjdk21&amp;jvmVariant=hotspot
</downloadUrl>
<icon>src/main/resources/icon.ico</icon>
<classPath>
@@ -150,22 +150,22 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20240303</version>
<version>20250517</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.2</version>
<version>1.27.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
<version>5.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -180,12 +180,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.23.1</version>
<version>2.25.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.17.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
@@ -205,7 +205,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>24.1.0</version>
<version>26.0.2</version>
</dependency>
</dependencies>

12 changes: 6 additions & 6 deletions src/main/java/lol/hyper/customlauncher/ConfigHandler.java
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ public void loadConfig(boolean log) {
JSONUtils.writeFile(configJSON, CONFIG_FILE);
}
if (configJSON.getInt("version") != CONFIG_VERSION) {
logger.warn("Config version is not correct! Somethings will not work correctly. Version should be " + CONFIG_VERSION + " but read " + configJSON.getInt("version"));
logger.warn("Config version is not correct! Somethings will not work correctly. Version should be " + CONFIG_VERSION + " but read {}", configJSON.getInt("version"));
}
}
setDefaults();
@@ -163,7 +163,7 @@ public void loadConfig(boolean log) {
if (!(installPath.exists())) {
try {
Files.createDirectory(installPath.toPath());
logger.info("Creating TTR install folder at " + installPath);
logger.info("Creating TTR install folder at {}", installPath);
new FirstLaunch();
} catch (IOException exception) {
logger.error("Cannot create TTR folder!", exception);
@@ -172,10 +172,10 @@ public void loadConfig(boolean log) {
}

if (log) {
logger.info("Config version: " + configJSON.getInt("version"));
logger.info("showInvasionNotifications: " + invasionNotifications);
logger.info("showFieldOfficeNotifications: " + fieldOfficeNotifications);
logger.info("ttrInstallLocation: " + installPath.getAbsolutePath());
logger.info("Config version: {}", configJSON.getInt("version"));
logger.info("showInvasionNotifications: {}", invasionNotifications);
logger.info("showFieldOfficeNotifications: {}", fieldOfficeNotifications);
logger.info("ttrInstallLocation: {}", installPath.getAbsolutePath());
}
}
}
Original file line number Diff line number Diff line change
@@ -74,8 +74,8 @@ public static void main(String[] args) {
logger = LogManager.getLogger(CustomLauncherRewrite.class);

logger.info("Program is starting.");
logger.info("Running version " + version);
logger.info("Current directory " + System.getProperty("user.dir"));
logger.info("Running version {}", version);
logger.info("Current directory {}", System.getProperty("user.dir"));

userAgent = "CustomLauncherRewrite https://github.com/hyperdefined/CustomLauncherRewrite " + version;

@@ -100,10 +100,10 @@ public static void main(String[] args) {
try {
Files.delete(new File("CustomLauncherRewrite-" + oldVersion + ".exe").toPath());
} catch (IOException exception) {
logger.error("Unable to delete old version " + oldVersion);
logger.error("Unable to delete old version {}", oldVersion);
new ExceptionWindow(exception);
}
logger.info("Deleting old version " + oldVersion);
logger.info("Deleting old version {}", oldVersion);
}
}

@@ -118,7 +118,7 @@ public static void main(String[] args) {
try {
Files.delete(currentFile.toPath());
} catch (IOException exception) {
logger.error("Unable to delete file " + currentFile.getAbsolutePath(), exception);
logger.error("Unable to delete file {}", currentFile.getAbsolutePath(), exception);
new ExceptionWindow(exception);
}
}
@@ -135,7 +135,7 @@ public static void main(String[] args) {
File configFolder = new File("config");
try {
if (!configFolder.exists()) {
logger.info("Config folder is missing, making folder at " + configFolder.getAbsolutePath());
logger.info("Config folder is missing, making folder at {}", configFolder.getAbsolutePath());
if (configFolder.mkdir()) {
logger.info("Config folder created!");
} else {
9 changes: 6 additions & 3 deletions src/main/java/lol/hyper/customlauncher/FirstLaunch.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public FirstLaunch() {
new PopUpWindow(null, "Welcome to CustomLauncherRewrite! I am first going to detect for an existing TTR install.\n I will copy screenshots, settings, and resource packs.");
if (OSDetection.isLinux()) {
copyLinuxInstall();
} else if (OSDetection.isWindows()){
} else if (OSDetection.isWindows()) {
copyWindowsInstall();
}
}
@@ -65,7 +65,7 @@ private void copyWindowsInstall() {
new PopUpWindow(null, "I am unable to find your TTR install location. You'll have to manually copy things over that you wish to keep.");
return;
}
logger.info("Found existing TTR install at " + windowsInstall);
logger.info("Found existing Windows TTR install at {}", windowsInstall);
copyFiles(windowsInstall);
}

@@ -79,7 +79,7 @@ private void copyLinuxInstall() {
new PopUpWindow(null, "I am unable to find your TTR install location. You'll have to manually copy things over that you wish to keep.");
return;
}
logger.info("Found existing TTR install at " + linuxInstall);
logger.info("Found existing Linux TTR install at {}", linuxInstall);
copyFiles(linuxInstall);
}

@@ -96,12 +96,15 @@ private void copyFiles(File source) {
File newInstall = new File("ttr-files");
try {
if (settings.exists()) {
logger.info("Copying {} --> {}{}settings.json", settings.getAbsolutePath(), newInstall.getAbsolutePath(), File.separator);
FileUtils.copyFileToDirectory(settings, newInstall);
}
if (resourcePacks.exists()) {
logger.info("Copying {} --> {}{}resources", resourcePacks.getAbsolutePath(), newInstall.getAbsolutePath(), File.separator);
FileUtils.copyDirectory(resourcePacks, new File(newInstall, "resources"));
}
if (screenshots.exists()) {
logger.info("Copying {} --> {}{}screenshots", screenshots.getAbsolutePath(), newInstall.getAbsolutePath(), File.separator);
FileUtils.copyDirectory(screenshots, new File(newInstall, "screenshots"));
}
} catch (IOException exception) {
4 changes: 2 additions & 2 deletions src/main/java/lol/hyper/customlauncher/accounts/Accounts.java
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ private void loadAccountsFromFile() {
}

if (accountType == null) {
logger.warn("Unknown account version " + version + " for account " + username);
logger.warn("Unknown account version {} for account {}", version, username);
logger.warn("Account data was modified? Skipping this account");
new PopUpWindow(null, "The account " + username + " has an invalid version number: " + version + ". This means that the account data was modified. This account will not be loaded.");
continue;
@@ -149,7 +149,7 @@ private void loadAccountsFromFile() {
// this will convert the old accounts system over
writeAccounts();
}
logger.info("Loaded " + accounts.size() + " accounts");
logger.info("Loaded {} accounts", accounts.size());
logger.info(accounts);
}

Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ private void makeRequest() {
if (configHandler.showFieldOfficeNotifications()) {
showNotification(office, true);
}
logger.info("Tracking new field office for " + fieldOfficeZone + ". Stars: " + difficulty + ". Annexes: " + totalAnnexes + ". Open: " + open);
logger.info("Tracking new field office for {}. Stars: {}. Annexes: {}. Open: {}", fieldOfficeZone, difficulty, totalAnnexes, open);
}
}

@@ -257,7 +257,7 @@ private void makeRequest() {
showNotification(pair.getValue(), false);
}
it.remove();
logger.info("Removing saved field office for " + key);
logger.info("Removing saved field office for {}", key);
}
}
runs++;
Loading