本文整理汇总了Java中org.bukkit.event.player.PlayerToggleFlightEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerToggleFlightEvent.setCancelled方法的具体用法?Java PlayerToggleFlightEvent.setCancelled怎么用?Java PlayerToggleFlightEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerToggleFlightEvent
的用法示例。
在下文中一共展示了PlayerToggleFlightEvent.setCancelled方法的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: 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);
}
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例6: 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);
}
示例7: 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);
}
}
示例8: 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);
}
示例9: 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();
}
示例10: 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);
}
}
示例11: 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);
}
}
}
示例12: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
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);
}
}
示例13: onPlayerToggleFlight
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
/**
* 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));
}
示例14: onPlayerCommandPreprocessEvent
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
@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;
}
}
}
示例15: onFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
@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);
}
}