当前位置: 首页>>代码示例>>Java>>正文


Java Player.setVelocity方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.setVelocity方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setVelocity方法的具体用法?Java Player.setVelocity怎么用?Java Player.setVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.setVelocity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        Vector vector = new Vector(0, 1, 0);
        vector.multiply(-0.10000000000000001D);
        p.setVelocity(vector);
        p.setFallDistance(0.0F);
        if(!p.isSneaking())
            Bukkit.getScheduler().cancelTask(id);
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:23,代码来源:ParachuteTask.java

示例2: onMove

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent e){
    Player p = e.getPlayer();
    WCUser user = WCSurvival.getPlayer(p);
    Block launch = p.getWorld().getBlockAt(p.getLocation()).getRelative(BlockFace.DOWN);
    Block base = launch.getRelative(BlockFace.DOWN);

    if (!e.getFrom().equals(e.getTo())){
        if (WCServer.afkMode.contains(user)) user.toggleAFK();
    }

    if(launch.getType() == Material.SPONGE && base.getType() == Material.DIAMOND_BLOCK){
        p.setVelocity(p.getLocation().getDirection().multiply(3));
        p.setVelocity(new Vector(p.getVelocity().getX(), 1.0D, p.getVelocity().getZ()));
        WCServer.getUser(p).sendSound(Sound.ENTITY_IRONGOLEM_ATTACK);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:18,代码来源:PlayerEvent.java

示例3: onFly

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
    if (this.controller.getGameFromPlayer(event.getPlayer()) != null) {
        final Game game = this.controller.getGameFromPlayer(event.getPlayer());
        final Player player = event.getPlayer();
        if ((player.getGameMode() != GameMode.CREATIVE)) {
            event.setCancelled(true);
            player.setAllowFlight(false);
            player.setFlying(false);
            if (game.getArena().getTeamMeta().isAllowDoubleJump()) {
                player.setVelocity(player.getLocation().getDirection()
                        .multiply(game.getArena().getTeamMeta().getDoubleJumpMeta().getHorizontalStrength())
                        .setY(game.getArena().getTeamMeta().getDoubleJumpMeta().getVerticalStrength()));
                try {
                    game.getArena().getTeamMeta().getDoubleJumpSound().play(player.getLocation());
                } catch (final InterPreter19Exception e) {
                    Bukkit.getServer().getConsoleSender().sendMessage(BlockBallPlugin.PREFIX_CONSOLE + ChatColor.RED + "Invalid 1.8/1.9 sound. [DoubleJumpSound]");
                }
                game.getArena().getTeamMeta().getDoubleJumpParticle().play(player.getLocation());
            }
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:24,代码来源:GameListener.java

示例4: playerForcefield

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void playerForcefield() {
    this.bumeper--;
    if (this.bumeper <= 0) {
        this.bumeper = 40;
        for (final Player player : this.getPlayers()) {
            if (!this.arena.isLocationInArea(player.getLocation()) && !SChatMenuManager.getInstance().isUsing(player)) {
                if (!this.bumpers.containsKey(player))
                    this.bumpers.put(player, 0);
                else
                    this.bumpers.put(player, this.bumpers.get(player) + 1);
                final Vector knockback = this.arena.getBallSpawnLocation().toVector().subtract(player.getLocation().toVector());
                player.getLocation().setDirection(knockback);
                player.setVelocity(knockback);
                final Vector direction = this.arena.getBallSpawnLocation().toVector().subtract(player.getLocation().toVector());
                player.setVelocity(direction.multiply(0.1));
                if (this.bumpers.get(player) == 5) {
                    player.teleport(this.arena.getBallSpawnLocation());
                }
            } else if (this.bumpers.containsKey(player)) {
                this.bumpers.remove(player);
            }
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:25,代码来源:HelperGameEntity.java

示例5: playerForcefield

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void playerForcefield() {
    if (this.innerForcefield) {
        this.bumeper--;
        if (this.bumeper <= 0) {
            this.bumeper = 40;
            for (final Player player : this.getPlayers()) {
                if (!this.arena.isLocationInArea(player.getLocation())) {
                    if (!this.bumpers.containsKey(player))
                        this.bumpers.put(player, 0);
                    else
                        this.bumpers.put(player, this.bumpers.get(player) + 1);
                    final Vector knockback = this.arena.getBallSpawnLocation().toVector().subtract(player.getLocation().toVector());
                    player.getLocation().setDirection(knockback);
                    player.setVelocity(knockback);
                    final Vector direction = this.arena.getBallSpawnLocation().toVector().subtract(player.getLocation().toVector());
                    player.setVelocity(direction.multiply(0.1));
                    if (this.bumpers.get(player) == 5) {
                        player.teleport(this.arena.getBallSpawnLocation());
                    }
                } else if (this.bumpers.containsKey(player)) {
                    this.bumpers.remove(player);
                }
            }
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:27,代码来源:EventGameEntity.java

示例6: onPlayerJump

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJump(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Vector velocity = player.getVelocity();
    Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);

    if (jumpModifier.getBonus() == 0 && jumpModifier.getMultiplier() == 1) {
        return;
    }

    // === START: Magic constants ===
    if (velocity.getY() == 0.41999998688697815D) {
        double jump = (1.5 + Math.sqrt(jumpModifier.getBonus())) * jumpModifier.getMultiplier();
        Vector moveDirection = event.getTo().toVector().subtract(event.getFrom().toVector());
        velocity.setX(moveDirection.getX() * jump * player.getWalkSpeed());
        velocity.setY(velocity.getY() * jump / 1.5);
        velocity.setZ(moveDirection.getZ() * jump * player.getWalkSpeed());
        player.setVelocity(velocity);
    }
    // === END: Magic constants ===
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:27,代码来源:ItemListener.java

示例7: onBlockBreak

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockPlaceEvent event) {
    if (event.isCancelled()) {
        Player player = event.getPlayer();
        if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
            return;
        }

        Block block = event.getBlockPlaced();
        if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
            int playerY = player.getLocation().getBlockY();
            int blockY = block.getLocation().getBlockY();
            if (playerY > blockY) {
                Vector vector = player.getVelocity();
                vector.setX(-0.1);
                vector.setZ(-0.1);
                player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:BlockJumpGlitchFixListener.java

示例8: castSpell

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void castSpell(final LivingEntity caster, final MobData md, Player target) {
    Vector v = caster.getLocation().toVector();
    for (Entity e : RMath.getNearbyEntities(caster.getLocation(), range)) {
        if (e instanceof Player) {
            Player p = (Player) e;
            if (p != null && p.isOnline()) {
                if (Spell.canDamage(p, false)) {
                    Vector pullVector = p.getLocation().toVector().subtract(v).normalize().multiply(-1.8);
                    pullVector.setY(pullVector.getY() + 0.35);
                    p.setVelocity(pullVector);
                }
            }
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:16,代码来源:GravitySpell.java

示例9: claimPoint

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void claimPoint(Player player, Location location) {
    if(!this.currentLocations.containsKey(location)) return;
    final PointType pointType = (PointType) this.currentLocations.get(location)[0];
    final FallingBlock entity = (FallingBlock) this.currentLocations.get(location)[1];
    this.currentLocations.remove(location);
    entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1f, 1f);
    player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1.1f);
    entity.remove();
    ScoreSidebar scoreSidebar = ((ScoreSidebar) this.getSidebar());
    scoreSidebar.setScore(player, (scoreSidebar.getScore(player) + pointType.getPoints()));
    if(pointType == PointType.SUPER_BOOST) {
        player.setVelocity(new org.bukkit.util.Vector(0, 1.7D, 0));
    }
    this.spawnPoint();
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:16,代码来源:TrampolinioGame.java

示例10: onGameTick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onGameTick(GameTickEvent event) {
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.setVelocity(player.getLocation().getDirection().normalize().multiply(0.5D).setY(-1D));
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:8,代码来源:DeadEndGame.java

示例11: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.075F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getBoots());
        double accuracy = Double.valueOf((new DecimalFormat("##.##")).format(speed - 0.69999999999999996D).replace(",", ".")).doubleValue();
        if(charge >= cost)
        {
            p.getInventory().setBoots(ItemEnergy.chargeItem(p.getInventory().getBoots(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            double gravity = 0.040000000000000001D;
            double offset = SlimefunStartup.chance(100, 50) ? accuracy : -accuracy;
            Vector vector = new Vector(p.getEyeLocation().getDirection().getX() * speed + offset, gravity, p.getEyeLocation().getDirection().getZ() * speed - offset);
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:35,代码来源:JetBootsTask.java

示例12: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.08F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getChestplate());
        if(charge >= cost)
        {
            p.getInventory().setChestplate(ItemEnergy.chargeItem(p.getInventory().getChestplate(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            Vector vector = new Vector(0, 1, 0);
            vector.multiply(thrust);
            vector.add(p.getEyeLocation().getDirection().multiply(0.2F));
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:34,代码来源:JetpackTask.java

示例13: e

import org.bukkit.entity.Player; //导入方法依赖的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);
        }
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:14,代码来源:DoubleJumpFeature.java

示例14: reset

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void reset(Player player) {
	Bukkit.getOnlinePlayers().stream().filter(other -> other != player).forEach(other -> other.hidePlayer(player));
	player.setGameMode(GameMode.CREATIVE);
       player.setHealth(20.0);
       player.setFoodLevel(20);
       player.getActivePotionEffects().forEach(potionEffect -> player.removePotionEffect(potionEffect.getType()));
       player.setAllowFlight(true);
       player.setFlying(true);
       player.setVelocity(player.getVelocity().setY(1.1));
       player.getInventory().clear();
       player.getInventory().setArmorContents(null);
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:13,代码来源:PlayerDeathListener.java

示例15: cast

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    int damage = pd.getDamage(true);
    switch (level) {
        case 1:
            damage *= 1.5;
            break;
        case 2:
            damage *= 1.75;
            break;
        case 3:
            damage *= 2.0;
            break;
        case 4:
            damage *= 2.25;
            break;
        case 5:
            damage *= 2.5;
            break;
        case 6:
            damage *= 2.75;
            break;
        case 7:
            damage *= 3.0;
            break;
        case 8:
            damage *= 3.25;
            break;
        case 9:
            damage *= 3.5;
            break;
        case 10:
            damage *= 3.75;
            break;
    }
    final int fDamage = damage;
    p.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(2).setY(0).add(new Vector(0, 0.5, 0)));
    RScheduler.schedule(Spell.plugin, new Runnable() {
        public void run() {
            ArrayList<Entity> hit = new ArrayList<Entity>();
            Spell.damageNearby(fDamage, p, p.getLocation(), 3.0, hit);
            RParticles.showWithOffset(ParticleEffect.EXPLOSION_LARGE, p.getLocation(), 3.0, 30);
        }
    }, RTicks.seconds(0.7));
    Spell.notify(p, "Woosh!");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:48,代码来源:Leap.java


注:本文中的org.bukkit.entity.Player.setVelocity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。