- package cn.seejava.lei2;
- import java.awt.Button;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import javax.swing.JOptionPane;
- public class GoldHelp implements Runnable{
- private String ip = null;
- private boolean suc = false;
- public GoldHelp(int i){
- switch(i){
- case 1:
- ip = "222.208.61.14";
- break;
- case 2:
- ip = "222.208.61.124";
- break;
- }
- }
- public void gstart(){
- //检测CF是不是已经启动
- if(cfRunning()){
- //执行
- JOptionPane.showMessageDialog(null, "请在登陆前启动此功能");
- return;
- }else{
- //
- runE2G();
- if(suc){
- waitQQlogin(true);
- waitQQlogin(false);
- stopE2G();
- }else{
- return;
- }
- }
- }
- public boolean cfRunning(){
- boolean flag = false;
- try {
- Process pro = Runtime.getRuntime().exec("cmd /c tasklist");
- BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
- String task = "";
- while((task=br.readLine())!=null){
- if(task.indexOf("crossfire.exe")!=-1){
- flag = true;
- break;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return flag;
- }
- public void runE2G (){
- File f = new File("easy2game");
- if(!f.exists()){
- JOptionPane.showMessageDialog(null, "你没正确安装easy2game无法正常使用金牌网吧");
- return ;
- }
- else{
- File f1 = new File("easy2game/Config.ini");
- try{
- BufferedWriter fos = new BufferedWriter(new FileWriter(f1));
- fos.write("[Setting]");
- fos.newLine();
- fos.write("Process=;qqlogin.exe;");
- fos.newLine();
- fos.write("Port=8801");
- fos.newLine();
- fos.write("Language=GB");
- fos.newLine();
- fos.write("Server="+ip);
- fos.newLine();
- fos.write("ProxyUDP=1");
- fos.newLine();
- fos.write("DisplayStatus=0");
- fos.newLine();
- fos.write("Game=");
- fos.newLine();
- fos.write("GetServerList=1");
- fos.newLine();
- fos.write("SaveServers="+ip+";");
- fos.newLine();
- fos.write("ProxyDNS=0");
- fos.newLine();
- fos.write("ProxyAll=0");
- fos.newLine();
- fos.write("Psw=6628737149168991491750414918631149189821491149179129815791591027492");
- fos.newLine();
- fos.write("User=真心社区最垃圾");
- fos.newLine();
- fos.newLine();
- fos.write("["+ip+"]");
- fos.newLine();
- fos.write("Port=8801;");
- fos.newLine();
- fos.write("User=真心社区最垃圾");
- fos.newLine();
- fos.write("Psw=6628737149168991491750414918631149189821491149179129815791591027492");
- fos.newLine();
- fos.close();
- String path = f.getAbsolutePath();
- Runtime.getRuntime().exec("cmd /c cmd /c start /min /b ""/d ""+path+"" "Easy2Game.exe"");
- suc = true;
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- public void waitQQlogin(boolean statu){
- if(statu){
- while(true){
- try {
- Process pro = Runtime.getRuntime().exec("cmd /c tasklist");
- BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
- String task = "";
- boolean flag = false;
- while((task=br.readLine())!=null){
- if(task.indexOf("QQLogin.exe")!=-1){
- flag = true;
- break;
- }
- }
- if(flag){
- //有这个进程
- break;
- }
- Thread.sleep(1000);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- return;
- }
- else{
- while(true){
- try {
- Process pro = Runtime.getRuntime().exec("cmd /c tasklist");
- BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
- String task = "";
- boolean flag = false;
- while((task=br.readLine())!=null){
- if(task.indexOf("QQLogin.exe")!=-1){
- flag = true;
- break;
- }
- }
- if(!flag){
- //没有这个进程
- break;
- }
- Thread.sleep(1000);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- return;
- }
- }
- public void stopE2G(){
- try {
- Runtime.getRuntime().exec("taskkill /F /IM easy2game.exe");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- @Override
- public void run() {
- gstart();
- }
- }