本文整理汇总了Java中org.spongepowered.api.item.inventory.slot.FuelSlot类的典型用法代码示例。如果您正苦于以下问题:Java FuelSlot类的具体用法?Java FuelSlot怎么用?Java FuelSlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FuelSlot类属于org.spongepowered.api.item.inventory.slot包,在下文中一共展示了FuelSlot类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemSmelt
import org.spongepowered.api.item.inventory.slot.FuelSlot; //导入依赖的package包/类
@Listener
public void onItemSmelt(ClickInventoryEvent event, @First Player player, @Getter("getTargetInventory") Inventory inventory) {
if (inventory.getArchetype() == InventoryArchetypes.FURNACE) {
Inventory smeltingInputs = inventory.query(QueryOperationTypes.INVENTORY_TYPE.of(InputSlot.class));
PermHandler ph = PermHandler.getInstance();
smeltingInputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {
ItemType itemType = itemStack.getType();
String itemId = itemType.getId();
if (slot instanceof FuelSlot) {
if (!ph.checkPerm(player, "protectionperms.item.fuel." + itemId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to use " + itemType.getName() + " as fuel!"));
}
} else {
if (!ph.checkPerm(player, "protectionperms.item.smelt." + itemId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to smelt " + itemType.getName() + '!'));
}
}
}));
}
}