Jittery Collision Bug

I’m getting a Jitter effect on my collision system. I have a guess but not completely sure. I’ve been researching collisions for a month now and finally got my code working with a very basic solution. Unfortunately, with every fix comes more bugs. My guess for this issue is that I’m doing the position resetting upon collision incorrectly? Or at the very least, inefficiently.

I’d prefer to make a listener or event system for cleanliness and modularity but it just seems to keep messing the code up more and more every time I tried.
This is the main tab with the setup and everything:

PVector pos, vel;
ArrayList<Platform> platforms;
Me me;
void setup() {
  size(720, 480);
  surface.setResizable(true);
  frameRate(60);
  platforms = new ArrayList<Platform>();
  pos = new PVector(40, height - 45);
  me = new Me(pos, new PVector(30, 30));
  rectMode(CENTER);
  textAlign(LEFT, CENTER);
  drawPlatform(width/30, new PVector(0,0), new PVector(30,30)); // top
  drawPlatform(width/30, new PVector(0,height-30), new PVector(30,30)); // bottom
  drawPlatform(width/60, new PVector(0,height-60), new PVector(30,30)); // bottom
  drawPlatform(5, new PVector(0,height/4), new PVector(30,30));
  drawPlatform(5, new PVector(width/2,height/2), new PVector(30,30));
  drawPlatform(2, new PVector(width,height/2), new PVector(30,30));
  drawPlatform(2, new PVector(width,height/2+60), new PVector(30,30));
  drawPlatform(2, new PVector(width,60), new PVector(30,30));
  for (Platform p : platforms) {
    p.render();
  }
}

void draw() {
  background(0);
  for (Platform p : platforms) {
    p.load();
  }
  me.update();
  //println(me.collided);
}

void drawPlatform(int amt, PVector pos, PVector size) {
  for(int i = 0; i < amt; i++) {
    Platform p = new Platform(new PVector(abs(width-((pos.x+(size.x/2)) + (i * size.x))), pos.y+(size.y/2)), size);
  }
}

void keyPressed() {
  if (keyCode == LEFT || key == 'a' || key == 'A') {
    me.vel.x = -4; 
  }
  if (keyCode == RIGHT || key == 'd' || key == 'D') {
    me.vel.x = 4;
  }
  if (keyCode == ' ' && me.canJump && !me.isJumping) {
    me.isJumping = true; 
    me.vel.y = -9;
    me.PrintDetails();
  }
}

void keyReleased() {
  if (keyCode == RIGHT || keyCode == LEFT || key == 'a' || key == 'A' || key == 'd' || key == 'D')
    me.vel.x = 0;
}

This is the other tab that contains the classes:

class Platform {
  PVector pos, size;
  float top, left, right, bottom;
  public Platform(PVector pos, PVector size) {
    this.pos = pos;
    this.size = size;
    platforms.add(this);
  }

  void load() {
    render();
    top = pos.y - size.y/2;
    left = pos.x - size.x/2;
    right = pos.x + size.x/2;
    bottom = pos.y + size.y/2;
  }

  void render() {
    fill(255, 10, 0);
    stroke(255);
    rect(pos.x, pos.y, size.x, size.y, 4);
    //textSize(8);
    if (mouseX >= left && mouseX <= right && mouseY >= top && mouseY <= bottom) {
      textFont(createFont("Arial Black", 12));
      fill(255);
      text("X:"+pos.x+"\nY:"+pos.y, left, pos.y-40);
    }
  }
}

class Me {
  PVector pos, size, vel = new PVector(0, 0), gravity = new PVector(0, 0.2), prevPos = new PVector(), delta = new PVector();
  boolean isJumping, isMoving, collided, isFalling, colLeft, colRight, colTop, colBottom, canJump;
  float groundHeight = 0, change_y = 0, change_x = 0, top, left, right, bottom;
  ArrayList<Platform> collisions;
  public Me(PVector pos, PVector size) {
    this.pos = pos;
    this.size = size;
    prevPos.y = pos.y;
    prevPos.x = pos.x;
    delta.y = pos.y - prevPos.y;
    delta.x = pos.x - prevPos.x;
    OnUpdate();
    canJump = true;
    collisions = new ArrayList<Platform>();
  }

  void render() {
    pushMatrix();
    stroke(255, 0, 0);
    fill(255);
    rect(pos.x, pos.y, size.x, size.y, 4);
    //textSize(12);
    textFont(createFont("Arial Black", 12));
    fill(255);
    text("X:"+pos.x+"\nY:"+pos.y, left, pos.y - 50);
    popMatrix();
  }

  void update() {
    prevPos.y = pos.y;
    prevPos.x = pos.x;
    vel.y += gravity.y;
    render();
    move();
    jump();
    detect();
    //if(colLeft || colRight) {
    //  vel.x = 0;
    //}
    if (collisions.size() != 0) {
      for (int i = 0; i < collisions.size(); i++)
        if (!intersects(collisions.get(i)))
          collisions.remove(i);
        else
          onCollision(collisions.get(i));
    } else {
      colTop = false;
      colBottom = false;
      colLeft = false;
      colRight = false;
    }
    if(colTop) {
      vel.y = 0;
      gravity.y = 0;
    } else {
      gravity.y = 0.2;
    }
    if (!isJumping) {
      pos.y += vel.y;
    }
    OnUpdate();
    delta.y = pos.y - prevPos.y;
    delta.x = pos.x - prevPos.x;
    if (isMoving) {
      PrintDetails();
    }
  }

  void OnUpdate() {
    isFalling = pos.y > prevPos.y;
    isMoving = pos.x != prevPos.x;
    top = pos.y - (size.y/2);
    left = pos.x - (size.x/2);
    right = pos.x + (size.x/2);
    bottom = pos.y + (size.y/2);
  }

  void move() {
    pos.x += vel.x;
    //PrintCollided();
  }

  void PrintCollided() {
    println("Colliding: Top:" + colTop + " - Left: " + colLeft + " - Right: " + colRight + " - Bottom: " + colBottom);
  }
  
  void PrintDetails() {
    println("Delta: \t" + delta);
    println("Pos: \t" + pos);
    println("Vel: \t" + vel);
    println("Collisions:" + collisions);
    println("Quad: \tTop:" + top+" Left:" + left + " Right+" + right + " Bottom:" + bottom);
    PrintCollided();
  }

  void jump() {
    if (isJumping) {
      pos.y += vel.y;
      //vel.y += gravity.y;
    }
  }
  void detect() {
    for (Platform p : platforms) {
      if (intersects(p)) {
        if (!collisions.contains(p)) {
          collisions.add(p);
          //onCollision(p);
        }
      }
      //else if (collisions.contains(p)) {
      //  collisions.remove(p);
      //}
    }
  }

  boolean intersects(Platform p) {
    return (right > p.left && bottom > p.top && p.right > left && p.bottom > top);
  }
  boolean contains(Platform p) {
    return (p.pos.x >= pos.x && p.pos.x <= pos.x && p.pos.y >= pos.y && p.pos.y <= pos.y);
  }

  void onCollision(Platform p) {
    //collided = true;
    if (right >= p.left && left <= p.right) {
      if (top < p.top && delta.y >= 0) {
        canJump = true;
        colBottom = true;
        isJumping = false;
        vel.y = 0;
        pos.y = p.top - size.y/2;
      } else if (bottom > p.bottom && delta.y < 0) {
        canJump = false;
        colTop = true;
        isJumping = false;
        pos.y = p.bottom + size.y/2;
        //vel.y = -vel.y;
      }
    }
    if (pos.y >= p.top && pos.y <= p.bottom) {
      if (right >= p.left-2 && delta.x >= 0) {
        colRight = true;
        println(3);
        vel.x = 0;
        pos.x = p.left - size.y/2 - 1;
      } else if (left <= p.right+2 && delta.x <= 0) {
        colLeft = true;
        println(4);
        vel.x = 0;
        pos.x = p.right + size.y/2+1;
      }
    }
  }
}

Pray yee, lest we find what’s wrong with my code :pray:t6:
I would be very grateful if I can get pointers on how to optimize the collision system as well.