Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / ChangingUnknownCommand.java
Created October 11, 2013 18:49
How to change the "unknown command" error message with ProtocolLib. Updated for Minecraft 1.6.4.
package com.comphenix.example;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.comphenix.protocol.Packets;
@aadnk
aadnk / GlowPlugn.java
Created October 15, 2013 23:53
Demonstrate the use of ItemRenamer's new API.
package com.comphenix.example;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@aadnk
aadnk / ExampleMod.java
Last active December 25, 2022 22:47
Intercept the TAB packet without ProtocolLib. Disallow tab completion of command names, but not parameters.
package com.comphenix.example;
import org.bukkit.plugin.java.JavaPlugin;
public class ExampleMod extends JavaPlugin {
private TabInterceptor interceptor;
@Override
public void onEnable() {
// Use ProtocolLib if its present
@aadnk
aadnk / AABB.java
Created October 23, 2013 18:25
A simple AABB intersection algorithm for Bukkit. Returns the intersection point as well.
/**
* Represents an axix-aligned bounding box.
*
* @author Kristian
*/
public class AABB {
public static class Vec3D {
/**
* Point with the coordinate (1, 1, 1).
*/
@aadnk
aadnk / FakePumpinHelmets.java
Created October 24, 2013 01:04
Display a fake pumkin helmet for all users. DEPRECIATED: Use https://gist.github.com/aadnk/11323369 instead.
package com.comphenix.example;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@aadnk
aadnk / Protocol.java
Created November 7, 2013 02:15
The original source code of ek.java (probably)
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import net.minecraft.server.Packet;
@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;
@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 / 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 / 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;