
com.bukket.samkio.Basic.BasicBlockListener.java
By: a guest on
Jan 20th, 2011 | syntax:
Java | size: 1.03 KB | hits: 2,603 | expires: Never
//The package
package com.bukkit.samkio.Basic;
//All the imports
import com.bukkit.samkio.Basic.BasicPlayerListener;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockListener;
//Start the class BasicBlockListener
public class BasicBlockListener extends BlockListener{
public static Basic plugin;
public BasicBlockListener(Basic instance) {
plugin = instance;
}
//This method is called when ever a block is placed.
public void onBlockPlace(BlockPlaceEvent event) {
//Get the player doing the placing
Player player = event.getPlayer();
//Get the block that was placed
Block block = event.getBlockPlaced();
//If the block is a torch and the player has the command enabled. Do this.
if(block.getType() == Material.TORCH && BasicPlayerListener.plugin.enabled(player)){
//Tells the player they have placed a torch
player.sendMessage("You placed a torch!");
}
}
}