@EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerMove(PlayerMoveEvent event) {
   BlockPlatform platform = windwalkers.get(event.getPlayer().getName());
   if (platform != null) {
     Player player = event.getPlayer();
     if (isExpired(player)) {
       turnOff(player);
     } else {
       if (falling.contains(player)) {
         if (event.getTo().getY() < event.getFrom().getY()) {
           falling.remove(player);
         } else {
           return;
         }
       }
       if (!player.isSneaking()) {
         Block block = event.getTo().subtract(0, 1, 0).getBlock();
         boolean moved = platform.isMoved(block, false);
         if (moved) {
           platform.movePlatform(block, true);
           addUse(player);
           chargeUseCost(player);
         }
       }
     }
   }
 }
 public static void global_no_mana_damaged(
     Player pl, final Plugin plugin, final EntityDamageByEntityEvent event) {
   event.setDamage(event.getDamage() * 2D);
   if (pl.isSneaking()) {
     pl.sendMessage(THRPlugin.thrpre + ChatColor.RED + pl.getName() + "貴方は霊力再生モードの為非常に柔いです!");
   }
 }
Example #3
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent e) {
   Player p = e.getPlayer();
   Block b = e.getBlock();
   if (p.getGameMode() == GameMode.CREATIVE) {
     if (b.getType() == Material.SKULL) {
       Skull skull = (Skull) e.getBlock().getState();
       String name = this.hasOwner(skull) ? skull.getOwner() : this.def;
       if (!this.hasTool(p)) {
         if (p.isSneaking()) {
           if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
             if (p.hasPermission(perm) || p.isOp()) {
               p.sendMessage(this.des.replace("#", name));
               // Disable skull?
             } else {
               e.setCancelled(true);
               p.sendMessage(this.noperm);
             }
           }
         } else if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           this.sw.getActionWorker().executeQuery(p, name);
           if (p.hasPermission(perm)) {
             e.setCancelled(true);
             p.sendMessage(RED + "To destroy skull you must sneak and break");
           } else {
             e.setCancelled(true);
             p.sendMessage(this.noperm);
           }
         }
       } else if (p.isSneaking()) {
         e.setCancelled(true);
         this.sw.getActionWorker().executeQuery(p.getPlayer(), name);
       } else {
         e.setCancelled(true);
         ItemStack s = p.getItemInHand();
         this.onBlockDamage(new BlockDamageEvent(p, b, s, false));
         if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           p.sendMessage(RED + "Block selected is already a part of a skull wall");
           p.sendMessage(RED + "Overlapping walls will not perform as expected!");
         }
       }
     }
   } else if (this.sw.getConfiguration().isProtecting()
       && e.getBlock().getType() == Material.SKULL
       && !p.hasPermission(perm))
     e.setCancelled(SkullWalls.getWallHandler().hasPermission(b, p, this.noperm));
 }
Example #4
0
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player && hasAbility((Player) event.getDamager())) {
     Player p = (Player) event.getDamager();
     if (p.isSneaking() && (!needToBlock || p.isBlocking())) {
       event.setCancelled(true);
     }
   }
 }
Example #5
0
 @Override
 public void on(PlayerInteractEvent e) {
   Player p = e.getPlayer();
   if (p.isSneaking()) {
     IPromptString.prompt(p, this, null, InterfacesPlugin.INSTANCE);
   } else {
     IPromptYN.prompt(p, this, null, InterfacesPlugin.INSTANCE);
   }
 }
 /**
  * Checks if the player is on ice.
  *
  * @return true, if the player is on ice
  */
 public boolean isOnIce() {
   if (onIce == null) {
     final org.bukkit.entity.Player entity = this.entityPlayer.getBukkitEntity();
     if (entity.isSneaking() || entity.isBlocking())
       onIce = getTypeId(blockX, Location.locToBlock(minY - 0.1D), blockZ) == Material.ICE.getId();
     else onIce = getTypeIdBelow().intValue() == Material.ICE.getId();
   }
   return onIce;
 }
 @Override
 public Object getArgument(Object obj[], SpellInformationObject so) {
   if (obj.length == 1 && obj[0] instanceof Player[] && ((Player[]) obj[0]).length > 0) {
     Player p = ((Player[]) obj[0])[0];
     if (p != null) {
       return p.isSneaking();
     }
   }
   return false;
 }
Example #8
0
 @EventHandler
 public void onDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player && hasAbility((Player) event.getEntity())) {
     Player p = (Player) event.getEntity();
     if (p.isSneaking() && (!needToBlock || p.isBlocking()) && p.getHealth() > 1) {
       event.setCancelled(true);
       p.damage(0);
       p.setHealth(p.getHealth() - 1);
     }
   }
 }
 @Override
 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.1);
     p.setVelocity(vector);
     p.setFallDistance(0.0f);
     if (!p.isSneaking()) Bukkit.getScheduler().cancelTask(id);
   }
 }
Example #10
0
  public void processAbilityActivation(SkillType skill) {
    if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
      return;
    }

    ItemStack inHand = player.getItemInHand();

    if (mcMMO.getModManager().isCustomTool(inHand)
        && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
      return;
    }

    if (!getAbilityUse()) {
      return;
    }

    for (AbilityType abilityType : AbilityType.values()) {
      if (getAbilityMode(abilityType)) {
        return;
      }
    }

    AbilityType ability = skill.getAbility();
    ToolType tool = skill.getTool();

    /*
     * Woodcutting & Axes need to be treated differently.
     * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
     */
    if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
      if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
        int timeRemaining = calculateTimeRemaining(ability);

        if (!getAbilityMode(ability) && timeRemaining > 0) {
          player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
          return;
        }
      }

      if (Config.getInstance().getAbilityMessagesEnabled()) {
        player.sendMessage(tool.getRaiseTool());
      }

      setToolPreparationMode(tool, true);
      new ToolLowerTask(this, tool)
          .runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onTraderTransaction(TraderTransactionEvent event) {
    if (!plugin.getDenizenNPCRegistry().isDenizenNPC(event.getNpc())) return;

    /* Shortcut to the ScriptHelper */
    //	ScriptHelper sE = plugin.getScriptEngine().helper;

    DenizenNPC theDenizen = plugin.getDenizenNPCRegistry().getDenizen(event.getNpc());
    Player player = (Player) event.getParticipant();

    /* Show NPC info if sneaking and right clicking */
    if (player.isSneaking()
        && player.isOp()
        && plugin.settings.RightClickAndSneakInfoModeEnabled()) {
      theDenizen.showInfo(player);
      return;
    }

    if (!theDenizen.hasTrigger(triggerName)) {
      if (plugin.debugMode)
        plugin.getLogger().log(Level.INFO, "...click trigger not enabled for this Denizen.");
      return;
    }

    // If Denizen is not interactable (ie. Denizen is toggled off, engaged or not cooled down)
    if (!theDenizen.isInteractable(triggerName, player)) {
      theDenizen.talk(TalkType.CHAT_PLAYERONLY, player, Reason.DenizenIsUnavailable);
      return;
    }

    if (!event.getResult().equals(TransactionResult.SUCCESS_BUY)) {
      if (plugin.debugMode) plugin.getLogger().log(Level.INFO, "...transaction not succeded.");
      return;
    }

    // Cool! Parse the Trigger...
    // Apply default cool-down to avoid click-spam, then send to parser. */
    //	sE.setCooldown(theDenizen, DenizenTriggerTransactionTrigger.class,
    // plugin.settings.DefaultClickCooldown());

    if (!parseClickTrigger(theDenizen, player, event.getItem())) {
      theDenizen.talk(TalkType.CHAT_PLAYERONLY, player, Reason.NoMatchingClickTrigger);
      return;
    }

    // Success!
  }
Example #12
0
  public boolean progress() {
    if (player.isDead() || !player.isOnline()) {
      remove();
      return false;
    }
    speedfactor = speed * (ProjectKorra.time_step / 1000.);
    if (!charging) {
      if (elements.isEmpty()) {
        remove();
        return false;
      }

      advanceSwipe();
    } else {
      if (GeneralMethods.getBoundAbility(player) == null) {
        remove();
        return false;
      }
      if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe")
          || !GeneralMethods.canBend(player.getName(), "AirSwipe")) {
        remove();
        return false;
      }

      if (!player.isSneaking()) {
        double factor = 1;
        if (System.currentTimeMillis() >= time + maxchargetime) {
          factor = maxfactor;
        } else if (AvatarState.isAvatarState(player)) {
          factor = AvatarState.getValue(factor);
        } else {
          factor =
              maxfactor * (double) (System.currentTimeMillis() - time) / (double) maxchargetime;
        }
        charging = false;
        launch();
        if (factor < 1) factor = 1;
        damage *= factor;
        pushfactor *= factor;
        return true;
      } else if (System.currentTimeMillis() >= time + maxchargetime) {
        AirMethods.playAirbendingParticles(player.getEyeLocation(), 3);
      }
    }
    return true;
  }
Example #13
0
 /**
  * Checks if the player is on ice.
  *
  * @return true, if the player is on ice
  */
 public boolean isOnIce() {
   if (onIce == null) {
     // TODO: Use a box here too ?
     // TODO: check if player is really sneaking (refactor from survivalfly to static access in
     // Combined ?)!
     if (blockFlags != null && (blockFlags.longValue() & BlockProperties.F_ICE) == 0) {
       // TODO: check onGroundMinY !?
       onIce = false;
     } else {
       final int id;
       if (player.isSneaking() || player.isBlocking()) {
         id = getTypeId(blockX, Location.locToBlock(minY - 0.1D), blockZ);
       } else {
         id = getTypeIdBelow().intValue();
       }
       onIce = BlockProperties.isIce(id);
     }
   }
   return onIce;
 }
Example #14
0
 /**
  * Simulates the gun being fired
  *
  * @param player Player that fired the gun
  */
 public void fire(final Player player) {
   loadedInClip--;
   SpoutGUI.getHudOf(player).updateHUD();
   lastFired = System.currentTimeMillis();
   if (!(player.isSneaking())) {
     player.setVelocity(player.getLocation().getDirection().multiply(-recoilBack));
     Location loc = player.getLocation();
     loc.setPitch(loc.getPitch() + -recoilVertical);
     loc.setYaw(loc.getYaw() + recoilHorizontal);
     player.teleport(loc);
   } else {
     player.setVelocity(player.getLocation().getDirection().multiply(-recoilBack / 2));
     Location loc = player.getLocation();
     loc.setPitch(loc.getPitch() + -recoilVertical / 2);
     loc.setYaw(loc.getYaw() + recoilHorizontal / 2);
     player.teleport(loc);
   }
   if (loadedInClip == 0) {
     if (autoReload) {
       reload(player);
     }
   }
 }
Example #15
0
 @EventHandler
 public final void PIE(final PlayerInteractEvent event) {
   if (event.getAction() != Action.RIGHT_CLICK_AIR
       && event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
   final Player player = event.getPlayer();
   if (!player.isSneaking()) return;
   final ItemStack item = event.getItem();
   if (item == null
       || item.getType()
           != Material.getMaterial(
               getConfig().getString("id").trim().toUpperCase().replace(' ', '_'))) return;
   final String name = getConfig().getString("name");
   if (!name.isEmpty()
       && (!item.hasItemMeta()
           || !item.getItemMeta().hasDisplayName()
           || !item.getItemMeta()
               .getDisplayName()
               .equals(ChatColor.translateAlternateColorCodes('&', name)))) return;
   final Item entity =
       player
           .getWorld()
           .dropItem(
               player.getEyeLocation().clone().subtract(0, 0.3, 0), new ItemStack(item.getType()));
   entity.setVelocity(
       player.getLocation().getDirection().normalize().multiply(getConfig().getDouble("speed")));
   entity.setMetadata("isminebomb", new FixedMetadataValue(this, player.getName()));
   if (getConfig().getBoolean("use")) {
     if (item.getAmount() == 1) player.setItemInHand(new ItemStack(Material.AIR));
     else {
       item.setAmount(item.getAmount() - 1);
       player.setItemInHand(item);
     }
   }
   new ExplodeTimer(entity, getConfig().getInt("power"))
       .runTaskLater(this, getConfig().getInt("delay") * 20L);
 }
  @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
  void onPlayerInteract(PlayerInteractEvent event) {
    Action action = event.getAction();
    Player player = event.getPlayer();
    Block clickedBlock = event.getClickedBlock();

    if (clickedBlock == null || player == null) {
      return;
    }

    if (clickedBlock.getType() == instance.config().alwaysOnMaterial
        || clickedBlock.getType() == instance.config().onlineOnlyMaterial) {
      if (action == Action.RIGHT_CLICK_BLOCK) {
        CChunkLoader chunkLoader =
            DataStoreManager.getDataStore()
                .getChunkLoaderAt(new BlockLocation(clickedBlock.getLocation()));
        if (player.getItemInHand().getType() == Material.BLAZE_ROD) {
          if (chunkLoader != null) {
            if (player.getUniqueId().equals(chunkLoader.getOwner())
                || player.hasPermission("betterchunkloader.edit")
                || (chunkLoader.isAdminChunkLoader()
                    && player.hasPermission("betterchunkloader.adminloader"))) {
              chunkLoader.showUI(player);
            } else {
              player.sendMessage(Messages.get("CantEditOthersChunkLoaders"));
            }
          } else {
            if (canBreak(clickedBlock, player)) {
              UUID uid = player.getUniqueId();
              if (clickedBlock.getType() == instance.config().alwaysOnMaterial) {
                if (!player.hasPermission("betterchunkloader.alwayson")) {
                  player.sendMessage(
                      Messages.get("NoPermissionToCreateAlwaysOnChunkLoaders")
                          + (player.isOp() ? " (betterchunkloader.alwayson is needed)" : ""));
                  return;
                }
                if (player.isSneaking() && player.hasPermission("betterchunkloader.adminloader")) {
                  uid = CChunkLoader.adminUUID;
                }
              } else if (clickedBlock.getType() == instance.config().onlineOnlyMaterial) {
                if (!player.hasPermission("betterchunkloader.onlineonly")) {
                  player.sendMessage(
                      Messages.get("NoPermissionToCreateOnlineOnlyChunkLoaders")
                          + (player.isOp() ? " (betterchunkloader.onlineonly is needed)" : ""));
                  return;
                }
              } else {
                return;
              }

              chunkLoader =
                  new CChunkLoader(
                      (int) (Math.floor(clickedBlock.getX() / 16.00)),
                      (int) (Math.floor(clickedBlock.getZ() / 16.00)),
                      clickedBlock.getWorld().getName(),
                      (byte) -1,
                      uid,
                      new BlockLocation(clickedBlock),
                      null,
                      clickedBlock.getType() == instance.config().alwaysOnMaterial);
              chunkLoader.showUI(player);
            } else {
              player.sendMessage(Messages.get("NoBuildPermission"));
            }
          }
        } else {
          if (chunkLoader != null) {
            player.sendMessage(chunkLoader.info());
            if (player.isSneaking()) {
              chunkLoader.showCorners(player);
            }
          } else {
            if (player.getItemInHand().getType() != instance.config().alwaysOnMaterial
                && player.getItemInHand().getType() != instance.config().onlineOnlyMaterial) {
              player.sendMessage(Messages.get("CanCreateChunkLoaders"));
            }
          }
        }
      }
    }
  }
Example #17
0
 /**
  * Output information specific to player-move events.
  *
  * @param player
  * @param from
  * @param to
  * @param mcAccess
  */
 public static void outputMoveDebug(
     final Player player,
     final PlayerLocation from,
     final PlayerLocation to,
     final double maxYOnGround,
     final MCAccess mcAccess) {
   final StringBuilder builder = new StringBuilder(250);
   final Location loc = player.getLocation();
   // TODO: Differentiate debug levels (needs setting up some policy + document in
   // BuildParamteres)?
   if (BuildParameters.debugLevel > 0) {
     builder.append("\n-------------- MOVE --------------\n");
     builder.append(player.getName() + " " + from.getWorld().getName() + ":\n");
     addMove(from, to, loc, builder);
   } else {
     builder.append(player.getName() + " " + from.getWorld().getName() + " ");
     addFormattedMove(from, to, loc, builder);
   }
   final double jump = mcAccess.getJumpAmplifier(player);
   final double speed = mcAccess.getFasterMovementAmplifier(player);
   final double strider = BridgeEnchant.getDepthStriderLevel(player);
   if (BuildParameters.debugLevel > 0) {
     try {
       // TODO: Check backwards compatibility (1.4.2). Remove try-catch
       builder.append(
           "\n(walkspeed=" + player.getWalkSpeed() + " flyspeed=" + player.getFlySpeed() + ")");
     } catch (Throwable t) {
     }
     if (player.isSprinting()) {
       builder.append("(sprinting)");
     }
     if (player.isSneaking()) {
       builder.append("(sneaking)");
     }
     if (player.isBlocking()) {
       builder.append("(blocking)");
     }
     final Vector v = player.getVelocity();
     if (v.lengthSquared() > 0.0) {
       builder.append("(svel=" + v.getX() + "," + v.getY() + "," + v.getZ() + ")");
     }
   }
   if (speed != Double.NEGATIVE_INFINITY) {
     builder.append("(e_speed=" + (speed + 1) + ")");
   }
   final double slow = PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.SLOW);
   if (slow != Double.NEGATIVE_INFINITY) {
     builder.append("(e_slow=" + (slow + 1) + ")");
   }
   if (jump != Double.NEGATIVE_INFINITY) {
     builder.append("(e_jump=" + (jump + 1) + ")");
   }
   if (strider != 0) {
     builder.append("(e_depth_strider=" + strider + ")");
   }
   // Print basic info first in order
   NCPAPIProvider.getNoCheatPlusAPI()
       .getLogManager()
       .debug(Streams.TRACE_FILE, builder.toString());
   // Extended info.
   if (BuildParameters.debugLevel > 0) {
     builder.setLength(0);
     // Note: the block flags are for normal on-ground checking, not with yOnGrond set to 0.5.
     from.collectBlockFlags(maxYOnGround);
     if (from.getBlockFlags() != 0)
       builder.append(
           "\nfrom flags: "
               + StringUtil.join(BlockProperties.getFlagNames(from.getBlockFlags()), "+"));
     if (from.getTypeId() != 0) addBlockInfo(builder, from, "\nfrom");
     if (from.getTypeIdBelow() != 0) addBlockBelowInfo(builder, from, "\nfrom");
     if (!from.isOnGround() && from.isOnGround(0.5)) builder.append(" (ground within 0.5)");
     to.collectBlockFlags(maxYOnGround);
     if (to.getBlockFlags() != 0)
       builder.append(
           "\nto flags: "
               + StringUtil.join(BlockProperties.getFlagNames(to.getBlockFlags()), "+"));
     if (to.getTypeId() != 0) addBlockInfo(builder, to, "\nto");
     if (to.getTypeIdBelow() != 0) addBlockBelowInfo(builder, to, "\nto");
     if (!to.isOnGround() && to.isOnGround(0.5)) builder.append(" (ground within 0.5)");
     NCPAPIProvider.getNoCheatPlusAPI()
         .getLogManager()
         .debug(Streams.TRACE_FILE, builder.toString());
   }
 }
Example #18
0
    protected void applyForce() {
      if (!isActive()) return;

      // Calculate speeds based on previous delta, to try to adjust for server lag
      float timeDeltaSeconds = (System.currentTimeMillis() - lastTick) / 1000.0f;
      Vector force = new Vector(0, gravity * timeDeltaSeconds, 0);

      float elevateMagnitude = (float) elevateRate * timeDeltaSeconds;
      float speedMinMagnitude = (float) minSpeed * timeDeltaSeconds;
      float speedMaxMagnitude = (float) maxSpeed * timeDeltaSeconds;

      Location playerLocation = player.getLocation();

      float pitch = playerLocation.getPitch();
      float yaw = playerLocation.getYaw();

      Vector scaledForce = force.clone();

      // scaled based on distance from target height
      /// this is the main levitate action
      int playerHeight = playerLocation.getBlockY();
      int heightDelta = targetHeight - playerHeight;
      if (heightDelta > 0) {
        int heightBoost = heightDelta > 16 ? 16 : heightDelta;
        scaledForce.multiply(heightBoost);
      } else if (heightDelta < 0) {
        scaledForce.setY(0);
      }

      // Trying out a suggestion, in a hacky way- adjust pitch so that "level" is really looking
      // down a bit
      pitch += 15;

      // Adjust target height based on aim
      Vector aim =
          new Vector(
              (0 - Math.sin(Math.toRadians(yaw))),
              (0 - Math.sin(Math.toRadians(pitch))),
              Math.cos(Math.toRadians(yaw)));
      aim.normalize();

      // only ascend if aiming mostly up, and if near the target
      if (heightDelta < 5 && pitch < -45) {
        hoverHeight += (elevateMagnitude * aim.getY());

        // We'll let the player go up higher than max height.
        if (hoverHeight > 255) hoverHeight = 255;
        if (hoverHeight < defaultHoverHeight) hoverHeight = defaultHoverHeight;
        updateTargetHeight();
      }

      // Periodically poll for ground level changes
      if (checkCounter++ > checkFrequency) {
        checkForGround();
      }

      // Steer- faster at higher altitudes, and scaled based on angle away from center (look up or
      // down to stop)
      float multiplier = speedMinMagnitude;
      if (!player.isSneaking()) {
        int heightFactor =
            hoverHeight > maxSpeedAtElevation ? maxSpeedAtElevation : (int) hoverHeight;
        multiplier *= (float) speedMaxMagnitude * heightFactor / maxSpeedAtElevation;
      }
      float verticalMultipler = 1.0f - (float) Math.abs(aim.getY());
      aim.multiply(multiplier * verticalMultipler);
      aim.setY(0);
      scaledForce.add(aim);

      // Logger.getLogger("Minecraft").info("Applying force: (" + scaledForce.getX() + ", " +
      // scaledForce.getY() + ", "+ scaledForce.getZ() + ")");
      player.setVelocity(scaledForce);

      this.lastTick = System.currentTimeMillis();
    }
Example #19
0
  /**
   * Monitor PlayerInteract events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Action action = event.getAction();
    Block block = event.getClickedBlock();
    ItemStack inHand = player.getItemInHand();
    Material material;

    /* Fix for NPE on interacting with air */
    if (block == null) {
      material = Material.AIR;
    } else {
      material = block.getType();
    }

    switch (action) {
      case RIGHT_CLICK_BLOCK:

        /* REPAIR CHECKS */
        if (Permissions.getInstance().repair(player)
            && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
          if (mcMMO.repairManager.isRepairable(inHand)) {
            mcMMO.repairManager.handleRepair(player, inHand);
            event.setCancelled(true);
            player.updateInventory();
          }
        }

        /* ACTIVATION CHECKS */
        if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
          if (!material.equals(Material.DIRT)
              && !material.equals(Material.GRASS)
              && !material.equals(Material.SOIL)) {
            Skills.activationCheck(player, SkillType.HERBALISM);
          }

          Skills.activationCheck(player, SkillType.AXES);
          Skills.activationCheck(player, SkillType.EXCAVATION);
          Skills.activationCheck(player, SkillType.MINING);
          Skills.activationCheck(player, SkillType.SWORDS);
          Skills.activationCheck(player, SkillType.UNARMED);
          Skills.activationCheck(player, SkillType.WOODCUTTING);
        }

        /* GREEN THUMB CHECK */
        if (inHand.getType().equals(Material.SEEDS)
            && BlockChecks.makeMossy(block)
            && Permissions.getInstance().greenThumbBlocks(player)) {
          Herbalism.greenThumbBlocks(inHand, player, block);
        }

        /* ITEM CHECKS */
        if (BlockChecks.abilityBlockCheck(block)) {
          Item.itemChecks(player);
        }

        /* BLAST MINING CHECK */
        if (player.isSneaking()
            && inHand.getTypeId() == Config.getInstance().getDetonatorItemID()
            && Permissions.getInstance().blastMining(player)) {
          BlastMining.detonate(event, player, plugin);
        }

        break;

      case RIGHT_CLICK_AIR:

        /* ACTIVATION CHECKS */
        if (Config.getInstance().getAbilitiesEnabled()) {
          Skills.activationCheck(player, SkillType.AXES);
          Skills.activationCheck(player, SkillType.EXCAVATION);
          Skills.activationCheck(player, SkillType.HERBALISM);
          Skills.activationCheck(player, SkillType.MINING);
          Skills.activationCheck(player, SkillType.SWORDS);
          Skills.activationCheck(player, SkillType.UNARMED);
          Skills.activationCheck(player, SkillType.WOODCUTTING);
        }

        /* ITEM CHECKS */
        Item.itemChecks(player);

        /* BLAST MINING CHECK */
        if (player.isSneaking()
            && inHand.getTypeId() == Config.getInstance().getDetonatorItemID()
            && Permissions.getInstance().blastMining(player)) {
          BlastMining.detonate(event, player, plugin);
        }

        break;

      case LEFT_CLICK_AIR:
      case LEFT_CLICK_BLOCK:

        /* CALL OF THE WILD CHECKS */
        if (player.isSneaking()) {
          Material type = inHand.getType();

          if (type == Material.RAW_FISH) {
            TamingManager tamingManager = new TamingManager(player);
            tamingManager.summonOcelot();
          } else if (type == Material.BONE) {
            TamingManager tamingManager = new TamingManager(player);
            tamingManager.summonWolf();
          }
        }

        break;

      default:
        break;
    }
  }
Example #20
0
  private void progress() {
    if (!Tools.canBend(player, Abilities.OctopusForm)
        || (!player.isSneaking() && !sourceselected)
        || !Tools.hasAbility(player, Abilities.OctopusForm)) {
      remove();
      return;
    }

    if (!sourceblock.getWorld().equals(player.getWorld())) {
      remove();
      return;
    }

    if (sourceblock.getLocation().distance(player.getLocation()) > range && sourceselected) {
      remove();
      return;
    }

    if (System.currentTimeMillis() > time + interval) {
      time = System.currentTimeMillis();

      Location location = player.getLocation();

      if (sourceselected) {
        Tools.playFocusWaterEffect(sourceblock);
      } else if (settingup) {
        if (sourceblock.getY() < location.getBlockY()) {
          source.revertBlock();
          Block newblock = sourceblock.getRelative(BlockFace.UP);
          sourcelocation = newblock.getLocation();
          if (!Tools.isSolid(newblock)) {
            source = new TempBlock(newblock, Material.WATER, full);
            sourceblock = newblock;
          } else {
            remove();
          }
        } else if (sourceblock.getY() > location.getBlockY()) {
          source.revertBlock();
          Block newblock = sourceblock.getRelative(BlockFace.DOWN);
          sourcelocation = newblock.getLocation();
          if (!Tools.isSolid(newblock)) {
            source = new TempBlock(newblock, Material.WATER, full);
            sourceblock = newblock;
          } else {
            remove();
          }
        } else if (sourcelocation.distance(location) > radius) {
          Vector vector =
              Tools.getDirection(sourcelocation, location.getBlock().getLocation()).normalize();
          sourcelocation.add(vector);
          Block newblock = sourcelocation.getBlock();
          if (!newblock.equals(sourceblock)) {
            source.revertBlock();
            if (!Tools.isSolid(newblock)) {
              source = new TempBlock(newblock, Material.WATER, full);
              sourceblock = newblock;
            }
          }
        } else {
          incrementStep();
          source.revertBlock();
          Vector vector = new Vector(1, 0, 0);
          startangle = vector.angle(Tools.getDirection(sourceblock.getLocation(), location));
          angle = startangle;
        }
      } else if (forming) {

        if (angle - startangle >= 360) {
          y += 1;
        } else {
          angle += 20;
        }
        formOctopus();
        if (y == 2) {
          incrementStep();
        }
      } else if (formed) {
        animstep += 1;
        if (animstep > 8) animstep = 1;
        formOctopus();
      } else {
        remove();
      }
    }
  }
Example #21
0
  public static Object handle(Object obj) {
    if (obj instanceof World.Environment) {
      World.Environment e = (World.Environment) obj;
      if (e == World.Environment.NETHER) {
        return "nether";
      } else {
        return "normal";
      }
    } else if (obj instanceof File) {
      return ((File) obj).toString();
    } else if (obj instanceof Player) {
      Player p = (Player) obj;
      JSONObject o = new JSONObject();

      o.put("name", p.getName());
      o.put("op", p.isOp());
      o.put("health", p.getHealth());
      o.put("ip", p.getAddress().toString());
      o.put("itemInHand", p.getItemInHand());
      o.put("location", p.getLocation());
      o.put("inventory", p.getInventory());
      o.put("sneaking", p.isSneaking());
      o.put("inVehicle", p.isInsideVehicle());
      o.put("sleeping", p.isSleeping());
      o.put("world", p.getServer().getWorlds().indexOf(p.getWorld()));

      return o;
    } else if (obj instanceof Server) {
      Server s = (Server) obj;

      JSONObject o = new JSONObject();

      o.put("maxPlayers", s.getMaxPlayers());
      o.put("players", Arrays.asList(s.getOnlinePlayers()));
      o.put("port", s.getPort());
      o.put("name", s.getName());
      o.put("serverName", s.getServerName());
      o.put("version", s.getVersion());
      o.put("worlds", s.getWorlds());

      return o;
    } else if (obj instanceof World) {
      World w = (World) obj;

      JSONObject o = new JSONObject();

      o.put("environment", w.getEnvironment());
      o.put("fullTime", w.getFullTime());
      o.put("time", w.getTime());
      o.put("name", w.getName());
      o.put("isThundering", w.isThundering());
      o.put("hasStorm", w.hasStorm());

      return o;
    } else if (obj instanceof Plugin) {
      Plugin p = (Plugin) obj;
      PluginDescriptionFile d = p.getDescription();

      JSONObject o = new JSONObject();

      o.put("name", d.getName());
      o.put("description", d.getDescription());
      o.put("authors", d.getAuthors());
      o.put("version", d.getVersion());
      o.put("website", d.getWebsite());
      o.put("enabled", JSONAPI.instance.getServer().getPluginManager().isPluginEnabled(p));

      return o;
    } else if (obj instanceof ItemStack) {
      ItemStack i = (ItemStack) obj;

      JSONObject o = new JSONObject();

      o.put("type", i.getTypeId());
      o.put("durability", i.getDurability());
      o.put("amount", i.getAmount());

      return o;
    } else if (obj instanceof PlayerInventory) {
      PlayerInventory p = (PlayerInventory) obj;

      JSONObject o = new JSONObject();

      JSONObject armor = new JSONObject();
      armor.put("boots", p.getBoots());
      armor.put("chestplate", p.getChestplate());
      armor.put("helmet", p.getHelmet());
      armor.put("leggings", p.getLeggings());

      o.put("armor", armor);
      o.put("hand", p.getItemInHand());
      o.put("inventory", Arrays.asList(p.getContents()));

      return o;
    } else if (obj instanceof Location) {
      Location l = (Location) obj;

      JSONObject o = new JSONObject();

      o.put("x", l.getX());
      o.put("y", l.getY());
      o.put("z", l.getZ());
      o.put("pitch", l.getPitch());
      o.put("yaw", l.getYaw());

      return o;
    } else if (obj instanceof Plugin[]) {
      List<Plugin> l = Arrays.asList((Plugin[]) obj);

      Collections.sort(l, new PluginSorter());

      return l;
    } else if (obj instanceof Object[]) {
      int l = ((Object[]) obj).length;
      JSONArray a = new JSONArray();
      for (int i = 0; i < l; i++) {
        a.add(((Object[]) obj)[i]);
      }

      return a;
    }
    Logger.getLogger("JSONAPI").warning("Uncaugh object! Value:");
    Logger.getLogger("JSONAPI").warning(obj.toString());
    Logger.getLogger("JSONAPI").warning("Type:");
    Logger.getLogger("JSONAPI").warning(obj.getClass().getName());

    return new Object();
  }
Example #22
0
 @Override
 public boolean isSneaking() {
   if (player != null) return player.isSneaking();
   return false;
 }
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onPlayerSneak(PlayerToggleSneakEvent event) {
    Player player = event.getPlayer();
    if (player == null) {
      Bending.getInstance().getLogger().warning("Null player in PlayerSneak");
      return;
    }
    BendingPlayer bender = BendingPlayer.getBendingPlayer(player);
    if (Bloodbending.isBloodbended(player) || Concussion.getTarget(player) != null) {
      event.setCancelled(true);
      return;
    }

    String ability = EntityTools.getBendingAbility(player);
    RegisteredAbility register = AbilityManager.getManager().getRegisteredAbility(ability);
    if (!player.isSneaking()
        && ((ability == null) || (register == null) || !register.isShift())
        && (player.getGameMode() == GameMode.SURVIVAL
            || player.getGameMode() == GameMode.ADVENTURE
            || !player.isFlying())) {
      if (bender.isBender(BendingElement.WATER)
          && EntityTools.canBendPassive(player, BendingElement.WATER)
          && !WaterSpout.isBending(player)) {
        FastSwimming ab =
            new FastSwimming(
                AbilityManager.getManager().getRegisteredAbility(FastSwimming.NAME), player);
        if (ab.canBeInitialized()) {
          ab.start();
          if (ab.getState() != BendingAbilityState.START
              && ab.getState() != BendingAbilityState.ENDED) {
            AbilityManager.getManager().addInstance(ab);
            return;
          }
        }
      }
    }

    if (EntityTools.canBend(player, register) && !player.isSneaking()) {
      Map<Object, BendingAbility> abilities = AbilityManager.getManager().getInstances(ability);
      boolean shouldCreateNew = true;
      for (BendingAbility a : abilities.values()) {
        if (a.getPlayer().equals(player) && !((BendingActiveAbility) a).sneak()) {
          shouldCreateNew = false;
        }
      }
      if (shouldCreateNew) {
        BendingActiveAbility ab = AbilityManager.getManager().buildAbility(ability, player);
        if (ab == null) {
          Bending.getInstance()
              .getLogger()
              .log(
                  Level.SEVERE,
                  "Ability "
                      + ability
                      + " failed to construct with buildAbility for player "
                      + player.getName());
          return;
        }
        if (ab.canBeInitialized()) {
          ab.sneak();
          if (ab.getState() != BendingAbilityState.START
              && ab.getState() != BendingAbilityState.ENDED) {
            AbilityManager.getManager().addInstance(ab);
          }
        }
      }
    }
  }
Example #24
0
  /**
   * Progresses this instance of Suffocate by 1 tick.
   *
   * @return true If progress does not stop, progresses succesfully
   */
  public boolean progress() {
    if (targets.size() == 0) {
      remove();
      return false;
    }
    if (player.isDead() || !player.isOnline()) {
      remove();
      return false;
    }
    String ability = GeneralMethods.getBoundAbility(player);
    if (ability == null
        || !ability.equalsIgnoreCase("Suffocate")
        || !GeneralMethods.canBend(player.getName(), "Suffocate")) {
      remove();
      return false;
    }

    for (int i = 0; i < targets.size(); i++) {
      LivingEntity target = targets.get(i);
      if (target.isDead()
          || !target.getWorld().equals(player.getWorld())
          || target.getLocation().distance(player.getEyeLocation()) > range) {
        breakSuffocateLocal(target);
        i--;
      } else if (target instanceof Player) {
        Player targPlayer = (Player) target;
        if (!targPlayer.isOnline()) {
          breakSuffocateLocal(target);
          i--;
        }
      }
    }
    if (targets.size() == 0) {
      remove();
      return false;
    }

    if (reqConstantAim) {
      double dist = player.getEyeLocation().distance(targets.get(0).getEyeLocation());
      Location targetLoc =
          player
              .getEyeLocation()
              .clone()
              .add(player.getEyeLocation().getDirection().normalize().multiply(dist));
      List<Entity> ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, aimRadius);

      for (int i = 0; i < targets.size(); i++) {
        LivingEntity target = targets.get(i);
        if (!ents.contains(target)) {
          breakSuffocateLocal(target);
          i--;
        }
      }
      if (targets.size() == 0) {
        remove();
        return false;
      }
    }

    if (System.currentTimeMillis() - time < chargeTime) {
      return false;
    } else if (!started) {
      started = true;
      final Player fplayer = player;
      for (LivingEntity targ : targets) {
        final LivingEntity target = targ;
        BukkitRunnable br1 =
            new BukkitRunnable() {
              @Override
              public void run() {
                GeneralMethods.damageEntity(fplayer, target, damage, "Suffocate");
              }
            };
        BukkitRunnable br2 =
            new BukkitRunnable() {
              @Override
              public void run() {
                target.addPotionEffect(
                    new PotionEffect(PotionEffectType.SLOW, (int) (slowRepeat * 20), (int) slow));
              }
            };
        BukkitRunnable br3 =
            new BukkitRunnable() {
              @Override
              public void run() {
                target.addPotionEffect(
                    new PotionEffect(
                        PotionEffectType.BLINDNESS, (int) (blindRepeat * 20), (int) blind));
              }
            };

        tasks.add(br1);
        tasks.add(br2);
        tasks.add(br3);
        br1.runTaskTimer(
            ProjectKorra.plugin, (long) (damageDelay * 20), (long) (damageRepeat * 20));
        br2.runTaskTimer(
            ProjectKorra.plugin, (long) (slowDelay * 20), (long) (slowRepeat * 20 / 0.25));
        br3.runTaskTimer(ProjectKorra.plugin, (long) (blindDelay * 20), (long) (blindRepeat * 20));
      }
    }

    animate();
    if (!player.isSneaking()) {
      remove();
      return false;
    }
    return true;
  }
Example #25
0
  /**
   * The actual check. First find out if the event needs to be handled at all Second check if the
   * player moved too far horizontally Third check if the player moved too high vertically Fourth
   * treat any occured violations as configured
   *
   * @param event
   */
  public Location check(Player player, Location from, Location to, MovingData data) {

    updateVelocity(player.getVelocity(), data);

    Location newToLocation = null;

    final long startTime = System.nanoTime();

    /** *********** DECIDE WHICH CHECKS NEED TO BE RUN ************ */
    final boolean flyCheck =
        !allowFlying && !plugin.hasPermission(player, PermissionData.PERMISSION_FLYING, checkOPs);
    final boolean runCheck = true;

    /** *************** REFINE EVENT DATA FOR CHECKS ************** */
    if (flyCheck || runCheck) {

      // In both cases it will be interesting to know the type of underground the player
      // is in or goes to
      final int fromType =
          helper.isLocationOnGround(from.getWorld(), from.getX(), from.getY(), from.getZ(), false);
      final int toType =
          helper.isLocationOnGround(to.getWorld(), to.getX(), to.getY(), to.getZ(), false);

      final boolean fromOnGround = fromType != MovingEventHelper.NONSOLID;
      final boolean toOnGround = toType != MovingEventHelper.NONSOLID;

      // Distribute data to checks in the form needed by the checks

      /** ******************* EXECUTE THE CHECKS ******************* */
      double result = 0.0D;

      if (flyCheck) {
        result += Math.max(0D, flyingCheck.check(player, from, fromOnGround, to, toOnGround, data));
      }

      if (runCheck) {
        result +=
            Math.max(
                0D,
                runningCheck.check(
                    from,
                    to,
                    !allowFakeSneak && player.isSneaking(),
                    !allowFastSwim && (fromType & toType & MovingEventHelper.LIQUID) > 0,
                    data));
      }

      /** ******* HANDLE/COMBINE THE RESULTS OF THE CHECKS ********** */
      data.jumpPhase++;

      if (result <= 0) {
        if (fromOnGround) {
          data.setBackPoint = from;
          data.jumpPhase = 0;
        } else if (toOnGround) {
          data.jumpPhase = 0;
        }
      } else if (result > 0) {
        // Increment violation counter
        data.violationLevel += result;
        if (data.setBackPoint == null) data.setBackPoint = from;
      }

      if (result > 0 && data.violationLevel > 1) {

        setupSummaryTask(player, data);

        int level = limitCheck(data.violationLevel - 1);

        data.violationsInARow[level]++;

        newToLocation =
            action(player, from, to, actions[level], data.violationsInARow[level], data);
      }
    }

    // Slowly reduce the level with each event
    data.violationLevel *= 0.97;
    data.horizFreedom *= 0.97;

    statisticElapsedTimeNano += System.nanoTime() - startTime;
    statisticTotalEvents++;

    return newToLocation;
  }
Example #26
0
 @Override
 public boolean isSneaking() {
   return player.isSneaking();
 }
  public boolean teleport(List<TeleportEntry> entries) {
    for (TeleportEntry entry : entries) {
      Entity entity = entry.getEntity();
      Location destination = entry.getDestination();
      Field sourceField = entry.getSourceField();
      Vec currentPosition = null;

      if (entity instanceof Player) {
        Player player = (Player) entity;

        plugin.getPlayerManager().getPlayerEntry(player.getName()).setTeleporting(false);

        // done teleport players with bypass permission

        if (plugin.getPermissionsManager().has(player, "preciousstones.bypass.teleport")) {
          continue;
        }

        // don't teleport if sneaking bypasses

        if (sourceField.hasFlag(FieldFlag.SNEAKING_BYPASS)
            && !sourceField.hasFlag(FieldFlag.TELEPORT_ON_SNEAK)) {
          if (player.isSneaking()) {
            continue;
          }
        }

        currentPosition = new Vec(player.getLocation());
      }

      // prepare teleport destination

      World world = destination.getWorld();

      Vec safe = findSafeLocation(destination);
      double x = safe.getX() + .5D;
      double y = safe.getY();
      double z = safe.getZ() + .5D;

      if (y == -1) {
        continue;
      }

      if (!world.isChunkLoaded(destination.getBlockX() >> 4, destination.getBlockZ() >> 4)) {
        world.loadChunk(destination.getBlockX() >> 4, destination.getBlockZ() >> 4);
      }

      Location loc =
          new Location(
              world, x, y, z, entity.getLocation().getYaw(), entity.getLocation().getPitch());

      // teleport the player

      if (sourceField.hasFlag(FieldFlag.TELEPORT_EXPLOSION_EFFECT)) {
        world.createExplosion(entity.getLocation(), -1);
      }

      entity.teleport(loc);

      if (sourceField.hasFlag(FieldFlag.TELEPORT_EXPLOSION_EFFECT)) {
        world.createExplosion(loc, -1);
      }

      if (entity instanceof Player) {
        Player player = (Player) entity;

        if (sourceField.hasFlag(FieldFlag.TELEPORT_ANNOUNCE)) {
          if (!entry.getAnnounce().isEmpty()) {
            ChatBlock.send(player, entry.getAnnounce());
          }
        }

        // start teleport back countdown

        if (sourceField.getSettings().getTeleportBackAfterSeconds() > 0) {
          if (sourceField.hasFlag(FieldFlag.TELEPORT_ANNOUNCE)) {
            ChatBlock.send(
                player,
                "teleportAnnounceBack",
                sourceField.getSettings().getTeleportBackAfterSeconds());
          }

          PlayerEntry playerEntry = plugin.getPlayerManager().getPlayerEntry(player.getName());

          playerEntry.setTeleportSecondsRemaining(
              sourceField.getSettings().getTeleportBackAfterSeconds());
          playerEntry.setTeleportVec(currentPosition);
          playerEntry.startTeleportCountDown();
          plugin.getStorageManager().offerPlayer(player.getName());
        }
      }
    }

    return true;
  }
Example #28
0
 @Override
 public boolean isSneaking() {
   return caller.isSneaking();
 }
Example #29
0
 public RainbowBoost(PlayerMoveEvent e) {
   p = e.getPlayer();
   jump = e.getFrom().getY() < e.getTo().getY();
   crouch = p.isSneaking();
 }
Example #30
0
 public static void HandleSwim(Server server) {
   for (Player player : server.getOnlinePlayers()) {
     Abilities ability = Tools.getBendingAbility(player);
     if (Tools.isBender(player.getName(), BendingType.Water)
         && Tools.canBendPassive(player, BendingType.Water)
         && player.isSneaking()
         && Tools.isWater(player.getLocation().getBlock())
         && !TempBlock.isTempBlock(player.getLocation().getBlock())
         && !(ability == Abilities.WaterManipulation
             || ability == Abilities.Surge
             || ability == Abilities.HealingWaters
             || ability == Abilities.PhaseChange
             || ability == Abilities.Bloodbending
             || ability == Abilities.IceSpike
             || Tools.getBendingAbility(player) == Abilities.OctopusForm)) {
       player.setVelocity(
           player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
     }
   }
   // for (Player p : s.getOnlinePlayers()) {
   // if ((!Tools.isBender(p, BendingType.Water)
   // || !Tools.canBendPassive(p, BendingType.Water) || p
   // .isSneaking()) && timers.containsKey(p))
   // timers.remove(p);
   // if (Tools.isBender(p, BendingType.Water)
   // && Tools.canBendPassive(p, BendingType.Water)
   // && p.getLocation().getBlock().isLiquid()
   // && !timers.containsKey(p)) {
   // timers.put(p, System.currentTimeMillis());
   // }
   // if (timers.containsKey(p)) {
   // if (timers.get(p) + (interval - 21) >= System
   // .currentTimeMillis()) {
   // locations.put(p, p.getLocation().getBlock().getLocation());
   // }
   // }
   // if (timers.containsKey(p)) {
   // if (!(timers.get(p) + interval >= System.currentTimeMillis())
   // && locations.containsKey(p)
   // && ((int) locations.get(p).getX() != (int) p
   // .getLocation().getBlock().getLocation().getX() || (int) locations
   // .get(p).getZ() != (int) p.getLocation()
   // .getBlock().getLocation().getZ())
   // && p.getLocation().getBlock().isLiquid()) {
   //
   // if (!p.getEyeLocation().getBlock().isLiquid()) {
   // timers.put(p, System.currentTimeMillis());
   // if ((p.getLocation().getYaw() > -45 && p.getLocation()
   // .getYaw() <= 45)
   // && locations.get(p).getZ() < p.getLocation()
   // .getZ()) {
   // Vector v = p.getLocation().getDirection().setY(0);
   // p.setVelocity(v.normalize().multiply(factor));
   // } else if ((p.getLocation().getYaw() > 45 && p
   // .getLocation().getYaw() <= 135)
   // && locations.get(p).getX() > p.getLocation()
   // .getX()) {
   // Vector v = p.getLocation().getDirection().setY(0);
   // p.setVelocity(v.normalize().multiply(factor));
   // } else if ((p.getLocation().getYaw() > 135 && p
   // .getLocation().getYaw() <= 225)
   // && locations.get(p).getZ() > p.getLocation()
   // .getZ()) {
   // Vector v = p.getLocation().getDirection().setY(0);
   // p.setVelocity(v.normalize().multiply(factor));
   // } else if ((p.getLocation().getYaw() > 225 && p
   // .getLocation().getYaw() <= 315)
   // && locations.get(p).getX() < p.getLocation()
   // .getX()) {
   // Vector v = p.getLocation().getDirection().setY(0);
   // p.setVelocity(v.normalize().multiply(factor));
   // }
   // } else {
   // timers.put(p, System.currentTimeMillis());
   // Vector v = p.getLocation().getDirection().normalize()
   // .multiply(factor);
   // p.setVelocity(v);
   // }
   // }
   // }
   // }
 }