GithubHelp home page GithubHelp logo

minecraft-query's Introduction

Minecraft Query

This is a go port of the minecraft-query library from xPaw PHP-Minecraft-Query

Example

  package main
  import (
    "fmt"

    mc "github.com/keloran/minecraft-query"
  )
  
  func main() {
    m := mc.Minecraft{
      Address: "localhost",
      Port: 25565,
      Timeout: 10,
    }
        
    ping(m)
    query(m)
  }
        
  func ping(m mc.Minecraft) {        
    ml, err := m.ConnectTCP()
    if err != nil {
      fmt.Printf("ping tcp: %v\n", err)
      return
    }
        
    r, err := ml.Ping(false)
    if err != nil {
      fmt.Printf("ping err: %v\n", err)
      return
    }
        
    ml.Disconnect()
    fmt.Printf("ping: %+v\n", r)
  }
        
  func query(m mc.Minecraft) {
    ml, err := m.ConnectUDP()
    if err != nil {
      fmt.Printf("query udp: %v\n", err)
      return
    }
        
    r, err := ml.Query()
    if err != nil {
      fmt.Printf("query err: %v\n", err)
      return
    }
        
    ml.Disconnect()
    fmt.Printf("query: %+v\n", r)
  }

Output

    ping: {
      Description: {
        Name: "A Minecraft Server",
      },
      Players: {
        Max: 20,
        Online: 1,
      },
      Version: {
        Version: "CraftBukkit 1.14.4", 
        Protocol: 498,
      }
    }

    query: {
      ServerInfo: {
        HostInfo: {
          Name: "A Minecraft Server", 
          Port: 25565,
          IP: "127.0.0.1",
        },
        Version: {
          Version: "1.14.4",
          Protocol: 0,
        },
        PlayerInfo: {
          Max: 20,
          Online: 1,
        },
      },
      GameInfo: {
        Type: "SMP",
        Name: "MINECRAFT",
        Map: "world",
      },
      Players:[{
        Name: "Keloran",
      }],
      Plugins:[{
        Name: "WorldEdit",
        Version: "7.0.1,61bc01",
      }, {
        Name: "WorldGuard", 
        Version: "7.0.1-SNAPSHOT,556b638",
      }],
    }
    

minecraft-query's People

Watchers

Max Hooton avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.