Merge pull request #3 from uakfdotb/improvements

Improvements
This commit is contained in:
Favyen Bastani
2018-11-26 16:01:28 -05:00
committed by GitHub
4 changed files with 83 additions and 54 deletions

23
.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

View File

@@ -1,18 +1,10 @@
package connect2;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import javax.net.ssl.HttpsURLConnection;
import java.nio.ByteBuffer;
import java.util.List;
public class ECList implements Runnable {
ECHost host;

50
src/connect2/GuiApp.java Normal file
View File

@@ -0,0 +1,50 @@
package connect2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
public class GuiApp implements ActionListener {
JButton launchBtn, exitBtn;
public GuiApp(){
JFrame frame = new JFrame("WC3Connect-Java");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.launchBtn = new JButton("Launch");
this.exitBtn = new JButton("Exit");
this.launchBtn.setFont(new Font("Arial", Font.PLAIN, 30));
this.exitBtn.setFont(new Font("Arial", Font.PLAIN, 30));
this.launchBtn.addActionListener(this);
this.exitBtn.addActionListener(this);
if(!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)){
this.launchBtn.setEnabled(false);
this.launchBtn.setText("Open your webbrowser and go to: 127.0.0.1:8033");
}
frame.getContentPane().add(this.launchBtn, BorderLayout.PAGE_START);
frame.getContentPane().add(this.exitBtn, BorderLayout.PAGE_END);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private void launch(){
try {
Desktop.getDesktop().browse(URI.create("http://127.0.0.1:8333"));
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == this.launchBtn) {
this.launch();
} else if(e.getSource() == this.exitBtn) {
System.exit(0);
}
}
}

View File

@@ -1,15 +1,8 @@
package connect2;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.net.URI;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main {
public static Map<String, String> ThirdPartyBotMap = new HashMap<String, String>();
@@ -21,22 +14,13 @@ public class Main {
ThirdPartyBotMap.put("85.10.199.252", "MMH-Euro");
new Thread(new LoadThirdPartyThread()).start();
new Web();
Web web = new Web();
JFrame frame = new JFrame("WC3Connect-Java");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton launch = new JButton("Launch");
JButton exit = new JButton("Exit");
launch.setFont(new Font("Arial", Font.PLAIN, 30));
exit.setFont(new Font("Arial", Font.PLAIN, 30));
launch.addActionListener(new LaunchListener());
exit.addActionListener(new ExitListener());
frame.getContentPane().add(launch, BorderLayout.PAGE_START);
frame.getContentPane().add(exit, BorderLayout.PAGE_END);
frame.pack();
frame.setVisible(true);
launch();
if(!GraphicsEnvironment.isHeadless()){
new GuiApp();
} else {
System.out.println("Open your webbrowser and go to: 127.0.0.1:8033");
}
}
public static String GetThirdPartyBot(String ip) {
@@ -45,14 +29,6 @@ public class Main {
}
}
public static void launch() {
try {
Desktop.getDesktop().browse(new URI("http://127.0.0.1:8333"));
} catch(Exception e) {
e.printStackTrace();
}
}
static class LoadThirdPartyThread implements Runnable {
public void run() {
try {
@@ -72,16 +48,4 @@ public class Main {
}
}
}
static class LaunchListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Main.launch();
}
}
static class ExitListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
}