Exemplo n.º 1
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    // Draw image
    String horse_type = (String) gameObject.getAttribute("this", "horse");
    if (horse_type != null) {
      drawIcon(g, "steed" + (useColorIcons() ? "_c" : ""), horse_type, 0.5);
    }

    // Draw Stats
    alteredMoveSpeed = false;
    String statSide = isTrotting() ? "trot" : "gallop";
    String asterisk = isTrotting() ? "" : "*";

    Speed speed = isTrotting() ? getTrotSpeed() : getGallopSpeed();
    String strength = (String) gameObject.getAttribute(statSide, "strength");

    TextType tt = new TextType(strength, getChitSize(), "BIG_BOLD");
    tt.draw(g, 10, (getChitSize() >> 1) - tt.getHeight(g), Alignment.Left);

    tt =
        new TextType(
            speed.getSpeedString() + asterisk,
            getChitSize(),
            alteredMoveSpeed ? "BIG_BOLD_BLUE" : "BIG_BOLD");
    tt.draw(
        g,
        getChitSize() >> 1,
        getChitSize() - (getChitSize() >> 2) - (getChitSize() >> 3),
        Alignment.Left);

    drawDamageAssessment(g);
  }
  /**
   * We listen to ProjectileLaunch events to prevent players from launching projectiles too quickly.
   *
   * @param event the event
   */
  @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
  public void onProjectileLaunch(final ProjectileLaunchEvent event) {
    /*
     *  ____            _           _   _ _        _                           _
     * |  _ \ _ __ ___ (_) ___  ___| |_(_) | ___  | |    __ _ _   _ _ __   ___| |__
     * | |_) | '__/ _ \| |/ _ \/ __| __| | |/ _ \ | |   / _` | | | | '_ \ / __| '_ \
     * |  __/| | | (_) | |  __/ (__| |_| | |  __/ | |__| (_| | |_| | | | | (__| | | |
     * |_|   |_|  \___// |\___|\___|\__|_|_|\___| |_____\__,_|\__,_|_| |_|\___|_| |_|
     *               |__/
     */
    // The shooter needs to be a player.
    if (!(event.getEntity().getShooter() instanceof Player)) return;

    // And the projectile must be one the following:
    switch (event.getEntityType()) {
      case ENDER_PEARL:
        break;
      case ENDER_SIGNAL:
        break;
      case EGG:
        break;
      case SNOWBALL:
        break;
      case THROWN_EXP_BOTTLE:
        break;
      case SPLASH_POTION:
        break;
      default:
        return;
    }

    final Player player = (Player) event.getEntity().getShooter();

    // Do the actual check...
    if (speed.isEnabled(player)) {
      final long now = System.currentTimeMillis();
      final Location loc = player.getLocation();
      if (Combined.checkYawRate(player, loc.getYaw(), now, loc.getWorld().getName()))
        event.setCancelled(true);
      if (speed.check(player))
        // If the check was positive, cancel the event.
        event.setCancelled(true);
      else if (Improbable.check(player, 1f, now))
        // COmbined fighting speed.
        event.setCancelled(true);
    }
  }
Exemplo n.º 3
0
 /**
  * Moves the mouse to (x,y).
  *
  * @param x x
  * @param y y
  */
 public static void move(int x, int y) {
   while (distTo(x, y) > 2) {
     List<Point> list = genLine(last.x, last.y, x, y);
     for (Point p : list) {
       hop(p);
       Task.sleep(Random.nextGaussian(25 / speed.ordinal(), Random.nextInt(5, 15)));
     }
   }
 }
  /**
   * We listener to PlayerInteract events to prevent players from spamming the server with monster
   * eggs.
   *
   * @param event the event
   */
  @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
  public void onPlayerInteract(final PlayerInteractEvent event) {
    /*
     *  ____  _                         ___       _                      _
     * |  _ \| | __ _ _   _  ___ _ __  |_ _|_ __ | |_ ___ _ __ __ _  ___| |_
     * | |_) | |/ _` | | | |/ _ \ '__|  | || '_ \| __/ _ \ '__/ _` |/ __| __|
     * |  __/| | (_| | |_| |  __/ |     | || | | | ||  __/ | | (_| | (__| |_
     * |_|   |_|\__,_|\__, |\___|_|    |___|_| |_|\__\___|_|  \__,_|\___|\__|
     *                |___/
     */
    // We are only interested by monster eggs.
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK
        || event.getPlayer().getItemInHand() == null
        || event.getPlayer().getItemInHand().getType() != Material.MONSTER_EGG) return;

    final Player player = event.getPlayer();

    // Do the actual check...
    if (speed.isEnabled(player) && speed.check(player))
      // If the check was positive, cancel the event.
      event.setCancelled(true);
  }
Exemplo n.º 5
0
  static {
    CoordinateSystem coordSys;

    try {
      coordSys =
          new PolarCoordinateSystem(
              CartesianVelocity2D.instance().getRealTupleType(),
              Speed.DEFAULT_UNIT,
              PlaneAngle.DEFAULT_UNIT);
      instance =
          new PolarVelocity(
              "Polar_Velocity",
              (Speed) Speed.instance(),
              (PlaneAngle) PlaneAngle.instance(),
              coordSys);
    } catch (Exception e) {
      System.err.println("PolarVelocity.<clinit>(): Couldn't initialize class: " + e);
      System.exit(1);
    }
  }
Exemplo n.º 6
0
 public void draw(Canvas canvas) {
   canvas.drawBitmap(bitmap, (int) speed.getX(), (int) speed.getY(), null);
 }