本文整理汇总了Java中org.bukkit.inventory.Inventory.addItem方法的典型用法代码示例。如果您正苦于以下问题:Java Inventory.addItem方法的具体用法?Java Inventory.addItem怎么用?Java Inventory.addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: construct
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public void construct(Player p) {
Bukkit.getPluginManager().registerEvents(this, AlphaLibary.getInstance());
Inventory page = getBlankPage(title, size);
for (ItemStack item : items) {
if (page.firstEmpty() == -1) {
PAGES.add(page);
page = getBlankPage(title, size);
page.addItem(item);
} else {
page.addItem(item);
}
}
PAGES.add(page);
p.openInventory(PAGES.get(currpage));
USERS.put(p.getUniqueId(), this);
}
示例2: show
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public void show() {
Inventory inv = Bukkit.getServer().createInventory(p, 9, Chat.colors("&oVoting Panel"));
int index = 0;
for (Map m : Map.getList()) {
ItemStack item = new ItemStack(Material.WOOL, 1, (short) index);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.AQUA + m.getTitle());
List<String> lore = new ArrayList<String>();
lore.add(Chat.colors("&2Votes: &f" + m.getVotes().size()));
lore.add(Chat.colors("&7Click to vote for this map!"));
meta.setLore(lore);
item.setItemMeta(meta);
inv.addItem(item);
index += 1;
}
p.openInventory(inv);
}
示例3: pushItems
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public ItemStack pushItems(Location l, ItemStack item, int slots[])
{
Inventory inv = inject(l, slots);
Map map = inv.addItem(new ItemStack[] {
item
});
int ai[];
int j = (ai = slots).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
}
Iterator iterator = map.entrySet().iterator();
if(iterator.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
return (ItemStack)entry.getValue();
} else
{
return null;
}
}
示例4: setup
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void setup(Player player) {
Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(plugin.getChallengesFile().getChallengesAmount()), ChatColor.BOLD + "Challenges");
String status = ChatColor.GREEN + " [COMPLETED]";
int level = plugin.getPlayerManager().getRank(player);
int prestige = plugin.getPlayerManager().getPrestige(player);
for(int i = 1; i <= plugin.getChallengesFile().getChallengesAmount(); i++) {
if(level + 1 == i)
status = ChatColor.YELLOW + " [CURRENT]";
else if(i > level)
status = ChatColor.RED + " [LOCKED]";
inv.addItem(ItemStackGenerator.createItem(plugin.getChallengesFile().getTypeMaterial(i), 0, 0, ChatColor.GOLD + "" + i + Convert.getOrdinalFor(i) + " challenge" + status,
Arrays.asList(ChatColor.GRAY + "Type: " + ChatColor.RED + WordUtils.capitalize(plugin.getChallengesFile().getType(i)),
ChatColor.GRAY + "Cost: " + Convert.toPrice(plugin.getChallengesFile().getPrice(i) * (prestige + 1), true)), true));
}
player.openInventory(inv);
}
示例5: setupAbilitiesMenu
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void setupAbilitiesMenu(Player player, boolean temporary) {
String title = temporary ? "Temporary" : "Permanent";
Inventory inventory = Bukkit.createInventory(player, Convert.getInventorySize(plugin.getAbilityManager().getAbilities().size()),
ChatColor.BOLD + title + " God Tokens");
for(Ability ability : plugin.getAbilityManager().getAbilities()) {
List<String> description = new ArrayList<>(ability.getDescription());
// Adding price depending whetver ability is permanent or temporary
if(temporary) {
description.add(ChatColor.GRAY + "Duration: " + ChatColor.RED + "15 minutes");
}
int price = temporary ? ability.getTemporaryPrice() : ability.getPermanentPrice();
String line = ChatColor.GRAY + "Price: " + ChatColor.RED + price + " GT";
description.add(line);
description.add(ChatColor.GRAY + "Supported items:");
for(ItemType item : ability.getItems()) {
description.add(ChatColor.RED + "- " + WordUtils.capitalize(item.toString().replaceAll("_", "").toLowerCase()));
}
inventory.addItem(ItemStackGenerator.createItem(ability.getIcon(), 0, 0, ChatColor.RED + ability.getName(), description, true));
}
player.openInventory(inventory);
}
示例6: pushItems
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static ItemStack pushItems(Location l, ItemStack item)
{
Inventory inv = inject(l);
Map map = inv.addItem(new ItemStack[] {
item
});
int ai[];
int j = (ai = getOutputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
}
Iterator iterator = map.entrySet().iterator();
if(iterator.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
return (ItemStack)entry.getValue();
} else
{
return null;
}
}
示例7: archived
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static Inventory archived(Player player) {
Inventory i = Bukkit.createInventory(null, 54, Messager.color("&7Archived Requests"));
ItemStack back = new ItemStack(Material.ARROW);
ItemMeta im = back.getItemMeta();
im.setDisplayName(Messager.color("&cBack"));
back.setItemMeta(im);
i.setItem(45, back);
int tillFull = 0;
for (int x = Main.getInstance().getConfig().getInt("current_id"); x <= 0; x--) {
if (tillFull >= 53) {
Messager.msgPlayer("&cAll of the archived requests could not fit in the GUI. Showing the newest first.", player);
break;
}
BanRequest br = new BanRequest(x);
if (br.closed) {
i.addItem(br.getArchivedItem());
tillFull++;
}
}
return i;
}
示例8: onPlayerInit
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
/**
* Gives players the resources necessary to enchant when they start playing in the game.
*
* @param event The event
*/
@EventHandler
public void onPlayerInit(PlayerInitEvent event) {
Player player = event.getPlayer();
Inventory inventory = player.getInventory();
inventory.addItem(
new ItemStack(Material.ENCHANTMENT_TABLE, 64),
new ItemStack(Material.BOOKSHELF, 64),
new ItemStack(Material.BOOKSHELF, 64),
new ItemStack(Material.LAPIS_BLOCK, 64)
);
if (anvils) {
inventory.addItem(new ItemStack(Material.ANVIL, 64));
}
player.setLevel(30);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
}
示例9: onCommand
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if(!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(GodFoodFile.getEffectAmount()), ChatColor.BOLD + "FoG");
for(int i = 1; i <= GodFoodFile.getEffectAmount(); i++) {
List<String> effects = new ArrayList<>();
for(String str : GodFoodFile.GetEffects(i)) {
String[] values = str.split(", ");
effects.add(ChatColor.RED + values[0] + " " + Convert.arabicToRome(Integer.parseInt(values[2])) + ChatColor.LIGHT_PURPLE + " " + values[1] + " sec.");
}
inv.addItem(ItemStackGenerator.createItem(
GodFoodFile.getFoodType(i), GodFoodFile.getAmount(i), GodFoodFile.getData(i), ChatColor.LIGHT_PURPLE + GodFoodFile.getName(i), effects));
}
player.openInventory(inv);
return true;
}
示例10: SimpleMovingInventory
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
/**
* Creates a new {@link Inventory} with multiple Sites
*
* @param p the {@link Player} to open the {@link Inventory} for
* @param size the site of the {@link Inventory}
* @param items a {@link ArrayList} of {@link ItemStack}s which should be inside the {@link Inventory}
* @param name the name of the {@link Inventory}
* @param nextPage the name for the {@link ItemStack} for the next page
* @param prevPage the name for the {@link ItemStack} for the previous page
*/
public SimpleMovingInventory(Player p, int size, ArrayList<ItemStack> items, String name, ItemStack nextPage, ItemStack prevPage) {
Bukkit.getPluginManager().registerEvents(this, AlphaLibary.getInstance());
this.title = name;
this.items = items;
this.size = size;
this.nextPage = nextPage;
this.previousPage = prevPage;
Inventory page = getBlankPage(name, size);
for (ItemStack item : items) {
if (page.firstEmpty() == -1) {
PAGES.add(page);
page = getBlankPage(name, size);
page.addItem(item);
} else {
page.addItem(item);
}
}
PAGES.add(page);
p.openInventory(PAGES.get(currpage));
USERS.put(p.getUniqueId(), this);
}
示例11: setupFoodEditListMenu
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void setupFoodEditListMenu(Player player) {
Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(GodFoodFile.getEffectAmount()), ChatColor.BOLD + "Edit Food of the Gods");
for(int i = 1; i <= GodFoodFile.getEffectAmount(); i++) {
inv.addItem(ItemStackGenerator.createItem(
GodFoodFile.getFoodType(i), GodFoodFile.getAmount(i), GodFoodFile.getData(i), ChatColor.LIGHT_PURPLE + GodFoodFile.getName(i), null));
}
player.openInventory(inv);
}
示例12: pushItems
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
protected void pushItems(Location l, ItemStack items[])
{
Inventory inv = inject(l);
inv.addItem(items);
int ai[];
int j = (ai = getOutputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
}
}
示例13: sFList
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public Inventory sFList(int start,Player p){
Inventory inv = Bukkit.createInventory(null,54 , "��9��l �䷽�б�");
for(WorkbenchRecipe sf:rs.getSF()){
if(!(p.hasPermission("RealSurvival.Items."+sf.getName())||(
p.hasPermission("RealSurvival.Items.*")&&p.hasPermission("RealSurvival.Items."+sf.getName())))) continue;
if(sf==null||sf.getProduct().get(24)==null)
inv.addItem(Items.getPlaceholder9(sf.getName(),new ItemStack(Material.BOOK).clone(),sf.getBuiltTime()));
else
inv.addItem(Items.getPlaceholder9(sf.getName(),sf.getProduct().get(24).clone(),sf.getBuiltTime()));
}
if(rs.getSF().size()>54)
inv.setItem(53, Items.getPlaceholder7());
return inv;
}
示例14: pushItems
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
protected void pushItems(Block b, ItemStack[] items) {
Inventory inv = inject(b);
inv.addItem(items);
for (int slot: getOutputSlots()) {
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
}
}
示例15: pushItems
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
protected transient void pushItems(Block b, ItemStack items[])
{
Inventory inv = inject(b);
inv.addItem(items);
int ai[];
int j = (ai = getOutputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
BlockStorage.getInventory(b).replaceExistingItem(slot, inv.getItem(slot));
}
}