Skip to content

Instantly share code, notes, and snippets.

@MineTheCube
MineTheCube / TeamPacket.java
Created Sep 9, 2017
Create, update and remove scoreboard teams using packets
View TeamPacket.java
package fr.onecraft.packets;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import java.util.Collection;
public class TeamPacket {
public enum Action {
@MineTheCube
MineTheCube / CrashClient.java
Created Sep 4, 2016
Crash a Minecraft client (close its window)
View CrashClient.java
package fr.onecraft.client;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@MineTheCube
MineTheCube / DetectInventoryOpenClose.java
Last active Feb 9, 2019
Detect when a player opens or closes his own inventory
View DetectInventoryOpenClose.java
package fr.onecraft.inventory;
import com.comphenix.tinyprotocol.TinyProtocol;
import io.netty.channel.Channel;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
@MineTheCube
MineTheCube / texture-to-head.php
Created Sep 1, 2016
Get head picture from base64 encoded texture
View texture-to-head.php
<?php
// Encoded equivalent of:
// {"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/56936d4f0d1b93fef775b1fbd19281b70c6f88475bb5a41bf372c12f1f8a22"}}}
$base64 = 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTY5MzZkNGYwZDFiOTNmZWY3NzViMWZiZDE5MjgxYjcwYzZmODg0NzViYjVhNDFiZjM3MmMxMmYxZjhhMjIifX19';
// Return skin from base64 texture
function get_head_from_texture($base64) {
$texture = json_decode(base64_decode($base64), true);
if (is_array($texture) and isset($texture['textures'], $texture['textures']['SKIN'], $texture['textures']['SKIN']['url'])) {
@MineTheCube
MineTheCube / head-api.php
Last active Sep 1, 2016
Display head of player from his username or uuid using MojangAPI (github project)
View head-api.php
<?php
/**
* Informations
* --------------------------------------
*
* This script use MojangAPI to display head of player from his username or uuid
*
* Parameters:
* user = username or UUID
@MineTheCube
MineTheCube / mc-authenticate.php
Created Jun 16, 2016
Authenticate with a Minecraft account
View mc-authenticate.php
<?php
/**
* Authenticate with a Minecraft account
*
* After a few fails, Mojang server will deny all requests, so use a proxy to bypass that limit
*
* @example $account = authenticate('user@gmail.com', '123456', '107.170.58.132:3128');
*
* @param string $id Minecraft username or Mojang email
@MineTheCube
MineTheCube / mc-api.php
Last active Aug 6, 2021
PHP functions to convert UUID to/from Minecraft username
View mc-api.php
<?php
/**
* Get UUID from Username
*
* @param string $username
* @return string|bool UUID (without dashes) on success, false on failure
*/
function username_to_uuid($username) {
$profile = username_to_profile($username);