juggl/minecraft

此包已弃用且不再维护。作者建议使用sven/minecraft-php包。

围绕Minecraft API的流畅包装。

1.0.0 2015-10-03 20:11 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:51:50 UTC


README

本版本已弃用!请使用sven/minecraft-php代替。

Minecraft API

Latest Version on Packagist Total Downloads Software License

这是一个简单的包,为您提供了快速开始Minecraft网站开发的所有工具。通过简单的、易读的API检索基于用户名的UUID或反之。

安装

通过composer

$ composer require juggl/minecraft

如果您使用Laravel框架,可以将MinecraftServiceProvider添加到您的providers数组中

// config/app.php
'providers' => [
    ...
    Juggl\Minecraft\MinecraftServiceProvider::class,
    ...
];

您也可以将Minecraft外观添加到aliases数组中,以便使用外观

// config/app.php
'aliases' => [
    ...
    'Minecraft' => Juggl\Minecraft\Facades\Minecraft::class,
    ...
];

用法

$minecraft = new Juggl\Minecraft\Minecraft;

// Retrieve UUID (without dashes) based on the username provided.
$minecraft->getUuidFromName($username);

// Supply an optional UNIX timestamp to get the UUID of the user who owned that
// username at the time.
$minecraft->getUuidFromName($username, time() - (365 * 24 * 60 * 60));

// Get array of names the user has played as.
$minecraft->getNameHistory($uuid);

// Extract current username from UUID provided.
$minecraft->getNameFromUuid($uuid);

// Get array of objects with info about each user (username & UUID).
$minecraft->getUuidsFromNames(['Notch', 'jeb_', 'Dinnerbone']);

如果您在config/app.php中指定了别名,则可以使用外观

Minecraft::getUuidFromName($username);

当然,也可以以这种方式访问所有其他方法。

速率限制

Mojang实施了一些速率限制,因此您预计会缓存结果。本包中所有内容的限制为每10分钟600个请求。请注意,Mojang可能会随时更改此限制。

致谢

这是一个围绕Mojang的API的包装器,美丽(但非官方)地记录在http://wiki.vg/Mojang_API

许可证

Juggl\Minecraft根据MIT许可证(MIT)授权。有关更多信息,请参阅许可证文件