本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.SlotType方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryType.SlotType方法的具体用法?Java InventoryType.SlotType怎么用?Java InventoryType.SlotType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryType
的用法示例。
在下文中一共展示了InventoryType.SlotType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateClick
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
/**
* Check
*
* @return Click is valid
*/
private boolean validateClick(Player player, PlayerWrapper playerWrapper, Slot slot,
ActionType actionType, ItemStack currentItem, InventoryType.SlotType slotType) {
if (playerWrapper != null) {
if (player != playerWrapper.getPlayer()) {
return false;
}
if (!PlayerUtils.checkLevel(player, slot.getRequiredLevel())) {
PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.level", slot.getRequiredLevel()));
return false;
}
if (!slot.isFree() && !playerWrapper.isBuyedSlot(slot.getName()) && !InventoryManager.buySlot(player, playerWrapper, slot)) {
return false;
}
}
return !((actionType == ActionType.GET && slot.getSlotType() != Slot.SlotType.ACTION
|| actionType == ActionType.DROP) && slot.isCup(currentItem) && slotType != InventoryType.SlotType.QUICKBAR);
}
示例2: windowClicked
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
/**
* Called when an open window is clicked.
*/
default boolean windowClicked(InventoryView window,
Inventory inventory,
ClickType clickType,
InventoryType.SlotType slotType,
int slotIndex,
@Nullable ItemStack item) {
return false;
}
示例3: getSlotType
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
@Contract(pure = true)
public static InventoryType.SlotType getSlotType(InventoryType.SlotType slotType, int rawSlot) {
if (rawSlot > 80) {
return InventoryType.SlotType.QUICKBAR;
}
return slotType;
}
示例4: getSlot
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
@Nullable
public Slot getSlot(int slotId, InventoryType.SlotType slotType) {
for (Slot slot : this.slots) {
if (slotType == InventoryType.SlotType.QUICKBAR) {
if ((slot.isQuick() || slot.getSlotType() == Slot.SlotType.SHIELD) && slot.getQuickSlot() == slotId) {
return slot;
}
} else if (slot.containsSlot(slotId)) {
return slot;
}
}
return null;
}
示例5: updateShieldSlot
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
public static void updateShieldSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
InventoryType.SlotType slotType, InventoryAction action,
ItemStack currentItem, ItemStack cursor) {
ActionType actionType = ActionType.getTypeOfAction(action);
if (actionType == ActionType.GET) {
if (slot.isCup(currentItem)) {
return;
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), slot.getCup());
} else {
player.getEquipment().setItemInOffHand(new ItemStack(Material.AIR));
}
} else if (actionType == ActionType.SET) {
if (slot.isCup(currentItem)) {
currentItem = null;
action = InventoryAction.PLACE_ALL;
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), cursor);
} else {
player.getEquipment().setItemInOffHand(cursor);
}
}
InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
示例6: updateQuickSlot
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
public static void updateQuickSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
InventoryType.SlotType slotType, InventoryAction action,
ItemStack currentItem, ItemStack cursor) {
ActionType actionType = ActionType.getTypeOfAction(action);
if (actionType == ActionType.GET) {
if (slot.isCup(currentItem)) {
return;
}
if (player.getInventory().getHeldItemSlot() == slot.getQuickSlot()) {
InventoryUtils.heldFreeSlot(player, slot.getQuickSlot(), InventoryUtils.SearchType.NEXT);
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), slot.getCup());
} else {
player.getInventory().setItem(slot.getQuickSlot(), slot.getCup());
}
action = InventoryAction.SWAP_WITH_CURSOR;
cursor = slot.getCup();
} else if (actionType == ActionType.SET) {
if (slot.isCup(currentItem)) {
currentItem = null;
action = InventoryAction.PLACE_ALL;
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), cursor);
} else {
player.getInventory().setItem(slot.getQuickSlot(), cursor);
}
}
InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
示例7: windowClicked
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
@Override
public boolean windowClicked(InventoryView window, Inventory inventory, ClickType clickType, InventoryType.SlotType slotType, int slotIndex, @Nullable ItemStack item) {
return true;
}
示例8: updateInventory
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
private static void updateInventory(
@NotNull Player player,
@NotNull Inventory inventory,
int slot,
InventoryType.SlotType slotType,
InventoryAction action,
ItemStack currentItem,
ItemStack cursorItem
) {
if (ActionType.getTypeOfAction(action) == ActionType.DROP) {
return;
}
if (action == InventoryAction.PLACE_ALL) {
if (ItemUtils.isEmpty(currentItem)) {
currentItem = cursorItem.clone();
} else {
currentItem.setAmount(currentItem.getAmount() + cursorItem.getAmount());
}
cursorItem = null;
} else if (action == InventoryAction.PLACE_ONE) {
if (ItemUtils.isEmpty(currentItem)) {
currentItem = cursorItem.clone();
currentItem.setAmount(1);
cursorItem.setAmount(cursorItem.getAmount() - 1);
} else if (currentItem.getMaxStackSize() < currentItem.getAmount() + 1) {
currentItem.setAmount(currentItem.getAmount() + 1);
cursorItem.setAmount(cursorItem.getAmount() - 1);
}
} else if (action == InventoryAction.PLACE_SOME) {
cursorItem.setAmount(currentItem.getMaxStackSize() - currentItem.getAmount());
currentItem.setAmount(currentItem.getMaxStackSize());
} else if (action == InventoryAction.SWAP_WITH_CURSOR) {
ItemStack tempItem = cursorItem.clone();
cursorItem = currentItem.clone();
currentItem = tempItem;
} else if (action == InventoryAction.PICKUP_ALL) {
cursorItem = currentItem.clone();
currentItem = null;
} else if (action == InventoryAction.PICKUP_HALF) {
ItemStack item = currentItem.clone();
if (currentItem.getAmount() % 2 == 0) {
item.setAmount(item.getAmount() / 2);
currentItem = item.clone();
cursorItem = item.clone();
} else {
currentItem = item.clone();
currentItem.setAmount(item.getAmount() / 2);
cursorItem = item.clone();
cursorItem.setAmount(item.getAmount() / 2 + 1);
}
} else if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
player.getInventory().addItem(currentItem);
currentItem = null;
}
if (slotType == InventoryType.SlotType.QUICKBAR) {
if (slot < 9) { // Exclude shield
player.getInventory().setItem(slot, currentItem);
}
} else {
inventory.setItem(slot, currentItem);
}
player.setItemOnCursor(cursorItem);
player.updateInventory();
}
示例9: getSlotType
import org.bukkit.event.inventory.InventoryType; //导入方法依赖的package包/类
@Override
public InventoryType.SlotType getSlotType() {
return delegate.getSlotType();
}