All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dailystruggle.rtp.common.tasks.teleport.ChunkCleanup Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package io.github.dailystruggle.rtp.common.tasks.teleport;

import io.github.dailystruggle.rtp.common.selection.region.Region;
import io.github.dailystruggle.rtp.common.serverSide.substitutions.RTPLocation;
import io.github.dailystruggle.rtp.common.tasks.RTPRunnable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

public final class ChunkCleanup extends RTPRunnable {
    public static final List> preActions = new ArrayList<>();
    public static final List> postActions = new ArrayList<>();
    private final RTPLocation location;
    private final Region region;

    public ChunkCleanup(RTPLocation location, Region region) {
        this.location = location;
        this.region = region;
    }

    @Override
    public void run() {
        preActions.forEach(consumer -> consumer.accept(this));
        region.removeChunks(location);
        postActions.forEach(consumer -> consumer.accept(this));
    }

    public RTPLocation location() {
        return location;
    }

    public Region region() {
        return region;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj == null || obj.getClass() != this.getClass()) return false;
        ChunkCleanup that = (ChunkCleanup) obj;
        return Objects.equals(this.location, that.location) &&
                Objects.equals(this.region, that.region);
    }

    @Override
    public int hashCode() {
        return Objects.hash(location, region);
    }

    @Override
    public String toString() {
        return "ChunkCleanup[" +
                "location=" + location + ", " +
                "region=" + region + ']';
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy