本文整理汇总了Java中org.bukkit.entity.Arrow类的典型用法代码示例。如果您正苦于以下问题:Java Arrow类的具体用法?Java Arrow怎么用?Java Arrow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Arrow类属于org.bukkit.entity包,在下文中一共展示了Arrow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
if (effect != null) {
((LivingEntity) e.getEntity()).addPotionEffect(effect);
}
}
if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
}
if ((e.getDamager() instanceof Snowball) && (((Snowball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
e.setDamage(e.getDamage() + damage);
}
}
示例2: parse
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@Override
public @Nullable ProjectileModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
final ItemParser itemParser = context.needModule(ItemParser.class);
FilterParser filterParser = context.needModule(FilterParser.class);
for(Element projectileElement : XMLUtils.flattenElements(doc.getRootElement(), "projectiles", "projectile")) {
String name = projectileElement.getAttributeValue("name");
Double damage = XMLUtils.parseNumber(projectileElement.getAttribute("damage"), Double.class, (Double) null);
double velocity = XMLUtils.parseNumber(Node.fromChildOrAttr(projectileElement, "velocity"), Double.class, 1.0);
ClickAction clickAction = XMLUtils.parseEnum(Node.fromAttr(projectileElement, "click"), ClickAction.class, "click action", ClickAction.BOTH);
Class<? extends Entity> entity = XMLUtils.parseEntityTypeAttribute(projectileElement, "projectile", Arrow.class);
List<PotionEffect> potionKit = itemParser.parsePotionEffects(projectileElement);
Filter destroyFilter = filterParser.parseOptionalProperty(projectileElement, "destroy-filter").orElse(null);
Duration coolDown = XMLUtils.parseDuration(projectileElement.getAttribute("cooldown"));
boolean throwable = XMLUtils.parseBoolean(projectileElement.getAttribute("throwable"), true);
context.features().define(projectileElement, new ProjectileDefinitionImpl(name, damage, velocity, clickAction, entity, potionKit, destroyFilter, coolDown, throwable));
}
return null;
}
示例3: onBowShot
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onBowShot(EntityShootBowEvent e) {
if (e.getEntity() instanceof Player &&
e.getProjectile() instanceof Arrow) {
Bukkit.getScheduler().runTaskLater(this, () -> {
if (!e.getProjectile().isDead()) {
EntityTrail t = new EntityTrail(this, e.getProjectile(),
new ScatteringSupplier(particles,
new Vector3(2.0f, 1.0f, 2.0f),
Vector3.ORIGIN, 5, 20, 1)
, 1);
trails.put(e.getProjectile(), t);
t.begin();
}
}, 5L);
}
}
示例4: onBowShot
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onBowShot(EntityShootBowEvent e) {
if (e.getEntity() instanceof Player &&
e.getProjectile() instanceof Arrow) {
Bukkit.getScheduler().runTaskLater(this, () -> {
if (!e.getProjectile().isDead()) {
EntityTrail t = new EntityTrail(this, e.getProjectile(),
new CircumferenceSupplier(particle, 1.2f, 0.9f, 0.0f, 1)
.rotateY(tick -> tick * (2.0f * (float) Math.PI / 20))
, 1);
trails.put(e.getProjectile(), t);
t.begin();
}
}, 5L);
}
}
示例5: onDamage
import org.bukkit.entity.Arrow; //导入依赖的package包/类
/**
* Switch players on arrow hit
*
* @param event Event instance
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageByEntityEvent event)
{
if (!event.isCancelled() && event.getDamager() instanceof Arrow && event.getEntity() instanceof Player)
{
ProjectileSource source = ((Arrow)event.getDamager()).getShooter();
if (source == null || !(source instanceof Player))
return;
Player player = (Player)source;
Location tmp = player.getLocation();
player.teleport(event.getEntity());
event.getEntity().teleport(tmp);
}
}
示例6: onDamage
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onDamage(EntityDamageByEntityEvent event)
{
Player player = null;
if(!(event.getDamager() instanceof Player))
{
if(event.getDamager() instanceof Arrow)
{
Arrow arrow = (Arrow) event.getDamager();
if(arrow.getShooter() instanceof Player)
{
player = (Player) arrow.getShooter();
}
}else return;
}else player = (Player) event.getDamager();
if(player != null && (userManager.get(player.getUniqueId()).isFrozen() || (!options.modeDamage && modeCoordinator.isInMode(player.getUniqueId()))))
{
event.setCancelled(true);
}
}
示例7: onDamage
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if ((event.getEntity() instanceof Player)) {
if ((event.getDamager() instanceof Player)) {
playerAttacksPlayer((Player) event.getEntity(),
(Player) event.getDamager());
return;
}
if ((event.getDamager() instanceof Arrow)) {
Arrow a = (Arrow) event.getDamager();
if ((a.getShooter() instanceof Player)) {
playerAttacksPlayer((Player) event.getEntity(),
(Player) a.getShooter());
return;
}
}
this.n = null;
}
}
示例8: onProjectileHit
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileHit(EntityDamageByEntityEvent e){
Entity entity = e.getEntity();
Entity damager = e.getDamager();
if(entity != null && entity instanceof Player && damager.getType().equals(EntityType.ARROW)){
Player player = (Player) entity;
if(isEnabled(player.getWorld())){
ProjectileSource shooter = ((Arrow) damager).getShooter();
if(shooter instanceof Player){
Player shootingPlayer = (Player) shooter;
if(player.getUniqueId().equals(shootingPlayer.getUniqueId())){
e.setCancelled(true);
debug("We cancelled your bow boost", player);
}
}
}
}
}
示例9: onShotArrow
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onShotArrow(EntityShootBowEvent event)
{
if(event.getEntity() instanceof Player){
Player p = (Player)event.getEntity();
if(event.getProjectile() instanceof Arrow){
Arena a = am.getArena(p);
if(a!=null){
if(a.isGame()){
SPlayer player = SPlayer.getDPlayer(p);
player.addShots(1);
}
}
}
}
}
示例10: onPlayerShoot
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerShoot(EntityDamageByEntityEvent evt) {
Player damager = null;
if (evt.getDamager() instanceof Arrow) {
Arrow arrow = (Arrow)evt.getDamager();
if (arrow.getShooter() instanceof Player) {
damager = (Player)arrow.getShooter();
}
} else if (evt.getDamager() instanceof Player) {
damager = (Player)evt.getDamager();
}
if (damager != null && perkService.playerHasPerk(damager, ArcherTree.FindWeaknessId)) {
if (evt.getEntity() instanceof LivingEntity) {
LivingEntity le = (LivingEntity)evt.getEntity();
le.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 5*20, 1));
}
}
}
示例11: onEntityDamageByEntity
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if(!((e.getEntity() instanceof Player) && Main.getConfiguration().getBoolean("disable-spawn-command-in-pvp.enabled")))
return;
final Player p = (Player) e.getEntity();
if(e.getDamager() instanceof Player) {
pvp(p);
pvp((Player) e.getDamager());
}
else if((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player)) {
pvp(p);
pvp((Player) ((Arrow) e.getDamager()).getShooter());
}
}
示例12: hitByArrow
import org.bukkit.entity.Arrow; //导入依赖的package包/类
private void hitByArrow(EntityDamageByEntityEvent event, BPPlayer bpDamager, Player damager, BPPlayer bpVictim, Player victim)
{
Arrow arrow = (Arrow) event.getDamager();
GameProperties damagerProps = bpDamager.getGameProperties();
CharacterType ct = damagerProps.getCharacterType();
if(ct == CharacterType.ARCHER)
{
Location damagerLocation = damager.getLocation();
Location victimLocation = victim.getLocation();
if(AbilityManager.isHeadshot(damagerLocation, victimLocation, arrow))
{
String displayName = bpVictim.getPVPName();
event.setDamage(event.getDamage() * 2);
AbilityManager.playHeadshotEffect(victim);
damager.sendMessage(MessageType.PVP_HEADSHOT.getTranslation().getValue(displayName));
}
}
}
示例13: onShoot
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler(ignoreCancelled=1, priority=EventPriority.MONITOR)
public void onShoot(ProjectileLaunchEvent e) {
Player player;
Arrow arrow;
if (e.getEntity() instanceof Arrow && (arrow = (Arrow)e.getEntity()).getShooter() != null && arrow.getShooter() instanceof Player && this.bowPull.containsKey((player = (Player)arrow.getShooter()).getUniqueId())) {
Long time = System.currentTimeMillis() - this.bowPull.get(player.getUniqueId());
double power = arrow.getVelocity().length();
Long timeLimit = 300;
int ping = this.getJanitor().lag.getPing(player);
if (ping > 400) {
timeLimit = 150;
}
if (power > 2.5 && time < timeLimit) {
this.getJanitor().logCheat(this, player, null, new String[0]);
}
}
}
示例14: OnEntityDamageByEntity
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)//确认不会把自己射中
public void OnEntityDamageByEntity(EntityDamageByEntityEvent e){
//System.out.print("监听到了被射中事件:\ndamager:"+e.getDamager().getType().toString()+
// "\n entityType:"+e.getEntityType().toString()+
// "\n entity:"+e.getEntity());
if (e.getDamager() != null//找得到伤害者
&& e.getDamager().getType() == EntityType.ARROW//是箭
&& ((Arrow) e.getDamager()).getShooter() instanceof Player//射击者是玩家
&& e.getEntityType() == EntityType.PLAYER //被击中者是玩家
&& isInList((Player)((Arrow) e.getDamager()).getShooter())//发出者在列表中
&& isInList((Player)e.getEntity())//被击中者在列表中
&& ((Arrow) e.getDamager()).getShooter() == e.getEntity()//是自己发出的
) {
//e.getEntity().setVelocity(e.getDamager().getVelocity());
//System.out.print("监听到了被射中事件2");
((Player)e.getEntity()).sendMessage(ChatColor.RED+"你已达到最大射程,为了免得你摔死,你正在降落");
e.setCancelled(true);
}
}
示例15: testArrowDamage
import org.bukkit.entity.Arrow; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testArrowDamage() {
dut.start();
List<Player> damagers = dut.getSortedDamagers(player);
assertEquals(0, damagers.size());
Arrow arrow = mock(Arrow.class);
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(arrow, player, null, 5);
dut.onEntityDamageByEntity(damageEvent);
damagers = dut.getSortedDamagers(player);
assertEquals(0, damagers.size());
when(arrow.getShooter()).thenReturn(d1);
dut.onEntityDamageByEntity(damageEvent);
damagers = dut.getSortedDamagers(player);
assertEquals(1, damagers.size());
assertEquals(d1, damagers.get(0));
}