Skip to content

Latest commit

Β 

History

History
68 lines (61 loc) Β· 1.66 KB

File metadata and controls

68 lines (61 loc) Β· 1.66 KB

BakaAPI

A Minecraft Server API Framework

Examples

examples.png

Config Samples

port: 8000 #Http API Port
auth: true #Use Authorize
password: "baka2333" #Authorize Password

Source Tree

.
β”œβ”€β”€ lib
β”‚Β Β  β”œβ”€β”€ PaperSpigot-latest.jar
β”‚Β Β  β”œβ”€β”€ gson-2.6.2.jar
β”‚Β Β  └── nanohttpd-2.2.0.jar
└── src
    β”œβ”€β”€ config.yml  #Plugin Config
    β”œβ”€β”€ moe
    β”‚Β Β  └── satori
    β”‚Β Β      └── BakaAPI
    β”‚Β Β          β”œβ”€β”€ App.java  # Http Service Class
    β”‚Β Β          β”œβ”€β”€ Controller #API Controller Class
    β”‚Β Β          β”‚Β Β  └── Players.java
    β”‚Β Β          β”œβ”€β”€ Main.java  #Plugins Main Class
    β”‚Β Β          └── Utils.java #Util Class
    └── plugin.yml  #Plugin Base Config
    

Authorize Demo

Please First composer require rmccue/requests

<?php
include 'vendor/autoload.php';
$api = "http://127.0.0.1:8000/";
$password = "baka2333";
$arr = [
	"action" => "Players",
	"method" => "kickPlayer",
	"username" => "KagurazakaSatori",
	"content" => "Meow: " . time(),
];
function getSign($arr, $secret) {
	ksort($arr);
	return strtoupper(md5(BuildQueryWithoutURLEncode($arr) . "@" . $secret));
}
function BuildQueryWithoutURLEncode($array) {
	$paramsJoined = array();
	foreach ($array as $param => $value) {
		$paramsJoined[] = "$param=$value";
	}
	$query = implode('&', $paramsJoined);
	return $query;
}
$sign = getSign($arr, $password);
$headers = [
	"X-AuthorizeToken" => $sign,
];

$result = Requests::get($api . "?" . BuildQueryWithoutURLEncode($arr), $headers);
print_r($result->body);