Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • ragnoroker: Join RuneGuild Today - New Server - Double exp + lots of events this weekend! - JOIN NOW - [link]
      Today at 03:54:49 PM
    • ragnoroker: Join RuneGuild Today - New Server - Double exp + lots of events this weekend! - JOIN NOW - [link]
      Today at 03:54:46 PM
    • hardcore22: are there any kind of silabsoft servers like back in the days i miss that
      May 25, 2020, 05:44:08 AM
    • Amcora: @ dr house contact me; greetings celien :)
      May 24, 2020, 03:16:21 PM
    • Amcora: Stop shouting around please
      May 24, 2020, 03:13:26 PM
    • iddsyou: PkOwnage OSRSPS [link]  Join us on Discord! [link]  Download: [link]
      May 17, 2020, 11:44:17 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ PLAYERS BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:48:19 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ PLAYERS BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:48:12 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ PLAYERS BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:47:56 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ PLAYERS BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:47:49 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ PLAYERS BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:47:42 AM
    • Decimate Returns: PROJECT DECIMATE RETURNS !! 300+ BACK IN 2012 - NOW WITH ALOT OF UPDATES ! JOIN NOW! [link]
      May 17, 2020, 02:47:29 AM
    • ragnoroker: BRAND NEW SERVER - PRE EOC - UNIQUE - JOIN TODAY :) - [link]
      May 15, 2020, 11:18:03 AM
    • ragnoroker: BRAND NEW SERVER - PRE EOC - UNIQUE - JOIN TODAY :) - [link]
      May 15, 2020, 11:17:53 AM
    • ragnoroker: BRAND NEW SERVER - PRE EOC - UNIQUE - JOIN TODAY :) - [link]
      May 15, 2020, 11:17:50 AM
    • Decimate Returns: Project Decimate 474 OSRS ; [link]
      May 13, 2020, 07:27:00 PM
    • hardcore22: are there any silabsoft servers left? of the good old days like hackscape
      May 12, 2020, 07:53:18 AM
    • iddsyou: yo guys check out this instagram post #pkownage  [link]
      May 06, 2020, 02:35:58 PM
    • fishingsheep: any servers like project catasrophe or frugoo scape been remade ?
      May 04, 2020, 05:01:00 PM
    • asshole_rule: relmitos the legend
      May 04, 2020, 04:28:54 PM

    Author Topic: [Any] Client Launcher/Updater  (Read 7305 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineFox2007

    • Member
    • ****
    • Posts: 567
    • Thanks: +0/-0
      • View Profile
    [Any] Client Launcher/Updater
    « on: February 24, 2014, 12:10:22 AM »
    First, no I did not choose to livestream the jar file, this would consume a lot of bandwidth on large servers and some people use shitty hosting with limited bandwidth. This was also just something I made in my spare time to learn something about swing, so please no hate ;_;

    You could also use this to get rid of the shitty checking in most 317 clients where you have to change a number and all that other shit. This will compare dates to the file stored online, and if It's newer it will prompt you for the download. Works only for clients, not the cache.
    ----------
    Preview:
    (click to show/hide)


    First, you need to make a new folder, call it whatever you like. Then inside, you need to make this structure:


    • Main Folder
      -- bin/ (output folder)
      -- src/
      ---- Launcher.java
      ---- Splash.java
    Splash.java:
    Code: Java
    1. importjavax.swing.*;
    2.  /**
    3.   * @author King Fox
    4.   */
    5. publicclass Launcher {
    6.    
    7.     publicstaticvoid main(String[] args){
    8.         final Splash s =new Splash();
    9.          s.setVisible(true);
    10.          SwingUtilities.invokeLater(newRunnable(){
    11.              publicvoid run()  {
    12.                   s.setVisible(true);
    13.              }
    14.          });
    15.     }
    16.  
    17. }
    18.  

    Launcher.java:
    Code: Java
    1. importjavax.swing.*;
    2.  
    3.  
    4. importjava.awt.*;
    5. importjava.io.*;
    6. importjavax.swing.*;
    7. importjava.io.*;
    8. importjava.net.*;
    9.  
    10. @SuppressWarnings("serial")
    11. publicclass Splash extendsJFrame{
    12.  
    13. // START EDIT
    14.    privatestaticString downloadUrl =";; // the download url
    15.   private static String fileName = "SomeJar.jar"; // the name you wish to save it as
    16.   private static String serverName = "Foxtrot"; // the server name
    17.   private static String backgroundImageUrl = ";;// url to a background image
    18.    privatestaticString saveDirectory =System.getProperty("user.home")+"/Desktop/";// the location where you wish to store the Jar
    19. // END EDIT
    20.  
    21.    publicstaticURL url;
    22.    privateJLabel imglabel;
    23.    privateImageIcon img;
    24.    privatestaticJProgressBar pbar;
    25.    Thread t =null;
    26.  
    27.    public Splash(){
    28.       super("Splash");
    29.        
    30.       File file =newFile(saveDirectory + fileName);
    31.        
    32.       try{
    33.          url =newURL(downloadUrl);
    34.       }catch(MalformedURLException e){
    35.          e.printStackTrace();
    36.       }
    37.      
    38.       setSize(543, 391);
    39.       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    40.       setLocationRelativeTo(null);
    41.       setUndecorated(true);
    42.        
    43.       try{
    44.          img =newImageIcon(newURL(backgroundImageUrl));
    45.       }catch(MalformedURLException e1){
    46.          e1.printStackTrace();
    47.       }
    48.        
    49.       imglabel =newJLabel(img);
    50.       add(imglabel);
    51.       setLayout(null);
    52.       pbar =newJProgressBar();
    53.       pbar.setMinimum(0);
    54.       pbar.setMaximum(100);
    55.       pbar.setStringPainted(true);
    56.       pbar.setForeground(Color.LIGHT_GRAY);
    57.       imglabel.setBounds(0, 0, 543, 391);
    58.       add(pbar);
    59.       pbar.setPreferredSize(newDimension(310, 30));
    60.       pbar.setBounds(70, 320, 404, 20);
    61.  
    62.  
    63.       try{
    64.          if(file.exists()){
    65.             URLConnection connection = url.openConnection();
    66.             connection.connect();
    67.             long time = connection.getLastModified();
    68.             if(time > file.lastModified()){
    69.                if(!startDialogue()){
    70.                   startApplication();
    71.                   return;
    72.                }
    73.             }else{
    74.                setVisible(true);
    75.                Thread.sleep(3000);
    76.                startApplication();
    77.                return;
    78.             }
    79.          }
    80.       }catch(Exception e){
    81.          e.printStackTrace();
    82.       }
    83.        
    84.       Thread t =newThread(){
    85.  
    86.          publicvoid run(){
    87.             OutputStream dest =null;
    88.             URLConnection download;
    89.             InputStream readFileToDownload =null;
    90.             try{
    91.                dest =newBufferedOutputStream(newFileOutputStream(saveDirectory + fileName));
    92.                download = url.openConnection();
    93.                readFileToDownload = download.getInputStream();
    94.                byte[] data =newbyte[1024];
    95.                int numRead;
    96.                long numWritten =0;
    97.                int length = download.getContentLength();
    98.                while((numRead = readFileToDownload.read(data))!=-1){
    99.                   dest.write(data, 0, numRead);
    100.                   numWritten += numRead;
    101.                   int percent =(int)(((double)numWritten /(double)length)* 100D);
    102.                   pbar.setValue(percent);
    103.                   pbar.setString(""+(percent <99?"Downloading "+serverName+" - "+percent+"%":"Complete")+"");
    104.                }
    105.             }catch(Exception exception){
    106.                exception.printStackTrace();
    107.             }finally{
    108.                try{
    109.                   if(readFileToDownload !=null)
    110.                      readFileToDownload.close();
    111.                   if(dest !=null)
    112.                      dest.close();
    113.                   Thread.sleep(1000L);
    114.                   startApplication();
    115.                }catch(IOException|InterruptedException ioe){
    116.                
    117.                }
    118.             }
    119.          }
    120.       };
    121.       t.start();
    122.    }
    123.    
    124.    publicboolean startDialogue(){
    125.       setVisible(true);
    126.       int selection =JOptionPane.showConfirmDialog(null, "An update is available. Do you wish to download?", "Update Available", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
    127.       return selection ==JOptionPane.OK_OPTION;
    128.    }
    129.  
    130.  
    131.    /**
    132.    * Launches the downloaded Jar file and closes the progress bar
    133.    */
    134.    publicstaticvoid startApplication(){
    135.       try{
    136.          Runtime.getRuntime().exec("java -jar "+(saveDirectory + fileName)+"");
    137.          Thread.sleep(1000L);
    138.          System.exit(0);
    139.       }catch(IOException|InterruptedException e){
    140.          e.printStackTrace();
    141.       }
    142.    }
    143.  
    144. }
    145.  

    Suggested you do this with an IDE such as Eclipse.
    Hopefully someone finds use for it ^-^ Splash.java contains all the information you need to edit.
    « Last Edit: February 25, 2014, 07:53:46 PM by Fox2007 »
    Foxtrot Studios - The next generation of java and web-development
    Runescape Gambling

    OfflineVain_

    • Member
    • ****
    • Posts: 3,057
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #1 on: February 24, 2014, 09:27:44 AM »
    useful to pushing out updates, but only if the user chooses to download it. id remove the prompt and just download it directly.

    another alternative would be runajar,  but of course will only be useful to servers with large bandwidth. it essentially runs the archive from the URL, without downloading anything except the cache. would basically run the client on the webserver, which would only be updated by the host.

    I use runajar personally because I can have one jar file, and quite a few shell scripts/batch commands and run any number of clients I want, only using different parameters. it saves hd space for all the servers I play from time to time.

    Offlinelare69

    • Member
    • ****
    • *
    • Posts: 5,322
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #2 on: March 11, 2014, 07:30:39 AM »
    useful to pushing out updates, but only if the user chooses to download it. id remove the prompt and just download it directly.

    another alternative would be runajar,  but of course will only be useful to servers with large bandwidth. it essentially runs the archive from the URL, without downloading anything except the cache. would basically run the client on the webserver, which would only be updated by the host.

    I use runajar personally because I can have one jar file, and quite a few shell scripts/batch commands and run any number of clients I want, only using different parameters. it saves hd space for all the servers I play from time to time.
    NERD

    just kidding :) pretty good release although I agree that they shouldn't be prompted and it should just download directly
    hi. check out luna:)

    Offlinetaymor46

    • First Time Poster
    • *
    • Posts: 3
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #3 on: September 07, 2016, 11:52:29 AM »
    can any one help me to add this auto client updater to my server
    ill pay for him!!

    skype : taymor gadban

    mail : [email protected]

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal