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