本文整理汇总了Java中org.bukkit.event.player.PlayerToggleFlightEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerToggleFlightEvent类的具体用法?Java PlayerToggleFlightEvent怎么用?Java PlayerToggleFlightEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerToggleFlightEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerToggleFlightEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
示例2: toggleGlideEvent
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
/**
* 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();
});
}
}
示例3: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
}
示例4: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
示例5: onPlayerToggleFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
/**
* 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);
}
}
示例6: AcrobatDoubleJump
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
}
}
示例7: onFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
示例8: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
}
示例9: flightToggle
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
}
示例10: processPlayerAbilities
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
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
}
示例11: onToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
示例12: onPlayerToggleFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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();
}
示例13: onToToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@EventHandler
public void onToToggleFlight(PlayerToggleFlightEvent ev)
{
if(isWatchingTutorial(ev.getPlayer().getUniqueId()))
{
ev.setCancelled(true);
ev.getPlayer().setFlying(true);
}
}
示例14: onFlyDisable
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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();
}
}
示例15: e
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入依赖的package包/类
@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);
}
}
}