Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / UpdateAttributes.java
Created July 28, 2013 03:32
How to intercept and modify Packet44UpdateAttributes in ProtocolLib 2.5.1. This example modifies the sprint speed to be 200% faster.
package com.comphenix.example;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ConnectionSide;
@aadnk
aadnk / OrcishMod.java
Created August 3, 2013 18:46
Transform text into orcish
package com.comphenix.example;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
@aadnk
aadnk / PressurePlate.java
Created August 11, 2013 04:34
Suppress pressure plate sounds.
package com.comphenix.example;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
@aadnk
aadnk / SoundlessTeethlessExplosion.java
Created August 29, 2013 21:44
Create a soundless explosion that does no damage.
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.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@aadnk
aadnk / ItemRenamerHideLore.java
Created September 25, 2013 02:05
Using the new ItemRenamer API to hide lore.
package com.comphenix.example;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.shininet.bukkit.itemrenamer.api.RenamerAPI;
@aadnk
aadnk / NbtFactory.java
Last active December 29, 2020 04:29
A compact library for editing or creating NBT tags, ready to be inserted into your project. It doesn't directly depend on CraftBukkit, but uses reflection to access it dynamically. Use this version for 1.7.2: http://tinyurl.com/attributestorage
package com.comphenix.example;
import java.io.BufferedInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@aadnk
aadnk / Attributes.java
Last active August 7, 2019 00:30
An attribute API that uses the following NbtFactory library: https://gist.github.com/aadnk/6753244
package com.comphenix.example;
import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bukkit.inventory.ItemStack;
@aadnk
aadnk / AttributeStorage.java
Created September 29, 2013 17:12
Store arbitrary data on an ItemStack safely by using attributes. Use the following attribute class: https://gist.github.com/aadnk/6754159
package com.comphenix.example;
import java.util.UUID;
import org.bukkit.inventory.ItemStack;
import com.comphenix.example.Attributes.Attribute;
import com.comphenix.example.Attributes.AttributeType;
import com.comphenix.example.Attributes.Operation;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
@aadnk
aadnk / ExtendLogoutTime.java
Last active December 25, 2015 01:09
Extend the time player's stay logged on on the server when they log out. This prevents PvP'ers from logging out in the middle of a fight.
package com.comphenix.example;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@aadnk
aadnk / ExtendedLogoutTime2.java
Created October 10, 2013 02:47
Second attempt at extending the logout time of players. This time we also handle players that simply quit the application.
package com.comphenix.example;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;