当前位置: 首页>>代码示例>>Java>>正文


Java CraftItemEvent.getWhoClicked方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.CraftItemEvent.getWhoClicked方法的典型用法代码示例。如果您正苦于以下问题:Java CraftItemEvent.getWhoClicked方法的具体用法?Java CraftItemEvent.getWhoClicked怎么用?Java CraftItemEvent.getWhoClicked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.CraftItemEvent的用法示例。


在下文中一共展示了CraftItemEvent.getWhoClicked方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例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(Ghosts.playerDataKey)) {
//            return;
//        }

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

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

        new UpdateInventoryTask((Player) whoClicked).runTaskLater(Ghosts.p, 0);
    }
 
开发者ID:TfT-02,项目名称:Ghosts,代码行数:17,代码来源:InventoryListener.java

示例13: onCraftItemEvent

import org.bukkit.event.inventory.CraftItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCraftItemEvent(final CraftItemEvent event)
{
	HumanEntity entity = event.getWhoClicked();

	if (entity instanceof Player)
	{
		final Player user = (Player)entity;
		final ItemStack item = event.getRecipe().getResult();

		if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
		{
			if (!Permissions.CRAFT.isAuthorized(user, item.getType(), item.getData()))
			{
				event.setCancelled(true);
				if (antib.getSettings().getData().isWarnOnBuildDisallow())
				{
					user.sendMessage(_("§4You are not permitted to create§c {0}§4.", item.getType().toString()));
				}
			}
		}
	}
}
 
开发者ID:Curtis3321,项目名称:Essentials,代码行数:24,代码来源:EssentialsAntiBuildListener.java

示例14: stopVanillaCraft

import org.bukkit.event.inventory.CraftItemEvent; //导入方法依赖的package包/类
@EventHandler
public void stopVanillaCraft(CraftItemEvent e) {
    if (!(e.getWhoClicked() instanceof Player)) return;
    Player p = (Player) e.getWhoClicked();
    if (!RUtils.isInInfectedWorld(p)) return;
    Recipe rr = e.getRecipe();
    ItemStack result = rr.getResult();
    if (rr instanceof ShapedRecipe) {
        ShapedRecipe srr = (ShapedRecipe) rr;
        if (result.getType() == Material.BOW && !shapedRecipesMatch(srr, plugin.bowRecipe)) e.setCancelled(true);
        if (Config.harderTorches && result.getType() == Material.TORCH && !srr.getIngredientMap().values().equals(plugin.torchRecipe.getIngredientList()))
            e.setCancelled(true);
        if (result.getType() == Material.ARROW && !srr.getIngredientMap().values().containsAll(plugin.arrowRecipe.getIngredientList()))
            e.setCancelled(true);
    }
    if (e.isCancelled()) e.setResult(Event.Result.DENY);
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:18,代码来源:SurvivorsListener.java

示例15: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onCraftItem(CraftItemEvent event) 
{
	if( event.getRecipe().getResult().getType() == Material.STONE_SWORD
			|| event.getRecipe().getResult().getType() == Material.IRON_SWORD
			|| event.getRecipe().getResult().getType() == Material.GOLD_SWORD
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_SWORD
|| event.getRecipe().getResult().getType() == Material.LEATHER_BOOTS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.LEATHER_HELMET
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_BOOTS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_HELMET
|| event.getRecipe().getResult().getType() == Material.GOLD_BOOTS
			|| event.getRecipe().getResult().getType() == Material.GOLD_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.GOLD_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.GOLD_HELMET
			|| event.getRecipe().getResult().getType() == Material.IRON_BOOTS
			|| event.getRecipe().getResult().getType() == Material.IRON_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.IRON_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.IRON_HELMET
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_BOOTS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_HELMET)
	{
		if( event.getWhoClicked().getType() == EntityType.PLAYER )
		{
			Player p = (Player)event.getWhoClicked();
			p.sendMessage("Sorry, you are not allowed to craft this item. Purchase it from a Safe Dock instead.");
		}
		event.setCancelled(false);
	}
 
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:38,代码来源:NavyCraft_InventoryListener.java


注:本文中的org.bukkit.event.inventory.CraftItemEvent.getWhoClicked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。