Skip to content

Commit

Permalink
CoronaUpdater 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tonikelope committed May 11, 2024
1 parent 26bc54f commit 2be8a4d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 28 deletions.
Binary file modified coronaupdater.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion coronaupdater/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>coronaupdater</artifactId>
<version>1.5</version>
<version>1.6</version>
<packaging>jar</packaging>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
Expand Down
82 changes: 55 additions & 27 deletions coronaupdater/src/main/java/com/tonikelope/coronaupdater/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Init extends javax.swing.JFrame {
public static final String USER_AGENT_WEB_BROWSER = "Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0";
public static volatile boolean MOD_UPDATE = false;
public static volatile boolean SPANISH = false;
public static volatile boolean ABORT_UPDATE = false;

/**
* Creates new form Init
Expand Down Expand Up @@ -71,6 +72,11 @@ private void initComponents() {
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setIconImage(new javax.swing.ImageIcon(getClass().getResource("/images/avatar_default.png")).getImage());
setUndecorated(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});

logo.setBackground(new java.awt.Color(255, 255, 255));
logo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
Expand Down Expand Up @@ -119,6 +125,14 @@ private void initComponents() {
pack();
}// </editor-fold>//GEN-END:initComponents

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:

if (Helpers.mostrarMensajeErrorSINO(this, SPANISH ? "¿SEGURO?" : "SURE?") == 0) {
ABORT_UPDATE = true;
}
}//GEN-LAST:event_formWindowClosing

/*
CORONAPOKER UPDATE PARAMS:
Expand Down Expand Up @@ -222,27 +236,33 @@ public void run() {

downloadMOD(ventana, args[3], zip_temp_file);

ZipFile zipFile;

if (!"".equals(args[4])) {
zipFile = new ZipFile(zip_temp_file, args[4].toCharArray());
if (ABORT_UPDATE) {
Files.move(Paths.get(args[0] + "_bak"), Paths.get(args[0]));
System.exit(1);
} else {
zipFile = new ZipFile(zip_temp_file);
}

zipFile.extractAll(args[0].replaceAll("/mod$", ""));
ZipFile zipFile;

if (!"".equals(args[4])) {
zipFile = new ZipFile(zip_temp_file, args[4].toCharArray());
} else {
zipFile = new ZipFile(zip_temp_file);
}

zipFile.extractAll(args[0].replaceAll("/mod$", ""));

StringBuilder java_bin = new StringBuilder();
StringBuilder java_bin = new StringBuilder();

java_bin.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java");
java_bin.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java");

String[] cmdArr = {java_bin.toString(), "-jar", args[2]};
String[] cmdArr = {java_bin.toString(), "-jar", args[2]};

Runtime.getRuntime().exec(cmdArr);
Runtime.getRuntime().exec(cmdArr);

Files.deleteIfExists(Paths.get(zip_temp_file));
Files.deleteIfExists(Paths.get(zip_temp_file));

Helpers.deleteDirectory(args[0] + "_bak");
Helpers.deleteDirectory(args[0] + "_bak");
}

} catch (Exception ex) {
ok = false;
Expand Down Expand Up @@ -278,15 +298,21 @@ public void run() {

downloadCoronaPoker(ventana, args[0], args[2]);

StringBuilder java_bin = new StringBuilder();
if (ABORT_UPDATE) {
Files.move(Paths.get(args[1] + ".bak"), Paths.get(args[1]));
System.exit(1);
} else {

StringBuilder java_bin = new StringBuilder();

java_bin.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java");
java_bin.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java");

String[] cmdArr = {java_bin.toString(), "-jar", args[2]};
String[] cmdArr = {java_bin.toString(), "-jar", args[2]};

Runtime.getRuntime().exec(cmdArr);
Runtime.getRuntime().exec(cmdArr);

Files.deleteIfExists(Paths.get(args[1] + ".bak"));
Files.deleteIfExists(Paths.get(args[1] + ".bak"));
}

} catch (Exception ex) {

Expand Down Expand Up @@ -351,20 +377,22 @@ public void run() {

int tot = 0;

while ((reads = bis.read(buffer)) != -1) {
while (!ABORT_UPDATE && (reads = bis.read(buffer)) != -1) {

bfos.write(buffer, 0, reads);
if (!ABORT_UPDATE) {
bfos.write(buffer, 0, reads);

tot += reads;
tot += reads;

int t = tot;
int t = tot;

Helpers.GUIRun(new Runnable() {
Helpers.GUIRun(new Runnable() {

public void run() {
ventana.getProgress_bar().setValue(t);
}
});
public void run() {
ventana.getProgress_bar().setValue(t);
}
});
}
}
}

Expand Down

0 comments on commit 2be8a4d

Please sign in to comment.