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


Java PlayerItemConsumeEvent.setCancelled方法代码示例

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


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

示例1: onPlayerItemConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerItemConsume(PlayerItemConsumeEvent event)
{		
	for (String itemString : Thirst.getInstance().getYAMLConfig().thirstQuenchingItems)
	{
		ThirstItem item = Thirst.getInstance().getYAMLConfig().new ThirstItem(itemString);
		
		ItemStack is = new ItemStack(Material.valueOf(item.getItem()), 1);
		
		//casting due to spigot api subject to change.
		is.setData(new MaterialData(is.getType(), (byte) item.getMetaData()));

		int quenchPercent = item.getQuenchPercent();
		
		if (is.getType() == event.getItem().getType() && event.getItem().getData().toString().equals(is.getData().toString())) {
               if (Thirst.getInstance().getYAMLConfig().itemConsumption || ThirstManager.getThirst().getPlayerThirst(event.getPlayer()) != 100)
                   ThirstManager.getThirst().setThirst(event.getPlayer(), ThirstManager.getThirst().getPlayerThirst(event.getPlayer()) + quenchPercent);
               else {
                   event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Thirst.getInstance().getYAMLConfig().itemConsumeMessage.replace("%player%", event.getPlayer().getName())));
                   event.setCancelled(true);
               }
           }
	}
}
 
开发者ID:GamerKing195,项目名称:Thirst,代码行数:26,代码来源:PlayerItemConsumeListener.java

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

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

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

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

示例6: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW) 
public void onConsume(PlayerItemConsumeEvent event) {
	if (ItemManager.getId(event.getItem()) == CivData.GOLDEN_APPLE) {
		CivMessage.sendError(event.getPlayer(), "You cannot use golden apples.");
		event.setCancelled(true);
		return;
	}
	
	if (event.getItem().getType().equals(Material.POTION)) {
		ConfigTechPotion pot = CivSettings.techPotions.get(Integer.valueOf(event.getItem().getDurability()));
		if (pot != null) {
			if (!pot.hasTechnology(event.getPlayer())) {
				CivMessage.sendError(event.getPlayer(), "You cannot use "+pot.name+" potions. You do not have the technology yet.");
				event.setCancelled(true);
				return;
			}
			if (pot.hasTechnology(event.getPlayer())) {
				event.setCancelled(false);
			}
		} else {
			CivMessage.sendError(event.getPlayer(), "You cannot use this type of potion.");
			event.setCancelled(true);
		}
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:26,代码来源:PlayerListener.java

示例7: OnPlayerConsumeEvent

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void OnPlayerConsumeEvent(PlayerItemConsumeEvent event) {
	ItemStack stack = event.getItem();

	/* Disable notch apples */
	if (ItemManager.getId(event.getItem()) == ItemManager.getId(Material.GOLDEN_APPLE)) {
		if (event.getItem().getDurability() == (short)0x1) {
			CivMessage.sendError(event.getPlayer(), "You cannot use notch apples. Sorry.");
			event.setCancelled(true);
			return;
		}
	}	

	if (stack.getType().equals(Material.POTION)) {
		int effect = event.getItem().getDurability() & 0x000F;			
		if (effect == 0xE) {
			event.setCancelled(true);
			CivMessage.sendError(event.getPlayer(), "You cannot use invisibility potions for now... Sorry.");
			return;
		}
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:23,代码来源:BlockListener.java

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

示例9: onPotionDrink

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler
public void onPotionDrink(PlayerItemConsumeEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			if(Team.getTeam(event.getPlayer()).equals(Minigame.getObservers())){
				event.setCancelled(true);
			} else {
				if(!Minigame.getCurrentMinigame().getState().equals(MatchState.STARTED)){

				}
			}
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
开发者ID:tatanpoker09,项目名称:TCMinigames,代码行数:23,代码来源:PlayerListener.java

示例10: onPlayerConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
/**
 * Checks to see if the player is attempting to drink a potion, and checks
 * the potion to see if it is allowed.
 *
 * @param event The PlayerItemConsumeEvent involving the player.
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerConsume(PlayerItemConsumeEvent event) {
    if (event.getItem().getType() != Material.POTION) {
        return;
    }
    // Check the type of potion in the player's hand
    Potion potion = Potion.fromItemStack(event.getItem());
    Collection<PotionEffect> effects = potion.getEffects();

    for (PotionEffect e : effects) {
        if (!(Util.canUsePotion(event.getPlayer(), e.getType()))) {
            // If we get here, we cancel this event and all is done.
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "You cannot use that potion here!");
            Util.removeDisallowedEffects(event.getPlayer());
            return; // We don't need to check any more.
        }
    }
}
 
开发者ID:Tribalforge,项目名称:AntiPotionField,代码行数:26,代码来源:PlayerEventRegionsHandler.java

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

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

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

示例14: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onConsume(PlayerItemConsumeEvent event) {
    Player player = event.getPlayer();
    InventoryData data = InventoryData.getData(player);

    boolean canCheckFastConsume = CHECK_MANAGER.canCheckPlayer(player, CheckType.FASTCONSUME);
    if (canCheckFastConsume) {
        // check and cancel if we failed.
        boolean cancel = FAST_CONSUME.check(player, data);
        event.setCancelled(cancel);
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:14,代码来源:InventoryListener.java

示例15: onPlayerConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerConsume(PlayerItemConsumeEvent event) {
    ItemStack stack = event.getItem();
    if (stack != null && stack.getType() == Material.GOLDEN_APPLE && stack.getDurability() == 1) {
        Player player = event.getPlayer();
        if (setCooldown(player, player.getUniqueId(), defaultCooldown, false, new Predicate<Long>() {
            @Override
            public boolean apply(@Nullable Long value) {
                return false;
            }
        })) {

            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588\u2588\u2588&c\u2588\u2588\u2588"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588&e\u2588\u2588&c\u2588\u2588\u2588"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', ("&c\u2588\u2588\u2588&e\u2588&c\u2588\u2588\u2588\u2588 &6&l " + this.name + ": ")));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588&6\u2588\u2588\u2588\u2588&c\u2588\u2588 &7  Consumed"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588\u2588&f\u2588&6\u2588&6\u2588\u2588&c\u2588"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588&f\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588 &6 Cooldown Remaining:"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', ("&c\u2588&6\u2588\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588 &7  " + DurationFormatter.getRemaining(getRemaining(player), true, false))));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588&6\u2588\u2588\u2588\u2588&c\u2588\u2588"));
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588\u2588\u2588&c\u2588\u2588\u2588"));
        } else {
            event.setCancelled(true);
            player.sendMessage(ChatColor.RED + "You still have a " + getDisplayName() + ChatColor.RED + " cooldown for another " + ChatColor.BOLD
                    + DurationFormatter.getRemaining(getRemaining(player), true, false) + ChatColor.RED + '.');
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:30,代码来源:GappleTimer.java


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