Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / PlayServerMultiBlockChange.java
Created March 31, 2014 00:04
Sending a WrapperPlayServerMultiBlockChange packet.
package com.comphenix.example;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class PlayServerMultiBlockChange extends JavaPlugin {
@Override
@aadnk
aadnk / OfflinePlayers.java
Created April 1, 2014 21:05
Serialize/deserialize offline player NBT data with ProtocolLib.
package com.comphenix.example;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
package com.comphenix.example;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
@aadnk
aadnk / DifferentArmorColor.java
Created April 10, 2014 01:54
Demonstrates different armor color per player.
package com.comphenix.example;
import org.bukkit.Color;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
@aadnk
aadnk / AnvilListener.java
Created April 13, 2014 00:44
Detect when anvils are broken by overuse.
package com.comphenix.example;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@aadnk
aadnk / CancelInventoryClick.java
Last active August 29, 2015 14:00
Cancel inventory clicks with TinyProtocol
package com.comphenix.example;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.example.Reflection.FieldAccessor;
import com.comphenix.example.Reflection.MethodInvoker;
import net.minecraft.util.io.netty.channel.Channel;
@aadnk
aadnk / FakeEquipment.java
Last active January 7, 2024 15:37
Modify the displayed armor and held item depending on the observing player.
/* The MIT License (MIT)
*
* Copyright (c) 2014 Kristian S. Stangeland
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@aadnk
aadnk / ItemSerialization.java
Last active November 30, 2015 18:35
ItemSerialization for Minecraft 1.7.9 that supports player inventories.
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.lang.reflect.Method;
import java.util.Arrays;
@aadnk
aadnk / AttackingHiddenPlayers.java
Created May 6, 2014 18:53
Attacking hidden players in 1.7.2.
package com.comphenix.example;
/*
* Attack hidden players
*
* Copyright 2014 Kristian S. Stangeland (Comphenix)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@aadnk
aadnk / PlayerDisplayModifier.java
Last active November 6, 2024 14:27
Change the display name and skin of any player. Credit to @bigteddy98, @ferrybig and @lenis0012 for writing the original version.
package com.comphenix.example;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;