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


Java ProjectileLaunchEvent.getEntity方法代码示例

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


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

示例1: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile projectile = event.getEntity();
    if (projectile instanceof EnderPearl) {
        EnderPearl enderPearl = (EnderPearl) projectile;
        ProjectileSource source = enderPearl.getShooter();
        if (source instanceof Player) {
            Player shooter = (Player) source;
            long remaining = getRemaining(shooter);
            if (remaining > 0L) {
                shooter.sendMessage(ChatColor.RED + "You are still on " + ChatColor.LIGHT_PURPLE + getName() + ChatColor.RED + " cooldown for another " + ChatColor.BOLD
                        + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + '.');

                event.setCancelled(true);
                return;
            }

            if (setCooldown(shooter, shooter.getUniqueId(), defaultCooldown, true)) {
                startDisplaying(shooter);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:EnderPearlTimer.java

示例2: onShoot

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的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]);
        }
    }
}
 
开发者ID:cumpe,项目名称:Janitor,代码行数:18,代码来源:FastBow.java

示例3: on

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void on(ProjectileLaunchEvent event) {
    Entity entity = event.getEntity();

    if (!(entity instanceof Egg)) return;

    Egg egg = (Egg) entity;

    // skip our own eggs
    if (((CraftEgg) entity).getHandle() instanceof CustomChickenEgg) return;

    // cancel the launch
    event.setCancelled(true);

    EntityEgg original = ((CraftEgg) egg).getHandle();

    // create our own egg from the original and spawn that
    CustomChickenEgg newEgg = new CustomChickenEgg(original.getWorld(), original.getShooter());
    original.getWorld().addEntity(newEgg, CreatureSpawnEvent.SpawnReason.EGG);
}
 
开发者ID:Eluinhost,项目名称:UberHardcore,代码行数:21,代码来源:ThrownEggHandler.java

示例4: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
	if (!(event.getEntity().getShooter() instanceof Player)) {
		return;
	}

	Player player = (Player) event.getEntity().getShooter();
	NormalAchievements category;
	if (event.getEntity() instanceof Snowball) {
		category = NormalAchievements.SNOWBALLS;
	} else if (event.getEntity() instanceof Egg) {
		category = NormalAchievements.EGGS;
	} else {
		return;
	}

	if (plugin.getDisabledCategorySet().contains(category.toString())) {
		return;
	}

	if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
		return;
	}

	updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:27,代码来源:AchieveSnowballEggListener.java

示例5: onGhastShoot

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void onGhastShoot(ProjectileLaunchEvent event) {
	if (event.getEntity() instanceof LargeFireball) {
		// ghast fireball
		LargeFireball frb = (LargeFireball) event.getEntity();
		if (frb.getShooter() instanceof Ghast) {
			Ghast g = (Ghast) frb.getShooter();
			DroneFighter f = getFighter(g);
			if (f == null) {
				g.remove();
				//System.out.println("f for ghast is null, removing!");
				event.setCancelled(true);
			} else {
				event.setCancelled(true);
				//System.out.println("Dud fire!");
			}
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:20,代码来源:SQSkywatch.java

示例6: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile entity = event.getEntity();
    if (!(entity instanceof ThrownPotion)) {
        return;
    }
    ProjectileSource shooter = entity.getShooter();
    if (!(shooter instanceof Player)) {
        return;
    }
    Location l = BukkitUtil.getLocation(entity);
    if (!PS.get().hasPlotArea(l.getWorld())) {
        return;
    }
    PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
    Plot plot = l.getOwnedPlot();
    if (plot != null && !plot.isAdded(pp.getUUID())) {
        entity.remove();
        event.setCancelled(true);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:PlayerEvents.java

示例7: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onProjectileLaunch (ProjectileLaunchEvent event)
  {
    if ( ! (event.getEntity() instanceof Arrow)
        || ! (event.getEntity().getShooter() instanceof Player))
      return;
    if ( ((Player) event.getEntity().getShooter())
        .hasPermission("headshot"))
      {
        event.getEntity()
            .setMetadata(
                "spawn-location",
                new FixedMetadataValue(plugin, event.getEntity()
                    .getLocation()));
      }
  }
 
开发者ID:DiGitHubCap,项目名称:Headshot,代码行数:17,代码来源:ProjectileListener.java

示例8: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    if (event.getEntity() == null) {
        return;
    }

    Projectile projectile = event.getEntity();
    // In the Bukkit API prior to 1.7, getShooter() returns a LivingEntity instead of a ProjectileSource
    Object shooterRaw = null;
    if (shooterIsLivingEntity) {
        try {
            if (getShooter == null) {
                getShooter = Projectile.class.getMethod("getShooter");
            }
            shooterRaw = getShooter.invoke(projectile);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            ConsoleLogger.logException("Error getting shooter", e);
        }
    } else {
        shooterRaw = projectile.getShooter();
    }
    if (shooterRaw instanceof Player && listenerService.shouldCancelEvent((Player) shooterRaw)) {
        event.setCancelled(true);
    }
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:26,代码来源:EntityListener.java

示例9: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileLaunch (ProjectileLaunchEvent event)
  {
    Projectile projectile = event.getEntity();
    if (projectile.getType() != EntityType.THROWN_EXP_BOTTLE
        || ! (projectile.getShooter() instanceof Player))
      return;
    Player player = (Player) projectile.getShooter();
    ItemStack item = player.getInventory().getItemInHand();
    if (item.getType() != Material.EXP_BOTTLE)
      return;
    ItemMeta meta = item.getItemMeta();
    if ( !meta.hasLore())
      return;
    for (String s : meta.getLore())
      {
        if (s == null)
          return;
        if (s.startsWith("Level "))
          {
            projectile.setMetadata("expbottlelevel", new LevelMetadata(
                Integer.parseInt(s.substring(s.indexOf(' ') + 1))));
          }
      }
  }
 
开发者ID:DiGitHubCap,项目名称:Merlin,代码行数:26,代码来源:PlayerListener.java

示例10: onShoot

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@Override
public void onShoot(ProjectileLaunchEvent event) {
    super.onShoot(event);

    if(event.getEntity() instanceof Arrow) {
        Arrow arrow = (Arrow) event.getEntity();
        arrow.setDamage(modifier.apply(arrow.getDamage()));
        arrow.setVelocity(arrow.getVelocity().multiply(modifier.apply(1d)));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:ArcherySymptom.java

示例11: projectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void projectileLaunch(ProjectileLaunchEvent e) {
	 Projectile projectile = e.getEntity();
	 if (projectile instanceof Snowball || projectile instanceof Egg || projectile instanceof Arrow) {
		 if (projectile.getShooter() instanceof Player) {
			 GamePlayer shooter = SkyWarsReloaded.getPC().getPlayer(((Player) projectile.getShooter()).getUniqueId());
			 String effect = shooter.getProjEffect();
			 if (effect != null) {
				 if (!effect.equalsIgnoreCase("normal") && shooter.inGame()) {
					 SkyWarsReloaded.getProjC().addProjectile(projectile, shooter.getProjEffect());
				 }
			 }
		 }
	 }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:16,代码来源:ProjectileListener.java

示例12: on

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void on(ProjectileLaunchEvent event){
    Projectile projectile = event.getEntity();
    if(projectile instanceof Arrow && projectile.getShooter() instanceof Player){
        final Arrow arrow = (Arrow) projectile;
        final int task = server.getScheduler().scheduleSyncRepeatingTask(plugin, ()-> {
            arrow.getLocation().getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
        }, 0L, 1L);
        particleTasks.put(arrow, task);
    }
}
 
开发者ID:mikroskeem,项目名称:MiniWynn,代码行数:12,代码来源:BowListener.java

示例13: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent e) {
    if(e.getEntity().getShooter() instanceof Player) {
        Player player = (Player) e.getEntity().getShooter();
        if(e.getEntity() instanceof Arrow) {
            return;
        }
        DynamicAC.getManager().getBackend().checkProjectile(player, e);
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:11,代码来源:PlayerListener.java

示例14: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
    final Projectile projectile = event.getEntity();
    if (event.getEntityType() == EntityType.SPLASH_POTION && projectile.getType().equals((Object)PotionEffectType.HEAL)) {
        if (projectile.getShooter() instanceof Player && ((Player) projectile.getShooter()).isSprinting()) {
            final Vector velocity = projectile.getVelocity();

            velocity.setY(velocity.getY() - 0.4);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:PotListener.java

示例15: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
    if (event.getEntityType() == EntityType.SPLASH_POTION) {
        final Projectile projectile = event.getEntity();

        if (projectile.getShooter() instanceof Player && ((Player) projectile.getShooter()).isSprinting()) {
            final Vector velocity = projectile.getVelocity();

            velocity.setY(velocity.getY() - 0.8);
            projectile.setVelocity(velocity);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:PotListener.java


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