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


Java CraftItemEvent類代碼示例

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


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

示例1: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
/**
 * Prevents crafting of EnderChest unless the player has permission
 *
 * @param event
 */
@EventHandler(priority = EventPriority.LOW)
public void onCraft(CraftItemEvent event) {
    if (DEBUG) {
        plugin.getLogger().info(event.getEventName());
    }
    Player player = (Player) event.getWhoClicked();
    if (Util.inWorld(player) || player.getWorld().equals(IslandWorld.getNetherWorld())) {
        if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) {
            if (!(player.hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) {
                Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("general.errors.no-permission"));
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:21,代碼來源:IslandGuard.java

示例2: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraft(CraftItemEvent e)
{
	Player p = (Player) e.getWhoClicked();
	if(e.getRecipe() instanceof ShapedRecipe)
	{
		ShapedRecipe sr = (ShapedRecipe) e.getRecipe();
		if(Bukkit.getBukkitVersion().contains("1.11"))
		{
			for(BagBase  bb : Util.getBags())
			{
				if(((ShapedRecipe)bb.getRecipe()).getShape().equals(sr.getShape()))
				{
					if(!hasPermission(new Permission("bag.craft." + bb.getName(), PermissionDefault.TRUE), p))
					e.setCancelled(true);					
				}
			}
		}
		else
		if(sr.getKey().getNamespace().startsWith("bag_"))
		{
			if(!hasPermission(new Permission("bag.craft." + sr.getKey().getKey(), PermissionDefault.TRUE), p))
			e.setCancelled(true);
		}
	}
}
 
開發者ID:benfah,項目名稱:Bags2,代碼行數:27,代碼來源:CraftListener.java

示例3: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
/**
 * Limits the player to one workbench by means of crafting.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
  if (event.getRecipe().getResult().getType().equals(Material.WORKBENCH)) {
    Player player = (Player) event.getWhoClicked();
    UUID uuid = player.getUniqueId();
    if (craftedWorkbench.contains(uuid)) {
      player.sendMessage(ChatColor.RED + "You may not craft another workbench!");
    } else {
      craftedWorkbench.add(uuid);
      limitWorkbenches(player);

      player.sendMessage(ChatColor.YELLOW + "You have crafted a workbench. You may not have another one.");
    }
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:21,代碼來源:BenchBlitz.java

示例4: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
/**
 * Prevents players from crafting leather or iron armor.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
  Material result = event.getRecipe().getResult().getType();
  if (result.equals(Material.LEATHER_HELMET)
      || result.equals(Material.LEATHER_CHESTPLATE)
      || result.equals(Material.LEATHER_LEGGINGS)
      || result.equals(Material.LEATHER_BOOTS)) {
    event.setCancelled(true);
    event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft leather armor!");
  } else if (result.equals(Material.IRON_HELMET)
      || result.equals(Material.IRON_CHESTPLATE)
      || result.equals(Material.IRON_LEGGINGS)
      || result.equals(Material.IRON_BOOTS)) {
    event.setCancelled(true);
    event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft iron armor!");
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:23,代碼來源:GoldRush.java

示例5: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraft(CraftItemEvent e) {
	if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getAllowCrafting()) {
		return;
	}
	
	if (e.getWhoClicked() instanceof Player) {
		Player p = (Player) e.getWhoClicked();
		Location loc = p.getLocation();
		
		if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration()
				.getWorlds().contains(loc.getWorld().getName())) {
			e.setCancelled(true);
		}
	}
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:17,代碼來源:QuestManager.java

示例6: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraft(final CraftItemEvent event) {

	final PlayerStat stat = PlayerStat.ITEMS_CRAFTED;

	// Get player
	final Player player = (Player) event.getWhoClicked();

	// Do general check
	if (!plugin.doGeneralCheck(player, stat))
		return;

	final String itemCrafted = event.getCurrentItem().getType().toString();

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
			StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world",
					player.getWorld().getName(), "item", itemCrafted));

}
 
開發者ID:Staartvin,項目名稱:Statz,代碼行數:21,代碼來源:ItemsCraftedListener.java

示例7: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraft(CraftItemEvent cie) {
  Player player = (Player) cie.getWhoClicked();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    return;
  }

  if (game.getState() == GameState.STOPPED) {
    return;
  }

  if (BedwarsRel.getInstance().getBooleanConfig("allow-crafting", false)) {
    return;
  }

  cie.setCancelled(true);
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:20,代碼來源:PlayerListener.java

示例8: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onCraftItem(CraftItemEvent event)
{
    if (!event.isCancelled())
    {
        ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, (short) 1);
        if (event.getRecipe().getResult() == gapple)
        {
            if (event.getWhoClicked() instanceof Player)
            {
                plugin.getCoreErrors().cantCraftGoldenApples((Player) event.getWhoClicked());
            }
            event.setCancelled(true);
        }
    }
}
 
開發者ID:Vanillacraft,項目名稱:vanillacraft,代碼行數:17,代碼來源:WorldNerf.java

示例9: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraftItem(CraftItemEvent event) {
	NovaPlayer nPlayer = PlayerManager.getPlayer(event.getWhoClicked());

	if(event.getRecipe().getResult().getType() != Material.SHIELD
			|| !nPlayer.hasGuild()
			|| nPlayer.getGuild().getBannerMeta().numberOfPatterns() == 0) {
		return;
	}

	for(ItemStack ingredient : event.getInventory().getContents()) {
		if(ingredient != null
				&& ingredient.getType() == Material.SHIELD
				&& ingredient.hasItemMeta()) {
			return;
		}
	}

	event.getInventory().setResult(BannerUtils.applyMeta(event.getRecipe().getResult(), nPlayer.getGuild().getBannerMeta()));
}
 
開發者ID:MarcinWieczorek,項目名稱:NovaGuilds,代碼行數:21,代碼來源:RegionInteractListener.java

示例10: OnCraftItemEvent

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void OnCraftItemEvent(CraftItemEvent event) {
	Player player;
	try {
		player = CivGlobal.getPlayer(event.getWhoClicked().getName());
	} catch (CivException e) {
		e.printStackTrace();
		return;
	}
	
	for (ItemStack stack : event.getInventory().getMatrix()) {
		BonusGoodie goodie = CivGlobal.getBonusGoodie(stack);
		if (goodie != null) {
			CivMessage.sendError(player, "Cannot use bonus goodies in a crafting recipe.");
			event.setCancelled(true);
		}
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:19,代碼來源:BonusGoodieManager.java

示例11: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
/**
 * Prevents crafting of EnderChest unless the player has permission
 *
 * @param event
 */
@EventHandler(priority = EventPriority.LOW)
public void onCraft(CraftItemEvent event) {
    if (DEBUG) {
        plugin.getLogger().info(event.getEventName());
    }
    Player player = (Player) event.getWhoClicked();
    if (inWorld(player) || player.getWorld().equals(ASkyBlock.getNetherWorld())) {
        if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) {
            if (!(player.hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) {
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:21,代碼來源:IslandGuard.java

示例12: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
    final HumanEntity whoClicked = event.getWhoClicked();

    if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
        return;
    }

    ItemStack result = event.getRecipe().getResult();

    if (!ItemUtils.isMcMMOItem(result)) {
        return;
    }

    new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:17,代碼來源:InventoryListener.java

示例13: onCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraft(CraftItemEvent event)
{
    if (event.getRecipe().getResult() == null)
    {
        return;
    }
    if (event.getWhoClicked() instanceof Player)
    {
        ItemCraft action = this.newAction(ItemCraft.class, event.getWhoClicked().getWorld());
        if (action != null)
        {
            this.setPlayerAndLocation((Player)event.getWhoClicked(), action);
            action.setItemstack(event.getRecipe().getResult());
            this.logAction(action);
        }
    }
    else
    {
        // TODO missing action entity craft item
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:23,代碼來源:ListenerItem.java

示例14: onCrafting

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR)
public void onCrafting(CraftItemEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (event.getWhoClicked() instanceof Player) {
		Player player = (Player) event.getWhoClicked();
		String playerID = PlayerConverter.getID(player);
		CraftData playerData = (CraftData) dataMap.get(playerID);
		if (containsPlayer(playerID) && item.compare(event.getRecipe().getResult()) && checkConditions(playerID)) {
			playerData.subtract(event.getRecipe().getResult().getAmount());
			if (playerData.isZero()) {
				completeObjective(playerID);
			}
		}
	}
}
 
開發者ID:Co0sh,項目名稱:BetonQuest,代碼行數:18,代碼來源:CraftingObjective.java

示例15: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onCraftItem(CraftItemEvent event) {

    FilteredWorkbenchView workbench = _viewMap.get(event.getView());
    if (workbench == null)
        return;

    ItemFilter filter = workbench.getItemFilter();
    if (filter == null)
        return;

    ItemStack result = event.getRecipe().getResult();

    if (!filter.isValid(result)) {
        tellNoCraftMessage(workbench);
        event.setCancelled(true);
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:19,代碼來源:FilteredWorkbenchView.java


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