Skip to content
This repository has been archived by the owner on Jul 21, 2019. It is now read-only.

Commit

Permalink
Launcher version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-wall committed Jan 27, 2019
1 parent dd1fa0d commit cbb8841
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 331 deletions.
31 changes: 31 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2019. PKLite - All Rights Reserved
Unauthorized modification, distribution, or possession of source code, via any medium is strictly prohibited.
Proprietary and confidential. Refer to PKLite License file for more information on full terms of this copyright and to determine what constitutes authorized use.
Written by PKLite(ST0NEWALL, others) <stonewall@pklite.xyz>, 2019

RuneLite License:
BSD 2-Clause License

Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 changes: 25 additions & 0 deletions RuneLite License
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.pklite</groupId>
<artifactId>launcher</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>xyz.pklite</groupId>
<artifactId>launcher</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
25 changes: 9 additions & 16 deletions src/main/java/xyz/pklite/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import java.awt.Color;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import xyz.pklite.launcher.components.AppFrame;
import xyz.pklite.launcher.utils.LauncherUpdate;

public class Launcher
{
Expand All @@ -23,28 +26,18 @@ public class Launcher

public static void main(String[] main)
{
String webVersion = null;
try
{
webVersion = Unirest.get(Settings.VERSION_URL).asString().getBody();
}
catch (UnirestException e)
{
e.printStackTrace();
}


UIManager.put("Button.select", new Color(1.0f, 1.0f, 1.0f, 0.05f));
System.setProperty("awt.useSystemAAFontSettings", "on");
System.setProperty("swing.aatext", "true");

app = new AppFrame();

app.setVisible(true);
app.setLocationRelativeTo(null);
if (!Settings.LAUNCHER_VERSION.equals(webVersion))
{
JOptionPane.showMessageDialog(null,"PKLite launcher is outdated. Download the" +
" newest from the releases page on our github at " + Settings.RELEASES_URL);
//System.exit(0);
}
ExecutorService executorService = new ScheduledThreadPoolExecutor(1);
executorService.submit(new LauncherUpdate());


}
}
4 changes: 2 additions & 2 deletions src/main/java/xyz/pklite/launcher/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Settings
public static final String HOMEPAGE_URL = "pklite.xyz";
public static final String VERSION_URL = "https://www.pklite.xyz/releases/launcher";
public static final String RELEASES_URL = "https://github.com/pklite/PKLite-Launcher/releases";
public static final String LAUNCHER_VERSION = "1.0.1";
public static final int NEWS_LIMIT = 3;
public static final String LAUNCHER_VERSION = "1.0.2";
public static final int NEWS_LIMIT = 4;

public static final Dimension frameSize = new Dimension(600, 350);
public static final Color borderColor = new Color(0, 0, 0);
Expand Down
109 changes: 59 additions & 50 deletions src/main/java/xyz/pklite/launcher/components/AppFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.awt.event.MouseMotionAdapter;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
Expand All @@ -42,6 +44,7 @@ public class AppFrame extends JFrame

public AppFrame()
{

setPreferredSize(Settings.frameSize);

appWidth = (int) getPreferredSize().getWidth();
Expand All @@ -54,7 +57,9 @@ public AppFrame()
getContentPane().setBackground(Settings.backgroundColor);

addMenuBar();
addNewsBox();
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(this::addNewsBox);

addLinks();
addHeader();
addPlayButton();
Expand All @@ -63,6 +68,7 @@ public AppFrame()
setIconImage(Utils.getImage("favicon_large.png").getImage());
addMouseListener();
pack();

}

public static JProgressBar pbar;
Expand Down Expand Up @@ -142,58 +148,61 @@ private void addLinks()

private void addNewsBox()
{
final int red = Settings.primaryColor.getRed();
final int green = Settings.primaryColor.getGreen();
final int blue = Settings.primaryColor.getBlue();

JLabel status1 = new JLabel(Settings.PROJECT_NAME + ": Open Source PvP Client");
status1.setForeground(Settings.primaryColor);
status1.setHorizontalAlignment(SwingConstants.CENTER);
status1.setBounds(0, 75, appWidth, 75);
Utils.setFont(status1, "OpenSans-Light.ttf", 28);
add(status1);
JLabel status2 = new JLabel("<html><h3>Latest news:</h3></html>");
status2.setForeground(Color.WHITE);
status2.setHorizontalAlignment(SwingConstants.CENTER);
status2.setBounds(0, 132, appWidth, 30);
Utils.setFont(status2, "OpenSans-Light.ttf", 16);
add(status2);


try
{
HttpResponse<JsonNode> newsFeedResponse = Unirest.get("https://www.pklite.xyz/wp-json/wp/v2/posts").asJson();
for (int i = 0; i < Settings.NEWS_LIMIT; i++)


final int red = Settings.primaryColor.getRed();
final int green = Settings.primaryColor.getGreen();
final int blue = Settings.primaryColor.getBlue();

JLabel status1 = new JLabel(Settings.PROJECT_NAME + ": Open Source PvP Client");
status1.setForeground(Settings.primaryColor);
status1.setHorizontalAlignment(SwingConstants.CENTER);
status1.setBounds(0, 75, appWidth, 75);
Utils.setFont(status1, "OpenSans-Light.ttf", 28);
add(status1);
JLabel status2 = new JLabel("<html><h3>Latest news:</h3></html>");
status2.setForeground(Color.WHITE);
status2.setHorizontalAlignment(SwingConstants.CENTER);
status2.setBounds(0, 132, appWidth, 30);
Utils.setFont(status2, "OpenSans-Light.ttf", 16);
add(status2);


try
{
JLabel newsLabel = new JLabel();
String newsEntry = "<html>";
String date = newsFeedResponse.getBody().getArray().getJSONObject(i).getString("date");
Date date1 = java.util.Date.from(Instant.parse(date + "Z"));
String link = newsFeedResponse.getBody().getArray().getJSONObject(i).getString("link");
String title = newsFeedResponse.getBody().getArray().getJSONObject(i).getJSONObject("title").getString("rendered");
String postDate = Utils.dateFormat.format(date1);
newsEntry += postDate + ": ";
newsEntry += title;
newsEntry += "</html>";
newsLabel.setText(newsEntry);
newsLabel.setForeground(Color.WHITE);
newsLabel.setHorizontalAlignment(SwingConstants.CENTER);
newsLabel.setBounds(0, 160 + (30 * i), appWidth, 30);
newsLabel.addMouseListener(new NewsLinkListener(link, newsLabel));
Utils.setFont(newsLabel, "OpenSans-Light.ttf", 14);
add(newsLabel);
HttpResponse<JsonNode> newsFeedResponse = Unirest.get("https://www.pklite.xyz/wp-json/wp/v2/posts").asJson();
for (int i = 0; i < Settings.NEWS_LIMIT; i++)
{
JLabel newsLabel = new JLabel();
String newsEntry = "<html>";
String date = newsFeedResponse.getBody().getArray().getJSONObject(i).getString("date");
Date date1 = java.util.Date.from(Instant.parse(date + "Z"));
String link = newsFeedResponse.getBody().getArray().getJSONObject(i).getString("link");
String title = newsFeedResponse.getBody().getArray().getJSONObject(i).getJSONObject("title").getString("rendered");
String postDate = Utils.dateFormat.format(date1);
newsEntry += postDate + ": ";
newsEntry += title;
newsEntry += "</html>";
newsLabel.setText(newsEntry);
newsLabel.setForeground(Color.WHITE);
newsLabel.setHorizontalAlignment(SwingConstants.CENTER);
newsLabel.setBounds(0, 160 + (30 * i), appWidth, 30);
newsLabel.addMouseListener(new NewsLinkListener(link, newsLabel));
Utils.setFont(newsLabel, "OpenSans-Light.ttf", 14);
add(newsLabel);
repaint();
}
}
}
catch (UnirestException e)
{
e.printStackTrace();
status2.setText("Error fetching news feed");
status2.repaint();
}
catch (JSONException e)
{
catch (UnirestException e)
{
e.printStackTrace();
status2.setText("Error fetching news feed");
status2.repaint();
}
catch (JSONException e)
{

}
}
}

private void addMenuBar()
Expand Down
36 changes: 14 additions & 22 deletions src/main/java/xyz/pklite/launcher/listeners/ButtonListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import xyz.pklite.launcher.Launcher;
import xyz.pklite.launcher.Settings;
import xyz.pklite.launcher.components.AppFrame;
import xyz.pklite.launcher.net.Download;
import xyz.pklite.launcher.net.NIODownload;
import xyz.pklite.launcher.net.Update;
import xyz.pklite.launcher.utils.Utils;

public class ButtonListener implements ActionListener
{

private static Download download;

@Override
public void actionPerformed(ActionEvent e)
Expand All @@ -43,6 +44,7 @@ public void actionPerformed(ActionEvent e)
AppFrame.pbar.setString("Checking for Client Updates...");

byte status = Update.updateExists();
System.out.println(status);
if (status == 0)
{
AppFrame.pbar.setString("Now Launching " + Settings.PROJECT_NAME + "!");
Expand All @@ -51,29 +53,19 @@ public void actionPerformed(ActionEvent e)
}
if (status == 1 || status == 3)
{
if (download == null)
try
{
download = new Download(Settings.DOWNLOAD_URL);
download.download();
NIODownload nioDownload = new NIODownload(Settings.DOWNLOAD_URL);
Future future = Executors.newSingleThreadExecutor().submit(nioDownload);
future.get();
AppFrame.pbar.setString("Update successful!");
Utils.launchClient();
}
else

catch (Exception e1)
{
switch (download.getStatus())
{
case Download.COMPLETE:
return;
case Download.DOWNLOADING:
download.pause();
break;
case Download.PAUSED:
download.resume();
break;
case Download.ERROR:
JOptionPane.showMessageDialog(Launcher.app,
"Eggs are not supposed to be green.",
"Inane error",
JOptionPane.ERROR_MESSAGE);
}
JOptionPane.showMessageDialog(null, e1.getMessage(),
"Error!", JOptionPane.ERROR_MESSAGE);
}
}
});
Expand Down
Loading

0 comments on commit cbb8841

Please sign in to comment.