當前位置: 首頁>>代碼示例>>Java>>正文


Java PrepareItemCraftEvent.getViewers方法代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.PrepareItemCraftEvent.getViewers方法的典型用法代碼示例。如果您正苦於以下問題:Java PrepareItemCraftEvent.getViewers方法的具體用法?Java PrepareItemCraftEvent.getViewers怎麽用?Java PrepareItemCraftEvent.getViewers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.inventory.PrepareItemCraftEvent的用法示例。


在下文中一共展示了PrepareItemCraftEvent.getViewers方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPreCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPreCraft(final PrepareItemCraftEvent event) 
{
    final Recipe recipe = event.getRecipe();

    // Invalid or incomplete recipe entered
    if (recipe == null)
        return;

    BelovedItem item = BelovedBlocks.getBelovedBlocksManager().getFromItem(recipe.getResult());
    if(item == null)
        item = BelovedBlocks.getToolsManager().getFromItem(recipe.getResult());
    
    if(item != null)
    {
        for(HumanEntity entity : event.getViewers())
        {
            if(!(entity instanceof Player && item.canCraft((Player)entity)))
            {
                event.getInventory().setResult(new ItemStack(Material.AIR));
            }
        }
    }
}
 
開發者ID:zDevelopers,項目名稱:BelovedBlocks,代碼行數:25,代碼來源:CraftingListener.java

示例2: onCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onCraft(PrepareItemCraftEvent event) {
	if (event.getRecipe() != null && event.getRecipe().getResult() != null) {
		Item item = Zephyrus.getItemManager().getItem(event.getRecipe().getResult());
		if (item == null) {
			return;
		}
		for (HumanEntity human : event.getViewers()) {
			if (human instanceof Player) {
				Player player = (Player) human;
				if (!player.hasPermission("zephyrus.craft." + item.getInternalName())) {
					event.getInventory().setResult(null);
					Language.sendError("crafting.item.nopermission", player, "[ITEM]", item.getName());
				} else if (Zephyrus.getUser(player).getLevel() < item.getCraftingLevel()) {
					event.getInventory().setResult(null);
					Language.sendError("crafting.item.requiredlevel", player, "[LEVEL]", item.getCraftingLevel()
							+ "", "[ITEM]", item.getName());
				}
			}
		}
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus-II,代碼行數:23,代碼來源:ItemListener.java

示例3: onPrepareItemCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onPrepareItemCraft(PrepareItemCraftEvent event) {
    for (HumanEntity viewer : event.getViewers()) {
        if (viewer.getGameMode() != GameMode.CREATIVE) {
            if(viewer instanceof Player) {
                RegisteredServiceProvider<CharacterPlugin> characterPluginProvider = Bukkit.getServer().getServicesManager().getRegistration(CharacterPlugin.class);
                if (characterPluginProvider != null) {
                    ItemStack craftedItem = event.getInventory().getResult();
                    if (plugin.canGainCraftEfficiency(craftedItem.getType())) {
                        CharacterPlugin characterPlugin = characterPluginProvider.getProvider();
                        net.wayward_realms.waywardlib.character.Character character = characterPlugin.getActiveCharacter((Player) viewer);
                        int craftEfficiency = plugin.getCraftEfficiency(character, craftedItem.getType());
                        int amount = (int) Math.max(1, Math.round(((double) craftEfficiency / 50D) * (double) craftedItem.getAmount()));
                        craftedItem.setAmount(amount);
                        if (ToolType.getToolType(event.getInventory().getResult().getType()) != null) {
                            ToolType type = ToolType.getToolType(event.getInventory().getResult().getType());
                            craftedItem.setDurability((short) (craftedItem.getType().getMaxDurability() - (0.75D * (double) plugin.getMaxToolDurability(character, type))));
                        }
                        event.getInventory().setResult(craftedItem);
                    }
                }
            }
        }
    }
}
 
開發者ID:WaywardRealms,項目名稱:Wayward,代碼行數:26,代碼來源:PrepareItemCraftListener.java

示例4: craftingHandler

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void craftingHandler(PrepareItemCraftEvent e) {
	if (results.containsKey(e.getRecipe().getResult())) {
		ICustomItem item = results.get(e.getRecipe().getResult());
		List<HumanEntity> players = e.getViewers();
		PlayerCraftCustomItemEvent event = new PlayerCraftCustomItemEvent(players, item, e);
		Bukkit.getPluginManager().callEvent(event);
		if (event.isCancelled()) {
			e.getInventory().setResult(null);
		}
		for (HumanEntity en : e.getViewers()) {
			if (en instanceof Player) {
				Player player = (Player) en;
				if (!player.hasPermission("zephyrus.craft." + item.getPerm())) {
					e.getInventory().setResult(null);
				}
				if (Zephyrus.getUser(player).getLevel() < item.getReqLevel()) {
					Lang.msg("zephyrus.craft.nolevel", player);
					e.getInventory().setResult(null);
				}
			}
		}
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus,代碼行數:25,代碼來源:PlayerListener.java

示例5: stopCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void stopCraft(PrepareItemCraftEvent e){
	for(HumanEntity he : e.getViewers()){
		if(he instanceof Player){
			Player p = (Player) he;
			if(! p.hasPermission("kaos.owner")) e.getInventory().setResult(new ItemStack(Material.AIR));
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:10,代碼來源:Core.java

示例6: onCraftHandle

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onCraftHandle(PrepareItemCraftEvent e) {
	if (checkName(e.getRecipe().getResult(), getDisplayName())) {
		List<HumanEntity> player = e.getViewers();
		for (HumanEntity en : player) {
			if (!en.hasPermission("zephyrus.craft.mana")) {
				e.getInventory().setResult(null);
			}
		}
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus,代碼行數:12,代碼來源:ManaPotion.java

示例7: onCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onCraft(PrepareItemCraftEvent e) {
	if (e.getRecipe().getResult() == getRecipe().getResult()) {
		for (HumanEntity en : e.getViewers()) {
			if (!en.hasPermission("zephyrus.spellbook.craft")) {
				e.getInventory().setResult(null);
				break;
			}
		}
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus,代碼行數:12,代碼來源:SpellBookItem.java


注:本文中的org.bukkit.event.inventory.PrepareItemCraftEvent.getViewers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。