本文整理汇总了Java中org.bukkit.event.entity.ProjectileHitEvent类的典型用法代码示例。如果您正苦于以下问题:Java ProjectileHitEvent类的具体用法?Java ProjectileHitEvent怎么用?Java ProjectileHitEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectileHitEvent类属于org.bukkit.event.entity包,在下文中一共展示了ProjectileHitEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
if (event.getEntity().getType() != EntityType.SNOWBALL || !event.getEntity().hasMetadata("paintball-ball") || !event.getEntity().getMetadata("paintball-ball").get(0).asString().equals(this.uuid.toString()))
return;
for (Block block : getNearbyBlocks(event.getEntity().getLocation(), 2))
{
if (block.getType() == Material.AIR || block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
continue;
if (this.isBlockGloballyUsed(block.getLocation()))
continue;
SimpleBlock simpleBlock = new SimpleBlock(Material.STAINED_CLAY, DyeColor.values()[new Random().nextInt(DyeColor.values().length)].getWoolData());
this.addBlockToUse(block.getLocation(), simpleBlock);
block.setType(simpleBlock.getType());
block.setData(simpleBlock.getData());
}
event.getEntity().remove();
}
示例2: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent evt) {
Projectile projectile = evt.getEntity();
String customId = projectile.getCustomName();
if (customId == null || !customId.equals("recreator.structure.turret.tnt")) return;
Location loc;
Block block = evt.getHitBlock();
if (block != null) {
loc = block.getLocation();
block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
return;
}
Entity entity = evt.getEntity();
if (entity != null) {
loc = entity.getLocation();
entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
}
}
示例3: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent evt) {
Projectile projectile = evt.getEntity();
String customId = projectile.getCustomName();
if (customId == null || !customId.equals("recreator.item.fatman")) return;
Location loc;
Block block = evt.getHitBlock();
if (block != null) {
loc = block.getLocation();
block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
return;
}
Entity entity = evt.getEntity();
if (entity != null) {
loc = entity.getLocation();
entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
}
}
示例4: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onProjectileHit(ProjectileHitEvent event)
{
if(event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SNOWBALL) return;
Projectile arrow = event.getEntity();
ProjectileSource source = arrow.getShooter();
if(source == null || !(source instanceof Player)) return;
Player player = (Player)source;
if(player.getGameMode() == GameMode.CREATIVE) return;
Flag flag = this.GetFlagInstanceAtLocation(arrow.getLocation(), player);
if(flag == null) return;
PlayerInventory inventory = player.getInventory();
ItemMeta meta = inventory.getItemInMainHand().getItemMeta();
if(meta != null && meta.hasEnchant(Enchantment.ARROW_INFINITE)) return;
arrow.remove();
inventory.addItem(new ItemStack(Material.ARROW));
}
示例5: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
World world = projectile.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.FIRE_ARROWS) && worldConfig.getBoolean(Config.FEATURE_FIRE_ARROWS_IGNITE_TARGET)) {
LivingEntity shooter = (LivingEntity) projectile.getShooter();
if (shooter.getType() == EntityType.SKELETON) { //Not sure why this is here, or why fire arrows even work with it here
return;
}
if (((CraftEntity) shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0) {
//if (shooter != null && ((CraftEntity)shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0){
Block block = projectile.getWorld().getBlockAt(projectile.getLocation());
if (block.getType() == Material.AIR) {
block.setType(Material.FIRE);
}
}
}
}
示例6: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (projectile instanceof Arrow) {
projectile.remove();
} else if (projectile instanceof Snowball && event.getEntity() instanceof Player) {
((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 1));
} else if (projectile instanceof Egg && projectile.getShooter() instanceof Player) {
projectile.getWorld().createExplosion(projectile.getLocation(), 0.0F);
for (Entity entity : projectile.getNearbyEntities(5, 5, 5)) {
if (entity instanceof Player) {
Player player = (Player) entity;
if (plugin.getGameArena().isZombie(player)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 5, 1));
}
}
}
}
}
示例7: onArrowLand
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onArrowLand(ProjectileHitEvent e) {
if (arrows.contains(e.getEntity())) {
arrows.remove(e.getEntity());
Location start = e.getEntity().getLocation();
if (arrowMaterials.containsKey(e.getEntity())) {
Material material = arrowMaterials.get(e.getEntity());
set(start, material);
start.add(1, 1, 0);
set(start, material);
start.add(0, 1, 0);
set(start, material);
start.add(1, -2, 0);
set(start, material);
arrowMaterials.remove(e.getEntity());
} else {
setRandom(start);
start.add(1, 1, 0);
setRandom(start);
start.add(0, 1, 0);
setRandom(start);
start.add(1, -2, 0);
setRandom(start);
}
}
}
示例8: eggBreak
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void eggBreak(final ProjectileHitEvent e) {
if (e.getEntity() instanceof Egg && eggs.contains(e.getEntity())) {
final Location l = e.getEntity().getLocation();
int radius = 3;
final int[][] newLocs = { { radius, 0 }, { -radius, 0 }, { 0, radius }, { 0, -radius }
};
for (int i = 0; i < 4; i++) {
final int count = i;
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, new Runnable() {
public void run() {
e.getEntity().getWorld().createExplosion(l.getX() + newLocs[count][0], l.getY(), l.getZ() + newLocs[count][1], 2.3F, false, true);
}
}, 4 * i);
}
eggs.remove(e.getEntity());
}
}
示例9: onProjectileHitEvent
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
private void onProjectileHitEvent(final ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (!(projectile instanceof Snowball))
return;
if (projectile.getShooter() instanceof Player) {
Player player = (Player) projectile.getShooter();
Game game = api.getGameManager().getGame(player);
if (game == null)
return;
if (game.getState() != GameState.PLAYING)
return;
PlantType type = game.getPlants().getMembers().get(player.getUniqueId());
if (type == null)
return;
if (type == PlantType.WINTER_MELON) {
freeze(getZombies(projectile, game), game);
}
}
}
示例10: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(ProjectileHitEvent e) {
List<Block> bList = new ArrayList<>();
Block b = e.getEntity().getLocation().getBlock();
bList.add(b);
bList.add(b.getRelative(BlockFace.DOWN));
bList.add(b.getRelative(BlockFace.EAST));
bList.add(b.getRelative(BlockFace.NORTH));
bList.add(b.getRelative(BlockFace.SOUTH));
bList.add(b.getRelative(BlockFace.WEST));
bList.add(b.getRelative(BlockFace.UP));
bList.add(b.getRelative(BlockFace.NORTH_EAST));
bList.add(b.getRelative(BlockFace.NORTH_WEST));
bList.add(b.getRelative(BlockFace.SOUTH_EAST));
bList.add(b.getRelative(BlockFace.SOUTH_WEST));
for(Block bl : bList){
if(bl.getType().equals(Material.GLASS) || bl.getType().equals(Material.THIN_GLASS)) {
Bukkit.getServer().getScheduler().runTaskLater(plugin, new ReplaceGlass(bl, bl.getType()), 1000);
bl.breakNaturally();
}
}
}
示例11: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Entity entity = event.getEntity();
// Config
float size = plugin.getConfig().getInt("Size of Explosion");
boolean damage = plugin.getConfig().getBoolean("Block Damage");
boolean fire = plugin.getConfig().getBoolean("Set Fire");
if (entity instanceof Snowball) {
Snowball snowball = (Snowball) entity;
Entity shooter = snowball.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
Location sb = snowball.getLocation();
if (plugin.players.contains(player.getName())) {
player.getWorld().createExplosion(sb.getX(), sb.getY(),
sb.getZ(), size, fire, damage);
}
}
}
}
示例12: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
final Entity entity = e.getEntity();
if (removeArrows.contains(entity.getEntityId())) {
entity.remove();
removeArrows.remove(entity.getEntityId());
} else if (rpgProjectiles.contains(entity.getEntityId())) {
RPGItem item = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId()));
new BukkitRunnable() {
public void run() {
rpgProjectiles.remove(entity.getEntityId());
}
}.runTask(Plugin.plugin);
if (item == null)
return;
item.projectileHit((Player) ((Projectile) entity).getShooter(), (Projectile) entity);
}
}
示例13: onSnowballHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler (priority = EventPriority.NORMAL)
public void onSnowballHit (ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.SNOWBALL) {
UUID uuid = event.getEntity().getUniqueId();
if (this.snowBalls.contains(uuid)) {
Location loc = event.getEntity().getLocation();
loc.setY(loc.getBlockY() - 1);
Block lBlock = loc.getBlock();
if (lBlock.getType().isSolid()) {
growSnow(loc);
}
this.snowBalls.remove(uuid);
}
}
}
示例14: onArrowImpactEvent
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onArrowImpactEvent(ProjectileHitEvent event) {
if (!(event.getEntity().getShooter() instanceof Player)) return;
Player player = (Player) event.getEntity().getShooter();
if (event.getEntity() instanceof Arrow && arrows.contains(event.getEntity())) {
arrows.remove(event.getEntity());
player.sendMessage(ChatColor.YELLOW + "Boom!");
final Location target = event.getEntity().getLocation();
for (int i = 0; i < 60; i++) {
final int k = i;
Bukkit.getScheduler().scheduleSyncDelayedTask(MausWasHere.PLUGIN, new Runnable() {
@Override
public void run() {
nukeEffect(target, 110 + k, 30 * k, k / 4);
}
}, i);
}
}
}
示例15: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
if (event.getEntityType() != EntityType.FISHING_HOOK &&
event.getEntityType() != EntityType.SNOWBALL &&
event.getEntityType() != EntityType.EGG) return;
ProjectileSource shooter = ((Projectile) event.getEntity()).getShooter();
if (shooter != null && shooter instanceof Player && event.getHitEntity() instanceof Damageable) {
((Damageable) event.getHitEntity()).damage(0.01, (Player) shooter);
}
}