Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / BukkitUnwrapper.java
Created December 22, 2012 17:59
Get the underlying net.minecraft.server-object of any Entity or ItemStack.
package com.comphenix.example;
/*
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
@aadnk
aadnk / ItemSerialization.java
Last active December 9, 2015 23:08
Enable serialization of CraftBukkit inventories. Compatible with version 1.4.7 only.
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import net.minecraft.server.v1_4_R1.NBTBase;
@aadnk
aadnk / MobSpawner.java
Created December 14, 2012 14:57
Spawn a fake mob using ProtocolLib
package com.comphenix.example;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
package com.comphenix.example;
/*
* Attack hidden players
*
* Copyright 2012 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 / PathFinderExample.jar
Created November 26, 2012 06:28
Path-find to a nearby block lit by sunlight
package com.comphenix.example;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.PathEntity;
import net.minecraft.server.PathPoint;
import net.minecraft.server.WorldServer;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@aadnk
aadnk / SynchronousCensor.java
Created November 21, 2012 05:43
Using the new synchronous client packet listeners
package com.comphenix.example;
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;
import com.comphenix.protocol.Packets;
@aadnk
aadnk / ColorChanger.java
Created November 19, 2012 05:33
Changing the color of armor with ProtocolLib
package com.comphenix.example;
import java.util.logging.Level;
import net.minecraft.server.NBTTagCompound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
@aadnk
aadnk / ItemSerialization.java
Created November 18, 2012 01:16
Serialize inventories using NBT (BASE 64 version)
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
@aadnk
aadnk / ItemSerialization.java
Created November 18, 2012 01:15
Serialize inventories using NBT
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.math.BigInteger;
import net.minecraft.server.NBTBase;
import net.minecraft.server.NBTTagCompound;
@aadnk
aadnk / TemporaryModifcations.java
Last active October 12, 2015 18:27
Using Google Guava to restore blocks after a certain amount of time.
package com.comphenix.example;
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;