Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package net.ytbolg.mcxa; import java.awt.HeadlessException; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.lang.System; import java.net.HttpURLConnection; import java.net.URL; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.zip.ZipFile; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; //iLauncher.mport javax.xml.parsers.ParserConfigurationException; //import static net.ytbolg.mcxa.GameInfo.tpf; import net.ytbolg.mcxa.Launcher.GameInfo; import static net.ytbolg.mcxa.Launcher.GameInfo.tpf; import net.ytbolg.mcxa.Launcher.GameInfoGet; import net.ytbolg.mcxa.Launcher.MakeCmd; import net.ytbolg.mcxa.Launcher.YggdrasilCheck; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.*; import org.xml.sax.SAXException; /** * * @author Ytong */ public class MCLaucherXA extends javax.swing.JFrame { public static AssetsDownloader ad = new AssetsDownloader(); public static final String MainTitle = "MCLauncherXA xxx by officeyutong".replaceAll("xxx", LangFile.Version); static ConfigFrame c = new ConfigFrame(); // static Properties p = new Properties(); JSONObject vs[]; /** * Creates new form MCLaucherXA */ public MCLaucherXA() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPopupMenu1 = new javax.swing.JPopupMenu(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); lxbq = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); fbbq = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jCheckBox1 = new javax.swing.JCheckBox(); jPasswordField1 = new javax.swing.JPasswordField(); jLabel8 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem5 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setResizable(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowActivated(java.awt.event.WindowEvent evt) { formWindowActivated(evt); } public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); jList1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jList1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jList1MouseClicked(evt); } }); jScrollPane1.setViewportView(jList1); jPanel1.setToolTipText(""); jLabel1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel1.setText(""); lxbq.setFont(new java.awt.Font("", 0, 12)); // NOI18N lxbq.setText("jLabel2"); jLabel3.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel3.setText("?"); fbbq.setFont(new java.awt.Font("", 0, 12)); // NOI18N fbbq.setText("jLabel4"); jLabel6.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel6.setText("?BMCLVAPI!"); jLabel9.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel9.setText("??"); jComboBox1.setEditable(true); jComboBox1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true" })); jComboBox1.setSelectedIndex(-1); jButton1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jButton1.setText("?"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lxbq)) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(fbbq))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(33, 33, 33))))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(lxbq)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3).addComponent(fbbq)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9).addComponent(jButton1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6))); jLabel2.setFont(new java.awt.Font("", 0, 12)); // NOI18N jTextField1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jTextField1.setText(" "); jLabel4.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel4.setText("?"); jTextField2.setFont(new java.awt.Font("", 0, 12)); // NOI18N jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } }); jTextField2.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jTextField2KeyTyped(evt); } }); jLabel5.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel5.setText("MB"); jCheckBox1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jCheckBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); } }); jPasswordField1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jPasswordField1.setEchoChar('*'); jLabel7.setFont(new java.awt.Font("", 0, 12)); // NOI18N jLabel7.setForeground(new java.awt.Color(255, 51, 51)); jLabel7.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel7MouseClicked(evt); } }); jMenuBar1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenu1.setText(""); jMenu1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenuItem1.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenuItem1.setText(""); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1); jMenuItem3.setText("Forge"); jMenuItem3.setToolTipText(""); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu1.add(jMenuItem3); jMenuItem2.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenuItem2.setText(""); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu1.add(jMenuItem2); jMenuItem4.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenuItem4.setText(""); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu1.add(jMenuItem4); jMenuBar1.add(jMenu1); jMenu2.setText(""); jMenu2.setFont(new java.awt.Font("", 0, 12)); // NOI18N jMenuItem5.setText(""); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu2.add(jMenuItem5); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel8)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jCheckBox1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(55, 55, 55) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPasswordField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel5))))) .addGap(0, 10, Short.MAX_VALUE))))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createSequentialGroup().addComponent(jLabel8).addGap(5, 5, 5) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout .createSequentialGroup().addGap(1, 1, 1) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20).addComponent(jCheckBox1) .addGap(18, 18, 18).addComponent(jLabel4)) .addGroup(layout.createSequentialGroup() .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated }//GEN-LAST:event_formWindowActivated private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed GameInfo.lauchArg = jComboBox1.getSelectedItem().toString(); // jButton2.setVisible(false); if (jList1.getSelectedIndex() == -1) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoselectVersion"), Lang.getLang("Main_NoselectVersionTitle"), JOptionPane.WARNING_MESSAGE); return; } // System.out.println("a"); if (jTextField1.getText().equals("")) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoUserName"), Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE); return; } if (jTextField2.getText().equals("")) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoMemory"), Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE); return; } GameInfo.memory = jTextField2.getText(); Config.setConfig("username", jTextField1.getText()); Config.setConfig("lastgameversion", String.valueOf(jList1.getSelectedIndex())); Config.setConfig("lastmemory", jTextField2.getText()); Config.setConfig("iszhengban", String.valueOf(jCheckBox1.isSelected())); Config.setConfig("zhengbanmima", String.valueOf(jPasswordField1.getPassword())); //// // System.out.println(GameInfo.Rundir + tpf + "MCXA.cfg"); Config.Save(); YggdrasilCheck y = YggdrasilCheck.getThis(); String name = jTextField1.getText(); try { if (jCheckBox1.isSelected()) { JSONObject j = new JSONObject(y.login( y.GenLoginJson(jTextField1.getText(), String.valueOf(jPasswordField1.getPassword())))); if (j.has("errorMessage")) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_LoginFaild") + "\n" + j.getString("errorMessage"), Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE); } System.out.println(j.toString()); name = new JSONObject(j.getString("selectedProfile")).getString("name"); // GameInfo.uuid=j.get("clientToken"); GameInfo.token = j.getString("accessToken"); // System.out.println(j); GameInfo.uuid = j.getJSONObject("selectedProfile").getString("id"); if (j.has("user")) { JSONObject j2 = j.getJSONObject("user"); if (j2.has("properties")) { JSONArray ja = j2.getJSONArray("properties"); System.out.println(ja); for (int y1 = 0; y1 < ja.length(); y1++) { JSONObject jo3 = ja.getJSONObject(y1); if (jo3.getString("name").equals("twitch_access_token")) { System.out.println(jo3); GameInfo.twitchToken = "{\"twitch_access_token\":\"[" + jo3.getString("value") + "\"]}"; } } } } } } catch (IOException ex) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_LoginFaild") + "\n" + ex, Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE); return; // Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_LoginFaild"), Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE); return; } if (GameInfo.twitchToken.equals("")) { GameInfo.twitchToken = "{}"; } //GameInfo.token="auth_access_token"; GameInfo.UserName = name; LauchInfoWindow.version = jList1.getSelectedValue().toString(); new LauchInfoWindow().setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked if (jList1.getSelectedIndex() == -1) { return; } try { if (MakeCmd.isChanged( new ZipFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString() + tpf + jList1.getSelectedValue().toString() + ".jar"))) { jComboBox1.setSelectedItem( "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true"); } else { jComboBox1.setSelectedItem(""); } } catch (IOException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } if (evt.getButton() == MouseEvent.BUTTON3 && jList1.getSelectedIndex() != -1) { jPopupMenu1.show(this, evt.getX() + 25, evt.getY() + 25); } if (evt.getButton() == MouseEvent.BUTTON2 && evt.getClickCount() == 2) { jButton1ActionPerformed(null); } try { BrushLabels(jList1.getSelectedIndex()); } catch (JSONException e) { } catch (Exception ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } // TODO add your handling code here: }//GEN-LAST:event_jList1MouseClicked private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed new VersionCheck().setVisible(true); jList1.setListData(GameInfoGet.getGameVersions());// TODO add your handling code here: }//GEN-LAST:event_jMenuItem1ActionPerformed private void jTextField2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField2KeyTyped //if(evt.getKeyChar()) // TODO add your handling code here: }//GEN-LAST:event_jTextField2KeyTyped private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed Config.setConfig("username", jTextField1.getText()); Config.setConfig("lastgameversion", String.valueOf(jList1.getSelectedIndex())); Config.setConfig("lastmemory", jTextField2.getText()); Config.Save(); // ConfigClass.showlauchinfowindows = Boolean.valueOf(p.getProperty("showlauchinfowindows")); new ConfigFrame().setVisible(true); }//GEN-LAST:event_jMenuItem2ActionPerformed private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField2ActionPerformed private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed jPasswordField1.setEnabled(jCheckBox1.isSelected()); // TODO add your handling code here: }//GEN-LAST:event_jCheckBox1ActionPerformed private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed new ForgeCheck().setVisible(true); jList1.setListData(GameInfoGet.getGameVersions());// TODO add your handling code here: }//GEN-LAST:event_jMenuItem3ActionPerformed public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (String children1 : children) { boolean success = deleteDir(new File(dir, children1)); if (!success) { return false; } } } // ? return dir.delete(); } private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened // GameInfo.uuid = UUID.randomUUID().toString().toUpperCase().replace("-", ""); // GameInfo.rb.getBundle(tpf) // jMenu3.setVisible(false); setTitle(MainTitle); jLabel2.setText(Lang.getLang("Main_Label_Username")); jCheckBox1.setText(Lang.getLang("Main_CheckBox_zhangben")); jLabel4.setText(Lang.getLang("Main_Label_Memory")); jLabel1.setText(Lang.getLang("Main_Label_Type")); jLabel3.setText(Lang.getLang("Main_Label_Time")); jLabel6.setText(Lang.getLang("Main_Label_BMCLVAPI")); jButton1.setText(Lang.getLang("Main_Button_Lauch")); // jButton2.setText(Lang.getLang("Main_Button_GetAss")); jMenu1.setText(Lang.getLang("Main_Menu_File")); jMenu2.setText(Lang.getLang("Main_Menu_Help")); jMenuItem1.setText(Lang.getLang("Main_Menu_DownVersion")); jMenuItem3.setText(Lang.getLang("Main_Menu_DownForge")); jMenuItem2.setText(Lang.getLang("Main_Menu_Config")); jMenuItem4.setText(Lang.getLang("Main_Menu_Update")); // jMenuItem4.setText(Lang.getLang("Main_Menu_Delete")); jLabel7.setText(Lang.getLang("Main_Label_Update")); jLabel9.setText(Lang.getLang("Main_Label_AppArgs")); jLabel7.setVisible(Updater.NeedUpdate()); JMenuItem ji = jPopupMenu1.add(Lang.getLang("Main_Menu_Delete")); JMenuItem j2 = jPopupMenu1.add(Lang.getLang("Main_Menu_Brush")); JMenuItem j3 = jPopupMenu1.add(Lang.getLang("Main_Button_GetAss")); JMenuItem j4 = jPopupMenu1.add(Lang.getLang("Main_Menu_RedownloadLib")); j2.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mousePressed(MouseEvent e) { jList1.setListData(GameInfoGet.getGameVersions()); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); ji.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { //if(e.getComponent().) // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mousePressed(MouseEvent e) { // System.out.println("Right click"); if (e.getButton() == MouseEvent.BUTTON1) { System.out.println( GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString()); deleteDir(new File( GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString())); jList1.setListData(GameInfoGet.getGameVersions()); } // System.out.println("Right click"); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } public void mouseDragged(MouseEvent e) { } }); j3.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mousePressed(MouseEvent e) { GameInfo.assVersion = jList1.getSelectedValue().toString(); try { GetAss(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } catch (ParserConfigurationException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } } @Override public void mouseReleased(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { ///// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); j4.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mousePressed(MouseEvent e) { try { Downloader d = new Downloader(); d.setUnzip(false); String al = GameInfoGet .libstotruedir(GameInfoGet.getLibs(jList1.getSelectedValue().toString())); String libs[] = al.split(";"); for (int a = 0; a < libs.length; a++) { libs[a] = libs[a].substring(1, libs[a].length() - 1); } for (String lib : libs) { File f = new File(lib); if (f.exists()) { f.delete(); } d.add(DownLoadURL.getURL(DownLoadURL.LIBRARIES, Integer.valueOf(Config.getConfig("DownSou"))) + lib.replaceFirst(Matcher.quoteReplacement(GameInfo.GameDir + tpf + "libraries"), ""), lib); } d.setVisible(true); d.start(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } catch (IOException | JSONException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } } @Override public void mouseReleased(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // this.setIconImage(this.getToolkit().getImage(getClass().getResource("/icon_16x16.icon"))); // System.out.println(p.getProperty("zhengbanmima")); jCheckBox1.setSelected(Config.getConfig("iszhengban").equals("true")); jCheckBox1ActionPerformed(null); setLocationRelativeTo(getOwner()); if (!System.getProperty("os.name").contains("Windows")) { jLabel8.setText(Lang.getLang("Main_NotWindows")); // jLabel9.setText(); } this.setResizable(false); jList1.setListData(GameInfoGet.getGameVersions());// TODO add your handling code here: GameInfo.downUrl = Config.getConfig("downUrl"); try { int m = GameInfoGet.getGameVersions().length; vs = new JSONObject[m]; // System.out.println(m); for (int i = 0; i < m; i++) { vs[i] = new JSONObject(ReadFile(GameInfo.GameDir + tpf + "versions" + tpf + GameInfoGet.getGameVersions()[i] + tpf + GameInfoGet.getGameVersions()[i] + ".json")); } jPasswordField1.setText(Config.getConfig("zhengbanmima")); if (Config.getConfig("zhengbanmima").equals("")) { jCheckBox1.setSelected(false); jPasswordField1.setEnabled(false); } jTextField1.setText(Config.getConfig("username")); jTextField2.setText(Config.getConfig("lastmemory")); int i = 0; // System.out.println(p.getProperty("lastgameversion")); i = Integer.parseInt(Config.getConfig("lastgameversion")); if (i < 0) { i = 0; } jList1.setSelectedIndex(i); if (jList1.getModel().getSize() != 0) { BrushLabels(jList1.getSelectedIndex()); } // OutputStream in = new FileOutputStream(GameInfo.Rundir + tpf + "MCXA.cfg"); Config.Save(); // p.store(in, "= ="); if (MakeCmd.isChanged( new ZipFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString() + tpf + jList1.getSelectedValue().toString() + ".jar"))) { jComboBox1.setSelectedIndex(0); } } catch (IOException | JSONException e) { } catch (Exception ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } // TODO add your handling code here: }//GEN-LAST:event_formWindowOpened private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseClicked new Updater().setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_jLabel7MouseClicked private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed new Updater().setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_jMenuItem4ActionPerformed private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed new About().setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_jMenuItem5ActionPerformed /** * @param args the command line arguments * @throws java.lang.Exception */ public static void main(String args[]) throws InterruptedException { //System.out.println(System.getProperty("os.name")); //Test.main(null); System.out.println(System.getProperty("os.arch")); // System.getProperties().list(System.out); try { String tx = new File(".").getCanonicalPath(); if (tx.endsWith("\\")) { tx = tx.substring(0, tx.length() - 1); } File f2 = new File(tx + "/update.note"); System.out.println(f2.exists() + f2.toString()); if (f2.exists()) { // Thread.sleep(3000); String x = ReadFile(f2.toString()); System.out.println(x); f2.deleteOnExit(); new File(x).delete(); } UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // Test t = new Test("H:\\mclaucherxa\\"); // t.countJavaFile(t.projectPath); GameInfo.tpf = getTpf(); // GameInfo.JavaPath = "java"; String fgf = System.getProperty("os.name").contains("Linux") ? "'" : "\""; if (!System.getProperty("os.name").contains("Windows")) { // GameInfo.JavaPath = "java"; GameInfo.JavaPath = System.getProperty("java.home") + tpf + "bin" + tpf + "java"; } else { // GameInfo.JavaPath = "java"; GameInfo.JavaPath = System.getProperty("java.home") + tpf + "bin" + tpf + "java.exe"; } // GameInfo.GameDir = "J:\\NewZM\\client\\.minecraft"; // GameInfoGet.getGameVersions(); GameInfo.Rundir = new File(".").getCanonicalPath(); System.out.println(GameInfo.Rundir); if (GameInfo.Rundir.endsWith("\\")) { GameInfo.Rundir = GameInfo.Rundir.substring(0, GameInfo.Rundir.length() - 1); } System.out.println(GameInfo.Rundir); GameInfo.GameDir = GameInfo.Rundir + GameInfo.tpf + ".minecraft"; //?? String Files[] = { "sChinese.lang", "tChinese.lang", "English.lang" }; String Langs[] = { LangFile.sChinese, LangFile.tChinese, LangFile.english }; ArrayList<File> file = new ArrayList<>(); for (int i = 0; i < Files.length; i++) { File f = new File(GameInfo.Rundir + tpf + "MCXA.Lang" + tpf + Files[i]); File par = f.getParentFile(); if (par.isFile() || !par.exists()) { par.mkdir(); } System.out.println(f); if (!f.exists()) { f.createNewFile(); file.add(f); } } for (int i = 0; i < file.size(); i++) { FileWriter fw = new FileWriter(file.get(i)); fw.write(Langs[i]); fw.close(); } // getClass().getResource("/sChinese.lang"). if (!(new File(GameInfo.Rundir + tpf + "MCXA.json")).exists()) { System.out.println("?"); new File(GameInfo.Rundir + tpf + "MCXA.json").createNewFile(); FileWriter fw = new FileWriter(GameInfo.Rundir + tpf + "MCXA.json"); fw.write("{}"); fw.close(); // p.load(new FileInputStream(GameInfo.Rundir + tpf + "MCXA.cfg")); String playerxxx = String.valueOf(new Random().nextInt(999)); if (playerxxx.length() != 3) { for (int i = 1; i < playerxxx.length() - 1; i++) { playerxxx = "0" + playerxxx; } } Config.Load(new File(GameInfo.Rundir + tpf + "MCXA.json")); Config.setConfig("username", "player" + playerxxx); Config.setConfig("lastgameversion", "0"); Config.setConfig("lastmemory", "1500"); // Config.setConfig("showlauchinfowindows", "true"); Config.setConfig("showlauchinfo", "true"); Config.setConfig("ifclose", "true"); Config.setConfig("zhengbanmima", ""); Config.setConfig("DownSou", "1"); Config.setConfig("Lang", "sChinese.lang"); Config.setConfig("iszhengban", "false"); Config.setConfig("GameDir", GameInfo.GameDir); Config.setConfig("JavaPath", GameInfo.JavaPath); Config.setConfig("isDuli", "false"); Config.Save(); } else { Config.Load(new File(GameInfo.Rundir + tpf + "MCXA.json")); } GameInfo.GameDir = Config.getConfig("GameDir"); if (new File(GameInfo.GameDir).exists() == false) { Config.setConfig("GameDir", GameInfo.Rundir + tpf + ".minecraft"); GameInfo.GameDir = Config.getConfig("GameDir"); Config.Save(); } GameInfo.JavaPath = Config.getConfig("JavaPath"); Lang.Load(new File(GameInfo.Rundir + tpf + "MCXA.Lang" + tpf + Config.getConfig("Lang"))); // // p.load(new FileInputStream(GameInfo.Rundir + tpf + "MCXA.cfg")); //p.store(new FileOutputStream(GameInfo.Rundir + tpf + "MCXA.cfg"), ""); /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ /* try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); }*/ //</editor-fold> //System.getProperties().list(System.out); /* Create and display the form */ if (!new File(GameInfo.GameDir).exists()) { JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoMinecraftDir")); File fi = new File(GameInfo.GameDir + GameInfo.tpf + "versions"); fi.mkdirs(); // System.exit(0); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MCLaucherXA().setVisible(true); } }); } catch (HeadlessException | IOException | ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel fbbq; private javax.swing.JButton jButton1; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JList jList1; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem3; private javax.swing.JMenuItem jMenuItem4; private javax.swing.JMenuItem jMenuItem5; private javax.swing.JPanel jPanel1; private javax.swing.JPasswordField jPasswordField1; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JLabel lxbq; // End of variables declaration//GEN-END:variables static String getTpf() { String a = System.getProperty("os.name"); if (a.contains("Windows")) { return "\\"; } else { return "/"; } } void BrushLabels(int index) throws JSONException, IOException { JSONObject jo = new JSONObject(ReadFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString() + tpf + jList1.getSelectedValue().toString() + ".json")); lxbq.setText(jo.getString("type")); fbbq.setText(jo.getString("releaseTime")); } static String ReadFile(String path) throws FileNotFoundException, IOException { File file = new File(path); FileReader r = new FileReader(file); char c[] = new char[(int) file.length()]; r.read(c); return String.valueOf(c); } static void GetAss() throws ParserConfigurationException { // System.out.println("Getting Ass"); String ver; // System.out.println("FUCK"); ad.setVersion(GameInfo.assVersion); try { PrintStream ps = System.out; // DefaultListModel m = new DefaultListModel(); boolean is1_6 = false; ver = new JSONObject(ReadFile(GameInfo.GameDir + tpf + "versions" + tpf + GameInfo.assVersion + tpf + GameInfo.assVersion + ".json")).getString("id"); ps.println("= ="); if (ver.contains("-")) { ver = ver.substring(0, ver.indexOf("-")); } try { //(HttpURLConnection) (new URL("http://bmclapi.bangbang93.com/indexes/" + ver + ".json").openConnection()).; // urlfile = new URL(remoteFilePath); HttpURLConnection httpUrl = (HttpURLConnection) new URL( DownLoadURL.getURL(DownLoadURL.INDEXES, Integer.valueOf(Config.getConfig("DownSou"))) + "/" + ver + ".json").openConnection(); httpUrl.connect(); BufferedInputStream bis = new BufferedInputStream(httpUrl.getInputStream()); } catch (Exception e) { ver = "1.7.4"; is1_6 = true; } if (true) { //? JSONObject jo = new JSONObject(downloadFile( DownLoadURL.getURL(DownLoadURL.INDEXES, Integer.valueOf(Config.getConfig("DownSou"))) + "/" + ver + ".json")).getJSONObject("objects"); System.out.println(ver + jo); JSONArray ja = jo.names(); ad.add(DownLoadURL.getURL(DownLoadURL.INDEXES, Integer.valueOf(Config.getConfig("DownSou"))) + "/" + ver + ".json", GameInfo.GameDir + tpf + "assets" + tpf + "indexes" + tpf + ver + ".json", null, false); for (int a = 0; a < ja.length(); a++) { JSONObject jo2 = jo.getJSONObject(ja.getString(a)); String hash = jo2.getString("hash"); String path = hash.substring(0, 2) + tpf + hash; File f = new File(GameInfo.GameDir + tpf + "assets" + tpf + "objects" + tpf + path); if (f.exists()) { continue; } if (!f.getParentFile().exists()) { f.getParentFile().mkdirs(); } ad.add(DownLoadURL.getURL(DownLoadURL.ASSETS, Integer.valueOf(Config.getConfig("DownSou"))) + "/" + path, GameInfo.GameDir + tpf + "assets" + tpf + "objects" + tpf + path, GameInfo.GameDir + tpf + "assets" + tpf + ja.get(a), true); } ad.start(); ad.setVisible(true); } else if (false) { HttpURLConnection h = (HttpURLConnection) new URL("http://www.bangbang93.com/bmcl/resources/") .openConnection(); InputStream is = h.getInputStream(); Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); NodeList nl = d.getElementsByTagName("ListBucketResult"); NodeList nl2 = nl.item(0).getChildNodes(); ArrayList<Node> nal = new ArrayList(); for (int i = 0; i < nl2.getLength(); i++) { if (nl2.item(i).getNodeName().equals("Contents")) { nal.add(nl2.item(i)); } } // ps.println(nal.size()); for (int i = 0; i < nal.size(); i++) { String f = (nal.get(i).getChildNodes().item(0).getChildNodes().item(0).getNodeValue()); String md5 = nal.get(i).getChildNodes().item(2).getChildNodes().item(0).getNodeValue(); // ps.println(md5); if (!f.contains(".")) { continue; } if (!new File(GameInfo.GameDir + tpf + "assets" + tpf + "virtual" + tpf + "legacy" + tpf + f) .exists()) { ad.add("http://bmclapi.bangbang93.com/resources/" + f, GameInfo.GameDir + tpf + "assets" + tpf + "virtual" + tpf + "legacy" + tpf + f, null, false); } else { File fi = new File( GameInfo.GameDir + tpf + "assets" + tpf + "virtual" + tpf + "legacy" + tpf + f); if (fi.isDirectory()) { continue; } FileInputStream fis = new FileInputStream(fi); byte b[] = new byte[(int) fi.length()]; fis.read(b); if (Md5(b).equals(md5)) { fis.close(); continue; } else { ad.add("http://bmclapi.bangbang93.com/resources/" + f, GameInfo.GameDir + tpf + "assets" + tpf + "virtual" + tpf + "legacy" + tpf + f, null, false); } fis.close(); } } ad.start(); ad.setVisible(true); } //ad.dispose(); } catch (IOException | JSONException | HeadlessException e) { e.printStackTrace(); //System.out.println(e); } catch (ParserConfigurationException | SAXException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } } private static String Md5(byte[] data) { StringBuffer buf = null; try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(data); byte b[] = md.digest(); int i; buf = new StringBuffer(""); for (int offset = 0; offset < b.length; offset++) { i = b[offset]; if (i < 0) { i += 256; } if (i < 16) { buf.append("0"); } buf.append(Integer.toHexString(i)); } // System.out.println("result: " + buf.toString().substring(8, 24)); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } return buf.toString(); } public static String downloadFile(String remoteFilePath) throws IOException { URL urlfile = null; HttpURLConnection httpUrl = null; BufferedInputStream bis = null; BufferedOutputStream bos = null; File f = new File(GameInfo.Rundir + GameInfo.tpf + "temp.tmp"); File xxxx = new File(f.getParent()); //StringWriter sb=new StringWri(); xxxx.mkdirs(); // f.mkdirs(); try { urlfile = new URL(remoteFilePath); httpUrl = (HttpURLConnection) urlfile.openConnection(); httpUrl.connect(); bis = new BufferedInputStream(httpUrl.getInputStream()); bos = new BufferedOutputStream(new FileOutputStream(f)); int len = 2048; byte[] b = new byte[len]; while ((len = bis.read(b)) != -1) { bos.write(b, 0, len); } bos.flush(); bis.close(); httpUrl.disconnect(); } catch (IOException e) { e.printStackTrace(); } finally { try { bis.close(); bos.close(); } catch (IOException e) { e.printStackTrace(); } } String x = ReadFile(GameInfo.Rundir + GameInfo.tpf + "temp.tmp"); f.deleteOnExit(); return x; } }