• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

codyphobe/minecraft: A class that enables developers to intergrate Minecraft wit ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

codyphobe/minecraft

开源软件地址(OpenSource Url):

https://github.com/codyphobe/minecraft

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Minecraft Class

This class was developed to provide a set of functions to integrate Minecraft within your projects. Under no circumstances are you permitted to use this for malicious purposes.

Example Usage

require 'class.minecraft.php';
if ($minecraft->signin('username', 'password')) {
    foreach($minecraft->account as $field => $value) {
        echo $field . '->' . $value . '<br>';
    }
} else {
    echo $minecraft->getLastError();
}

Login

$minecraft->signin('username', 'password', 'version');

This function is used to login to your Minecraft account, taking 3 parameters: username (or email since Mojang account migration), password and the version of the minecraft launcher (optional) which is currently 12 by defaults. This returns true if the user was successfully authenticated and false otherwise. An array is also set upon successful login which contains the following...

  • current_version: The current version of the games resources.
  • correct_username: A correctly formatted username.
  • session_token: The current session used to login to the Minecraft client.
  • premium_account: If the account specified is of premium status.
  • player_skin: The url to the users custom skin, if applicable.
  • request_timestamp: the timestamp for the request which is formatted as DDMMYYYYHHMMSS in local server time.

If the authentication fail, you can use the getLastError() method to see why.


Is Premium

$minecraft->isPremium('username');

This function determines if the user specified has a premium account or not. It takes a single parameter of username (optional if already used successfully the signin method) and returns true if a premium account was detected and false otherwise.


Get Skin Url

$minecraft->getSkinUrl('username');

This function firstly checks the user specified has a premium account, then returns an url to the skin file for that user if a custom skin was found. It takes a single parameter which is the username of the user you which to get the skin file of (optional if already used successfully the signin method).


Keep Alive

$minecraft->keepAlive('session', 'username');

This function is used to keep the user's current session alive, this command needs to be sent to the Minecraft servers every 600 ticks (60 seconds) otherwise the user is signed out. It takes 2 parameters, the username and session returned from signing into the account (optionals if already used successfully the signin method), this can be obtained with the code above...


Account

$minecraft->account['session_token'];

This variable is false if you didn't sign in correctly.


Render Skin

$minecraft->renderSkin($render_type, $size, $username);

This function renders the specified player's skin. It takes 3 parameters, the first being the username of the player who's skin you wish to render, the render_type which can either be head OR body and the size you would like the rendered image to be. Please note when rendering the full body, the image width is half the size of the image height. You can include this function directly inside a img tag by using the following example...

<img src="data:image/png;base64,<?= base64_encode($minecraft->renderSkin('head', 64, 'nblackburn')) ?>">

If you want to call a php script which generate rendered skin, you can also use it like that :

<?php

require 'class.minecraft.php';

header('Content-Type: image/png');
$mc = new Minecraft();
// parameters can be passed by GET e.g.
echo $mc->renderSkin('head', 64, 'nblackburn');

So in your html file, you can just like it like an ordinary image.

<img src="path/to/your/script.php">

Get Username

$minecraft->getUsername();

This function return the username of the last successfully signed in user.

If no user has been successfully signed in, this function will throw an exception.

Get Last Error

$minecraft->getLastError();

This function can be called after an unsuccessfull call of signin to know why it failed.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap