承接 publicuhc/minecraft-auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

publicuhc/minecraft-auth

Composer 安装命令:

composer require publicuhc/minecraft-auth

包简介

Fake Minecraft server for authentication checking

README 文档

README

SensioLabsInsight

PHP Library for running a 'fake' Minecraft server that checks authentications are correct with the session servers and kicks the player afterwards. Has a callback to change the disconnect message. I use if for verification codes to link minecraft accounts without needing them to input their password.

Install

Install via composer by adding "publicuhc/minecraft-auth": "dev-master" to your composer require.

Dependencies: Will be handled by composer on install, requires the PHP mcrypt extension to run. (You can install this on linux with apt-get install php5-mcrypt or similar)

Example Usage

use PublicUHC\MinecraftAuth\AuthServer\AuthServer;

$server = new AuthServer(25565, '0.0.0.0');

$server->on('login_success', function($username, $uuid, DisconnectPacket $packet){
    echo "USERNAME: $username, UUID: $uuid\n";
    $packet->setReason("USERNAME: $username, UUID: $uuid");
});

$server->on('status_request', function(StatusResponsePacket $packet) {
    $packet->setDescription('test server')
        ->setMaxPlayers(10)
        ->setOnlineCount(1000)
        ->setVersion('1.8+')
        ->setProtocol(47);
});

$server->start();

Explanation

new AuthServer(25565, '0.0.0.0');

Creates a new auth server to bind on the port 25565 and on all interfaces (0.0.0.0). If second parameter is ommited it will bind to 127.0.0.1 for localhost connections.

$server->on('login_success', function($username, $uuid, DisconnectPacket $packet){
    echo "USERNAME: $username, UUID: $uuid\n";
    $packet->setReason("USERNAME: $username, UUID: $uuid");
});

This is the login_success event. It is called whenever a successful connection has been made. Username is the username of the client connecting, UUID is the minecraft UUID (without -s). $packet is a DisconnectPacket object that will be sent to the client after the event. Use setReason (to set an array/string reason that will be json encoded before sending) or setReasonJSON (to set a pre-encoded json string).

$server->on('status_request', function(StatusResponsePacket $packet) {
    $packet->setDescription('test')
        ->setMaxPlayers(10)
        ->setOnlineCount(1000)
        ->setVersion('1.8+')
        ->setProtocol(47);
        ->setOnlinePlayers([
            [
                'name' => 'Eluinhost',
                'id'   => '000000000000-0000-0000-0000-00000000'
            ]
        ]);
});

This is the status_request event. It is called whenever a client requests data for the server list.

->setDescription(string); - Sets the description that shows up in the server list
->setMaxPlayers(int) - the number after the / on the list
->setOnlineCount(int) - the number before the / on the list
->setVersion(string) - If the client is connecting on a different protocol this version number will show instead of min/max players
->setProtocol(47) - The protocol version to set to, we only accept 47 so either set this to 47 or leave it out ->setOnlinePlayers(array) - An array of player names to show when hovering over the online count. For array format check the PHPDoc comment
->setFavicon(string) - The image in text format (i.e. data:image/png;base64,DATAHERE)

All of the method can be ignored. If they are not set the following will be set instead:

->setDescription(string); - Default: §4▁§e▂§4▃§e▄§4▅§e▆§4▇§e█ §4§l PHPAuthServer §e█§4▇§e▆§4▅§e▄§4▃§e▂§4▁ §c▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
->setMaxPlayers(int) - Default: -1
->setOnlineCount(int) - Default: -1
->setVersion(string) - Default: 1.8+ ->setProtocol(47) - Default: 47 ->setOnlinePlayers(array) - Default: []
->setFavicon(string) - Default: null (no favicon)

Due to the single thread nature of PHP all events will be blocking other code. If you run any long running processes in here it will stop processing other connections until it is complete. Either keep computation low or fork processes to run long running code.

`$server->start()`

Starts the server, nothing after this method will be called as it blocking, make sure to run everything you need before this.

统计信息

  • 总下载量: 136
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 27
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2014-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固