本文整理匯總了Java中org.bukkit.event.block.BlockPlaceEvent.getBlock方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPlaceEvent.getBlock方法的具體用法?Java BlockPlaceEvent.getBlock怎麽用?Java BlockPlaceEvent.getBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.block.BlockPlaceEvent
的用法示例。
在下文中一共展示了BlockPlaceEvent.getBlock方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
event.setCancelled(true);
return;
}
if (State.PVP)
return;
Block b = event.getBlock();
if (b.getType()==Material.TNT && !State.PVP) {
Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!");
event.setCancelled(true);
}
Team team = Team.getTeam(event.getPlayer());
if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
event.setCancelled(true);
}
if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
event.setCancelled(true);
}
}
示例2: onPlaceChest
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlaceChest(BlockPlaceEvent e) {
if (!cm.isAntiQuickDoubleChest) {
return;
}
Block block = e.getBlock();
if (block == null) {
return;
}
Material blockType = block.getType();
if (Material.CHEST == blockType || Material.TRAPPED_CHEST == blockType) {
if (isShopBlockNearby(block)) {
e.setCancelled(true);
e.getPlayer().sendMessage(i18n.tr("antiQuickShopDoubleChest"));
}
}
}
示例3: BlockPlaceEvent
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void BlockPlaceEvent(BlockPlaceEvent e){
Player p = e.getPlayer();
Block b = e.getBlock();
if (e.getItemInHand().getType() == Material.DROPPER && e.getItemInHand().getEnchantments() != null && e.getItemInHand().getEnchantments().containsKey(Enchantment.ARROW_DAMAGE)) {
Casino c = new Casino(e.getBlockPlaced().getLocation());
c.effect();
}
for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
if (en instanceof Player){
if(en == p) continue;
if(b.getType() == Material.FIRE){
if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado."));
e.setCancelled(true);
}
}
}
}
}
示例4: onPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent e) {
if (e.isCancelled()) {
return;
}
if (!e.getBlock().getType().equals(Material.CAULDRON)) {
return;
}
Block b = e.getBlock();
Location loc = b.getLocation();
loc.setY(loc.getY() + 1);
Block upon = loc.getBlock();
if (upon.getType().equals(Material.AIR)) {
return;
}
e.setCancelled(true);
e.getPlayer().sendMessage(Messages.getMessages().getNoPlace().replace("&", "§"));
}
示例5: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
Block b = event.getBlock();
b.setMetadata("blockBreaker", new FixedMetadataValue(PrisonPicks.getInstance(), player.getUniqueId()));
}
示例6: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
/**
* Tagging placed logs
*
* @param event Event
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
Block block = event.getBlock();
if (block.getType().equals(Material.LOG) || block.getType().equals(Material.LOG_2))
block.setMetadata("placed", new FixedMetadataValue(this.plugin, event.getPlayer().getUniqueId()));
}
示例7: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(final BlockPlaceEvent event) {
final Block block = event.getBlock();
if(block.getType() == FoundDiamondsListener.SEARCH_TYPE) {
this.foundLocations.add(block.getLocation().toString());
}
}
示例8: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onBlockPlace(final BlockPlaceEvent event) {
final Block block = event.getBlock();
final WorldBorder worldBorder = wbHandler.getBorder(block.getWorld());
if (worldBorder != null && !worldBorder.isInBounds(block)) {
event.setCancelled(true);
event.getPlayer().sendMessage(DENY_BUILD);
}
}
示例9: onPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent evt) {
Block source = evt.getBlock();
Structure s = match(source);
if (s == null) return;
s.onCreate(evt);
}
示例10: onPlaceBlock
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlaceBlock(BlockPlaceEvent e) {
Block block = e.getBlock();
Material blockMaterial = block.getType();
int x = block.getX();
int y = block.getY();
int z = block.getZ();
WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());
if (CropControl.getDAO().isTracked(block) == true) {
// We've got a replacement
CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
handleRemoval(block, chunk);
}
if (harvestableCrops.containsKey(blockMaterial)) {
// we placed a block overtop an existing crop. Will be handled by a break event?
/*Crop crop = chunk.getCrop(x, y, z);
if (crop != null) {
crop.setRemoved();
CropControl.getPlugin().debug("Missed an event? Replacing a Crop at {0}, {1}, {2}", x, y, z);
//return;
}*/
// We've placed a crop!
Crop.create(chunk, x, y, z, blockMaterial.toString(), getBaseCropState(blockMaterial),
e.getPlayer().getUniqueId(), System.currentTimeMillis(), harvestableCrops.get(blockMaterial));
} else if (blockMaterial == Material.SAPLING) {
// we placed a block overtop an existing sapling. TODO: Do I need to remove sapling here, or will there be a break event?
/*Sapling sapling = chunk.getSapling(x, y, z);
if (sapling != null) {
sapling.setRemoved();
CropControl.getPlugin().debug("Missed an event? Replacing a Sapling at {0}, {1}, {2}", x, y, z);
//return;
}*/
// We've placed a sapling!
Sapling.create(chunk, x, y, z, getSaplingType(block.getData()),
e.getPlayer().getUniqueId(), System.currentTimeMillis(), false);
} else if (blockMaterial == Material.CHORUS_FLOWER) {
/*if (CropControl.getDAO().isTracked(block) == true) {
CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
//return;
}*/
// TODO: Check if connected to an existing chorus tree.
// First register the "tree"
Tree chorusPlant = Tree.create(chunk, x, y, z, Material.CHORUS_PLANT.toString(),
e.getPlayer().getUniqueId(), System.currentTimeMillis());
// Then the component in the tree.
TreeComponent.create(chorusPlant, chunk, x, y, z, Material.CHORUS_PLANT.toString(),
e.getPlayer().getUniqueId(), false);
} else if (blockMaterial.isSolid()){ // check for cactus.
for (BlockFace face : CropControlEventHandler.directions) {
Block adj = block.getRelative(face);
if (Material.CACTUS.equals(adj.getType())) {
Location loc = adj.getLocation();
if (!pendingChecks.contains(loc)) {
pendingChecks.add(loc);
handleBreak(adj, BreakType.PLAYER, e.getPlayer().getUniqueId(), null);
}
}
}
}
}
示例11: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
blockBridge.notifyBlockUpdate(block.getLocation(), block.getType(), block.getState());
}