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


Java ProjectileLaunchEvent类代码示例

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


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

示例1: onGrenadeLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGrenadeLaunch(final ProjectileLaunchEvent event) {
    if (event.getEntity().getShooter() instanceof Player) {
        Player player = (Player) event.getEntity().getShooter();
        ItemStack stack = player.getItemInHand();

        if(stack != null) {
            // special case for grenade arrows
            if (stack.getType() == Material.BOW) {
                int arrows = player.getInventory().first(Material.ARROW);
                if (arrows == -1) return;
                stack = player.getInventory().getItem(arrows);
            }

            Grenade grenade = Grenade.ITEM_TAG.get(stack);
            if(grenade != null) {
                grenade.set(plugin, event.getEntity());
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:GrenadeListener.java

示例2: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
/**
 * Launch 2 more arrows when one is launched
 *
 * @param event Event
 */
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event)
{
    if (event.getEntity().getType() != EntityType.ARROW || !(event.getEntity().getShooter() instanceof Player) || event.getEntity().hasMetadata("TAM"))
        return;

    final Vector velocity = event.getEntity().getVelocity();

    for(int i = 0; i < 2; i++)
    {
        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            EntityArrow entityArrow = new EntityArrow(((CraftWorld)event.getEntity().getWorld()).getHandle(), ((CraftLivingEntity)event.getEntity().getShooter()).getHandle(), 1F);
            entityArrow.shoot(((CraftLivingEntity)event.getEntity().getShooter()).getHandle().pitch, ((CraftLivingEntity)event.getEntity().getShooter()).getHandle().yaw, 0.0F, 3.0F, 1.0F);
            entityArrow.getBukkitEntity().setMetadata("TAM", new FixedMetadataValue(this.plugin, true));
            entityArrow.getBukkitEntity().setVelocity(velocity);
            ((CraftWorld)event.getEntity().getWorld()).getHandle().addEntity(entityArrow);
        }, 5L * (i + 1));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:ThreeArrowModule.java

示例3: checkProjectile

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
public void checkProjectile(Player player, ProjectileLaunchEvent e) {
    incrementOld(player, projectilesShot, 10);
    if(!projectileTime.containsKey(player)) {
        projectileTime.put(player,System.currentTimeMillis());
    } else if(projectilesShot.get(player) == 10) {
        long time = System.currentTimeMillis() - projectileTime.get(player);
        projectileTime.remove(player);
        projectilesShot.remove(player);
        if(time < 1500) {
            for(Player pla : DynamicAC.instance.onlinestaff) {
                pla.sendMessage(DynamicAC.prefix + player.getName() + " failed Fast Bow!");
            }
            e.setCancelled(true);
            DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()), "Fast Bow");
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:18,代码来源:BackendChecks.java

示例4: 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

示例5: on

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST)
public void on(ProjectileLaunchEvent event) {
    if (event.isCancelled() || !(event.getEntity().getShooter() instanceof Player) || !config.isCountdownBlockProjectile()) {
        return;
    }

    Player player = (Player) event.getEntity().getShooter();
    Arena arena = getArena(player);

    if (arena == null) {
        return;
    }

    if (arena.isCounting()) {
        Helper.pm(player, "Errors.blocked-countdown-action", true);
        event.setCancelled(true);
    }
}
 
开发者ID:RealizedMC,项目名称:Duels,代码行数:19,代码来源:ArenaManager.java

示例6: 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

示例7: 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

示例8: 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

示例9: PlayerTrownArrow

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
@EventHandler
public void PlayerTrownArrow(ProjectileLaunchEvent e){
	if (!(e.getEntity().getShooter() instanceof Player)){
		return;
	}
	
	RedProtect.get().logger.debug("Is ProjectileLaunchEvent event.");
	
	Location l = e.getEntity().getLocation();
	Player p = (Player) e.getEntity().getShooter();
	Region r = RedProtect.get().rm.getTopRegion(l);
	
	if (r != null && !r.canProtectiles(p)){
		e.setCancelled(true);
		RPLang.sendMessage(p, "playerlistener.region.cantuse");
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:18,代码来源:RPPlayerListener.java

示例10: disable

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
public void disable() {
    // Unregister your events on plugin disable.
    // PlayerJoinEvent.getHandlerList().unregister(plugin);
    PlayerBucketFillEvent.getHandlerList().unregister(this);
    PlayerBucketEmptyEvent.getHandlerList().unregister(this);
    ProjectileLaunchEvent.getHandlerList().unregister(this);
    PlayerMoveEvent.getHandlerList().unregister(this);
    EntityDamageEvent.getHandlerList().unregister(this);
    PlayerJoinEvent.getHandlerList().unregister(this);
    PlayerLoginEvent.getHandlerList().unregister(this);
    PlayerQuitEvent.getHandlerList().unregister(this);
    PlayerKickEvent.getHandlerList().unregister(this);
    PlayerChangedWorldEvent.getHandlerList().unregister(this);
    PlayerPickupItemEvent.getHandlerList().unregister(this);
    PlayerDropItemEvent.getHandlerList().unregister(this);
    InventoryClickEvent.getHandlerList().unregister(this);
    PlayerInteractEvent.getHandlerList().unregister(this);
    PlayerAnimationEvent.getHandlerList().unregister(this);
    PlayerRespawnEvent.getHandlerList().unregister(this);
    AsyncPlayerChatEvent.getHandlerList().unregister(this);
                            
}
 
开发者ID:ModernDayPlayer,项目名称:SurvivalGamesX,代码行数:23,代码来源:PlayerListener.java

示例11: onProjectileLaunch

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileLaunch(ProjectileLaunchEvent ev) {
    LivingEntity shooter = (LivingEntity) ev.getEntity().getShooter();

    if ((shooter instanceof Player)) {
        Player p = (Player) shooter;

        if ((plugin.getGameManager().isSpectator(p)
                || plugin.getGameManager().getState() == SGGameState.LOBBY 
                || plugin.getGameManager().getState() == SGGameState.STARTING 
                || plugin.getGameManager().getState() == SGGameState.PRE_DEATHMATCH)
                && !plugin.getGameManager().isAdmin(p)) {
            ev.setCancelled(true);
        }
    }
}
 
开发者ID:ModernDayPlayer,项目名称:SurvivalGamesX,代码行数:17,代码来源:PlayerListener.java

示例12: 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

示例13: 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

示例14: onProjectileThrow

import org.bukkit.event.entity.ProjectileLaunchEvent; //导入依赖的package包/类
@EventHandler
public void onProjectileThrow(ProjectileLaunchEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			if(event.getEntity().getShooter() instanceof Player){
				if(Team.getTeam((Player)event.getEntity().getShooter()).equals(Minigame.getObservers())){
					event.setCancelled(true);	
				} else {
					if(!Minigame.getCurrentMinigame().getState().equals(MatchState.STARTED)){
						event.setCancelled(true);
					}
				}
			}
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
开发者ID:tatanpoker09,项目名称:TCMinigames,代码行数:25,代码来源:PlayerListener.java

示例15: 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


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