mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-03-29 13:19:43 +01:00

Folia Support --------- Co-authored-by: Rockyers <ethan@yocom.org> Co-authored-by: TechnicallyCoded <technicallycoded@gmail.com> Co-authored-by: HSGamer <huynhqtienvtag@gmail.com>
43 lines
1.5 KiB
Java
43 lines
1.5 KiB
Java
package com.gmail.nossr50.skills.taming;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.util.CancellableRunnable;
|
|
import com.gmail.nossr50.util.Misc;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class TrackedTamingEntity extends CancellableRunnable {
|
|
private final @NotNull LivingEntity livingEntity;
|
|
private final @NotNull CallOfTheWildType callOfTheWildType;
|
|
private final @NotNull Player player;
|
|
|
|
protected TrackedTamingEntity(@NotNull LivingEntity livingEntity, @NotNull CallOfTheWildType callOfTheWildType, @NotNull Player player) {
|
|
this.player = player;
|
|
this.callOfTheWildType = callOfTheWildType;
|
|
this.livingEntity = livingEntity;
|
|
|
|
int tamingCOTWLength = mcMMO.p.getGeneralConfig().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
|
|
|
|
if (tamingCOTWLength > 0) {
|
|
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
|
|
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(livingEntity, this, length);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
mcMMO.getTransientEntityTracker().removeSummon(this.getLivingEntity(), player, true);
|
|
this.cancel();
|
|
}
|
|
|
|
public @NotNull CallOfTheWildType getCallOfTheWildType() {
|
|
return callOfTheWildType;
|
|
}
|
|
|
|
public @NotNull LivingEntity getLivingEntity() {
|
|
return livingEntity;
|
|
}
|
|
}
|