io.github.dailystruggle.rtp.common.tasks.teleport.ChunkCleanup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of RTP Show documentation
Show all versions of RTP Show documentation
a random teleport plugin
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 + ']';
}
}