本文整理匯總了Java中org.bukkit.event.entity.EntityShootBowEvent.getBow方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityShootBowEvent.getBow方法的具體用法?Java EntityShootBowEvent.getBow怎麽用?Java EntityShootBowEvent.getBow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityShootBowEvent
的用法示例。
在下文中一共展示了EntityShootBowEvent.getBow方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEntityShootBowEvent
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityShootBowEvent(EntityShootBowEvent event) {
if ((event.getBow().hasItemMeta() && event.getBow().getItemMeta().getDisplayName().equals("Ender bow")) || event
.getBow() instanceof EnderBowPlugin.EnderBow) {
// Create custom event
EntityShootEnderBowEvent entityShootEnderBowEvent = new EntityShootEnderBowEvent(event);
// Call the custom event
EnderBowPlugin.getInstance().getServer().getPluginManager().callEvent(entityShootEnderBowEvent);
// Do the following, if it wasn't cancelled
if (!entityShootEnderBowEvent.isCancelled()) {
// Fire an ender pearl
event.getEntity().launchProjectile(EnderPearl.class).setVelocity(event.getProjectile().getVelocity());
// Play the 'ENDERMAN_TELEPORT' sound
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
}
// Cancel the original Event, so no arrows are fired
event.setCancelled(true);
}
}
示例2: onEntityShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
Entity projectile = event.getProjectile();
if (!(projectile instanceof Arrow)) {
return;
}
ItemStack bow = event.getBow();
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
示例3: entityShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
@EventHandler
private void entityShootBow(EntityShootBowEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
CustomItem customItem = CustomItemManager.getCustomItem(event.getBow());
if (verifyCustomItem(customItem, player, false)) {
DelayedPlayerDetails details = new DelayedPlayerDetails(event.getBow(), player);
((CustomBow) customItem).onShootBow(event, details);
if (!event.isCancelled() && event.getProjectile() instanceof Projectile) {
details.lock();
event.getProjectile().setMetadata("CustomItem-bow", new FixedMetadataValue(CustomItemManager._plugin, new Object[] { customItem, details }));
}
}
}
}
示例4: onShoot
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
@EventHandler
public void onShoot(EntityShootBowEvent event)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
ItemStack mainItem = event.getBow();
if(mainItem.getItemMeta().getLore() != null)
{
Random rand = new Random();
if(event.getForce() >= 1.0F)
{
final Entity arrow = event.getProjectile();
final Vector velocity = player.getLocation().getDirection().add(new Vector(0, 0.025, 0)).multiply(4);
arrow.setVelocity(velocity);
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SHULKER_BULLET_HURT, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
final Runnable task = new Runnable()
{
int times = 4;
public void run()
{
if(!arrow.isOnGround())
{
arrow.setVelocity(velocity);
if(times-- > 0)
Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 5);
}
}
};
Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1);
}
else
{
event.setCancelled(true);
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
}
}
}
}
示例5: EntityShootEnderBowEvent
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
public EntityShootEnderBowEvent(EntityShootBowEvent event) {
this(event.getEntity(), event.getBow(), event.getForce());
}
示例6: onEntityBowShoot
import org.bukkit.event.entity.EntityShootBowEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityBowShoot(EntityShootBowEvent event) {
if (event.getBow() != null && event.getBow().containsEnchantment(Enchantment.ARROW_DAMAGE) && event.getBow().getEnchantmentLevel(Enchantment.ARROW_DAMAGE) > 1) {
event.getProjectile().setMetadata("rage", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
}
}