This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03bcc06
commit 148826a
Showing
1,846 changed files
with
9,445 additions
and
20,881 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
130 changes: 7 additions & 123 deletions
130
application-main/src/main/java/com/zyneonstudios/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,134 +1,18 @@ | ||
package com.zyneonstudios; | ||
|
||
import com.zyneonstudios.application.Application; | ||
import com.zyneonstudios.application.installer.java.Architecture; | ||
import com.zyneonstudios.application.installer.java.OperatingSystem; | ||
import com.zyneonstudios.application.utils.ZLogger; | ||
import com.zyneonstudios.application.utils.frame.ZyneonSplash; | ||
import live.nerotv.shademebaby.ShadeMeBaby; | ||
import live.nerotv.shademebaby.utils.FileUtil; | ||
|
||
import java.io.File; | ||
import java.net.URLDecoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import com.zyneonstudios.application.frame.ZyneonSplash; | ||
import com.zyneonstudios.application.main.NexusApplication; | ||
import com.zyneonstudios.nexus.desktop.NexusDesktop; | ||
|
||
public class Main { | ||
|
||
private static String applicationPath; | ||
public static ZyneonSplash splash; | ||
private static ZLogger logger; | ||
public static String version; | ||
public static OperatingSystem operatingSystem; | ||
public static Architecture architecture; | ||
private static boolean test = false; | ||
public static ZyneonSplash splash = null; | ||
|
||
public static void main(String[] args) { | ||
splash = new ZyneonSplash(); | ||
splash.setVisible(true); | ||
FileUtil.deleteFolder(new File(getDirectoryPath()+"temp/")); | ||
version = "2024.8.1f"; | ||
ArrayList<String> arguments = new ArrayList<>(); | ||
String name = "Neo Primalia"; | ||
architecture = getArchitecture(); | ||
logger = new ZLogger("ZYNEON"); | ||
String fullVersion = version+" ▪ "+name; | ||
logger.log("[MAIN] Updated user interface: "+update()); | ||
boolean online = false; | ||
for(String arg:args) { | ||
arg = arg.toLowerCase(); | ||
switch (arg) { | ||
case "--test" -> { | ||
test = true; | ||
version = new SimpleDateFormat("yyyy.M.d-HHmmss").format(Calendar.getInstance().getTime()); | ||
name = "Test"; | ||
fullVersion = version+" ▪ "+name; | ||
} | ||
case "--debug" -> { | ||
logger.setDebugEnabled(true); | ||
ShadeMeBaby.getLogger().setDebugEnabled(true); | ||
} | ||
case "--online" -> online = true; | ||
} | ||
} | ||
arguments.add(fullVersion); | ||
System.gc(); | ||
logger.log("[MAIN] Launching Zyneon Application version "+fullVersion+"..."); | ||
Application application = new Application(arguments); | ||
application.start(online); | ||
} | ||
|
||
public static ZLogger getLogger() { | ||
return logger; | ||
} | ||
|
||
private static boolean update() { | ||
boolean updated; | ||
try { | ||
new File(getDirectoryPath() + "libs/zyneon/instances.json").delete(); | ||
logger.log("[MAIN] Deleted old user interface files: " + new File(getDirectoryPath() + "libs/zyneon/").mkdirs()); | ||
logger.log("[MAIN] Created new user interface extraction folder: " + new File(getDirectoryPath() + "temp/ui/").mkdirs()); | ||
FileUtil.extractResourceFile("content.zip",getDirectoryPath()+"temp/content.zip",Main.class); | ||
FileUtil.unzipFile(getDirectoryPath()+"temp/content.zip", getDirectoryPath() + "temp/ui"); | ||
logger.log("[MAIN] Deleted user interface archive: " + new File(getDirectoryPath()+"temp/content.zip").delete()); | ||
updated = true; | ||
} catch (Exception e) { | ||
logger.error("[MAIN] Couldn't update application user interface: "+e.getMessage()); | ||
updated = false; | ||
} | ||
logger.log("[MAIN] Deleted old updater json: " + new File(getDirectoryPath() + "updater.json").delete()); | ||
logger.log("[MAIN] Deleted old version json: " + new File(getDirectoryPath() + "version.json").delete()); | ||
return updated; | ||
} | ||
|
||
public static String getDirectoryPath() { | ||
if (applicationPath == null) { | ||
String folderName = "Zyneon/Application"; | ||
String appData; | ||
String os = System.getProperty("os.name").toLowerCase(); | ||
if (os.contains("win")) { | ||
operatingSystem = OperatingSystem.Windows; | ||
appData = System.getenv("LOCALAPPDATA"); | ||
} else if (os.contains("mac")) { | ||
operatingSystem = OperatingSystem.macOS; | ||
appData = System.getProperty("user.home") + "/Library/Application Support"; | ||
} else { | ||
operatingSystem = OperatingSystem.Linux; | ||
appData = System.getProperty("user.home") + "/.local/share"; | ||
} | ||
Path folderPath = Paths.get(appData, folderName); | ||
try { | ||
Files.createDirectories(folderPath); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e.getMessage()); | ||
} | ||
applicationPath = folderPath + "/"; | ||
} | ||
return URLDecoder.decode(applicationPath, StandardCharsets.UTF_8); | ||
} | ||
|
||
private static Architecture getArchitecture() { | ||
String os = System.getProperty("os.arch"); | ||
ArrayList<String> aarch = new ArrayList<>(); | ||
aarch.add("ARM"); | ||
aarch.add("ARM64"); | ||
aarch.add("aarch64"); | ||
aarch.add("armv6l"); | ||
aarch.add("armv7l"); | ||
for(String arch_os:aarch) { | ||
if(arch_os.equalsIgnoreCase(os)) { | ||
return Architecture.aarch64; | ||
} | ||
} | ||
return Architecture.x64; | ||
} | ||
|
||
public static boolean isTest() { | ||
return test; | ||
NexusDesktop.getLogger().setName("APP",true); | ||
NexusDesktop.init(); | ||
new NexusApplication(args).launch(); | ||
} | ||
} |
Oops, something went wrong.