Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

com.bukket.samkio.Basic.BasicBlockListener.java

By: a guest on Jan 20th, 2011  |  syntax: Java  |  size: 1.03 KB  |  views: 2,778  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //The package
  2. package com.bukkit.samkio.Basic;
  3. //All the imports
  4. import com.bukkit.samkio.Basic.BasicPlayerListener;
  5. import org.bukkit.Material;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.block.BlockPlaceEvent;
  9. import org.bukkit.event.block.BlockListener;
  10. //Start the class BasicBlockListener
  11. public class BasicBlockListener extends BlockListener{
  12.          public static Basic plugin;
  13.          public BasicBlockListener(Basic instance) {
  14.          plugin = instance;
  15.     }
  16.          //This method is called when ever a block is placed.
  17.          public void onBlockPlace(BlockPlaceEvent event) {
  18.                  //Get the player doing the placing
  19.                         Player player = event.getPlayer();
  20.                         //Get the block that was placed
  21.                         Block block = event.getBlockPlaced();
  22.                         //If the block is a torch and the player has the command enabled. Do this.
  23.                         if(block.getType() == Material.TORCH && BasicPlayerListener.plugin.enabled(player)){
  24.                                 //Tells the player they have placed a torch
  25.                         player.sendMessage("You placed a torch!");
  26.                         }
  27.                 }
  28. }