本文整理匯總了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);
}
}
}
}
}
示例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());
}
示例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);
}
示例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>();
}
示例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!");
}
}
示例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!");
}
}
示例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);
}
示例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));
}
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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;
}