@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
{
if (!this.allowed.contains(event.getPlayer().getUniqueId()))
return;
this.allowed.remove(event.getPlayer().getUniqueId());
if (this.hub.getPlayerManager().isBusy(event.getPlayer()))
return;
event.setCancelled(true);
event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().multiply(1.6D).setY(1.0D));
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0F, 1.0F);
for (int i = 0; i < 20; i++)
ParticleEffect.CLOUD.display(0.5F, 0.15F, 0.5F, 0.25F, 20, event.getPlayer().getLocation().subtract(0.0F, 0.20F, 0.0F));
event.getPlayer().setAllowFlight(false);
}
java类org.bukkit.event.player.PlayerToggleFlightEvent的实例源码
DoubleJumpListener.java 文件源码
项目:Hub
阅读 29
收藏 0
点赞 0
评论 0
PlayerListener.java 文件源码
项目:AddGun
阅读 20
收藏 0
点赞 0
评论 0
/**
* Keeps track of player glide; if they are gliding we track when they glided, or, clear if no longer gliding.
*
* @param event
* the flying toggle event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void toggleGlideEvent(PlayerToggleFlightEvent event) {
if (event.isFlying()) {
glidingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
//if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + "glide started"); }
return System.currentTimeMillis();
});
glidingEnd.remove(event.getPlayer().getUniqueId());
} else {
/*if (glidingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) {
event.getPlayer().sendMessage(ChatColor.GOLD + " glide cleared");
}*/
glidingSince.remove(event.getPlayer().getUniqueId());
glidingEnd.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
return System.currentTimeMillis();
});
}
}
DoubleJumpMatchModule.java 文件源码
项目:ProjectAres
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
Jumper jumper = this.jumpers.get(player);
if(jumper == null) return;
if(event.isFlying()) {
event.setCancelled(true);
this.setCharge(jumper, 0f);
this.refreshJump(player);
// calculate jump
Vector impulse = player.getLocation().getDirection();
impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5);
impulse.multiply(jumper.kit.power / 3f);
event.getPlayer().applyImpulse(impulse, true);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
}
}
FlagDef_NoFlight.java 文件源码
项目:GriefPreventionFlags
阅读 27
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true)
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
{
Player player = event.getPlayer();
if(player.isFlying()) return;
if(player.hasPermission("gpflags.bypass")) return;
Flag flag = this.GetFlagInstanceAtLocation(player.getLocation(), player);
if(flag == null) return;
GPFlags.sendMessage(player, TextMode.Err, Messages.CantFlyHere);
event.setCancelled(true);
Location underLocation = player.getLocation().add(0, -1, 0);
Material underType = underLocation.getBlock().getType();
if(!underType.isSolid()) player.teleport(underLocation);
player.setFallDistance(player.getFallDistance() + 1);
}
DoubleJumpListener.java 文件源码
项目:Cardinal
阅读 23
收藏 0
点赞 0
评论 0
/**
* Cancels the player from flying and adds to the player's velocity.
*
* @param event The event called.
*/
@EventHandler
public void onPlayerToggleFly(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
UUID id = player.getUniqueId();
KitDoubleJump.DoubleJumpData data = players.get(id);
if (data != null && data.isEnabled() && players.containsKey(player.getUniqueId())
&& player.getExp() <= 1.0f && event.isFlying()) {
player.setAllowFlight(false);
player.setExp(0.0f);
event.setCancelled(true);
Vector normal = player.getEyeLocation().getDirection();
normal.setY(0.75 + Math.max(normal.getY() * 0.5, 0));
normal.multiply(data.getPower() / 2);
event.getPlayer().setVelocity(normal);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
}
}
Acrobat.java 文件源码
项目:AnnihilationPro
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void AcrobatDoubleJump(PlayerToggleFlightEvent event)
{
Player player = event.getPlayer();
if(player.getGameMode() != GameMode.CREATIVE)
{
AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId());
if(Game.isGameRunning() && p != null && p.getKit().equals(this))
{
Delays.getInstance().addDelay(player, System.currentTimeMillis()+10000, this.getInternalName());
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(player.getLocation().getDirection().setY(1).multiply(1));
player.playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 1.0F, 2.0F);
}
else
{
player.setAllowFlight(false);
player.setFlying(false);
}
}
}
PlayerListener.java 文件源码
项目:BedwarsRel
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onFly(PlayerToggleFlightEvent tfe) {
Player p = tfe.getPlayer();
Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
if (g == null) {
return;
}
if (g.getState() == GameState.STOPPED) {
return;
}
if (g.getState() == GameState.RUNNING && g.isSpectator(p)) {
tfe.setCancelled(false);
return;
}
tfe.setCancelled(true);
}
AIOPlugin.java 文件源码
项目:AIOJetpacks
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent e)
{
this.getJetpackManager().checkJetpackItemForPlayer(e.getPlayer());
JetpackItem item = this.getJetpackManager().getJetpackItemForPlayer(e.getPlayer());
if (item != null)
{
if (item.isEnabled())
{
item.setEnabled(false);
}
else
{
item.setEnabled(true);
}
e.setCancelled(true);
}
}
EQCListener.java 文件源码
项目:Bukkit-EQC
阅读 31
收藏 0
点赞 0
评论 0
@EventHandler()
public void flightToggle(PlayerToggleFlightEvent ev) {
Player p = ev.getPlayer();
UUID key = p.getUniqueId();
//copy pasta!
if (isFlying.contains(key)) {
//stop flight and restore state
p.setFlying(false);
p.setAllowFlight(wasAllowedFlying.contains(key));
if (wasAllowedFlying.contains(key)) {
wasAllowedFlying.remove(key);
}
isFlying.remove(key);
}
}
NetHandlerPlayServer.java 文件源码
项目:Cauldron
阅读 24
收藏 0
点赞 0
评论 0
public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_)
{
// CraftBukkit start - d() should be isFlying()
if (this.playerEntity.capabilities.allowFlying && this.playerEntity.capabilities.isFlying != p_147348_1_.func_149488_d())
{
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.playerEntity), p_147348_1_.func_149488_d());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled())
{
this.playerEntity.capabilities.isFlying = p_147348_1_.func_149488_d(); // Actually set the player's flying status
}
else
{
this.playerEntity.sendPlayerAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
DoubleJump4NCPPlugin.java 文件源码
项目:DoubleJump4NCP
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onToggleFlight(PlayerToggleFlightEvent event) {
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || !event.getPlayer().hasPermission("doublejump") || event.getPlayer().hasMetadata("DJ_OFF"))
return;
PlayerDoubleJumpEvent pdje = new PlayerDoubleJumpEvent(event.getPlayer(), power);
getServer().getPluginManager().callEvent(pdje);
if (pdje.isCancelled()) return;
if (ncp != null) {
ncp.allowDoubleJump(event.getPlayer());
}
event.getPlayer().setAllowFlight(false);
event.getPlayer().setFlying(false);
event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection()
.multiply(2 * pdje.getPower())
.setY(1 * pdje.getPower()));
event.setCancelled(true);
}
DoubleJumpKit.java 文件源码
项目:CardinalPGM
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerToggleFly(PlayerToggleFlightEvent event) {
if (!enabled) return;
Player player = event.getPlayer();
if (!players.contains(player.getUniqueId()) || player.getExp() > 1.0f || !event.isFlying()) return;
player.setAllowFlight(false);
player.setExp(0.0f);
event.setCancelled(true);
Vector normal = player.getEyeLocation().getDirection();
normal.setY(0.75 + Math.max(normal.getY() * 0.5, 0));
normal.multiply(power / 2);
event.getPlayer().setVelocity(normal);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
update();
}
Tutorial.java 文件源码
项目:SamaGamesAPI
阅读 32
收藏 0
点赞 0
评论 0
@EventHandler
public void onToToggleFlight(PlayerToggleFlightEvent ev)
{
if(isWatchingTutorial(ev.getPlayer().getUniqueId()))
{
ev.setCancelled(true);
ev.getPlayer().setFlying(true);
}
}
MovementListener.java 文件源码
项目:DynamicAC
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
@SuppressWarnings("all") //sick of intellij giving me unused warnings
public void onFlyDisable(PlayerToggleFlightEvent e) {
if(e.isFlying()) return;
try {
Flight.setMovingExempt(e.getPlayer(), this.getClass(),2000);
} catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
DoubleJumpFeature.java 文件源码
项目:VoxelGamesLibv2
阅读 23
收藏 0
点赞 0
评论 0
@GameEvent
public void e(@Nonnull PlayerToggleFlightEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE) {
if (!disabled.contains(player.getUniqueId())) {
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(player.getLocation().getDirection().multiply(1.6).setY(1));
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 4, 1);
}
}
}
PlayerConnection.java 文件源码
项目:CraftBukkit
阅读 29
收藏 0
点赞 0
评论 0
public void a(PacketPlayInAbilities packetplayinabilities) {
// CraftBukkit start
if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status
} else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
EventHub.java 文件源码
项目:gFeatures
阅读 19
收藏 0
点赞 0
评论 0
public void onPlayerToggleFlight(PlayerToggleFlightEvent event){
Player player = event.getPlayer();
if ((player.getGameMode() != GameMode.CREATIVE))
{
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(st.giveVector(player.getLocation()).multiply(3));
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0F, -5.0F);
}
}
DoubleJumpPlugin.java 文件源码
项目:spigot-double-jump
阅读 19
收藏 0
点赞 0
评论 0
/**
* Handles player flight.
* @param event The event.
*/
@EventHandler (priority = EventPriority.HIGH)
public void onPlayerToggleFlight (PlayerToggleFlightEvent event) {
if (event.getPlayer ().getGameMode () == GameMode.CREATIVE || event.getPlayer ().getGameMode () == GameMode.SPECTATOR) return;
event.setCancelled (true);
event.getPlayer ().setAllowFlight (false);
event.getPlayer ().setVelocity (event.getPlayer ().getLocation ().getDirection ().multiply (1.6d).setY (1.0d));
}
AntiWorldFlyToggleFly.java 文件源码
项目:AntiWorldFly
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerCommandPreprocessEvent(PlayerToggleFlightEvent event) {
if (plugin.isDisabled() || event.getPlayer().hasPermission("antiworldfly.fly")) {
return;
}
if (!this.plugin.isAntiFlyCreative() && event.getPlayer().getGameMode() == GameMode.CREATIVE
|| "SPECTATOR".equals(event.getPlayer().getGameMode().toString())) {
return;
}
Player player = event.getPlayer();
for (String world : plugin.getAntiFlyWorlds()) {
if (event.getPlayer().getWorld().getName().equalsIgnoreCase(world)) {
// Disable flying.
player.setAllowFlight(false);
player.getPlayer().setFlying(false);
event.setCancelled(true);
if (plugin.isChatMessage()) {
player.sendMessage(plugin.getChatHeader() + plugin.getPluginLang().getString("fly-disabled-chat",
"Flying is disabled in this world."));
}
if (plugin.isTitleMessage()) {
try {
PacketSender.sendTitlePacket(player, "{\"text\":\""
+ plugin.getPluginLang().getString("fly-disabled-title", "&9AntiWorldFly") + "\"}",
"{\"text\":\"" + plugin.getPluginLang().getString("fly-disabled-subtitle",
"Flying is disabled in this world.") + "\"}");
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE, "Errors while trying to display flying disabled title: ",
e);
}
}
break;
}
}
}
PlayerConnection.java 文件源码
项目:Almura-Server
阅读 27
收藏 0
点赞 0
评论 0
public void a(Packet202Abilities packet202abilities) {
// CraftBukkit start
if (this.player.abilities.canFly && this.player.abilities.isFlying != packet202abilities.f()) {
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packet202abilities.f());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packet202abilities.f(); // Actually set the player's flying status
}
else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
PlayerConnection.java 文件源码
项目:Tweakkit-Server
阅读 29
收藏 0
点赞 0
评论 0
public void a(PacketPlayInAbilities packetplayinabilities) {
// CraftBukkit start
if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status
} else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
DoubleJump.java 文件源码
项目:TheSurvivalGames
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
if ((player.getGameMode() != GameMode.CREATIVE)) {
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(player.getLocation().getDirection().multiply(1.6D).setY(1.0D));
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.0F, -10.0F);
}
}
FreezeComponent.java 文件源码
项目:CraftoPlugin
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void onFlightToggle(final PlayerToggleFlightEvent event) {
if (!this.frozenPlayers.isEmpty() && !event.isCancelled() && this.frozenPlayers.containsKey(event.getPlayer().getUniqueId())) {
if (!event.isFlying()) {
event.setCancelled(true);
final Location3w location = this.frozenPlayers.get(event.getPlayer().getUniqueId());
location.setYaw(event.getPlayer().getLocation().getYaw());
location.setPitch(event.getPlayer().getLocation().getPitch());
event.getPlayer().teleport(location);
}
}
}
PlayerConnection.java 文件源码
项目:SpigotSource
阅读 23
收藏 0
点赞 0
评论 0
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
// CraftBukkit start
if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status
} else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
DoubleJumpEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void onJump(PlayerToggleFlightEvent e) {
if(e.getPlayer().getGameMode() == GameMode.CREATIVE) {
return;
}
XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
if(xp.hasDoubleJump()) {
e.setCancelled(true);
e.getPlayer().setAllowFlight(false);
e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().add(new Vector(0, 3, 0)).normalize());
}
}
GenericListener.java 文件源码
项目:SimpleJail
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
{
if (!event.getPlayer().isFlying())
{
if (context.getJailedPlayers().contains(event.getPlayer().getName()))
{
event.setCancelled(true);
}
}
}
PlayerConnection.java 文件源码
项目:Craft-city
阅读 28
收藏 0
点赞 0
评论 0
public void a(Packet202Abilities packet202abilities) {
// CraftBukkit start
if (this.player.abilities.canFly && this.player.abilities.isFlying != packet202abilities.f()) {
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packet202abilities.f());
this.server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.player.abilities.isFlying = packet202abilities.f(); // Actually set the player's flying status
}
else {
this.player.updateAbilities(); // Tell the player their ability was reverted
}
}
// CraftBukkit end
}
PlayerToggleFly.java 文件源码
项目:SuperSkyBros
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
public void toggleFly(PlayerToggleFlightEvent e) {
long now = System.currentTimeMillis();
if (this.blackWorlds.contains(e.getPlayer().getName())) return;
PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(e.getPlayer().getPlayer(), false);
Bukkit.getServer().getPluginManager().callEvent(event);
/* if (!VaultManager.getInstance().perms.has(e.getPlayer(), "scb.mario.use") && (!VaultManager.getInstance().perms.has(e.getPlayer(), "scb.mario.triple")))
return;
*/
Player p = e.getPlayer();
Vector jump;
Vector look;
if (p.isSprinting()) {
p.setNoDamageTicks(160);
jump = p.getVelocity().multiply(1.2D).setY(2.0D);
look = p.getLocation().getDirection().multiply(0.6D);
p.playSound(p.getLocation(), Sound.EXPLODE, 1.0F, -5.0F);
} else {
p.setNoDamageTicks(140);
jump = p.getVelocity().multiply(1.8D).setY(1.6D);
look = p.getLocation().getDirection().multiply(0.7D);
p.playSound(p.getLocation(), Sound.HORSE_ZOMBIE_HIT, 1.0F, 5.0F);
}
if ((e.isFlying()) && (p.getGameMode() != GameMode.CREATIVE)) {
p.setFlying(false);
p.setAllowFlight(false);
jump.add(look);
p.setVelocity(jump);
}
}
SpectatorListener.java 文件源码
项目:Arcadia-Spigot
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
if(!Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().isAlive(event.getPlayer())) {
event.setCancelled(true);
}
}
IsFlying.java 文件源码
项目:ConditionalPerms
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void setup(TerminableConsumer consumer) {
Events.subscribe(PlayerToggleFlightEvent.class)
.handler(e -> getPlugin().refreshPlayer(e.getPlayer(), 1L))
.bindWith(consumer);
}