Skip to content

Commit

Permalink
Second mirror implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Tech-FZ committed Aug 20, 2022
1 parent 8c0e1ac commit 9e74e12
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 10 deletions.
Binary file modified bin/randopackage/RandochooseMain$1.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$2.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$3.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$4.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$5.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain$6.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseMain.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdate$1.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdate.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdateStageTwo$2.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdateStageTwo$3.class
Binary file not shown.
Binary file added bin/randopackage/RandochooseUpdateStageTwo$4.class
Binary file not shown.
Binary file modified bin/randopackage/RandochooseUpdateStageTwo.class
Binary file not shown.
4 changes: 4 additions & 0 deletions doc/Changelog English.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Randochoose 0.2.2 Alpha
- Completion: 20th August, 2022
- It took me long to get into the mood to update Randochoose again, but the only change is that you can now choose if you rather want to get Randochoose from GitHub or from Codeberg.

Randochoose 0.2.1 Alpha
- Completion: 7th May, 2022
- The updater has been fixed.
Expand Down
8 changes: 5 additions & 3 deletions src/randopackage/RandochooseMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ public class RandochooseMain {

public static int majorVer = 0;
public static int minorVer1 = 2;
public static int minorVer2 = 1;
public static int minorVer2 = 2;

public static void main(String[] args) {
String link = "https://raw.githubusercontent.com/Tech-FZ/randochoose/main/vercheck.rdc";
String link2 = "https://codeberg.org/lucien-rowan/randochoose/raw/branch/main/vercheck.rdc";
File out = new File("vercheck.rdc");
new Thread(new RandochooseUpdate(link, out, false)).start();
new Thread(new RandochooseUpdate(link, link2, out, false)).start();

JFrame mainFrame = new JFrame();
mainFrame.setTitle("Randochoose");
Expand Down Expand Up @@ -65,8 +66,9 @@ public void actionPerformed(ActionEvent arg0) {
updateBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String link = "https://raw.githubusercontent.com/Tech-FZ/randochoose/main/vercheck.rdc";
String link2 = "https://codeberg.org/lucien-rowan/randochoose/raw/branch/main/vercheck.rdc";
File out = new File("vercheck.rdc");
new Thread(new RandochooseUpdate(link, out, true)).start();
new Thread(new RandochooseUpdate(link, link2, out, true)).start();
}
});

Expand Down
32 changes: 27 additions & 5 deletions src/randopackage/RandochooseUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public class RandochooseUpdate implements Runnable {
String link;
File out;
boolean manual;
String link2;

public RandochooseUpdate(String link, File out, boolean manual) {
public RandochooseUpdate(String link, String link2, File out, boolean manual) {
this.link = link;
this.link2 = link2;
this.out = out;
this.manual = manual;
}
Expand All @@ -44,7 +46,27 @@ public void run() {
}

catch (Exception e) {
noInternet();
try {
URL url = new URL(link2);
HttpURLConnection http = (HttpURLConnection)url.openConnection();
BufferedInputStream in = new BufferedInputStream(http.getInputStream());
FileOutputStream fos = new FileOutputStream(out);
BufferedOutputStream bout = new BufferedOutputStream(fos, 1024);
byte[] buffer = new byte[1024];
int read = 0;

while((read = in.read(buffer, 0, 1024)) >= 0) {
bout.write(buffer, 0, read);
}

bout.close();
in.close();
RandochooseUpdateStageTwo.checkStage(RandochooseMain.majorVer, RandochooseMain.minorVer1, RandochooseMain.minorVer2, this.manual);
}

catch (Exception ex) {
noInternet();
}
}

}
Expand All @@ -71,19 +93,19 @@ public static void noInternet() {
causeLbl2.setFont(new Font("Arial", 0, 14));
noEntryPanel.add(causeLbl2);

JLabel causeLbl3 = new JLabel("- If it still fails, your administrator might have blocked access to GitHub.");
JLabel causeLbl3 = new JLabel("- If it still fails, your administrator might have blocked access to GitHub and Codeberg.");
causeLbl3.setFont(new Font("Arial", 0, 14));
noEntryPanel.add(causeLbl3);

JLabel causeLbl4 = new JLabel(" Contact him or her for further information.");
causeLbl4.setFont(new Font("Arial", 0, 14));
noEntryPanel.add(causeLbl4);

JLabel causeLbl5 = new JLabel("- If these are all not the case, GitHub servers might be down at the moment.");
JLabel causeLbl5 = new JLabel("- If these are all not the case, GitHub and Codeberg servers might be down at the moment.");
causeLbl5.setFont(new Font("Arial", 0, 14));
noEntryPanel.add(causeLbl5);

JLabel causeLbl6 = new JLabel(" In this case, try again when GitHub is online again.");
JLabel causeLbl6 = new JLabel(" In this case, try again when GitHub and/or Codeberg are online again.");
causeLbl6.setFont(new Font("Arial", 0, 14));
noEntryPanel.add(causeLbl6);

Expand Down
27 changes: 25 additions & 2 deletions src/randopackage/RandochooseUpdateStageTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void newVerAvailable(int[] currVer, int[] latestVer) {
noticeLabel3.setFont(new Font("Arial", 0, 16));
noEntryPanel.add(noticeLabel3);

JLabel questionLbl = new JLabel("Do you want to be redirected to the GitHub repository of");
JLabel questionLbl = new JLabel("Do you want to be redirected to the GitHub or Codeberg repository of");
questionLbl.setFont(new Font("Arial", 0, 16));
noEntryPanel.add(questionLbl);

Expand All @@ -94,7 +94,7 @@ public static void newVerAvailable(int[] currVer, int[] latestVer) {

JPanel btnPanel = new JPanel(new GridLayout(1, 2, 10, 10));

JButton yesBtn = new JButton("Yes");
JButton yesBtn = new JButton("Yes, on GitHub");
yesBtn.setFont(new Font("Arial", 0, 14));

yesBtn.addActionListener(new ActionListener() {
Expand All @@ -117,6 +117,29 @@ public void actionPerformed(ActionEvent arg0) {

btnPanel.add(yesBtn);

JButton codebergBtn = new JButton("Yes, on Codeberg");
codebergBtn.setFont(new Font("Arial", 0, 14));

codebergBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Desktop desk = Desktop.getDesktop();

try {
desk.browse(new URI("https://codeberg.org/lucien-rowan/randochoose/releases"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

noEntryDialog.setVisible(false);
}
});

btnPanel.add(codebergBtn);

JButton noBtn = new JButton("No");
noBtn.setFont(new Font("Arial", 0, 14));

Expand Down

0 comments on commit 9e74e12

Please sign in to comment.