当前位置: 首页>>代码示例>>Java>>正文


Java SlotType.RESULT属性代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.SlotType.RESULT属性的典型用法代码示例。如果您正苦于以下问题:Java SlotType.RESULT属性的具体用法?Java SlotType.RESULT怎么用?Java SlotType.RESULT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.event.inventory.InventoryType.SlotType的用法示例。


在下文中一共展示了SlotType.RESULT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onShiftCrafting

@EventHandler(priority=EventPriority.LOW)
public void onShiftCrafting(InventoryClickEvent event) {
	if (event.getSlotType() == SlotType.RESULT
			&& event.getClick().equals(ClickType.SHIFT_LEFT)
			&& event.getWhoClicked() instanceof Player) {
		Player player = (Player) event.getWhoClicked();
		String playerID = PlayerConverter.getID(player);
		if (containsPlayer(playerID)) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:12,代码来源:CraftingObjective.java

示例2: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
            type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:67,代码来源:CraftInventoryView.java

示例3: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
                type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:66,代码来源:CraftInventoryView.java

示例4: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING && slot < 9) {
            type = SlotType.ARMOR;
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:60,代码来源:CraftInventoryView.java

示例5: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999 || slot == -1) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
                type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:66,代码来源:CraftInventoryView.java

示例6: a

public void a(Packet102WindowClick packet102windowclick) {
    if (this.player.dead) return; // CraftBukkit

    if (this.player.activeContainer.windowId == packet102windowclick.a && this.player.activeContainer.c(this.player)) {
        // CraftBukkit start - Call InventoryClickEvent
        if (packet102windowclick.slot == -1) {
            // Vanilla doesn't do anything with this, neither should we
            return;
        }

        InventoryView inventory = this.player.activeContainer.getBukkitView();
        SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot);

        InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
        org.bukkit.inventory.Inventory top = inventory.getTopInventory();
        if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) {
            org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
            if (recipe != null) {
                event = new org.bukkit.event.inventory.CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
            }
        }
        server.getPluginManager().callEvent(event);

        ItemStack itemstack = null;
        boolean defaultBehaviour = false;

        switch(event.getResult()) {
        case DEFAULT:
            itemstack = this.player.activeContainer.clickItem(packet102windowclick.slot, packet102windowclick.button, packet102windowclick.shift, this.player);
            defaultBehaviour = true;
            break;
        case DENY: // Deny any change, including changes from the event
            break;
        case ALLOW: // Allow changes unconditionally
            org.bukkit.inventory.ItemStack cursor = event.getCursor();
            if (cursor == null) {
                this.player.inventory.setCarried((ItemStack) null);
            } else {
                this.player.inventory.setCarried(CraftItemStack.asNMSCopy(cursor));
            }
            org.bukkit.inventory.ItemStack item = event.getCurrentItem();
            if (item != null) {
                itemstack = CraftItemStack.asNMSCopy(item);
                if (packet102windowclick.slot == -999) {
                    this.player.drop(itemstack);
                } else {
                    this.player.activeContainer.getSlot(packet102windowclick.slot).set(itemstack);
                }
            } else if (packet102windowclick.slot != -999) {
                this.player.activeContainer.getSlot(packet102windowclick.slot).set((ItemStack) null);
            }
            break;
        }
        // CraftBukkit end

        if (ItemStack.matches(packet102windowclick.item, itemstack)) {
            this.player.playerConnection.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true));
            this.player.h = true;
            this.player.activeContainer.b();
            this.player.broadcastCarriedItem();
            this.player.h = false;
        } else {
            this.r.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d));
            this.player.playerConnection.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false));
            this.player.activeContainer.a(this.player, false);
            ArrayList arraylist = new ArrayList();

            for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
                arraylist.add(((Slot) this.player.activeContainer.c.get(i)).getItem());
            }

            this.player.a(this.player.activeContainer, arraylist);

            // CraftBukkit start - Send a Set Slot to update the crafting result slot
            if (type == SlotType.RESULT && itemstack != null) {
                this.player.playerConnection.sendPacket((Packet) (new Packet103SetSlot(this.player.activeContainer.windowId, 0, itemstack)));
            }
            // CraftBukkit end
        }
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:81,代码来源:PlayerConnection.java

示例7: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            }
            break;
        case BREWING:
            if (slot == 0) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING && slot < 9) {
            type = SlotType.ARMOR;
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:agaricusb,项目名称:MCPBukkit,代码行数:60,代码来源:CraftInventoryView.java

示例8: onInventoryClick

public void onInventoryClick(InventoryClickEvent event) {
    if (event.getInventory().getType() == InventoryType.ANVIL && event.getSlotType() == SlotType.RESULT) {
        Inventory anvil = event.getInventory();
        ItemStack anvilResult = anvil.getItem(event.getSlot());
    }
}
 
开发者ID:HSAR,项目名称:OrdosLoot,代码行数:6,代码来源:OrdosLoot.java


注:本文中的org.bukkit.event.inventory.InventoryType.SlotType.RESULT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。