Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / EntityProximityDetector.java
Created October 8, 2012 18:21
Entity proximity detection API
package com.comphenix.proximity;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@aadnk
aadnk / MonitorListener.java
Created October 12, 2012 05:27
A monitor listener for ProtocolLib
package com.comphenix.example;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.events.ConnectionSide;
import com.comphenix.protocol.events.ListenerPriority;
@aadnk
aadnk / LoggedPluginManager.java
Created October 13, 2012 23:58
Simple proxy-classes for adding better error handling in Minecraft.
/*
* Logged-classes - Simple proxy-classes for adding better error handling in Minecraft.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
@aadnk
aadnk / ExampleMod.java
Last active December 6, 2022 18:28
Hide or show players in the player list only (TAB).
package com.comphenix.example;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class ExampleMod extends JavaPlugin {
private HidePlayerList playerList;
@aadnk
aadnk / Sleepwalking.java
Created October 25, 2012 19:34
Sleepwalking
package com.comphenix.example;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
@aadnk
aadnk / CountdownMod.java
Created October 29, 2012 22:11
Count down in the MOTD field.
package com.comphenix.example;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.apache.commons.lang.time.DateUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@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;
@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 / 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 / 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;