本文整理汇总了Java中org.bukkit.Material.CARPET属性的典型用法代码示例。如果您正苦于以下问题:Java Material.CARPET属性的具体用法?Java Material.CARPET怎么用?Java Material.CARPET使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.CARPET属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onButtonClick
@EventHandler
public void onButtonClick(final InventoryClickEvent event) {
ItemStack stack = event.getCurrentItem();
final MatchPlayer player = this.getMatch().getPlayer(event.getWhoClicked());
if(stack == null || player == null) return;
if(stack.getType() != Material.WOOL && stack.getType() != Material.CARPET) return;
ItemMeta meta = stack.getItemMeta();
if(!meta.hasDisplayName()) return;
String name = meta.getDisplayName();
if(!name.startsWith(BUTTON_PREFIX)) return;
event.setCancelled(true);
final int score = stack.getAmount();
if(!isScoreValid(score)) return;
this.getMatch().getScheduler(MatchScope.LOADED).createTask(() -> {
Integer oldScore = playerRatings.get(player);
if(oldScore == null || oldScore != score) {
player.playSound(Sound.UI_BUTTON_CLICK, 1, 2);
rate(player, score);
}
else {
player.getBukkit().closeInventory();
}
});
}
示例2: onPlace
@EventHandler
public void onPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
Material block = event.getBlock().getType();
if ((modMode.contains(player.getName())) &&
(block == Material.CARPET)) {
event.setCancelled(true);
player.updateInventory();
}
}