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