本文整理匯總了Java中cn.nukkit.event.entity.ProjectileHitEvent類的典型用法代碼示例。如果您正苦於以下問題:Java ProjectileHitEvent類的具體用法?Java ProjectileHitEvent怎麽用?Java ProjectileHitEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProjectileHitEvent類屬於cn.nukkit.event.entity包,在下文中一共展示了ProjectileHitEvent類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onProjectileHit
import cn.nukkit.event.entity.ProjectileHitEvent; //導入依賴的package包/類
@EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
EntityProjectile entity = (EntityProjectile) event.getEntity();
Location loc = NukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(loc.getWorld())) {
return true;
}
PlotArea area = loc.getPlotArea();
if (area == null) {
return true;
}
Plot plot = area.getPlotAbs(loc);
Entity shooter = entity.shootingEntity;
if (shooter instanceof Player) {
PlotPlayer pp = NukkitUtil.getPlayer((Player) shooter);
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
kill(entity, event);
return false;
}
return true;
}
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return true;
}
kill(entity, event);
return false;
}
if (shooter == null) {
kill(entity, event);
return false;
}
return true;
}
示例2: onProjectileHit
import cn.nukkit.event.entity.ProjectileHitEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false) //DON'T FORGET THE ANNOTATION @EventHandler
public void onProjectileHit(ProjectileHitEvent event) throws Exception
{
Entity snowball = event.getEntity();
Position loc = snowball.getLocation();
Integer kind = null;
String who = null;
snowball.getLevel().removeEntity(snowball);
if(whodi.containsKey((int)snowball.getId())){
for (Map.Entry<Integer, String> e : whodi.get((int)snowball.getId()).entrySet()) {
kind = e.getKey();
who = e.getValue();
}
}
if(who !=null){
Player wdi =Server.getInstance().getPlayer(who);
if(kind == 1 || kind == 4 || kind == 8){
int ds = 3;
if(kind == 8){
ds = 2;
}
if(kind == 4){
ds = 5;
}
int x=loc.getFloorX();
int y=loc.getFloorY();
int z=loc.getFloorZ();
ExplodeSound sound = new ExplodeSound(new Vector3(x,y,z));//サウンドオブジェクトの生成
loc.getLevel().addSound(sound);//サウンドを再生
ExplodeParticle particle = new ExplodeParticle(new Vector3(x,y,z));
int count = 20;
for(int i = 0;i < count; ++i){
loc.getLevel().addParticle(particle);
}
for(Player playera : Server.getInstance().getOnlinePlayers().values()){
if(Math.abs(playera.getX()-x)<=ds & Math.abs(playera.getY()-y)<=ds & Math.abs(playera.getZ()-z)<=ds & wdi != playera){
EntityDamageByEntityEvent ev = new EntityDamageByEntityEvent(wdi,playera, EntityDamageEvent.CAUSE_ENTITY_EXPLOSION, 8);//EntityDamageEvent::CAUSE_MAGICを変えることでダメージの種類を、1を変えることでダメージの強さが変更できます
playera.attack(ev);
}
}
}}
}