spirit55555/php-minecraft 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

spirit55555/php-minecraft

最新稳定版本:v2.0.1

Composer 安装命令:

composer require spirit55555/php-minecraft

包简介

Useful PHP classes for Minecraft

README 文档

README

Latest Stable Version Total Downloads License PHP Version Require

PHP-Minecraft

Useful PHP classes for Minecraft

Using Composer?

First require it like this:

composer require spirit55555/php-minecraft

and then use it like this:

<?php
require 'vendor/autoload.php';
use \Spirit55555\Minecraft\MinecraftColors;

MinecraftColors::clean("test");
?>

Not using Composer?

Just download the files and include them.

MinecraftColors.php

Convert Minecraft color codes to HTML/CSS. Can also remove the color codes.

Usage

<?php
require 'vendor/autoload.php';
use \Spirit55555\Minecraft\MinecraftColors;

//Support for § and & signs
$text = '§4Lorem §3§lipsum §rdolor &nsit &c&mamet';

################
# JAVA EDITION #
################

//Convert to HTML with CSS colors
echo MinecraftColors::convertToHTML($text);

//Same as above, but will replace \n with <br />
echo MinecraftColors::convertToHTML($text, true);

//Same as above, but will use CSS classes instead of inline styles
echo MinecraftColors::convertToHTML($text, true, true, 'mc-motd--');

//Will be compatible with the server.properties file
echo MinecraftColors::convertToMOTD($text);

//Will be compatible with BungeeCord's config.yml file
echo MinecraftColors::convertToMOTD($text, '&');

//Will also output RGB/HEX colors, if they exist (&#000000)
//NOTE: Not supported in Vanilla Minecraft
echo MinecraftColors::convertToMOTD($text, '&', true);

//Same as above, but RGB/HEX in a long format (&x&0&0&0&0&0&0)
//NOTE: Not supported in Vanilla Minecraft
echo MinecraftColors::convertToMOTD($text, '&', true, true);

//Remove all color codes
echo MinecraftColors::clean($text);

###################
# BEDROCK EDITION #
###################

//Convert to HTML with CSS colors
echo MinecraftColors::convertToBedrockHTML($text);

//Same as above, but will use CSS classes instead of inline styles
echo MinecraftColors::convertToBedrockHTML($text, true, 'mc-motd--');

//Will be compatible with the server.properties file
echo MinecraftColors::convertToBedrockMOTD($text);

//Remove all color codes
echo MinecraftColors::cleanBedrock($text);

?>

MinecraftJSONColors.php

Converts Minecraft JSON text to legacy format ('§aHello')

Usage

<?php
require 'vendor/autoload.php';
use \Spirit55555\Minecraft\MinecraftJSONColors;

$first_component = ['text' => 'first '];
$second_component = ['text' => 'second ', 'color' => 'red'];
$third_component = ['text' => 'third ', 'strikethrough' => true];
$json = ['extra' => [$first_component, $second_component, $third_component]];

echo MinecraftJSONColors::convertToLegacy($json);
?>

MinecraftVotifier.php

Send Votifier votes to a Minecraft server.

This supports v2 (token) and v1 (public key) versions of the protocol.

If both are supplied, it will try v2 first and fall back to v1.

Usage

<?php
require 'vendor/autoload.php';
use Spirit55555\Minecraft\MinecraftVotifier;
use Spirit55555\Minecraft\MinecraftVotifierVote;

try {
	$vote = new MinecraftVotifierVote('SERVICE_NAME', 'IP_ADDRESS', 'USERNAME', 'UUID');

	$votifier = new MinecraftVotifier('SERVER_HOST', 'VOTIFIER_PORT', 'TOKEN', 'PUBLIC_KEY');
	$votifier->sendVote($vote);
}

catch (Exception $e) {
	echo $e->getMessage();
}
?>

More information about the Votifier protocols: https://github.com/NuVotifier/NuVotifier/wiki/Technical-QA

统计信息

  • 总下载量: 20.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 67
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 67
  • Watchers: 7
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2016-06-19