本文整理匯總了Java中org.bukkit.event.entity.ProjectileLaunchEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java ProjectileLaunchEvent.setCancelled方法的具體用法?Java ProjectileLaunchEvent.setCancelled怎麽用?Java ProjectileLaunchEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.ProjectileLaunchEvent
的用法示例。
在下文中一共展示了ProjectileLaunchEvent.setCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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");
}
}
}
示例2: 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);
}
}
}
}
示例3: 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);
}
}
示例4: 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);
}
示例5: 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");
}
}
示例6: 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);
}
}
}
示例7: 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!");
}
}
}
}
示例8: 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);
}
}
示例9: 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;
}
}
}
示例10: 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);
}
}
示例11: onThrow
import org.bukkit.event.entity.ProjectileLaunchEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onThrow(ProjectileLaunchEvent event) {
if (event.getEntity().getShooter() instanceof Player) {
Player player = (Player) event.getEntity().getShooter();
if (this.editKits.containsKey(player.getUniqueId())) {
event.setCancelled(true);
}
}
}
示例12: onPearlThrow
import org.bukkit.event.entity.ProjectileLaunchEvent; //導入方法依賴的package包/類
/**
* Prevent pearling with an exile pearl
* @param e The event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPearlThrow(ProjectileLaunchEvent e) {
if (!(e.getEntity() instanceof EnderPearl)) {
return;
}
final Player p = (Player)e.getEntity().getShooter();
if (p == null) {
return;
}
ExilePearl pearl = pearlApi.getPearlFromItemStack(p.getInventory().getItemInMainHand());
if (pearl == null) {
return;
}
msg(p, Lang.pearlCantThrow);
e.setCancelled(true);
// Need to schedule this or else the re-created pearl doesn't show up
Bukkit.getScheduler().scheduleSyncDelayedTask(pearlApi, new Runnable() {
@Override
public void run() {
p.getInventory().setItemInMainHand(pearl.createItemStack());
}
});
}
示例13: onProjectileLaunch
import org.bukkit.event.entity.ProjectileLaunchEvent; //導入方法依賴的package包/類
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Player shooter = null;
Projectile projectile = event.getEntity();
if (projectile.getShooter() instanceof Player) {
shooter = (Player) projectile.getShooter();
}
if (shooter == null) {
return;
}
SpleefArena arena = PlayerManager.getArena(shooter.getUniqueId());
if (arena == null) {
return;
}
if (arena.getStatus() != GameStatus.ACTIVE || arena.countdownIsActive()) {
event.setCancelled(true);
return;
}
// splegg weapon
if (shooter.getItemInHand() != null && shooter.getItemInHand().getType() == Material.DIAMOND_HOE) {
return;
}
if (projectile.getType() == EntityType.EGG) {
projectile.setMetadata("EpicSpleef:Grenade", new FixedMetadataValue(SpleefMain.getInstance(), 1));
}
}
示例14: onFastBow
import org.bukkit.event.entity.ProjectileLaunchEvent; //導入方法依賴的package包/類
@EventHandler
public void onFastBow(ProjectileLaunchEvent event) {
if(main.getConfig().getBoolean("hacks.fastbow")) {
if(event.getEntity() instanceof Arrow && event.getEntity().getShooter() instanceof Player) {
final Player player = (Player) event.getEntity().getShooter();
if(player.hasPermission(Permission.BOW_BYPASS)) {
return;
}
if(arrow.contains(player.getName())) {
Alerter alert = Alerter.getInstance();
if(counter.get(player.getName()) != null) {
counter.put(player.getName(), counter.get(player.getName())+1);
} else {
counter.put(player.getName(), 1);
}
alert.alertHack(player, HackType.FASTBOW, counter.get(player.getName()));
if(counter.get(player.getName()) > 30) {
event.setCancelled(true);
}
if(counter.get(player.getName()) == 25) {
AutoBan.getInstance().autobanPlayer(player, 25, HackType.FASTBOW);
}
} else {
arrow.add(player.getName());
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
@Override
public void run() {
arrow.remove(player.getName());
}
}, 2);
}
}
}
}
示例15: onProjectileLaunchEvent
import org.bukkit.event.entity.ProjectileLaunchEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onProjectileLaunchEvent(ProjectileLaunchEvent event) {
if (event.getEntity() instanceof Player) {
PlotMapInfo pmi = manager.getMap(BukkitUtil.adapt(event.getEntity().getWorld()));
if (pmi != null && !pmi.canUseProjectiles()) {
event.getEntity().sendMessage(api.C("ErrCannotUseEggs"));
event.setCancelled(true);
}
}
}