Помогите Выводит ошибку при компиляции лаунчера.

MuffinColor

Активный участник
Пользователь
Баллы
66
Имя в Minecraft
MuffinColor
Exception in thread "main" java.lang.NullPointerException
at me.main.Launcher.Main.<init>(Main.java:72)
at me.main.Launcher.Main.main(Main.java:226)
Это ошибка (226 строка - ошибка из-за 72 так как не может ее запустить)
Помогите пофиксить!

Вот код:
Код:
package me.main.Launcher;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.EmptyBorder;

import me.main.Launcher.settings.GuardUtil;
import me.main.Launcher.settings.Util;

public class Main extends JFrame{
    public static Main mgui;
    public static MCStart MineStart;
    
    public static String[] AuthData = null;
    public static boolean Version = false;
    
    public static JPanel BGPane;
    public static Box MBox;
    
    public static JPanel MainPane;
    
    public static JLabel UpdText;
    public static JProgressBar UpdBar;
    
    public static JLabel LgLabel = new JLabel("Логин: ");
    public static JTextField LgField = new JTextField(20);
    public static JLabel PassLabel = new JLabel("Пароль: ");
    public static JPasswordField PassField = new JPasswordField(20);
    public JButton LgButton = new JButton("Войти");
    
    
    public Main() {
        setTitle("PhoenixNetwork");
        setBackground(Color.BLACK);
        this.setSize(new Dimension(1000, 550));
        this.setResizable(false);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        BGPane = new JPanel();
        BGPane.setBackground(Color.GRAY);

        Box buttonb = Box.createHorizontalBox();
        buttonb.add(LgButton);
        Box passb = Box.createHorizontalBox();
        passb.add(PassLabel);
        passb.add(Box.createVerticalStrut(8));
        passb.add(PassField);
        Box loginb = Box.createHorizontalBox();
        loginb.add(LgLabel);
        loginb.add(Box.createVerticalStrut(8));
        loginb.add(LgField);
        LgLabel.setPreferredSize(PassLabel.getPreferredSize());
        MBox = Box.createVerticalBox();
        MBox.setBorder(new EmptyBorder(10,10,10,10));
        MBox.add(loginb);
        MBox.add(Box.createVerticalStrut(15));
        MBox.add(passb);
        MBox.add(Box.createVerticalStrut(15));
        MBox.add(LgButton);
        MainPane.add(MBox);
        
        BGPane.add(MainPane);
        this.getContentPane().add(BGPane);
        
        LgButton.addActionListener(new ActionListener() {           
            public void actionPerformed(ActionEvent ev) {
                if(!LgField.getText().equals("") && (!new String(PassField.getPassword()).equals(""))){
                    if (Authorise(LgField.getText(), new String (PassField.getPassword()))) {
//                        JOptionPane.showMessageDialog((Component)
//                                null,
//                                "Вы вошли!",
//                                "Ура!",
//                                JOptionPane.INFORMATION_MESSAGE);
                        BGPane.removeAll();
                        BGPane.add(UPDPane());
                        BGPane.validate();
                        BGPane.repaint();
                    } else if(Version) {
                        JOptionPane.showMessageDialog((Component)
                                null,
                                "Ваш клиент устарел!",
                                "Обновите клиент! Если ошибка останется, сообщите нам на форуме или в группе",
                                JOptionPane.WARNING_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog((Component)
                                null,
                                "Вы не ввели логин или пароль",
                                "Ошибка",
                                JOptionPane.WARNING_MESSAGE);
                    }
                } else {
                    JOptionPane.showMessageDialog((Component)
                            null,
                            "Вы не ввели логин или пароль",
                            "Ошибка",
                            JOptionPane.WARNING_MESSAGE);
                    
                }
            }
        
        });
    }
    
    public JPanel UPDPane() {
        JPanel UPane = new JPanel();
        
        UpdText = new JLabel();
        UpdText.setText("");
        
        UpdBar = new JProgressBar();
        UpdBar.setStringPainted(true);
        UpdBar.setMinimum(0);
        UpdBar.setMaximum(100);
        UpdBar.setValue(0);
        UpdBar.setPreferredSize(new Dimension(700,50));
        
        Box ubox1 = Box.createHorizontalBox();
        ubox1.add(UpdText);
        ubox1.add(Box.createHorizontalStrut(10));
        Box ubox2 = Box.createHorizontalBox();
        ubox2.add(UpdBar);
        ubox2.add(Box.createHorizontalStrut(10));
        ubox1.add(Box.createHorizontalStrut(10));
        Box Ubox = Box.createVerticalBox();
        Ubox.setBorder(new EmptyBorder(10, 10, 10, 10));
        Ubox.add(ubox1);
        Ubox.add(Box.createVerticalStrut(15));
        Ubox.add(ubox2);
        Ubox.add(Box.createVerticalStrut(5));
        
        UPane.add(Ubox);
        
        GetUpdate();
        
        return UPane;
    }
    
    public static boolean Authorise(final String user, final String pass) {
        String AuthResult = Util.Connect("http://phoenixnetwork.ru/htdocs/vidget/auth.php", "a=auth" + "&user" + user + "&password=" + GuardUtil.ShaHash(pass));
        
        if (AuthResult == null) {
            return false;
        }
        
        
        switch (AuthResult.trim()) {
           case "Bad login":
               return false;
           case "WV":
               Version = true;
               return false;   
           default:
               try {
                   AuthData = AuthResult.split("<>");
                   return true;
               } catch (Exception ex) {
                   return false;
               }
        }
    }
    
    public static void GetUpdate() {
        new Thread() {
            public void run() {
                try {
                    UpdText.setText("Подключение к веб-серверу....");
                    URL url = new URL("http://launcher.phoenixnetwork.ru/htdocs/vidget/client.zip");
                    HttpsURLConnection updcon = (HttpsURLConnection) url.openConnection();
                    File client = new File(Util.getWorkDir().getAbsolutePath() + File.separator, "client.zip");
                    long cll_web = updcon.getContentLength();
                    UpdBar.setMaximum((int) cll_web);
                    
                    FileOutputStream fw = null;
                    if(client.length() != cll_web && cll_web > 1) {
                        BufferedInputStream bis = new BufferedInputStream(updcon.getInputStream());
                        UpdText.setText("Проверяем пути...");
                        fw = new FileOutputStream(client);
                        UpdText.setText("Загружаем клиент...");
                        byte[] by = new byte[1024];
                        int count = 0;
                        while ((count = bis.read(by)) != -1) {
                            fw.write(by, 0, count);
                            UpdBar.setValue((int) client.length());
                            UpdBar.setString("Скачано " + ((int) client.length() / 1024) + "КБайт из " + (cll_web / 1024) + "КБайт");
                        }
                    } else {
                        fw.close();
                        UpdText.setText("Распаковываем клиент...");
                        Util.Unzip(Util.getWorkDir().getAbsolutePath() + File.separator + "client.zip", Util.getWorkDir().getAbsolutePath() + File.separator);
                        UpdText.setText("Распаковка завершена.");
                        UpdBar.setString("Готово!");
                        MineStart = new MCStart(LgField.getText(), AuthData[2].trim());
                    }
                    
                    
                } catch (IOException ex) {
                    
                }
            }
        }
        .start();
    }
    
    public static void main(String[] args) {
        try {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                }
            }
        } catch (Exception ex){
            }
        
        Main frame = new Main();
        frame.show();
        }
}
 
Странный у тебя плагин, что ты в этот раздел обратился. 🙄
 
Назад
Верх