Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void update(){
- try{
- Socket socket = new Socket();
- socket.connect(new InetSocketAddress(ip, port), 1 * 1000);
- DataOutputStream out = new DataOutputStream(socket.getOutputStream());
- DataInputStream in = new DataInputStream(socket.getInputStream());
- out.write(0xFE);
- StringBuilder str = new StringBuilder();
- int b;
- while((b = in.read()) != -1){
- if(b != 0 && b > 16 && b != 255 && b != 23 && b != 24){
- str.append((char) b);
- }
- }
- String[] data = str.toString().split("§");
- int onlinePlayers = Integer.valueOf(data[1]);
- int maxPlayers = Integer.valueOf(data[2]);
- String motd = data[0];
- sign.setLine(0, "§aMini-Jeu");
- sign.setLine(1, onlinePlayers + "/" + maxPlayers);
- sign.setLine(2, ip);
- sign.setLine(3, motd);
- socket.close();
- }catch(Exception e){
- error = e.getLocalizedMessage();
- sign.setLine(0, "§4Mini-Jeu");
- sign.setLine(1, null);
- sign.setLine(2, ChatColor.DARK_RED + "Serveur fermé.");
- sign.setLine(3, null);
- }
- sign.update();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement