本文整理匯總了Java中org.bukkit.block.Chest.update方法的典型用法代碼示例。如果您正苦於以下問題:Java Chest.update方法的具體用法?Java Chest.update怎麽用?Java Chest.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Chest
的用法示例。
在下文中一共展示了Chest.update方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: popChest
import org.bukkit.block.Chest; //導入方法依賴的package包/類
private void popChest(Block item,Random rand) {
//if (item.getType() != Material.CHEST) return;
Chest c = (Chest) item.getState();
Inventory inv = c.getInventory();
int count = rand.nextInt(6);
for (int i = 1; i < count; i++) {
int chance = rand.nextInt(chestLoot.length);
int amount = rand.nextInt(5);
amount++;
ItemStack is = new ItemStack(chestLoot[chance],amount);
inv.addItem(is);
}
//MonoCities.log("populating chest");
c.update();
}
示例2: onInteract
import org.bukkit.block.Chest; //導入方法依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent event){
if(event.getClickedBlock().getType().equals(Material.CHEST)){
if(event.getClickedBlock().getState() instanceof Chest){
Chest chest = (Chest) event.getClickedBlock().getState();
if(this.chests.contains(chest))
return;
this.chests.add(chest);
populate(chest.getInventory());
chest.update();
}
}
}
示例3: fillChest
import org.bukkit.block.Chest; //導入方法依賴的package包/類
void fillChest(Block block) {
if (block.getState() instanceof Chest) {
Chest chest = (Chest) block.getState();
getRandom (1,5,chest);
chest.update();
}
}
示例4: onInventoryOpen
import org.bukkit.block.Chest; //導入方法依賴的package包/類
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e){
if(isInventoryFromHut(e.getInventory())){
e.setCancelled(true);
Integer thisHutId = getHutIdFromChestInventory(e.getInventory());
Chest chest = (Chest) e.getInventory().getHolder();
chest.update();
Inventory inv = getHutInventoryFromId(thisHutId);
e.getPlayer().openInventory(inv);
}
}