Ir para conteúdo
  • 0

[API] Resultado individual


Solitario

Pergunta

Gostaria de saber como faço para que o resultado sempre de individual '-' por que quero fazer uma api de consulta só que o resultado ta sendo atualizado em todos ... tou usando 

getMotd Status3 = new getMotd();
Status3.Sv(ip, porta);
if(Status3.estaOnline()){
String motd = Status3.obterMotd();
}

 

 

para puxar os dados

 

E assim que ta a class:

public class getMotd {
    private static String motd;
    private static boolean online;

    public String obterMotd(){
        if(getMotd.motd != null){
            return getMotd.motd;
        }
        return "";
    }

    public boolean estaOnline(){
        return getMotd.online;
    }

    public void setOnline(boolean online){
        getMotd.online = online;
    }

    public void setMotd(String motd){
        getMotd.motd = motd;
    }

    public void Sv(String host, int port) {
 
    //Code grande porem vou simplificar setOnline(true) se tiver resultado ok ... e setMotd(string) no resultado ... 

    }
Link para o comentário
Compartilhar em outros sites

15 respostass a esta questão

Posts Recomendados

se colocar static, esse field vai ser igual para todos os objetos (explicação top)

então tira os static se quiser criar vários objetos. E não se esqueça de salvar o objeto em algum lugar, eu costumo salvar no constructor.. mas você nem isso tem ;-;

 

o meu ficou assim

 

 

public class Motd {

    private String msg;
    private Boolean online;

    public Motd(String msg, Boolean online) {
        this.msg = msg;
        this.online = online;

        SkyKits.getSkyKits().getMotds().add(this);
    }

    public Motd() {
        SkyKits.getSkyKits().getMotds().add(this);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Boolean getOnline() {
        return online;
    }

    public void setOnline(Boolean online) {
        this.online = online;
    }

    public void Sv(String host, int port) {

        //Code grande porem vou simplificar setOnline(true) se tiver resultado ok ... e setMotd(string) no resultado ... 

    }

} 

 

 

Creio que você só precisa de mudar o getMotd.online para this.online

E se está utilizando o intellij, pressiona alt + insert, clicar em getter + setter, clica nos fields em que você quer criar o getter e o setter e em ok, puufff magia. O mesmo para constructor, toString(), etc.

Link para o comentário
Compartilhar em outros sites

se colocar static, esse field vai ser igual para todos os objetos (explicação top)

então tira os static se quiser criar vários objetos. E não se esqueça de salvar o objeto em algum lugar, eu costumo salvar no constructor.. mas você nem isso tem ;-;

 

o meu ficou assim

 

 

public class Motd {

    private String msg;
    private Boolean online;

    public Motd(String msg, Boolean online) {
        this.msg = msg;
        this.online = online;

        SkyKits.getSkyKits().getMotds().add(this);
    }

    public Motd() {
        SkyKits.getSkyKits().getMotds().add(this);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Boolean getOnline() {
        return online;
    }

    public void setOnline(Boolean online) {
        this.online = online;
    }

    public void Sv(String host, int port) {

        //Code grande porem vou simplificar setOnline(true) se tiver resultado ok ... e setMotd(string) no resultado ... 

    }

} 

 

 

Creio que você só precisa de mudar o getMotd.online para this.online

E se está utilizando o intellij, pressiona alt + insert, clicar em getter + setter, clica nos fields em que você quer criar o getter e o setter e em ok, puufff magia. O mesmo para constructor, toString(), etc.

'-' acho que nunca usei constructor .-. ;-; e acho que não sei usar nem começar .-.

Link para o comentário
Compartilhar em outros sites

'-' acho que nunca usei constructor .-. ;-; e acho que não sei usar nem começar .-.

imagine que tem um objeto assim

public class Motd{

    private String msg;

    public Motd(String msg){ //constructor
        this.msg = msg;
        System.out.printLn("Um novo motd foi criado!");
    }

    public String getMsg(){
        return this.msg;
    }
 
    public void setMsg(String msg){
        this.msg = msg;
    }

} 

quando um motd for criado, o que estiver dentro do constructor vai ser executado.

 

Basicamente o que você fez para criar um motd foi isso

Motd motd = new Motd();
motd.setMsg("Bem vindo");

com um constructor apenas é preciso isso

Motd motd = new Motd("Bem vindo");

porque no constructor já seta a msg, e também irá printar "Um novo motd foi criado!" quando um objeto é criado.

 

@Edit

Já agora, POO (Programação Orientada a Objetos) é algo que qualquer programador de java deveria saber, então recomendo você olhar essa playlist.

Editado por zAth
Link para o comentário
Compartilhar em outros sites

imagine que tem um objeto assim

public class Motd{

    private String msg;

    public Motd(String msg){ //constructor
        this.msg = msg;
        System.out.printLn("Um novo motd foi criado!");
    }

    public String getMsg(){
        return this.msg;
    }
 
    public void setMsg(String msg){
        this.msg = msg;
    }

} 

quando um motd for criado, o que estiver dentro do constructor vai ser executado.

 

Basicamente o que você fez para criar um motd foi isso

Motd motd = new Motd();
motd.setMsg("Bem vindo");

com um constructor apenas é preciso isso

Motd motd = new Motd("Bem vindo");

porque no constructor já seta a msg, e também irá printar "Um novo motd foi criado!" quando um objeto é criado.

'-' ok '-' ... continuo meio bugado .. O que devo fazer para mandar e retornar então >.<?

Até agora ta tipo assim:

 

 

package me.arthurgui.hub.api;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

public class Server {
    private boolean online;
    private String motd;

    public Server(String msg, Boolean online) {
        this.motd = msg;
        this.online = online;
        
    }

    public String getMotd() {
        return motd;
    }

    public void setMotd(String motd) {
        this.motd = motd;
    }



    public boolean isOnline() {
        return online;
    }

    public void setOnline(boolean online) {
        this.online = online;
    }




    public void Sv(String host, int port) {
             // code com set online e set motd
    }

}
 
Server Status = new Server();
	Status.Sv(ip1, 25566);
	if (Status.isOnline()) {}
} 

 

 

 

Não sei como devo colocar ele '-' new Server(); porém se eu colocar o motd e tal já taria dando isso não ? (to 100% bugado nisso)

Link para o comentário
Compartilhar em outros sites

'-' ok '-' ... continuo meio bugado .. O que devo fazer para mandar e retornar então >.<?

Até agora ta tipo assim:

 

 

package me.arthurgui.hub.api;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

public class Server {
    private boolean online;
    private String motd;

    public Server(String msg, Boolean online) {
        this.motd = msg;
        this.online = online;
        
    }

    public String getMotd() {
        return motd;
    }

    public void setMotd(String motd) {
        this.motd = motd;
    }



    public boolean isOnline() {
        return online;
    }

    public void setOnline(boolean online) {
        this.online = online;
    }




    public void Sv(String host, int port) {
             // code com set online e set motd
    }

}
 
Server Status = new Server();
	Status.Sv(ip1, 25566);
	if (Status.isOnline()) {}
} 

 

 

 

Não sei como devo colocar ele '-' new Server(); porém se eu colocar o motd e tal já taria dando isso não ? (to 100% bugado nisso)

você está usando Status.isOnline() sem atribuir um valor nele ( espero que você faça isso no Status.sv() )

 

Eu acho que assim já dá certo, usa new Server(msg, online) se você já souber o que atribuir, se não souber apenas use new Server() e depois atribua.

Eu adicionaria mais um field, String name, para saber de que servidor o motd é. De resto penso que resulte.

Link para o comentário
Compartilhar em outros sites

você está usando Status.isOnline() sem atribuir um valor nele ( espero que você faça isso no Status.sv() )

 

Eu acho que assim já dá certo, usa new Server(msg, online) se você já souber o que atribuir, se não souber apenas use new Server() e depois atribua.

Eu adicionaria mais um field, String name, para saber de que servidor o motd é. De resto penso que resulte.

To usando setOnline(true) '-' ... só que bom ... fiz outro jeito '-' e acho que não deu muito certo kk (Vou mandar o code enteiro pra você ver)

 

 

 

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

public class Server {
    private boolean online;
    private String motd;


    public String getMotd() {
        return motd;
    }

    public void setMotd(String motd) {
        this.motd = motd;
    }



    public boolean isOnline() {
        return online;
    }

    public void setOnline(boolean online) {
        this.online = online;
    }




    public Server(String host, int port) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Socket socket = null;
                InetAddress addr = null;

                // INSERT hostname here (name or ip)
                String hostname = host;

                //========== Converting hostname to ip ===========
                try {
                    addr = InetAddress.getByName(hostname);
                } catch (UnknownHostException e2) {
                    e2.printStackTrace();
                }

                hostname = addr.getCanonicalHostName();

                //============ Creating Socket ============

                try {
                    socket = new Socket(hostname, port);
                    setOnline(true);
                }catch (IOException e1) {
                    setOnline(false);
                }
                if(socket == null){
                    return;
                }
                DataOutputStream output = null;
                BufferedReader reader = null;
                StringBuilder str = new StringBuilder();

                try {
                    output = new DataOutputStream(socket.getOutputStream());
                    reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));   // notice the UTF-8 here!

                    // Allocate Buffer with the right amount of bytes
                    ByteBuffer buffer = ByteBuffer.allocate(7 + hostname.length());

                    //========= START Writing Protocol header ========
                    buffer.put((byte) (6 + hostname.length())); // send length of whole packet
                    buffer.put((byte) 0); // send packetID
                    buffer.put((byte) 47); // send protocol Version

                    //========= Start Writing Hostname ===========

                    //Write length of HostName
                    buffer.put((byte) hostname.length());

                    for(int i = 0; i < hostname.length(); i++) {
                        buffer.put((byte) hostname.toCharArray()[i]);
                    }

                    //=============start writing port================
                    int[] portBytes = new int[2];
                    portBytes[0] = (byte) (port & 0xFF);
                    portBytes[1] = (byte) ((port >>> 8) & 0xFF);
                    buffer.put((byte) portBytes[1]);
                    buffer.put((byte) portBytes[0]);


                    //==========Add State==========
                    buffer.put((byte) 1);

                    output.write(buffer.array());

                    output.flush();

                    //=========== Send Request =========
                    buffer = ByteBuffer.allocate(2);
                    buffer.put((byte) 1);
                    buffer.put((byte) 0);

                    output.write(buffer.array());

                    output.flush();

                    int tmpInt;

                    while((tmpInt = reader.read()) != -1 && tmpInt < 65535) {
                        if(str.toString().endsWith("fav")) {
                            break;
                        }
                        str.append((char) tmpInt);
                    }

                    //get Result
                    String result = str.toString(); // get String
                    int descriptionIndex = result.indexOf("\"description\":\"") + 15;    // get MOTD start index
                    int descEndIndex = result.indexOf("\",\"", descriptionIndex);     // get MOTD end index

                    result = result.substring(descriptionIndex, descEndIndex);        // get the MOTD
                    setMotd(result);

                } catch(StringIndexOutOfBoundsException ex) {
                    // maybe do sth?
                } catch(IOException e) {
                    // do sth
                }
                finally {
                    try {
                        if(reader != null) {
                            reader.close();
                        }
                        if(output != null) {
                            output.close();
                        }
                        if(socket != null) {
                            socket.close();
                        }

                    } catch(IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();


    }
} 

 

 

Link para o comentário
Compartilhar em outros sites

To usando setOnline(true) '-' ... só que bom ... fiz outro jeito '-' e acho que não deu muito certo kk (Vou mandar o code enteiro pra você ver)

 

 

 

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

public class Server {
    private boolean online;
    private String motd;


    public String getMotd() {
        return motd;
    }

    public void setMotd(String motd) {
        this.motd = motd;
    }



    public boolean isOnline() {
        return online;
    }

    public void setOnline(boolean online) {
        this.online = online;
    }




    public Server(String host, int port) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Socket socket = null;
                InetAddress addr = null;

                // INSERT hostname here (name or ip)
                String hostname = host;

                //========== Converting hostname to ip ===========
                try {
                    addr = InetAddress.getByName(hostname);
                } catch (UnknownHostException e2) {
                    e2.printStackTrace();
                }

                hostname = addr.getCanonicalHostName();

                //============ Creating Socket ============

                try {
                    socket = new Socket(hostname, port);
                    setOnline(true);
                }catch (IOException e1) {
                    setOnline(false);
                }
                if(socket == null){
                    return;
                }
                DataOutputStream output = null;
                BufferedReader reader = null;
                StringBuilder str = new StringBuilder();

                try {
                    output = new DataOutputStream(socket.getOutputStream());
                    reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));   // notice the UTF-8 here!

                    // Allocate Buffer with the right amount of bytes
                    ByteBuffer buffer = ByteBuffer.allocate(7 + hostname.length());

                    //========= START Writing Protocol header ========
                    buffer.put((byte) (6 + hostname.length())); // send length of whole packet
                    buffer.put((byte) 0); // send packetID
                    buffer.put((byte) 47); // send protocol Version

                    //========= Start Writing Hostname ===========

                    //Write length of HostName
                    buffer.put((byte) hostname.length());

                    for(int i = 0; i < hostname.length(); i++) {
                        buffer.put((byte) hostname.toCharArray()[i]);
                    }

                    //=============start writing port================
                    int[] portBytes = new int[2];
                    portBytes[0] = (byte) (port & 0xFF);
                    portBytes[1] = (byte) ((port >>> 8) & 0xFF);
                    buffer.put((byte) portBytes[1]);
                    buffer.put((byte) portBytes[0]);


                    //==========Add State==========
                    buffer.put((byte) 1);

                    output.write(buffer.array());

                    output.flush();

                    //=========== Send Request =========
                    buffer = ByteBuffer.allocate(2);
                    buffer.put((byte) 1);
                    buffer.put((byte) 0);

                    output.write(buffer.array());

                    output.flush();

                    int tmpInt;

                    while((tmpInt = reader.read()) != -1 && tmpInt < 65535) {
                        if(str.toString().endsWith("fav")) {
                            break;
                        }
                        str.append((char) tmpInt);
                    }

                    //get Result
                    String result = str.toString(); // get String
                    int descriptionIndex = result.indexOf("\"description\":\"") + 15;    // get MOTD start index
                    int descEndIndex = result.indexOf("\",\"", descriptionIndex);     // get MOTD end index

                    result = result.substring(descriptionIndex, descEndIndex);        // get the MOTD
                    setMotd(result);

                } catch(StringIndexOutOfBoundsException ex) {
                    // maybe do sth?
                } catch(IOException e) {
                    // do sth
                }
                finally {
                    try {
                        if(reader != null) {
                            reader.close();
                        }
                        if(output != null) {
                            output.close();
                        }
                        if(socket != null) {
                            socket.close();
                        }

                    } catch(IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();


    }
} 

 

 

parece-me certo a parte do objeto, quando criar um novo objeto isso dae vai ser executado ;-; o que não deu certo?

se for algo de socket, eu não entendo.. :/

Link para o comentário
Compartilhar em outros sites

parece-me certo a parte do objeto, quando criar um novo objeto isso dae vai ser executado ;-; o que não deu certo?

se for algo de socket, eu não entendo.. :/

sei la '-' ficou todos mostrando offline '-'

s5vAJWi.png

Bem que quando ta em static e tal (O metodo que tava usando antes) fica se trocando entre todos os resultados (Fica piscando o resultado dos 3 que solicito)

 

Fiz um debug no socket ...

 

3TIP8tW.png

ta funcionando porém não ta funcionando os set eu acho '-'

Editado por Solitario
Link para o comentário
Compartilhar em outros sites

sei la '-' ficou todos mostrando offline '-'

s5vAJWi.png

Bem que quando ta em static e tal (O metodo que tava usando antes) fica se trocando entre todos os resultados (Fica piscando o resultado dos 3 que solicito)

E todos estão online? ou você está usando o mesmo objeto para todos os servidores ou é esse método de socket que não está funcionando '-' e que infelizmente eu não entendo..

De certeza que não está usando o mesmo objeto para todos os servidores? Ou que pelo menos esse servidor está online?

Link para o comentário
Compartilhar em outros sites

E todos estão online? ou você está usando o mesmo objeto para todos os servidores ou é esse método de socket que não está funcionando '-' e que infelizmente eu não entendo..

De certeza que não está usando o mesmo objeto para todos os servidores? Ou que pelo menos esse servidor está online?

Tipo ... o socket ta funcional '-' 

 

Fiz um debug no socket ...

 

3TIP8tW.png

ta funcionando porém não ta funcionando os set eu acho '-'

 

Só estou no pc então só tem 1 servidor on '-'

 

Code que uso pra puxar:

 

Server Status = new Server(ip1, 25566);
				if (Status.isOnline()) {
					String[] motd = Status.getMotd().split(";");
					if (motd[0].equalsIgnoreCase("Carregando")) {
						hg1 = "§eCarregando";
						hg1t = "§e--";
						hg1o = "§e--";
					}
					if (motd[0].equalsIgnoreCase("Aguardando")) {
						hg1 = "§aAguardando para o torneio";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Invencibilidade")) {
						hg1 = "§eEm Invencibilidade";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Andamento")) {
						hg1 = "§cEm Jogo";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Finalizado")) {
						hg1 = "§6" + motd[1] + " Venceu!";
						hg1t = "§e--";
						hg1o = "§e--";
					}
					hg1 = "§eOnline - Dados indisponiveis";
				} else {
					hg1 = "§eOffline";
					hg1t = "§c--";
					hg1o = "§c--";
				}


		Server Status2 = new Server(ip2, 25567);
		if (Status2.isOnline()) {
			String[] motd = Status2.getMotd().split(";");
			if (motd[0].equalsIgnoreCase("Carregando")) {
				hg2 = "§eCarregando";
				hg2t = "§e--";
				hg2o = "§e--";
			}
			if (motd[0].equalsIgnoreCase("Aguardando")) {
				hg2 = "§aAguardando para o torneio";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Invencibilidade")) {
				hg2 = "§eEm Invencibilidade";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Andamento")) {
				hg2 = "§cEm Jogo";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Finalizado")) {
				hg2 = "§6" + motd[1] + " Venceu!";
				hg2t = "§e--";
				hg2o = "§e--";
			}
			hg2 = "§eOnline - Dados indisponiveis";
		} else {
			hg2 = "§eOffline";
			hg2t = "§c--";
			hg2o = "§c--";
		}

		Server Status3 = new Server(ip3, 25568);
		if (Status3.isOnline()) {
			String[] motd = Status3.getMotd().split(";");
			if (motd[0].equalsIgnoreCase("Carregando")) {
				hg3 = "§eCarregando";
				hg3t = "§e--";
				hg3o = "§e--";
			}
			if (motd[0].equalsIgnoreCase("Aguardando")) {
				hg3 = "§aAguardando para o torneio";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Invencibilidade")) {
				hg3 = "§eEm Invencibilidade";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Andamento")) {
				hg3 = "§cEm Jogo";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Finalizado")) {
				hg3 = "§6" + motd[1] + " Venceu!";
				hg3t = "§e--";
				hg3o = "§e--";
			}
			hg3 = "§eOnline - Dados indisponiveis";
		} else {
			hg3 = "§eOffline";
			hg3t = "§c--";
			hg3o = "§c--";
		}
	} 

 

 

@edit

Fiz um debug '-' ele recebe null e o ip no isOnline '-'

bSnzjxd.png

E de repente aconteceu que ta só retornando false - null

Editado por Solitario
Link para o comentário
Compartilhar em outros sites

Tipo ... o socket ta funcional '-' 

 

Fiz um debug no socket ...

 

3TIP8tW.png

ta funcionando porém não ta funcionando os set eu acho '-'

 

Só estou no pc então só tem 1 servidor on '-'

 

Code que uso pra puxar:

 

Server Status = new Server(ip1, 25566);
				if (Status.isOnline()) {
					String[] motd = Status.getMotd().split(";");
					if (motd[0].equalsIgnoreCase("Carregando")) {
						hg1 = "§eCarregando";
						hg1t = "§e--";
						hg1o = "§e--";
					}
					if (motd[0].equalsIgnoreCase("Aguardando")) {
						hg1 = "§aAguardando para o torneio";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Invencibilidade")) {
						hg1 = "§eEm Invencibilidade";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Andamento")) {
						hg1 = "§cEm Jogo";
						hg1t = "§e" + motd[1];
						hg1o = "§e" + motd[2];
					}
					if (motd[0].equalsIgnoreCase("Finalizado")) {
						hg1 = "§6" + motd[1] + " Venceu!";
						hg1t = "§e--";
						hg1o = "§e--";
					}
					hg1 = "§eOnline - Dados indisponiveis";
				} else {
					hg1 = "§eOffline";
					hg1t = "§c--";
					hg1o = "§c--";
				}


		Server Status2 = new Server(ip2, 25567);
		if (Status2.isOnline()) {
			String[] motd = Status2.getMotd().split(";");
			if (motd[0].equalsIgnoreCase("Carregando")) {
				hg2 = "§eCarregando";
				hg2t = "§e--";
				hg2o = "§e--";
			}
			if (motd[0].equalsIgnoreCase("Aguardando")) {
				hg2 = "§aAguardando para o torneio";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Invencibilidade")) {
				hg2 = "§eEm Invencibilidade";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Andamento")) {
				hg2 = "§cEm Jogo";
				hg2t = "§e" + motd[1];
				hg2o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Finalizado")) {
				hg2 = "§6" + motd[1] + " Venceu!";
				hg2t = "§e--";
				hg2o = "§e--";
			}
			hg2 = "§eOnline - Dados indisponiveis";
		} else {
			hg2 = "§eOffline";
			hg2t = "§c--";
			hg2o = "§c--";
		}

		Server Status3 = new Server(ip3, 25568);
		if (Status3.isOnline()) {
			String[] motd = Status3.getMotd().split(";");
			if (motd[0].equalsIgnoreCase("Carregando")) {
				hg3 = "§eCarregando";
				hg3t = "§e--";
				hg3o = "§e--";
			}
			if (motd[0].equalsIgnoreCase("Aguardando")) {
				hg3 = "§aAguardando para o torneio";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Invencibilidade")) {
				hg3 = "§eEm Invencibilidade";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Andamento")) {
				hg3 = "§cEm Jogo";
				hg3t = "§e" + motd[1];
				hg3o = "§e" + motd[2];
			}
			if (motd[0].equalsIgnoreCase("Finalizado")) {
				hg3 = "§6" + motd[1] + " Venceu!";
				hg3t = "§e--";
				hg3o = "§e--";
			}
			hg3 = "§eOnline - Dados indisponiveis";
		} else {
			hg3 = "§eOffline";
			hg3t = "§c--";
			hg3o = "§c--";
		}
	} 

 

 

@edit

Fiz um debug '-' ele recebe null e o ip no isOnline '-'

bSnzjxd.png

E de repente aconteceu que ta só retornando false - null

vish slá talvez tente usar this.online = true; em vez do setOnline(true); já que está mexendo dentro da class.. não entendo de socket :/

Link para o comentário
Compartilhar em outros sites

vish slá talvez tente usar this.online = true; em vez do setOnline(true); já que está mexendo dentro da class.. não entendo de socket :/

é.... só que agora acho que não vai dar pra fazer já que o socket ta dando connection refused .-.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...