本文整理汇总了Java中org.bukkit.Material.BUCKET属性的典型用法代码示例。如果您正苦于以下问题:Java Material.BUCKET属性的具体用法?Java Material.BUCKET怎么用?Java Material.BUCKET使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.BUCKET属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSingleIngredientResult
/**
* Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
* For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
*
* @param ingredient the material data used as a crafting ingredient.
* @return the material data that vanilla recipes would give back upon crafting
*/
public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
if (ingredient == null) return new MaterialData(Material.AIR);
switch(ingredient.getItemType()) {
case MILK_BUCKET:
case WATER_BUCKET:
case LAVA_BUCKET:
return new MaterialData(Material.BUCKET);
case DRAGONS_BREATH:
return new MaterialData(Material.GLASS_BOTTLE);
default: return new MaterialData(Material.AIR);
}
}
示例2: handleCategoryInventoryClick
private void handleCategoryInventoryClick(InventoryClickEvent ice,
Game game, Player player) {
int catSize = getCategoriesSize(player);
int sizeCategories = getInventorySize(catSize) + 9;
int rawSlot = ice.getRawSlot();
if ((rawSlot >= getInventorySize(catSize))
&& (rawSlot < sizeCategories)) {
ice.setCancelled(true);
if (ice.getCurrentItem().getType() == Material.BUCKET) {
game.getPlayerSettings(player).setOneStackPerShift(false);
player.playSound(player.getLocation(),
SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
1.0F);
openCategoryInventory(player);
return;
}
if (ice.getCurrentItem().getType() == Material.LAVA_BUCKET) {
game.getPlayerSettings(player).setOneStackPerShift(true);
player.playSound(player.getLocation(),
SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
1.0F);
openCategoryInventory(player);
return;
}
}
if (rawSlot >= sizeCategories) {
if (ice.isShiftClick()) {
ice.setCancelled(true);
return;
}
ice.setCancelled(false);
return;
}
MerchantCategory clickedCategory = getCategoryByMaterial(ice
.getCurrentItem().getType());
if (clickedCategory == null) {
if (ice.isShiftClick()) {
ice.setCancelled(true);
return;
}
ice.setCancelled(false);
return;
}
openBuyInventory(clickedCategory, player, game);
}
示例3: onInteract
public void onInteract(PlayerInteractEvent e, Entity ent) {
//e.getPlayer().sendMessage("A");
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
for (Entity en : e.getPlayer().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getClickedBlock().getLocation())) {
Menu m;
if (e.getPlayer().getInventory().getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
m = new Menu("Keycode2", 27);
}
else {
m = new Menu("Keycode", 27);
}
ItemStack code = new ItemStack(Material.PAPER, 1);
ItemMeta codem = code.getItemMeta();
codem.setDisplayName("&f&l".replace('&', '�'));
code.setItemMeta(codem);
m.inv.setItem(15, code);
ItemStack res = new ItemStack(Material.BUCKET, 1);
ItemMeta resm = res.getItemMeta();
resm.setDisplayName("&f&lReset".replace('&', '�'));
res.setItemMeta(resm);
m.inv.setItem(13, res);
for (int i = 0; i < 27; i++) {
ItemStack it = new ItemStack(Material.IRON_BLOCK, 1);
HashMap<Integer, Integer> id = new HashMap<Integer, Integer>();
id.put(0, 1);
id.put(1, 2);
id.put(2, 3);
id.put(9, 4);
id.put(10, 5);
id.put(11, 6);
id.put(18, 7);
id.put(19, 8);
id.put(20, 9);
id.put(12, 0);
if (id.containsKey(i)) {
ItemMeta itm = it.getItemMeta();
itm.setDisplayName(("&f&l" + String.valueOf(id.get(i))).replace('&', '�'));
it.setItemMeta(itm);
m.inv.setItem(i, it);
}
}
if (plu.containsKey(e.getPlayer())) {plu.remove(e.getPlayer());}
if (plr.containsKey(e.getPlayer())) {plr.remove(e.getPlayer());}
if (plrs.contains(e.getPlayer())) {plrs.remove(e.getPlayer());}
if (e.getPlayer().getInventory().getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
m.show(e.getPlayer());
e.getPlayer().sendMessage(ChatColor.GREEN + "Please enter the keycode to then reset");
plr.put(e.getPlayer(), en);
}
else {
m.show(e.getPlayer());
e.getPlayer().sendMessage(ChatColor.GREEN + "Please enter the keycode");
plu.put(e.getPlayer(), en);
}
e.setCancelled(true);
}
}
}
}
示例4: isBucket
public static boolean isBucket(Material bucket) {
return bucket == Material.BUCKET || bucket == Material.LAVA_BUCKET || bucket == Material.WATER_BUCKET || bucket == Material.MILK_BUCKET;
}