mcMMO/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
Yomamaeatstoes c34230a82e
mcMMO-Folia-PR (#4925)
Folia Support

---------

Co-authored-by: Rockyers <ethan@yocom.org>
Co-authored-by: TechnicallyCoded <technicallycoded@gmail.com>
Co-authored-by: HSGamer <huynhqtienvtag@gmail.com>
2023-08-26 16:16:18 -07:00

28 lines
890 B
Java

package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
public class TravelingBlockMetaCleanup extends CancellableRunnable {
private final @NotNull Entity entity;
private final @NotNull mcMMO pluginRef;
public TravelingBlockMetaCleanup(@NotNull Entity entity, @NotNull mcMMO pluginRef) {
this.entity = entity;
this.pluginRef = pluginRef;
}
@Override
public void run() {
if(!entity.isValid()) {
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
this.cancel();
} else if (!entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK)) {
this.cancel();
}
}
}