コード例 #1
0
 /**
  * 3 decimal digits after comma (StringUtil.fdec3). No leading new line.
  *
  * @param from
  * @param to
  * @param loc Reference location for from, usually Player.getLocation().
  * @param builder
  * @return
  */
 public static void addFormattedMove(
     final Location from, final Location to, final Location loc, final StringBuilder builder) {
   if (loc != null && !TrigUtil.isSamePos(from, loc)) {
     builder.append("(");
     addFormattedLocation(loc, builder);
     builder.append(") ");
   }
   addFormattedMove(
       from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ(), builder);
 }
コード例 #2
0
 /**
  * Intended for vehicle-move events.
  *
  * @param player
  * @param vehicle
  * @param from
  * @param to
  * @param fake true if the event was not fired by an external source (just gets noted).
  */
 public static void outputDebugVehicleMove(
     final Player player,
     final Entity vehicle,
     final Location from,
     final Location to,
     final boolean fake) {
   final StringBuilder builder = new StringBuilder(250);
   final Location vLoc = vehicle.getLocation();
   final Location loc = player.getLocation();
   // TODO: Differentiate debug levels (needs setting up some policy + document in
   // BuildParamteres)?
   final Entity actualVehicle = player.getVehicle();
   final boolean wrongVehicle =
       actualVehicle == null || actualVehicle.getEntityId() != vehicle.getEntityId();
   if (BuildParameters.debugLevel > 0) {
     builder.append(
         "\n-------------- VEHICLE MOVE " + (fake ? "(fake)" : "") + "--------------\n");
     builder.append(player.getName() + " " + from.getWorld().getName() + ":\n");
     addMove(from, to, null, builder);
     builder.append("\n Vehicle: ");
     addLocation(vLoc, builder);
     builder.append("\n Player: ");
     addLocation(loc, builder);
   } else {
     builder.append(
         player.getName()
             + " "
             + from.getWorld().getName()
             + "veh."
             + (fake ? "(fake)" : "")
             + " ");
     addFormattedMove(from, to, null, builder);
     builder.append("\n Vehicle: ");
     addFormattedLocation(vLoc, builder);
     builder.append(" Player: ");
     addFormattedLocation(loc, builder);
   }
   builder.append(
       "\n Vehicle type: "
           + vehicle.getType()
           + (wrongVehicle
               ? (actualVehicle == null ? " (exited?)" : " actual: " + actualVehicle.getType())
               : ""));
   NCPAPIProvider.getNoCheatPlusAPI()
       .getLogManager()
       .debug(Streams.TRACE_FILE, builder.toString());
 }
コード例 #3
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());
   }
 }