Пример #1
0
 public static int[] getSums(
     Location firstPoint, Location secndPoint, List<List<CountBlock>> ArrayPaints) {
   World world = firstPoint.getWorld();
   if (world.equals(secndPoint.getWorld())) {
     int[] sum_paint = new int[ArrayPaints.size()];
     int[] cords = area(firstPoint, secndPoint);
     for (int x = cords[0]; x <= cords[1]; x++) {
       for (int y = cords[2]; y <= cords[3]; y++) {
         for (int z = cords[4]; z <= cords[5]; z++) {
           Block block = new Location(world, x, y, z).getBlock();
           for (int i = 0; i < ArrayPaints.size(); i++) {
             for (CountBlock paint : ArrayPaints.get(i)) {
               if (paint.equals(block)) {
                 sum_paint[i]++;
                 break;
               }
             }
           }
         }
       }
     }
     return sum_paint;
   }
   return new int[] {-1};
 }
Пример #2
0
 public static float[] getRates(
     Location firstPoint,
     Location secndPoint,
     List<List<CountBlock>> ArrayPaints,
     List<CountBlock> objects) {
   World world = firstPoint.getWorld();
   if (world.equals(secndPoint.getWorld())) {
     int[] sum_paint = new int[ArrayPaints.size()];
     int sum_obj = 0;
     int[] cords = area(firstPoint, secndPoint);
     for (int x = cords[0]; x <= cords[1]; x++) {
       for (int y = cords[2]; y <= cords[3]; y++) {
         for (int z = cords[4]; z <= cords[5]; z++) {
           Block block = new Location(world, x, y, z).getBlock();
           for (int i = 0; i < ArrayPaints.size(); i++) {
             for (CountBlock paint : ArrayPaints.get(i)) {
               if (paint.equals(block)) {
                 sum_paint[i]++;
                 break;
               }
             }
           }
           if (objects != null) {
             for (CountBlock paint : objects) {
               if (paint.equals(block)) {
                 sum_obj++;
                 break;
               }
             }
           } else {
             if (!block.getType().equals(Material.AIR)) {
               sum_obj++;
             }
           }
         }
       }
     }
     float[] rates = new float[ArrayPaints.size()];
     for (int i = 0; i < ArrayPaints.size(); i++) {
       rates[i] = (float) sum_paint[i] / (float) sum_obj * 100.0f;
     }
     return rates;
   }
   return new float[] {-1f};
 }
Пример #3
0
 public static int getSum(Location firstPoint, Location secndPoint, List<CountBlock> paints) {
   World world = firstPoint.getWorld();
   if (world.equals(secndPoint.getWorld())) {
     int sum = 0;
     int[] cords = area(firstPoint, secndPoint);
     for (int x = cords[0]; x <= cords[1]; x++) {
       for (int y = cords[2]; y <= cords[3]; y++) {
         for (int z = cords[4]; z <= cords[5]; z++) {
           Block block = new Location(world, x, y, z).getBlock();
           for (CountBlock paint : paints) {
             if (paint.equals(block)) {
               sum++;
               break;
             }
           }
         }
       }
     }
     return sum;
   }
   return -1;
 }
Пример #4
0
 public static float getRate(
     Location firstPoint, Location secndPoint, List<CountBlock> paints, List<CountBlock> objects) {
   World world = firstPoint.getWorld();
   if (world.equals(secndPoint.getWorld())) {
     int sum_paint = 0;
     int sum_obj = 0;
     int[] cords = area(firstPoint, secndPoint);
     for (int x = cords[0]; x <= cords[1]; x++) {
       for (int y = cords[2]; y <= cords[3]; y++) {
         for (int z = cords[4]; z <= cords[5]; z++) {
           Block block = new Location(world, x, y, z).getBlock();
           for (CountBlock paint : paints) {
             if (paint.equals(block)) {
               sum_paint++;
               break;
             }
           }
           if (objects != null) {
             for (CountBlock paint : objects) {
               if (paint.equals(block)) {
                 sum_obj++;
                 break;
               }
             }
           } else {
             if (!block.getType().equals(Material.AIR)) {
               sum_obj++;
             }
           }
         }
       }
     }
     return (float) sum_paint / (float) sum_obj * 100.0f;
   }
   return -1;
 }