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


Java PlayerItemConsumeEvent.getPlayer方法代码示例

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


在下文中一共展示了PlayerItemConsumeEvent.getPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent e){
    Player p = e.getPlayer();
    ItemStack item = e.getItem();
    Material type = item != null ? item.getType() : Material.AIR;
    int thirst = p.getLevel();

    if (type == Material.POTION && item.getDurability() == 0 && p.getInventory().getItemInMainHand().isSimilar(item)){
        p.getInventory().getItemInMainHand().setType(Material.AIR);

        for (ItemStack i : p.getInventory().getContents()){
            if (i.getType() == Material.GLASS_BOTTLE){
                i.setType(Material.AIR);
            }
        }

        p.setLevel(0);
        if (thirst + 256 >= 1000){
            p.setLevel(1000);
            return;
        }
        p.setLevel(thirst + 256);
        p.sendMessage(p.getLevel() + " // " + thirst + 256);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:26,代码来源:Thirst.java

示例2: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.POISONOUS_POTATO)
	{
		for (PotionEffect effect : player.getActivePotionEffects())
	        player.removePotionEffect(effect.getType());

		Random rand = new Random();
		if(rand.nextInt(10) + 1 <= 6)
		{
			player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 0), true);
			player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 0), true);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:19,代码来源:PoisonousPotato.java

示例3: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.BEETROOT)
	{
		int amp = 0;
		int dur = 200;
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE))
			{
				dur += effect.getDuration();
				if(dur > 600) dur = 600;
				player.removePotionEffect(effect.getType());
			}
		}
		player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, dur, amp));
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:BeetrootStrength.java

示例4: onPlayerItemConsumeEvent

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerItemConsumeEvent(PlayerItemConsumeEvent event)
{
	Player player = event.getPlayer();
	
	if (!WorldGuardUtils.hasBypass(player))
	{
		ItemMeta itemMeta = event.getItem().getItemMeta();
		if (itemMeta instanceof PotionMeta)
		{
			WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlag.class).drinkPotion(player, Potion.fromItemStack(event.getItem()).getEffects());
		}
		else
		{
			Material material = event.getItem().getType();
			if (material == Material.MILK_BUCKET)
			{
				WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlag.class).drinkMilk(player);
			}
		}
	}
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:23,代码来源:PlayerListener.java

示例5: onEat

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEat(final PlayerItemConsumeEvent event) {

	final PlayerStat stat = PlayerStat.FOOD_EATEN;

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

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

	final String foodName = StatzUtil.getFoodName(event.getItem());

	if (foodName == null)
		return;

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

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:24,代码来源:FoodEatenListener.java

示例6: onPlayerItemConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
	Player player = event.getPlayer();
	ItemStack item = event.getItem();
	
	// if the item is not a potion we don't want to care.
	if (item == null || item.getType() != Material.POTION) {
		return;
	}
	
	// if the potion has the durability of a strength 2 potion, tell them and cancel.
	if (item.getDurability() == 8233) {
		player.sendMessage(ChatColor.RED + "Strength II is disabled.");
		event.setCancelled(true);
	}
}
 
开发者ID:LeonTG,项目名称:NoStrengthII,代码行数:17,代码来源:DrinkListener.java

示例7: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onConsume(PlayerItemConsumeEvent e){
    if(e.getItem() == null){
        return;
    }
    
	Player p = e.getPlayer();
    //deny potion
	if (p == null){
		return;
	}
    
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (r != null && e.getItem().getType().equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)){
    	RPLang.sendMessage(p, "playerlistener.region.cantuse");
    	e.setCancelled(true);
    }
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:19,代码来源:RPMine19.java

示例8: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
  public void onConsume(PlayerItemConsumeEvent e){
      if(e.getItem() == null){
          return;
      }
      
      Player p = e.getPlayer();
      Location l = p.getLocation();
      
      Region r = RedProtect.get().rm.getTopRegion(l);

//deny item usage
List<String> items = RPConfig.getGlobalFlagList(p.getWorld().getName()+".deny-item-usage.items");
  	if (e.getItem() != null && items.contains(e.getItem().getType().name())){
  		if (r != null && ((!RPConfig.getGlobalFlagBool(p.getWorld().getName()+".deny-item-usage.allow-on-claimed-rps") && r.canBuild(p)) || 
  				(RPConfig.getGlobalFlagBool(p.getWorld().getName()+".deny-item-usage.allow-on-claimed-rps") && !r.canBuild(p)))){
  			RPLang.sendMessage(p, "playerlistener.region.cantuse");
  			e.setCancelled(true);  
  			return;
  		}
  		if (r == null && !RPConfig.getGlobalFlagBool(p.getWorld().getName()+".deny-item-usage.allow-on-wilderness") && !RedProtect.get().ph.hasPerm(p, "redprotect.bypass.world")){
  			RPLang.sendMessage(p, "playerlistener.region.cantuse");
  			e.setCancelled(true);
	}
      }
  }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:27,代码来源:RPGlobalListener.java

示例9: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onConsume(PlayerItemConsumeEvent e){
    if(e.getItem() == null){
        return;
    }
    
	Player p = e.getPlayer();
    //deny potion
	if (p == null){
		return;
	}
	
    if(RPUtil.denyPotion(e.getItem(), p)){
    	e.setCancelled(true);                    
    }
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPPlayerListener.java

示例10: onPlayerItemConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
/**
 * On player item consume.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
	
	Player player = event.getPlayer();
	IPlayerConfEntry entry;
	
	if((entry = playerConf.get(player)) != null
			&& !entry.isAdminMod()) {
	
		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(player.getLocation());
		
		if (!checkPermission(land, player, PermissionList.EAT.getPermissionType())) {
			messagePermission(player);
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:23,代码来源:PlayerListener.java

示例11: onPlayerEat

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerEat(PlayerItemConsumeEvent e) {
    final Player player = e.getPlayer();
    ItemStack itemConsumed = e.getItem();
    if (itemConsumed.isSimilar(CraftingAndRecipes.redstoneApple())) {
        player.setVelocity(player.getVelocity().setY(0.4));
        player.sendMessage(ChatColor.RED + "[CPU] You just got shocked by eating a redstone apple!");
        player.sendMessage(ChatColor.RED + "[CPU] You can't move that well!");
        CPUPlugin.bukkitScheduler.scheduleSyncDelayedTask(CPUPlugin.plugin, new BukkitRunnable() {
            @Override
            public void run() {
                player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2000, 1));
                player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 2000, 4));
            }
        }, 60);
    }
}
 
开发者ID:waicool20,项目名称:CPU,代码行数:18,代码来源:EatsRedstoneApple.java

示例12: onItemConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
/**
 * Fires when an item is consumed. As we are not altering the event,
 * but we do want to know if it is cancelled, we run it on the Monitor
 * priority.
 * 
 * @param event Event to handle.
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemConsume(PlayerItemConsumeEvent event) {
	if (event.getItem().getType() == Material.MILK_BUCKET) {
		// We don't want to cancel the event, but we want to re-apply darkness after the event
		// has completed - if needed, so that the player can't cheat using the milk.
		final Player player = event.getPlayer();
		getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {

			@Override
			public void run() {
				DarkerNights.checkBlindness(player);
			}
			
		});
	}
}
 
开发者ID:clienthax,项目名称:DarkerNights,代码行数:24,代码来源:DarkerNights.java

示例13: onUseHealItem

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onUseHealItem(PlayerItemConsumeEvent e) {
    final Player p = e.getPlayer();
    if (!RUtils.isInInfectedWorld(p)) return;
    final ItemStack hand = e.getItem();
    if (hand == null || hand.getType() != Material.MELON || hand.getDurability() != (short) 14) return;
    if (p.getMaxHealth() == p.getHealth() && p.getFoodLevel() >= 20) {
        e.setCancelled(true); // don't waste medpacks - should never happen, though
        return;
    }
    double newHealth = p.getHealth() + 8D;
    int newFood = p.getFoodLevel() + 8;
    if (newHealth > p.getMaxHealth()) newHealth = p.getMaxHealth();
    if (newFood > 20) newFood = 20;
    p.setHealth(newHealth);
    p.setFoodLevel(newFood);
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:18,代码来源:SurvivorsListener.java

示例14: onDrinky

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrinky(PlayerItemConsumeEvent e) {
    final Player p = e.getPlayer();
    final ItemStack hand = e.getItem();
    if (hand == null || hand.getType() != Material.POTION || hand.getDurability() != (short) 0 || !RUtils.isInInfectedWorld(p))
        return;
    PConfManager pcm = PConfManager.getPConfManager(p);
    float thirst = pcm.getFloat("thirst");
    if (!pcm.isSet("thirst")) thirst = 1F;
    if (thirst >= 1F) {
        e.setCancelled(true); // let's not waste water bottles
        return;
    }
    thirst += Config.thirstRestorePercent / 100F;
    if (thirst > 1F) thirst = 1F;
    pcm.set("thirst", thirst);
    pcm.set("thirstSaturation", (float) Config.thirstSaturationMax);
    p.setExp(thirst);
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:20,代码来源:ThirstListener.java

示例15: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(!Survival.settings.getBoolean("Mechanics.Thirst.Enabled"))
	{
		if(event.isCancelled()) return;
		Player player = event.getPlayer();
		if(event.getItem().getType() == Material.BEETROOT_SOUP)
		{
			event.setCancelled(true);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:14,代码来源:WaterBowl.java


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