About

QueriEd is a Java library for querying server and player info from some popular game servers

  • Valid game types:
  • BF - Battlefield 1942
  • BF2 - Battlefield 2
  • BFV - Battlefield Vietnam
  • COD - Call of Duty
  • D3 - Doom 3
  • ET - Enemy Territory
  • HL - Halflife
  • HL2 - Halflife 2 (Source)
  • UT - Unreal Tournament
  • UT2003 - Unreal Tournament 2003
  • UT2004 - Unreal Tournament 2004
  • Q3 - Quake 3
  • NWN - Never Winter Nights

Usage

Here is some example code on how to use the library. This code is included in the package as Demo.java

package net.sourceforge.queried;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo {
    public static void main(String[] args) {
        // GG CS 194.29.194.31:27015
        check("HL", "194.29.194.31", 27015);
        check("HL", "212.112.129.13", 27028);
        check("HL", "212.112.129.13", 27027);
        
        // LK 129.242.32.199:14567
        check("BF", "129.242.32.199", 23000);
        
        // jolt bfv (06)
        check("BFV", "213.208.119.142", 23000);

        // gg - ET
        check("ET", "grave.netsonic.fi", 27960); 
        check("ET", "62.4.74.235", 30200);

        // CoD
        check("COD", "195.20.108.173", 28960);
        check("COD", "195.20.108.173", 28961);

        // Quake 3
        check("Q3", "212.110.165.69", 27961);
        check("Q3", "67.105.233.39", 27960);
        
        // UTs        
        check("UT", "213.201.220.12", 7778);
        check("UT2003", "82.165.33.64", 8898);
        check("UT2004", "193.195.76.213", 7787);

        // D3
        check("D3", "24.247.149.124", 27666);
        check("D3", "203.96.92.66", 28666);
    }

    private static void check(String gameType, String ip, int port) {
        System.out.println("ServerInfo ["+ gameType +"]:");

        ServerInfo serverInfo = QueriEd.serverQuery(27777, gameType, ip, port);
        if(serverInfo == null) {
            System.out.println("ServerInfo == null");
        } else {
            System.out.println(serverInfo.getName() +" :: IP: "+ serverInfo.getIp()
                +":"+ serverInfo.getPort() +" :: "+ serverInfo.getGame() +" :: Map: "+ serverInfo.getMap()
                +" :: Players: "+ serverInfo.getPlayerCount() +"/"+ serverInfo.getMaxPlayers());
        }
         

        System.out.println("PlayerInfo:");

        ArrayList playerInfo = QueriEd.playerQuery(27777, gameType, ip, port);
        if(playerInfo != null && playerInfo.size() > 0) {
            Iterator iter = playerInfo.iterator();
            int count = 0;
            while(iter.hasNext()) {
                PlayerInfo pInfo = (PlayerInfo) iter.next();
                if(count > 0) {
                    System.out.print(", ");
                }
                count++;
                System.out.print(pInfo.getName() +" ["+ pInfo.getScore() +"/"+ pInfo.getKills() +"/"+ pInfo.getDeaths() +"]");
            }
        } else {
            System.out.println("No players");
        }
        System.out.println("");
        System.out.println("");

    }

}