Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / FakeWither.java
Created January 10, 2014 00:27
FakeWither for 1.7.2. Remember to add the appropriate classes from PacketWrapper.
package com.comphenix.example;
import com.comphenix.protocol.events.PacketContainer;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@aadnk
aadnk / FlightController.java
Last active January 2, 2016 00:29
A simple API for multiple plugins to negotiate if flight is to be allowed. See http://forums.bukkit.org/threads/proposal-central-flight-mediation-plugin.214379/
package com.comphenix.example;
import java.util.Map;
import java.util.logging.Level;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
@aadnk
aadnk / SendRawTellPacket.java
Created January 1, 2014 03:36
Send a raw tell command to a player through ProtocolLib.
package com.comphenix.example;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@aadnk
aadnk / SignEditorPlugin.java
Created December 28, 2013 14:15
Allow players to edit signs through a command.
package com.comphenix.example;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ConcurrentMap;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@aadnk
aadnk / ItemSerialization.java
Created December 26, 2013 20:33
Only use this version if you've used ItemSerialization before, and want backwards compatibility. This Bukkit-only version is far superior: https://gist.github.com/aadnk/8138186
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;
@aadnk
aadnk / BukkitSerialization.java
Created December 26, 2013 20:17
Serialize and deserialize inventories to a string.
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
@aadnk
aadnk / ChangingUnknownCommand.java
Last active February 23, 2023 03:48
Change the "unknown command" message in 1.7.2 with ProtocolLib.
package com.comphenix.example;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
@aadnk
aadnk / FaviconMod.java
Created December 25, 2013 01:03
Use the player's face as server favicon. Uses an asynchronous manager to perform player skin downloads on different worker threads.
package com.comphenix.example;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
import java.util.Arrays;
import java.util.concurrent.ConcurrentMap;
@aadnk
aadnk / TinyProtocol.java
Last active December 25, 2022 22:46
A tiny method enabling packet interception. Also found here: http://bit.ly/1fvVWiX
package com.comphenix.tinyprotocol;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.Level;
// These are not versioned, but they require CraftBukkit
import net.minecraft.util.io.netty.channel.Channel;
@aadnk
aadnk / ModifyDroppedItemStack.java
Created November 11, 2013 21:38
Modify the appearance of a dropped item stack on the client side.
package com.comphenix.example;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ConnectionSide;
import com.comphenix.protocol.events.PacketAdapter;