本文整理汇总了Java中org.bukkit.event.player.PlayerToggleFlightEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerToggleFlightEvent.getPlayer方法的具体用法?Java PlayerToggleFlightEvent.getPlayer怎么用?Java PlayerToggleFlightEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerToggleFlightEvent
的用法示例。
在下文中一共展示了PlayerToggleFlightEvent.getPlayer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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);
}
}
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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();
}
示例9: 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);
}
}
}
示例10: 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);
}
}
示例11: 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;
}
}
}
示例12: 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);
}
}
示例13: toggleFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
@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);
}
}
示例14: onFly
import org.bukkit.event.player.PlayerToggleFlightEvent; //导入方法依赖的package包/类
@EventHandler
public void onFly(PlayerToggleFlightEvent e) {
final Player p = e.getPlayer();
Arena arena = plugin.amanager.getPlayerArena(p.getName());
if (p.getGameMode() != GameMode.CREATIVE) {
if(arena != null){
if(arena.getPlayersManager().isSpectator(p.getName())){
e.setCancelled(false);
p.setFlying(true);
return;
}
if(!arena.getStatusManager().isArenaRunning()){
e.setCancelled(true);
return;
}
if(u.contains(p)){
e.setCancelled(true);
return;
}
if(plugin.getConfig().get("doublejumps." + p.getName()) == null || plugin.getConfig().getInt("doublejumps." + p.getName()) == 0){
e.setCancelled(true);
p.setAllowFlight(false);
plugin.getConfig().set("doublejumps." + p.getName(), null);
plugin.saveConfig();
return;
}else{
plugin.getConfig().set("doublejumps." + p.getName(), plugin.getConfig().getInt("doublejumps." + p.getName()) - 1);
}
e.setCancelled(true);
p.setFlying(false);
p.setVelocity(p.getLocation().getDirection().multiply(1.5D).setY(0.7D));
TNTRun.getInstance().sound.NOTE_PLING(p, 5, 999);
plugin.saveConfig();
u.add(p);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){
public void run(){
u.remove(p);
p.setAllowFlight(true);
}
}, 20);
}else{
if(p.hasPermission("tntrun.fly.everywhere")){
p.setFlying(true);
p.setAllowFlight(true);
}else{
p.setAllowFlight(false);
p.setFlying(false);
e.setCancelled(true);
}
}
}else{
p.setAllowFlight(true);
}
}