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


Java Item.setPickupDelay方法代码示例

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


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

示例1: specialItemActionCheck

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void specialItemActionCheck(final PlayerInteractEvent event)
{
	if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
	{
		Player player = event.getPlayer();
		AnniPlayer pl = AnniPlayer.getPlayer(player.getUniqueId());
		if(pl != null && pl.getKit().equals(this))
		{
			if(this.isHookItem(player.getItemInHand()))
			{
				if(!Delays.getInstance().hasActiveDelay(player, this.getInternalName()))
				{
					Delays.getInstance().addDelay(player, System.currentTimeMillis()+5000, this.getInternalName());//kits.addDelay(player.getName(), DelayType.SCORPIO, 10, TimeUnit.SECONDS);
					Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.NETHER_STAR,1));
					item.setPickupDelay(Integer.MAX_VALUE);
					item.setVelocity(player.getEyeLocation().getDirection().multiply(2));
					Bukkit.getScheduler().scheduleSyncDelayedTask(AnnihilationMain.getInstance(), new HookTracer(item,pl,90,this.getName()), 1);
				}
			}
		}
	}
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:24,代码来源:Scorpio.java

示例2: doOnRightClick

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public void doOnRightClick(final Racer racer, Action action)
{
    ItemStack stack = racer.getPlayer().getItemInHand();
    ItemStack thro = racer.getPlayer().getItemInHand().clone();
    thro.setAmount(1);

    if(stack.getAmount() == 1)
    {
        racer.getPlayer().getInventory().clear();
        return;
    }

    stack.setAmount(stack.getAmount() - 1);

    racer.getPlayer().getInventory().setItem(0, stack);

    Item item = racer.getPlayer().getWorld().dropItem(racer.getPlayer().getLocation(), thro);
    item.setPickupDelay(0);

    racer.getPlayer().sendMessage(getMessage());
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:23,代码来源:LightningPowerup.java

示例3: doOnLeftClick

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public void doOnLeftClick(Racer racer, Action action)
{
    ItemStack stack = racer.getPlayer().getItemInHand();
    final ItemStack thro = racer.getPlayer().getItemInHand().clone();
    thro.setAmount(1);

    racer.getPlayer().getInventory().clear();
    if(stack.getAmount() - 1 > 0)
    {
        stack.setAmount(stack.getAmount() - 1);
    }

    racer.getPlayer().getInventory().setItem(0, stack);

    Item item = racer.getPlayer().getWorld().dropItem(racer.getPlayer().getLocation(), thro);
    item.setVelocity(racer.getPlayer().getEyeLocation().getDirection().multiply(plugin.getConfig().getDouble("Powerups.Lightning.ThrowAheadMultiplier")));
    item.setPickupDelay(0);
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:20,代码来源:LightningPowerup.java

示例4: CraftingOperation

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public CraftingOperation(Block block, ItemStack stack) {
	this.block = block;
	ItemStack toDrop = stack.clone();
	toDrop.setAmount(1);
	stack.setAmount(stack.getAmount()-1);
	Item item = block.getWorld().dropItem(block.getLocation().add(0.5, 1.2, 0.5), toDrop);
	item.setVelocity(new Vector(0,0,0));
	item.teleport(block.getLocation().add(0.5, 1.5, 0.5));
	item.setPickupDelay(Integer.MAX_VALUE);
	item.setGlowing(true);
	item.setGravity(false);
	this.book = item;
	items = new HashMap<Item, BukkitRunnable>();
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:15,代码来源:CraftingOperation.java

示例5: onPlayerPickupItem

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Limits the player to one workbench in their inventory at a time, by means of picking up an item.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  Player player = event.getPlayer();
  if (item.getItemStack().getType().equals(Material.WORKBENCH)
      && player.getInventory().contains(Material.WORKBENCH)) {
    event.setCancelled(true);
    item.setPickupDelay(20);

    player.sendMessage(ChatColor.RED + "You may not pick up another workbench!");
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:18,代码来源:BenchBlitz.java

示例6: onPlayerPickupItem

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Prevents a player from picking up a bow.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  if (item.getItemStack().getType().equals(Material.BOW)) {
    event.setCancelled(true);
    item.setPickupDelay(20);
    
    event.getPlayer().sendMessage(ChatColor.RED + "You may not pick up a bow!");
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:16,代码来源:Bowless.java

示例7: spawn

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public static void spawn(Location location, ItemStack itemstack, long ticks) {
	final Item item = location.getWorld().dropItem(location, itemstack);
	item.setPickupDelay(Integer.MAX_VALUE);
	Bukkit.getScheduler().scheduleSyncDelayedTask(CSCoreLib.getLib(), new Runnable() {
		
		@Override
		public void run() {
			if (item != null) item.remove();
		}
	}, ticks);
}
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:12,代码来源:FakeItem.java

示例8: dropItem

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public void dropItem(Location dropLocation, ItemStack itemStack) {
  Item item = this.game.getRegion().getWorld().dropItemNaturally(dropLocation, itemStack);
  item.setPickupDelay(0);
  if (this.spread != 1.0) {
    item.setVelocity(item.getVelocity().multiply(this.spread));
  }
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:8,代码来源:ResourceSpawner.java

示例9: throwGrenade

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public void throwGrenade(final Player player){
	Location loc = player.getEyeLocation().toVector().add(player.getLocation()
			.getDirection().multiply(2))
			.toLocation(player.getWorld(), player.getLocation().getYaw(), player.getLocation().getPitch());
	
	ItemStack itemStack = super.getItemStack();

       ItemStack itemGrenade = new ItemStack(itemStack.getType());
       itemGrenade.setData(super.getItemStack().getData());
       
       final Item grenade = player.getWorld().dropItem(loc, itemGrenade);
       grenade.setVelocity(player.getLocation().getDirection().multiply(2));

       grenade.setPickupDelay(999999);

       if(player.getItemInHand().getAmount()==1){
           player.setItemInHand(new ItemStack(Material.AIR, 1));
       } else {
           ItemStack itemInHand = player.getItemInHand();
           itemInHand.setAmount(itemInHand.getAmount()-1);
           player.setItemInHand(itemInHand);
       }
       
       // Makes a delay of the delay variable, and triggers the grenade
       McAssault.plugin.getServer().getScheduler().scheduleSyncDelayedTask(McAssault.plugin, new Runnable() {
           @Override
           public void run() {
           	trigger(player, grenade);
           }
       }, delay);

}
 
开发者ID:viktorstrate,项目名称:mcAssault,代码行数:33,代码来源:Grenade.java

示例10: skeletonAttacks

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public static void skeletonAttacks(Skeleton boss, Player damager){
    int attack = r.nextInt(8);
    List<Player> near = new ArrayList<>();

    boss.getNearbyEntities(7, 7, 7).forEach(en -> {
        if (en instanceof Player) {
            near.add((Player) en);
        }
    });

    switch (attack){
        case 0:
            if (boss.getHealth() + 20 >= boss.getMaxHealth()) boss.setHealth(boss.getMaxHealth());
            boss.setHealth(boss.getHealth() + 20);
            break;
        case 1:
            List<Item> bones = new ArrayList<>();

            for (int i = 0 ; i < 20; i++) {
                ItemStack osso = new ItemStack(Material.BONE, 1);
                Location dropLoc = boss.getLocation();
                dropLoc.setX(dropLoc.getX() + r.nextDouble() - r.nextDouble());
                dropLoc.setY(dropLoc.getY() + r.nextDouble() - r.nextDouble());
                dropLoc.setZ(dropLoc.getZ() + r.nextDouble() - r.nextDouble());
                final Item bone = boss.getWorld().dropItem(dropLoc, osso);
                Vector v = new Vector(Math.random() - Math.random(), Math.random(), Math.random() - Math.random()).multiply(1);

                bone.setVelocity(v);
                bone.setPickupDelay(Integer.MAX_VALUE);

                bones.add(bone);
            }
            ParticleEffect.EXPLOSION_HUGE.display(new Vector(0, 0, 0), 2, boss.getLocation(), 50);

            near.forEach(p -> {
                if (!p.equals(damager)) {
                    WCTWD.getPlayer(p).sendSound(Sound.ENTITY_GENERIC_EXPLODE);
                    p.damage(3);
                }
            });
            WCTWD.getPlayer(damager).sendSound(Sound.ENTITY_GENERIC_EXPLODE);
            damager.damage(3);

            bs.runTaskLater(plugin, () -> bones.forEach(b -> b.remove()), 40);
            break;

        default:
            break;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:51,代码来源:MobAttack.java

示例11: add

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public void add(ItemStack stack) {
	World world = block.getWorld();
	Location location = block.getLocation().add(0, 1, 0.5);

	ItemStack cloned = stack.clone();
	cloned.setAmount(1);
	Item entity = world.dropItem(location, cloned);
	entity.setVelocity(new Vector(0, 0, 0));
	entity.teleport(location);
	entity.setGravity(false);
	entity.setGlowing(true);
	entity.setPickupDelay(Integer.MAX_VALUE);
	stack.setAmount(stack.getAmount() - 1);

	BukkitRunnable runnable = new BukkitRunnable() {
		int tickCount = 0;
		int speed = 8;
		// Circle maths!
		double unit = 2 * Math.PI / (speed * 10);
		double divisor = speed * Math.PI;

		@Override
		public void run() {
			entity.setVelocity(
					new Vector(Math.sin(unit * tickCount) / divisor, 0, Math.cos(unit * tickCount) / divisor));

			tickCount++;
			if (tickCount == speed * 10) {
				tickCount = 0;
			}
		}
	};
	runnable.runTaskTimer(MystiCraft.getInstance(), 1, 1);
	items.put(entity, runnable);
	String spell = getSpell();
	if (spell != null) {
		book.setCustomName("Ready to craft: " + spell);
		book.setCustomNameVisible(true);
	} else {
		book.setCustomNameVisible(false);
	}
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:43,代码来源:CraftingOperation.java

示例12: respawn

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public Item respawn() {
    Item itemSpawn = location.getWorld().dropItem(location, item.clone());
    itemSpawn.setVelocity(new Vector(0, 0, 0));
    itemSpawn.setPickupDelay(20 * 2);
    return itemSpawn;
}
 
开发者ID:Minehut,项目名称:GamePlate,代码行数:7,代码来源:ItemSpawnerModule.java


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