本文整理匯總了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();
}
}