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