Skip to content

Instantly share code, notes, and snippets.

@MineTheCube
MineTheCube / TeamPacket.java
Created September 9, 2017 00:18
Create, update and remove scoreboard teams using packets
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 September 4, 2016 00:57
Crash a Minecraft client (close its window)
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 February 9, 2019 13:53
Detect when a player opens or closes his own inventory
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 September 1, 2016 18:27
Get head picture from base64 encoded texture
<?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 September 1, 2016 18:26
Display head of player from his username or uuid using MojangAPI (github project)
<?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 June 16, 2016 13:22
Authenticate with a Minecraft account
<?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 August 9, 2023 08:40
PHP functions to convert UUID to/from Minecraft username
<?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);