Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / CancellationDetector.java
Last active April 23, 2025 02:06
A class that allows you to detect which plugin cancelled a given event.
package com.comphenix.example;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import org.bukkit.event.Cancellable;
@aadnk
aadnk / DetectFireworks.java
Created May 15, 2013 04:25
Detect when fireworks explode.
package com.comphenix.example;
import org.bukkit.World;
import org.bukkit.entity.Firework;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ConnectionSide;
@aadnk
aadnk / Ability.java
Last active November 6, 2024 14:25
A simple cooldown system with charges.
package com.comphenix.example;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.bukkit.entity.Player;
public class Ability {
/**
@aadnk
aadnk / BlockChangeArray.java
Created May 17, 2013 04:42
Disguise a block (like a chest) as an arbitrary block.
package com.comphenix.example;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.bukkit.Location;
import org.bukkit.World;
/**
* Utility class for creating arrays of block changes.
@aadnk
aadnk / GhostManager.java
Created May 25, 2013 02:06
Ghosts in Minecraft
// Based on lenis0012's GhostFactory
package com.comphenix.example;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
@aadnk
aadnk / GhostManager.java
Last active July 13, 2019 21:22
Second version of GhostManager
package com.comphenix.example;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@aadnk
aadnk / VisibilityDetection.java
Created June 5, 2013 17:35
Detect if players are visible to each other. May need some reworking to make it more accurate.
package com.comphenix.example;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@aadnk
aadnk / ChangingUnknownCommand.java
Created June 8, 2013 12:07
How to change the "unknown command" error message with ProtocolLib.
package com.comphenix.example;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary;
@aadnk
aadnk / SpawnFakeWither.java
Last active December 18, 2015 14:59
Spawn a fake wither boss. 1.7.2 version: https://gist.github.com/aadnk/9373802
package com.comphenix.example;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
@aadnk
aadnk / MapPacketSize.java
Last active December 18, 2015 20:39
Measure the size of map packets sent to every player.
package com.comphenix.example;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import net.minecraft.server.v1_5_R3.Packet;
import org.bukkit.Location;