Skip to content

Instantly share code, notes, and snippets.

@EdGruberman
Created January 5, 2013 02:56
Show Gist options
  • Save EdGruberman/4459403 to your computer and use it in GitHub Desktop.
Save EdGruberman/4459403 to your computer and use it in GitHub Desktop.
Inventory.java
package edgruberman.bukkit.simpletest;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.plugin.Plugin;
public class Inventory implements Listener {
Inventory(final Plugin plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onInventoryClose(final InventoryCloseEvent event) {
final Player player = ((Player) event.getPlayer());
player.sendMessage("You just closed a " + event.getInventory().getHolder().getClass().getName());
if (!(event.getInventory().getHolder() instanceof BlockState)) return;
player.sendMessage("It is located at " + ((BlockState) event.getInventory().getHolder()).getLocation());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment