當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。