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


Java SlotType.CONTAINER属性代码示例

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


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

示例1: 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

示例2: 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

示例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;
            }
            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

示例4: onInventoryClickEvent

@EventHandler
public void onInventoryClickEvent(final InventoryClickEvent event) {
	if (event.getWhoClicked() instanceof Player) {
		Player player = (Player) event.getWhoClicked();
		Game game = api.getGameManager().getGame(player);
		if (game != null) {
			if (game.getState() == GameState.PLAYING|| game.getState() == GameState.ENDING) {
				event.setCancelled(true);
				return;
			}
		}
		if (api.getInvManager().inGameInvContains(player.getUniqueId())) {
			event.setCancelled(true);
			if (event.getSlotType() != SlotType.CONTAINER)
				return;
			Game g = api.getGameManager().getGame(event.getSlot());
			if (g == null)
				return;
			if (api.getGameManager().isPlayerInGame(player)) {
				api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("already in game"));
				return;
			}
			api.getTeamManager().addPlayer(player, g, PlantType.PEASHOOTER, ZombieType.BASIC);
			player.closeInventory();
		} else if (api.getInvManager().inTypeInvContains(player.getUniqueId())) {
			event.setCancelled(true);
			if (game == null) {
				api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("not in a game"));
				return;
			}
			if (game.getState() == GameState.WAITING || game.getState() == GameState.STARTING) {
				PlantType plantType = api.getInvManager().getPlantType(event.getSlot());
				ZombieType zombieType = api.getInvManager().getZombieType(event.getSlot());
				
				if (plantType == null && zombieType == null)
					return;
				
				if (game.getPlants().getMembers().containsKey(player.getUniqueId())) {
					if (plantType != null) {
						if (!player.hasPermission(api.getInvManager().getPermission(event.getSlot()))) {
							api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("upgrade"));
							player.closeInventory();
							return;
						}
						api.getTeamManager().removePlant(player);
						HashMap<UUID, PlantType> plants = game.getPlants().getMembers();
						plants.put(player.getUniqueId(), plantType);
						game.getPlants().setMembers(plants);
						player.closeInventory();
						api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("type changed"));
					}
				} else if (game.getZombies().getMembers().containsKey(player.getUniqueId())) {
					if (zombieType != null) {
						if (!player.hasPermission(api.getInvManager().getPermission(event.getSlot()))) {
							api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("upgrade"));
							player.closeInventory();
							return;
						}
						api.getTeamManager().removeZombie(player);
						HashMap<UUID, ZombieType> zombies = game.getZombies().getMembers();
						zombies.put(player.getUniqueId(), zombieType);
						game.getZombies().setMembers(zombies);
						player.closeInventory();
						api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("type changed"));
					}
				}
			} else {
				api.getMessageUtil().sendMessage(player, api.getMessageUtil().getMessage("game already started"));
				player.closeInventory();
			}
		}
	}
}
 
开发者ID:Lactem,项目名称:PvZ,代码行数:73,代码来源:Events.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: 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


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