Skip to content

Instantly share code, notes, and snippets.

Garris0n- / lazy cooldown
Last active Aug 29, 2015
Lazy cooldown example
View lazy cooldown
//this demonstrates lazy cooldowns, because using a list and a scheduler is an absolutely terrible idea
//BCBroz, why do you cause us so much pain...*sigh*
//in this example, the ability is to be able to break a block instantly with your fist once per minute
//as this is an example for tutorial purposes, a lot of code is dragged out into variables for clarity
//please do not copy-paste or use this code without reading the comments and fully understanding what is going on
private HashMap<UUID, Long> map = new HashMap<UUID, Long>(); //the map to hold our cooldown times
Garris0n- / self-cancelling task
Last active Jul 18, 2021
Example of a self-cancelling Bukkit task.
View self-cancelling task
public void countdown(final Player player){ //A method
new BukkitRunnable(){ //BukkitRunnable, not Runnable
int countdown = 10; //Instance variable in our anonymous class to easily hold the countdown value
public void run(){
if(countdown <= 0 || !player.isOnline()){ //countdown is over or player left the server, just two example reasons to exit
package de.bananaco.change;
import net.minecraft.server.v1_7_R1.*;
import org.bukkit.*;
import org.bukkit.command.*;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.event.player.PlayerJoinEvent;
public class WorldChanger extends JavaPlugin implements Listener {
((Map) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass);
//Registers the name to the mob, this appears to be for saving nbt tags. Theoretically, this will turn all mobs in your world into your mob, so maybe you shouldn't touch it.
((Map) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString);
//Registers the name you provided. This appears to be used by stuff and not do anything wrong, so you should probably leave this one.
((Map) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass);
//Registers mob id to this mob, which, I believe, will cause it to become the default mob class for the id provided.
((Map) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, paramInt);
//Registers the mob to the mob id. This is essentially the reverse of e, and, I believe, assigns how the mob will display to clients. I'm pretty sure the client crashes without this one.
((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString,
Garris0n- / gist:8509072
Created Jan 19, 2014
Copy-pasteable info thingy on java/bukkit learning resources
View gist:8509072
[url=]Official[/url] | [url=]Youtube[/url] | [url=]Book[/url]
[url=]Official[/url] | [url=]Youtube[/url] | [url=]Book[/url]
View Anvil Opener (1.7.2).java
//Method to open an anvil inventory to a player
public static void openAnvil(Player player, Inventory inventory){
//Get our EntityPlayer
EntityPlayer p = ((CraftPlayer) player).getHandle();
//Create the AnvilContainer
AnvilContainer container = new AnvilContainer(p);
Garris0n- /
Last active Dec 31, 2015
Location <--> String serialization
public static String locationToString(Location location){ //Method to turn a location into a string
return location.getWorld() + ";" + location.getX() + ";" + location.getY() + ";" + location.getZ(); //Return a string with the format world;x;y;z
public static Location stringToLocation(String string){ //turn a string into a location