本文整理匯總了Java中org.bukkit.event.block.BlockPlaceEvent.getBlockPlaced方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPlaceEvent.getBlockPlaced方法的具體用法?Java BlockPlaceEvent.getBlockPlaced怎麽用?Java BlockPlaceEvent.getBlockPlaced使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.block.BlockPlaceEvent
的用法示例。
在下文中一共展示了BlockPlaceEvent.getBlockPlaced方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockBreak
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockPlaceEvent event) {
if (event.isCancelled()) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
return;
}
Block block = event.getBlockPlaced();
if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
int playerY = player.getLocation().getBlockY();
int blockY = block.getLocation().getBlockY();
if (playerY > blockY) {
Vector vector = player.getVelocity();
vector.setX(-0.1);
vector.setZ(-0.1);
player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
}
}
}
}
示例2: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlockPlaced();
ItemStack stack = event.getItemInHand();
Player player = event.getPlayer();
if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) {
ItemMeta meta = stack.getItemMeta();
if (meta.hasLore() && meta.hasDisplayName()) {
CreatureSpawner spawner = (CreatureSpawner) block.getState();
List<String> lore = meta.getLore();
if (!lore.isEmpty()) {
String spawnerName = ChatColor.stripColor(lore.get(0).toUpperCase());
Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class, spawnerName);
if (entityTypeOptional.isPresent()) {
spawner.setSpawnedType(entityTypeOptional.get());
spawner.update(true, true);
player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner.");
}
}
}
}
}
示例3: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
Gamer g = Gamer.get(event.getPlayer());
Block b = event.getBlockPlaced();
if (event.getBlockPlaced().getType() != Material.STONE_PLATE)
return;
event.setCancelled(false);
Mine mine = new Mine(g, b);
b.setMetadata("Mine", new FixedMetadataValue(Nexus.getPlugin(), Mine.getList().indexOf(mine)));
}