本文整理匯總了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));
}
}
}
}
示例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());
}
}
}
}
}
示例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);
}
}
}
}
}
}
示例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);
}
}
}
}
}
示例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));
}
}
}
示例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);
}
}
}
}
示例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;
}
}
}
}